Jump to content
Sign in to follow this  
igneous01

Supereasy random artillery fire script

Recommended Posts

For those people who want to simulate some random mortar/artillery fire in their mission without the processing of actual artillery units that fire.

put this into your init sqf

// random mortar fire function
if (isnil "DZ_fnc_MortarFire") then {
   DZ_fnc_MortarFire = {
       private ["_ammo", "_marker", "_xcoord", "_ycoord", "_timer", "_fire"];
       _ammo = _this select 0;
       _marker = _this select 1;
       _xcoord = _this select 2;
       _ycoord = _this select 3;
       _timer = _this select 4;
       _fire = true;
       while {_fire} do {
           _firerun = _ammo createvehicle [(getmarkerpos _marker select 0) + random _xcoord, (getmarkerpos _marker select 1) + random _ycoord, getmarkerpos _marker select 2];
           sleep (random _timer);
       };
   };
};

then place a trigger on the map, set the condition to true.

add this in the activation field.

mf1 = ["ARTY_Sh_81_HE", "mort1", 100, 150, 17] spawn DZ_fnc_MortarFire; 

where, "ARTY_Sh_81_HE" is the classname of the shell, "mort1" is the name of a marker, and the rest are in order,

x y radius of where the shells will go off,

max random time to fire.

if you want to have multiple areas with random shelling of artillery, then just copy paste the above and change the marker name.

hope this helps some noobies looking for artillery

Share this post


Link to post
Share on other sites

If started from a trigger like that in MP, it will be creating a bomb for each player.

Share this post


Link to post
Share on other sites

yes thats true, im not experienced working with mp types of scripts or missions, so i wouldnt know.

i guess adding if (isdedicated) or if (isserver) would fix that, then it would only execute on the server machine.

Share this post


Link to post
Share on other sites

Yeah, could use isserver to limit it. Or change the createvehicle to createvehiclelocal to avoid the network traffic by creating them locally for everyone.

Share this post


Link to post
Share on other sites

so heres the mp version (didnt test it tho, i have no methods of testing in mp)

// random mortar fire function
if (isserver) then {
if (isnil "DZ_fnc_MortarFire") then {
   DZ_fnc_MortarFire = {
       private ["_ammo", "_marker", "_xcoord", "_ycoord", "_timer", "_fire"];
       _ammo = _this select 0;
       _marker = _this select 1;
       _xcoord = _this select 2;
       _ycoord = _this select 3;
       _timer = _this select 4;
       _fire = true;
       while {_fire} do {
           _firerun = _ammo createvehicle [(getmarkerpos _marker select 0) + random _xcoord, (getmarkerpos _marker select 1) + random _ycoord, getmarkerpos _marker select 2];
           sleep (random _timer);
       };
   };
};
};

that should make it mp compatible, but like i said, never dealt with mp or had a ways of testing in mp. so not too sure

Edited by Igneous01

Share this post


Link to post
Share on other sites

Wouldn't locally created ordnance just mess the MP side completely? Invisible explosions(?) destroying and killing stuff.

Share this post


Link to post
Share on other sites

i think your right. it would only create it on the server machine, meaning only the admin/host would see it.

looks like i was right just sticking to createvehicle...

Share this post


Link to post
Share on other sites
Wouldn't locally created ordnance just mess the MP side completely? Invisible explosions(?) destroying and killing stuff.

Well, dont quote me, but my guess is that it doesnt matter for eye candy. Why would there be invisible explosions when no bombs are synched? Not like synching bombs will make sure that tree will fall same way for everyone etc anyway. Stuff getting killed should be determined by the explosion on the machine the unit/vehicle is local to?

Share this post


Link to post
Share on other sites
Well, dont quote me, but my guess is that it doesnt matter for eye candy. Why would there be invisible explosions when no bombs are synched? Not like synching bombs will make sure that tree will fall same way for everyone etc anyway. Stuff getting killed should be determined by the explosion on the machine the unit/vehicle is local to?

The problem is that there will be no eye candy for the clients if the bombs exist only for the server.

Share this post


Link to post
Share on other sites
yeah, could use isserver to limit it. or change the createvehicle to createvehiclelocal to avoid the network traffic by creating them locally for everyone.

or ;)

Share this post


Link to post
Share on other sites
Is there a whistling sound? :]

no didnt add a whistling sound, but i believe there might be a way to synchronize it with a trigger that plays the whistling sound file.

Share this post


Link to post
Share on other sites
or ;)

Creating them locally for each client would multiply said problem.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×