Jump to content
Midnighters

Issue with vehicles when script ran multiple times

Recommended Posts

Hello all.

I ran into a problem recently.

I found that if I set _trg to trg then my triggers work outside a given set of brackets. Which is expected.

same with _ied and ied

 

iedtype = (_this select 0); //marker or map based. Either a string with the marker name, or as string with "mapPos"
probability = (_this select 1); //probability
arrayMin = ((_this select 2) select 0); //array of numbers ex: [1,2,3]
arrayMedian = ((_this select 2) select 1);
arrayMax = ((_this select 2) select 2);
allowRoads = (_this select 3); //boolean
debug = (_this select 4); //boolean
safeZones = (_this select 5); //array
findMapPos = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition");
findMapSize = getNumber(configFile >> "CfgWorlds" >> worldName >> "mapSize");
findRoads = findMapPos nearRoads findMapSize;
iedSelection = ["_iedUrbanBig_F","_iedLandBig_F"];
explosionSelection = ["M_Titan_AT","Bo_Mk82","Bo_GBU12_LGB","R_230mm_He","R_80MM_HE"];
fnc_explosion = { (selectRandom explosionSelection) createVehicle (getPos (_this select 0)) };

if(iedType == "mapPos") then {
for "_i" from 0 to random[arrayMin,arrayMedian,arrayMax] do {
	if(allowRoads) then {
				if(probability > random 100) then {
					_ied = (selectRandom iedSelection) createVehicle (getPos (selectRandom findRoads));
					_trg = createtrigger["EmptyDetector",(getPos _ied)];
					_trg setTriggerArea[1,1,1,false];
					_trg setTriggerActivation["Any","PRESENT",false];
					_trg setTriggerStatements["this","(selectRandom explosionSelection) createVehicle (getPos _ied); deleteVehicle _ied;",""];
					if((count safeZones) > 0) then {
					{	if((getPos _ied) inArea (getPos _x)) then { deleteVehicle _ied; };
						if((getPos _trg) inArea (getPos _x)) then { deleteVehicle _trg; };
					 } forEach safeZones;
						};
					if(debug) then {
						_mkr = createMarker[(str(getPos _ied)),(getPos _ied)];
						_mkr setMarkerType "hd_dot";
						_mkr setMarkerColor "ColorRed";
					};
				};
			};
		};	
	};

This is the entirety of the script, I am nowhere near done with it. But the issue is that when the trigger is activated, another ied is set off. I'm thinking because ied is all the same to the script.

Rather than each fo them being their own mine? 

Share this post


Link to post
Share on other sites

yeah it definitely has no idea where the ied is at..

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

×