Sign in to follow this  
Followers 0
mantls

Roadside IED Script

102 posts in this topic

Hey there,

This Script will spawn both IEDs and Junk alongside roads inside of a given radius. The IEDs can be disarmed by Anybody with a Toolkit.

In order to disarm an IED, you have to approach it very slowly and carefully and then simply use the addaction.

UPDATE1:

  • Added call parameters
  • added Cleanup function

UPDATE2:

  • Fixed: IED placement improved
  • Fixed: Bug with the Addaction ("Disarm" was still visible for other players after disarming)
  • removed: You no longer have to be an Explosive Specialist to disarm IEDs
  • New: Randomised Force of explosion
  • New: Toolkit needed for disarming

Small Update 3:

  • Added: Side Parameter

Usage:

1. Create a marker called "center"

2. Set parameters in "IED\ied.sqf"

3. Define Functions in Init.sqf (copy from the one in the folder)

4. Call it however you want (Init, trigger, addaction, etc...)

Download: https://www.dropbox.com/s/2nf9p421njc5503/IED.zip (Always up to date)

Armaholic: http://www.armaholic.com/page.php?id=20839 (Thank you Foxhound!)


Ied.sqf

//                                    |--------------------------------------------|  
//                                    | Dynamic IED script by - Mantis and MAD_T - |  
//                                    |        Version 2c - 12.6.2013              |  
//                                    | Check out TACO at www.nss-gamers.com       |  
//                                    |--------------------------------------------|  

// USAGE:
//        1. Create a Marker called "Center" somewhere on Map
//        2. Set Parameters in script.
//        3. Call it however you want (Init, trigger, addaction, etc...) 
//
//
//        NOTE: The more Roads in an area the higher the probability of IEDs spawning there.




//null = ["markername", amount, distance,side, cleanup(0 or 1)] execVM "IED\ied.sqf";


if (!isserver) exitwith {};


