Home   Help Search Login Register  

Author Topic: Multiplayer Random Artillery  (Read 3110 times)

0 Members and 1 Guest are viewing this topic.

Strat

  • Guest
Multiplayer Random Artillery
« on: 25 Dec 2004, 23:21:26 »
I have used/tried all the artillery strikes on OFPEC, the 3 or 4 that I could find.

I'm having a problem, I set a Helipad(invisible) as what the flak artillery is aiming for. Since it is on the ground, it hits the ground. I've tried changing the Height Command, but it is useless.

This is the script I've found the most easiest to use. (I am the Suber n00b).  I want the flak to hit about 20 or so meters off the ground, so it lights up, but isn't killing off my teammates.

Script Made by Pica

Code: [Select]
;
;Created by Pica
;
;area of flak around target
;random  height of flak
;target aircraft
;game logic name
;ammo to use
;example
;[150,10,blackhawk,log1,"shell73"] exec "flak.sqs"


_area = _this select 0
_height = _this select 1
_target = _this select 2
_logic = _this select 3
_ord = _this select 4



#loop
_where = getpos _target
_logic setpos [(_where select 0) - random _area + random _area, (_where select 1) - random _area + random _area, (_where select 2) + random _height +10]

_bomb = _ord camcreate getpos _logic
_bomb = _ord camcreate getpos _logic

~random 2.5

;you can change the condition below the end
? alive _target : goto "loop"

I'm not sure how many of you are familiar. And if you are wondering, I don't want to use a helicopter, it is a WWII mission. Kind of based on Band of Brothers where they are outside foy, and getting hit with flak.

All help is appreciated.

-Ben

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Multiplayer Random Artillery
« Reply #1 on: 29 Dec 2004, 13:15:12 »
try this

1) Create a visible object
2) setpos it to the height you want it
3) save its position as a variable
4) delete the object

use the saved position as the target location for your flak

(I dont think you can setpos logics with height, i believe they just return 2 coordinates)

*********************************************************
STAGE1
create an object in the mission editor, something that you can see, lets say a Danger sign

name it "Target1"

Place the following line in the danger signs init box

this setpos [getpos this select 0, getpos this select 1,10]
adjust the value  10 to increase or decrease the objects height


by previewing the mission, you will be able to get "Target1" exactly where you want it

*********************************************************
STAGE2
Place the following lines in a script eg init.sqs

~0.1
Flakpos = getpos Target1
deletevehicle Target1

*********************************************************
STAGE2
use

Flakpos

as your target location

eg

[150,10,blackhawk,Flakpos,"shell73"] exec "flak.sqs"



*****************************************************************
NB>>>

I believe camcreate is only run locally on a machine
this means, that the randomness of the shell position will be different on each clients (Players) machine, whereas if you have the server run a createvehicle command, the object is seen in the same place on all clients even though only the server ran the script
« Last Edit: 01 Jan 2005, 16:35:03 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Strat

  • Guest
Re:Multiplayer Random Artillery
« Reply #2 on: 30 Dec 2004, 02:15:32 »
Hey, I really appreciate it. That works wonderful.

-Ben

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Re:Multiplayer Random Artillery
« Reply #3 on: 30 Dec 2004, 02:41:56 »
First note; As Torex suggested, get rid of CAMCREATE ...... it doesnt work correctly for this task in Multiplayer. Replace it with CREATEVEHICLE ..... works perfect then.

Next note;
Sample of my MP Artillery script;
Code: [Select]
_position = _this select 0
_radius = _this select 1

?!(local server) : exit  ; run only on server

_power = "laserguidedbomb"
_mx = (getpos _position select 0)
_my = (getpos _position select 1)
_mz = 0

#Randomize
_dir = random 360
_dis = random _radius
_rx = (sin _dir) * _dis
_ry = (cos _dir) * _dis

#Boom
_Booom = _power createVehicle [(_mx + _rx), (_my + _ry), (_mz)]  

This works for ground strikes. BTW, laserguidedbomb is probably too deadly, use your shell73 instead.
To modify for Air/flak strikes try (untested code);
Code: [Select]
_position = _this select 0       ; Target
_radius = _this select 1         ;blast radius
_AimHigh = _this select 2          ;distance above wanting to miss
_NumRounds = _this select 3        ;number of explosions in one call

?!(local server) : exit           ; run only on server

_power = "shell73"
_mx = (getpos _position select 0)
_my = (getpos _position select 1)
_mz = (getpos _position select 2)

