cpthammerbeard 10 Posted March 25, 2015 (edited) Hello, I'm looking for a bit of help with a condition. The task is to clear out mines. The mines are scripted and generated in random positions and therefore don't have names assigned to them so I can't check using !mineActive mine1 and !mineActive mine2......... //get the editor based marker _smNavalMinePos = getMarkerPos "smNavalClearOne"; //create visible area marker and area for enemy divers to patrol _smNavalMineArea = createMarker ["smNavalClearOneArea",_smNavalMinePos]; _smNavalMineArea setmarkerShape "ellipse"; _smNavalMineArea setMarkersize [130,130]; _smNavalMineArea setMarkerColor "colorBlack"; for "_i" from 1 to 8 do { //find a random location _minePos = [_smNavalMinePos,10,60,10,2,0,0] call BIS_fnc_findSafePos; //create a mine _mineSpawn = createMine ["UnderwaterMine",_minePos,[],0]; //sink mine 2m below the surface _mineSpawn setPosATL [_minePos select 0,_minePos select 1,(getPosATL _mineSpawn select 2) - 2]; }; //create tigger to check the state of placed mines _trgMineChecker = createTrigger ["EmptyDetector", _smNavalMinePos]; _trgMineChecker setTriggerArea[130,130,0,false]; _trgMineChecker setTriggerActivation["ANY","PRESENT",false]; _trgMineChecker setTriggerStatements["({!mineActive _x} count thisList) == 8","minesDefused = true", ""]; waitUntil{(!isNil ("minesDefused"))}; //win lose messages switch (minesDefused) do { case true: { hint "its true"; }; case false: { hint "its false"; }; }; Many thanks :) Edited March 25, 2015 by CptHammerBeard Share this post Link to post Share on other sites
Larrow 2814 Posted March 25, 2015 Could just store the mines in an array when you spawn them. Rather than setting up a trigger just spawn a thread to check the mines. Something like (untested).. //create visible area marker and area for enemy divers to patrol _smNavalMineArea = createMarker ["smNavalClearOneArea",_smNavalMinePos]; _smNavalMineArea setmarkerShape "ellipse"; _smNavalMineArea setMarkersize [130,130]; _smNavalMineArea setMarkerColor "colorBlack"; //ARRAY to store mines _myMines = []; for "_i" from 1 to 8 do { //find a random location _minePos = [_smNavalMinePos,10,60,10,2,0,0] call BIS_fnc_findSafePos; //create a mine _mineSpawn = createMine ["UnderwaterMine",_minePos,[],0]; //Add mine to ARRAY _myMines pushBack _mineSpawn; //sink mine 2m below the surface _mineSpawn setPosATL [_minePos select 0,_minePos select 1,(getPosATL _mineSpawn select 2) - 2]; }; //Create thread to monitor mines _checkMines = _myMines spawn { //Passed mines ARRAY _mines = _this; //Loop forever while { true } do { //Exit loop if the are 0 active mines if ( { mineActive _x }count _mines == 0 ) exitWith { //Set variable minesDefused = true; }; //Check every half second sleep 0.5; }; }; Share this post Link to post Share on other sites
cpthammerbeard 10 Posted March 25, 2015 That works wonderfully! Thanks Larrow. Share this post Link to post Share on other sites