_centermrk = _this select 0;
_center = getmarkerpos _centermrk;     // Your Centerpoint
_counter = 0;
_amount = _this select 1;                        // Amount of IEDS on Map        
_dist = _this select 2;
_check = _this select 4;
_side = _this select 3;
if (_check == 1) then {


while {_counter < _amount} do 
{
_force = random 100;
_rdist = 5.75;
_list = _center nearRoads _dist;
_iedarray =["Land_GarbagePallet_F","Land_CanisterFuel_F","Land_GarbageWashingMachine_F","Land_JunkPile_F","Land_CanisterPlastic_F","Land_Tyres_F","Land_GarbageBags_F","Land_Wreck_Truck_F"]; // Objects used as IEDs
_iedtype = _iedarray select (floor random (count _iedarray));
_road = _list select (round random (count _list));
_roadDir = getDir _road;
_chance = random 100;
_newDir = _roadDir;
if (_chance < 50) then {_newDir = (_NewDir + 180)};		
_dir = _newdir;
_pos = getpos _road;
_posx = _pos select 0;
_posy = _pos select 1;
_tx = (_posx + (_rdist * sin(_dir)));
_ty = (_posy + (_rdist * cos(_dir)));
_iedpos = [_tx,_ty,0];

Call compile format ['
ied_%1 = _iedtype createVehicle _iedpos;
ied_%1 setDir (random 360);
ied_%1 enableSimulation false;', iedcounter];



_junktype = _iedarray select (floor random (count _iedarray));
_road2 = _list select (round random (count _list));
 while { _road2 == _road} do
  { _road2 = _list select (round random (count _list));
   };   

_pos = getpos _road2;
_posx2 = _pos select 0;
_posy2 = _pos select 1;
_tx2 = (_posx2 + (_rdist * sin(_dir)));
_ty2 = (_posy2 + (_rdist * cos(_dir)));
_junkpos = [_tx2,_ty2,0];
_junk = _junktype createVehicle _junkpos;
_junk setdir (random 360);


if (_force >= 0 && _force < 33) then {

call compile format ['
t_%1 = createTrigger ["EmptyDetector", _iedpos]; 
t_%1 setTriggerArea [8,8,0,true]; 
t_%1 setTriggerActivation [_side,"PRESENT",false]; 
t_%1 setTriggerStatements ["this && {speed _x >= 4.8} foreach thislist && {((position  _x) select 2) < 3} foreach thislist && (alive ied_%1)","""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2; deletevehicle ied_%1",""];
', iedcounter, _iedpos];
};


if (_force >= 33 && _force < 70) then {

call compile format ['
t_%1 = createTrigger ["EmptyDetector", _iedpos]; 
t_%1 setTriggerArea [8,8,0,true]; 
t_%1 setTriggerActivation [_side,"PRESENT",false]; 
t_%1 setTriggerStatements ["this && {speed _x >= 4.8} foreach thislist && {((position  _x) select 2) < 3} foreach thislist && (alive ied_%1)","""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2; deletevehicle ied_%1",""];
', iedcounter, _iedpos];

};


if (_force >= 70 && _force <= 100) then {

call compile format ['
t_%1 = createTrigger ["EmptyDetector", _iedpos]; 
t_%1 setTriggerArea [8,8,0,true]; 
t_%1 setTriggerActivation [_side,"PRESENT",false]; 
t_%1 setTriggerStatements ["this && {speed _x >= 4.8} foreach thislist && {((position  _x) select 2) < 3} foreach thislist && (alive ied_%1)","""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2; deletevehicle ied_%1",""];
', iedcounter, _iedpos];

};





call compile format ['
[[ied_%1, t_%1],"Disarm", true, true] spawn BIS_fnc_MP;
[[ied_%1, t_%1],"explosive", true, true] spawn BIS_fnc_MP;', iedcounter];



call compile format ['                                             // DEBUG! comment out for full Mission
bombmarker_%1 = createmarker ["bombmarker_%1", _iedpos];
"bombmarker_%1" setMarkerTypeLocal "hd_warning";
"bombmarker_%1" setMarkerColorLocal "ColorRed";
"bombmarker_%1" setMarkerTextLocal "bomb";', iedcounter];
_counter = _counter + 1;
iedcounter = iedcounter + 1; 
};


}; 

if (_check == 0) then { 
   _counter = -1;
   while {iedcounter != _counter} do 
   {

    call compile format ['
    deletevehicle t_%1;
    deletevehicle ied_%1;
    deletemarker "bombmarker_%1";', iedcounter];



    iedcounter = iedcounter - 1;
  };
   _counter = 0;
iedcounter = 0;
 };








disarm.sqf

//private ["t_%1"];

t = (_this select 0);

_array_item = items player;


if (_array_item find "ToolKit" > -1) then {

player switchMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 5.5;
deletevehicle (_this select 3);
[[t],"removeAct", true, true] spawn BIS_fnc_MP;
hint "Disarmed!";

}

else {


 player switchMove "AinvPknlMstpSlayWrflDnon_medic";
 sleep 2;
 "M_Mo_82mm_AT_LG" createVehicle (position t);
 "M_Mo_82mm_AT_LG" createVehicle (position t);
 "M_Mo_82mm_AT_LG" createVehicle (position t);
 deletevehicle (_this select 3);
 [[t],"removeAct", true, true] spawn BIS_fnc_MP;
 deletevehicle t;
 };





Init.sqf

iedcounter = 0;

Disarm = {
        _unit = _this select 0;
	 _b = _this select 1;
	 _unit addAction ["Disarm", "IED\Disarm.sqf", ( _b), 0, false, true, "", "(_target distance _this) < 3"];

};		 

removeAct = {
            _unit = _this select 0;
     _unit removeaction 0;
		 };	 


I plan on adding Eventhandlers for explosives, Rockets and Grenades. But please feel free to post suggestions, bugs, questions and of course your opinion.

UPDATE2: Still working on the explosives/Damage thing :/ Making some Progress though.

Cheers.

Edited by mantls
Update

Share this post


Link to post
Share on other sites

Nice script, you should post this on Armaholic too. :)

Dirty Haz

Share this post


Link to post
Share on other sites

Thank you :)

Not yet, as there are a few things i want to get done before that. In the BIS Forums i can just update it on my own.

Will do some work on it today.

Edited by mantls

Share this post


Link to post
Share on other sites

Can't get it working, it is coming up with lots of errors on mission load/start...

Dirty Haz

Share this post


Link to post
Share on other sites

Did you use the parameters correctly?

What does it say? If you could post your code then i'll have a look.

Share this post


Link to post
Share on other sites

I have got it working now, cheers!

Dirty Haz

Share this post


Link to post
Share on other sites

Suggestions:

Maybe make a % chance that the IED will explode.

Maybe move them more on the roadside as some spawned on the road itself (I think it was the bigger objects that did this, I have removed them from the object array for now).

Maybe make it so that all can disarm IEDs if a Toolkit/Mine Detector is equipped.

Also, is this script MP compatible?

Dirty Haz

Share this post


Link to post
Share on other sites

1# Aye, noted.

2# Was planning on changing the angle anyway.

3#Yeah, think thats a bit better that way as people tend to leave sessions at some point in time.

And yeah it is MP compatible :) Thx for your Feedback!

Share this post


Link to post
Share on other sites

No problem, keep me posted with the new updates/changes! :)

Dirty Haz

Share this post


Link to post
Share on other sites

Small Update.

Still working on the reaction to Damage though...

Share this post


Link to post
Share on other sites

Any chance someone would be willing to help a noob install this on their mission ?

Share this post


Link to post
Share on other sites

Its documented in the IED.sqf.

1. place a marker down and name it(e.g. center).

2. copy the contents of the Init.sqf included in the DL into your missions Ini.sqf

3. call the script with null = ["marker", amount, distance, 1] execVM "IED\ied.sqf";

to delete the IEDs null = ["markername", amount, distance, 0] execVM "IED\ied.sqf";

Edited by mantls

Share this post


Link to post
Share on other sites

What are the changes in this small update?

Dirty Haz

Share this post


Link to post
Share on other sites

They're listed in the Original Post but there you go:

UPDATE2:
  • Fixed: IED placement improved
  • Fixed: Bug with the Addaction ("Disarm" was still visible for other players after disarming)
  • removed: You no longer have to be an Explosive Specialist to disarm IEDs
  • New: Randomised Force of explosion
  • New: Toolkit needed for disarming

I'm currently testing a few different Eventhandlers but if anyone has an already working solution please let me know :D

cheers

Share this post


Link to post
Share on other sites

Hi mantls ! and thank's for your script !

Your script is called a missing file when approaching an IED :

null_%1 = [%2] execVM ""ambush.sqf""; deletevehicle ied_%1",""];

Can you tell me where I just change the effect of the explosion ?

(M_Mo_82mm_AT_LG i think ? but i see a lot in .sqf)

I just wish that ied damage the vehicle and not to destroy :)

Than you

[RFF] MkL

Share this post


Link to post
Share on other sites

Oh, oops. Thats something extra i used in of my Missions. Simply delete null_%1 = [%2] execVM ""ambush.sqf"" or use the newest Version.

I probably got some files mixed up in DropBox at some point.

There are different explosions, though many don't seem to work properly. Just add/delete ""M_Mo_82mm_AT_LG"" createVehicle %2; as many times as you want to make them stronger/weaker.

Edit: The explosions are "created" in the Trigger

call compile format ['
t_%1 = createTrigger ["EmptyDetector", _iedpos]; 
t_%1 setTriggerArea [8,8,0,true]; 
t_%1 setTriggerActivation ["West","PRESENT",false]; 
t_%1 setTriggerStatements ["this && {speed _x >= 4.8} foreach thislist && {((position  _x) select 2) < 3} foreach thislist && (alive ied_%1)","[color="#FF0000"][u]""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2[/u][/color]; deletevehicle ied_%1",""];
', iedcounter, _iedpos];
};

You could of course have them shoot flares/smoke/Teddybears by changing the red marked lines.

Edited by mantls

Share this post


Link to post
Share on other sites

Hi, can someone send me a test mission with working IED script, I can't get it to work. Finally I got it to work but when IED is detonating there is ERROR: Missing ambush.sqf script.

Edited by PawelKPL

Share this post


Link to post
Share on other sites
Hi, can someone send me a test mission with working IED script, I can't get it to work. Finally I got it to work but when IED is detonating there is ERROR: Missing ambush.sqf script.

Like i said, please update to newest version or simply remove it from the script like its documented in the previous post.

EDIT: Yeah... just saw something was left over. Fixed the Download, sorry for that. I mixed things up.

Edited by mantls

Share this post


Link to post
Share on other sites
Oh, oops. Thats something extra i used in of my Missions. Simply delete null_%1 = [%2] execVM ""ambush.sqf"" or use the newest Version.

I probably got some files mixed up in DropBox at some point.

There are different explosions, though many don't seem to work properly. Just add/delete ""M_Mo_82mm_AT_LG"" createVehicle %2; as many times as you want to make them stronger/weaker.

Edit: The explosions are "created" in the Trigger

call compile format ['
t_%1 = createTrigger ["EmptyDetector", _iedpos]; 
t_%1 setTriggerArea [8,8,0,true]; 
t_%1 setTriggerActivation ["West","PRESENT",false]; 
t_%1 setTriggerStatements ["this && {speed _x >= 4.8} foreach thislist && {((position  _x) select 2) < 3} foreach thislist && (alive ied_%1)","[color="#FF0000"][u]""M_Mo_82mm_AT_LG"" createVehicle %2;""M_Mo_82mm_AT_LG"" createVehicle %2[/u][/color]; deletevehicle ied_%1",""];
', iedcounter, _iedpos];
};

You could of course have them shoot flares/smoke/Teddybears by changing the red marked lines.

Good job ! Perfect what i want :)

For other user of this script, if you want do not destroy completly the car, use "M_RPG32_F", is better for that ... ;)

I tested with a lot other, but a lot dont work ... maybe cause is "Alpha" ... (?)

Share this post


Link to post
Share on other sites

hi,

is it possible to use smaller objects like can etc.. ???

Just a suggestion, have a param for the trigger side.

Edited by Mariodu62
suggetion

Share this post


Link to post
Share on other sites

Yeah, many explosions don't seem to be implemented as of yet.

However i've seen some more in the VTS 4.0 Missions by L'etranger. Have to take a look at that Colossus of Mission at some point.

First things first though, damagereactions are my goal for the next update.

@Marioudu62 It is! simply add/remove the classnames in the _iedarray

_iedarray =["Land_GarbagePallet_F","Land_GarbageWashingMachine_F","Land_JunkPile_F","Land_CanisterPlastic_F","Land_Tyres_F","Land_GarbageBags_F","Land_Wreck_Truck_F"]; // Objects used as IEDs

Share this post


Link to post
Share on other sites

Juste a question, sometimes ieds don't explode, is it normal or not ?

Share this post


Link to post
Share on other sites

Mh? Are you referring to Junk?

The Script spawns both IEDs aswell as junk, which will not explode. It serves as a "distraction".

Share this post


Link to post
Share on other sites

HI, thank you for that script, It works ok but when in multiplayer on the map I have red bomb markers, also what is ied_counter=0/1 ?

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  
Followers 0