#Randomize
_dir = random 360
_dir2 = random 360
_dis = random _radius
_dis2 = random _radius
_rx = (sin _dir) * _dis
_ry = (cos _dir) * _dis
_rz = (cos _dir2) * _dis2

#Boom
_Booom = _power createVehicle [(_mx + _rx), (_my + _ry), (_mz + _rz + _AimHigh)]

_NumRounds = _NumRounds - 1
?(_NumRounds < 1 ) : exit
~0.2              ; delay between rounds
goto "Randomize"
 

Sample call would be;
[Blackhawk1, 10, 20, 5] exec "Scriptname.sqs"
(Target, Radius, AimHigh, #Rounds)

Hope that was of some help.

Offline Clayborne

  • Members
  • *
Re: Multiplayer Random Artillery
« Reply #4 on: 22 Jul 2010, 22:52:07 »
Ok I know this is six years old but it's relevant.

I need a random impact zone in MP so I'm trying to modify an SP script. But Terox said up there that createvehicle is global. Does this mean that if I have only the server run the script, I don't have to make the clients run it too? And the random impacts will be the same for everyone?

I was about to make two seperate scripts so that would help a bunch.

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Multiplayer Random Artillery
« Reply #5 on: 24 Jul 2010, 21:26:06 »
Hi Clayborne.

Yes, createVehicle is definitely a global command. It will create one vehicle per execution. So if you let all computers execute createvehicle commands in the same place at the same time, you will get 4 or 5 jeeps stacked on top of each other (for example). Only run creation commands on the server.

And yes, the random impact zones will be the same. A shell will not be in more than one place at the same time, unless there's lag. Obviously, it would be best to have all the random processing done on one computer, though.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Clayborne

  • Members
  • *
Re: Multiplayer Random Artillery
« Reply #6 on: 27 Jul 2010, 12:41:04 »
Ok, cool.

I'm also using OnMapSingleClick to control the artillery. I haven't used this before but it works fine in SP so far. If anyone could look at this and tell me if it should work in MP that would be helpful.


The Map click command is started like this (got this from another thread here)

Code: [Select]
a = 0
b = 0
clicked = false

onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true; publicVariable "a"; publicVariable "b"; publicVariable "clicked"; [] exec "Arty1.sqs"}

In the mission, you define the number of rounds you want by using a radio command. At the moment it is 1 or 3. This sets a variable called RoundCount to the desired number and PublicVariables it. This is then passed into the script via Arty1.sqs which looks like this;


Code: [Select]
onMapSingleClick {}
_pos = [a,b,-1]

~2

target setpos _pos  //here I am SetPos'ing a small object which serves as the target marker

[GetPos Target,"Shell125",25,0,ROUNDCOUNT,5,5,3,25] exec "g_arty.sqs"

where g_arty.sqs is the main artillery script. After that, the position (a,b) and 'clicked' values are reset to 0 and publicvariabled,  and the Map click command is defined again in the same fashion.

As long as I exit ?! localserver at the start of these scripts should this work in MP?

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Multiplayer Random Artillery
« Reply #7 on: 27 Jul 2010, 18:32:41 »
Quote
As long as I exit ?! localserver at the start of these scripts should this work in MP?

Sounds like it. It's hard to tell these things from just reading, to be honest. One way to test is to open two instances of OFP and join your own hosted game. This gives you FADE warning messages, though. I'm not sure if it will damage your copy of OFP.

Another option is to use the free OFP dedicated server program, set up your own server, and then join it. This doesn't activate FADE, but I never understood how to use the dedicated server program. :P

Anyway, although I think your method will work, I did notice a possible area for improvement:

Code: [Select]
target setpos _pos  //here I am SetPos'ing a small object which serves as the target marker
An object setPos'd on one computer will be setPos'd on all computers, so this code seems to make your global variables "a" and "b" redundant. Just use local variables, and the other computers will know the co-ordinates based on the position of the target marker.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Clayborne

  • Members
  • *
Re: Multiplayer Random Artillery
« Reply #8 on: 27 Jul 2010, 18:51:51 »
Yeah but don't I need A and B to tell the script where the map click was?

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Multiplayer Random Artillery
« Reply #9 on: 27 Jul 2010, 23:12:59 »
Yeah but don't I need A and B to tell the script where the map click was?

What's wrong with simply writing

Code: [Select]
onMapSingleClick {target setPos _pos}

???

The target will now necessarily be where the map click was.
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)