Jump to content
Sign in to follow this  
Tonmeister

random carbomb script

Recommended Posts

so here is a simple car bomb script that will randomly place an ied into a car and set it off based on distance to the vehicle.

place this into the init line of the vehicles you want to potentially have an ied planted.

nul=[this] execVM "carbomb.sqf";

place this script in your mission folder;

carbomb.sqf

_object = _this select 0;
_value = random 100;

if (_value < 25) then {
_trg=createTrigger["EmptyDetector", position _object];
_trg setTriggerArea[8,8,0,false];
_trg setTriggerActivation["WEST","PRESENT",false];
_trg setTriggerStatements["this", "_bomb = nearestObject [getPos (thislist select 0), 'Car']; boom = 'R_57mm_HE' createVehicle position _bomb", ""];
};

to increase the chances of any vehicle to have an ied planted, simply increase the integer of _value in the script.

also props to ProfTournesol for his advice. here is the orig thread...

http://forums.bistudio.com/showthread.php?t=94670

cheers

Share this post


Link to post
Share on other sites

Nice idea, will try out. Thx!

Share this post


Link to post
Share on other sites

In what format do you "write" a script? Word doc?...In order to place it in your missions folder? I have DL a couple scripts but I'm not sure how to create them.

Share this post


Link to post
Share on other sites
In what format do you "write" a script? Word doc?...In order to place it in your missions folder? I have DL a couple scripts but I'm not sure how to create them.

you can use notepad , notpad++ or chris's editor thingy.

depending on what scripting your using its either .SQS or .SQF you save files as..

Share this post


Link to post
Share on other sites

I'd add some isserver checks in there if it's used in MP.

Share this post


Link to post
Share on other sites

Nice script. You may want to put the chance as a parameter too instead of hardcoded, eg.:

nul=[this, 25] execVM "carbomb.sqf";

Share this post


Link to post
Share on other sites

Ive been trying this for OA demo and its not working. I can do a trigger present blufor and itll go off once in area but for some reason it doesnt set off with this script. I like the probability but Id really like more randomness in my mission..

Share this post


Link to post
Share on other sites
Ive been trying this for OA demo and its not working. I can do a trigger present blufor and itll go off once in area but for some reason it doesnt set off with this script. I like the probability but Id really like more randomness in my mission..

Same here doesn't seem to work?

Share this post


Link to post
Share on other sites

Heres a simple one I used in Arma2:

To make a BOMB:

Place an car in your mission.

Name the car TARGET

Then create an trigger and choose how you want to activated it, for example we'll use Radio Alpha.

In the the trigger's Activation Field put the following:

BOMB = "Bo_GBU12_LGB" createVehicle getpos TARGET;

Place the trigger somewhere you want the bomb to go off, then send your car

into the trigger and click on the radio alpha, and BOOM!

Theres many ways to do this,

you can have the car as an object instead, like an IED, and have it so

for example:

when blufor is present in the trigger the bomb goes off _( this would be an area trigger, instead of a radio.

Radio trigger you will use alpha , bravo, ect., Area trigger is triggered by who is present, so like blufor(USA), or Opfor(russia) ect.,

or you can substitute a civillian, or even another faction, maybe a soldier, dont matter,

give them the name Target, and do it that way.

Keep in mind you dont have to have it named as Target you can name it whatever but be sure

to change the name in the code seen above, also you can change the size of the bomb to maybe

something smaller, youll have to get the class name for it though.

Edited by Gnter Severloh

Share this post


Link to post
Share on other sites

Thats all nice but is there a way we could get a random carbomb script to work with Silvie? Like i would just drop down the silvie module on my mission and have a script that randomly makes some of the spawned vehicles bombcars that will go off like when your in a 20m radius of the car? that would be pretty nice as really nobody would know what car really is an bombcar and wich not ;s

Share this post


Link to post
Share on other sites

Using the bomb example I posted you could do that,

create 2 cars,

then create one car with a small trigger around it, enough for a person to walk up to it.

in the trigger's init line put:

BOMB = "Bo_GBU12_LGB" createVehicle getpos TARGET;

Place a player, and name yourself target or whatever you want, be sure to adjust the code accordingly

with the name you give yourself or another person whos demise is eminent:D.

Now highlight both cars, and copy n paste multiple areas, and mix them up,

you wont know which one is the bomb ingame, if you position the cars in odd way.

When you or whoever has the name target walks up to the car BOOM!

thats another way, no scripts needed, just an object, a trigger, and something,

or someone with the name thats in the code.

Share this post


Link to post
Share on other sites

Well i know u could do it that way but thats not just what i wanted. in that way the editor most times still knows what car is a bomb car even if u mix em up^^ thats why i asked for a solution with the silvie module :S no offence mate but i think there is a difference

Share this post


Link to post
Share on other sites

Nice one Ebola!

I've done a similar script but using the DAC module to generate random objects which will then have a chance of being IED's.

Here's what I've done so far:

In your description.ext:

class Params
{

       class IEDcount	//params array 0
       {
	title = "IEDS:";
	values[] = {0,1,20,50,75};
	default = 75;
	texts[] = {"None","Very Few","A couple","Many","Shoitloads"};
};

class IEDtypes	//params array 1
       {
	title = "IED Types:";
	values[] = {1,3,4,};
	default = 3;
	texts[] = {"Flesh Wound","Lifelong Limp","Widowmaker"};
};
};

function to create IED on Object fn_makeIED:

private ["_spawnObject","_rvalue","_explType"];
_spawnObject = _this select 0;
_rvalue = round(random 100)+1;

if (_rvalue < (paramsArray select 0)) then
{
switch (round(random (paramsArray select 1)+1)) do
{

	case 1: {_explType = "'R_57mm_HE'";};
	case 2: {_explType = "'ARTY_Sh_81_HE'";};
	case 3: {_explType = "'ARTY_Sh_120_HE'";};
	case 4: {_explType = "'Bo_GBU12_LGB'";};
};

_trg=createTrigger["EmptyDetector",position _spawnObject]; 
_trg setTriggerArea[15,15,0,false];
_trg setTriggerActivation["WEST","PRESENT",true];
_trg setTriggerStatements["this", format ["%1 createVehicle %2",_explType, ([position _spawnObject, 3] call CBA_fnc_randPos)], ""];
};
[/spoiler]

Then in the [b]DAC_Config_Objects.sqf[/b]
[spoiler][code]
case 10:
{
	_Object_Pool =	[
					[12,1],
					["BMP2Wreck",5,0,0.0,0,0,"[_obj] call fn_makeIED",[0,"ColorRed"]],
					//Add more objects to the array using the same format and function call
				];
};

You then just create a DAC object zone and use the object pool above.

It still isn't fully randomised yet so every object will explode with a GBU12 bang!

I'll be adding Paramater based random values for bomb types and probability of IED presence when I have a chance.

EDIT: added randomisation!

I'd also like to figure out a way of making the DAC Object generator limit the placement to roadsides only.

Edited by Wobbleyheadedbob

Share this post


Link to post
Share on other sites

this was posted a LONG time ago but noone thought or asked how to attach the trigger to the object that is calling the script. this seems to work and makes for some great ALICE spawned suicide bombers.

to attach it i added

_trg attachto [_object]

and for testing purposes i made sure 100% of the spawned civilians would be bombers, here is the full script and the ALICE init code

script

_object = _this select 0;
_value = random 100;


if (_value < [b]150[/b]) then {
   _trg=createTrigger["EmptyDetector", position _object];
   _trg setTriggerArea[5,5,0,false];
   _trg setTriggerActivation["WEST","PRESENT",false];
   _trg setTriggerStatements["this", "_bomb = nearestObject [getPos (thislist select 0), 'Man']; boom = '[b]R_57mm_HE[/b]' createVehicle position _bomb", ""];
   _trg attachto [_object]
};


change the two highlited items above to change the percentage of spawns that will be bombers and the bomb type

ALICE

[bIS_alice_mainscope,"ALICE_civilianinit",[{nul=[_this] execVM "ied.sqf";}]] call bis_fnc_variablespaceadd;

Share this post


Link to post
Share on other sites
Do you know if it will work in MP?

it should..maybe should put server side checks

been attempting to get it to work on my wasteland but apparently it decided to not work at all.. even locally... im so confused now, been trying for over 2 hours now to get it lol

Share this post


Link to post
Share on other sites

This works in MP & on Dedi

Add this to SILVIE Module

BIS_silvie_mainscope setvariable ["vehicleInit",{[_this] execVM "carbomb.sqf";_this lock false}];

then

carbomb.sqf

_object = _this select 0;
_value = random 100;

//Change 30 to what ever you like test with 100 !

if (_value < 30) then {
_blowup = false;
while {alive _object} do
   {
   // include vehicles
       _targetArray = nearestObjects [(getPos _object), ["MAN", "LandVehicle"], 10];
       if ((count _targetArray) > 0) then
       {
           {
               if (str(side _x) == "WEST") then
               {
               _blowup = true;
               };
           } forEach _targetArray;
       };
       if (_blowup) then
       {
   //HINT "CAR BOMB.....";
  if (isServer) then
{
  [nil, nil, rHINT, "CAR BOMB...TAKE COVER"] call RE;
};  
  // player commandChat "CAR BOMB....." ;
   sleep 5;
       _boom = "Bo_GBU12_LGB" createVehicle (position _object);
       }
       else
       {
       sleep 10;        // change to tweak wait time before checks
       };
   };
};  

Share this post


Link to post
Share on other sites
This works in MP & on Dedi

all sides except for CIV would be done with changing:

               if (str(side _x) == "WEST") then

to

               if (str(side _x) == "WEST"||"EAST"||"GUER") then

or even

               if (str(side _x) != "CIV") then

correct?

Share this post


Link to post
Share on other sites
Yep that would work , there would be a lot going off !

if i did that i would remove the land vehicles from the list.. dont want to blow the cars up from a vehicle that spawned next to it that was !CIV XD

even tho that basically means anyone in a car can just drive up and nothing happen..

edit-

im having a weird issue... it isnt working now.. it worked a few hours ago.. i have nothing in the RPT either, just normal startup stuff

here is the mission, does it work for you? https://dl.dropbox.com/u/1465291/iedtest.Takistan.pbo

Edited by H3NRY

Share this post


Link to post
Share on other sites
if i did that i would remove the land vehicles from the list.. dont want to blow the cars up from a vehicle that spawned next to it that was !CIV XD

even tho that basically means anyone in a car can just drive up and nothing happen..

edit-

im having a weird issue... it isnt working now.. it worked a few hours ago.. i have nothing in the RPT either, just normal startup stuff

here is the mission, does it work for you? https://dl.dropbox.com/u/1465291/iedtest.Takistan.pbo

For some reason dropbox just opens the file , weird , but i can see the scripts and it looks like you are using your script not the one i posted ?

Share this post


Link to post
Share on other sites
For some reason dropbox just opens the file , weird , but i can see the scripts and it looks like you are using your script not the one i posted ?

yah i am. i seem to have figured out that it is not setting it as the init of the spawned CIV, it is in there correct and exactly as was shown above ( re copied everything and made a new pbo, the one i uploaded) andstill no go.. now arma has me lost, works one minute but not the next, same EVERYTHING ( tried adding mods, removing mods, new profile, deleting all profiles... nada.)

i must have messed something up somewhere but i guess i will figure that out on my own.

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  

×