Jump to content
jcae2798

Counting mines in list

Recommended Posts

Sorry all, i tried and tried till i'm ready to bang my head on the wall.  I did some searches which has a lot of info but still cant get what i need to work.

 

What i am trying to do is is count active mines in a trigger and when it hits 0, trigger is activated..

 

I tried the following with no luck and many more!:

(({mineActive _x} count allmines) in thistrigger) == 0
{({mineActive _x} count (allmines))} count thislist == 0
((count thisList) == ({mineActive _x} count allmines)) == 0
(({mineActive _x} in thislist) count allmines) == 0

Would appreciate some help.  Thanks as always!

Share this post


Link to post
Share on other sites

I would not chose a trigger for that. Not sure thisList will contain the mines. Do the following:

 

Try the following.

 

Put a game logic in the trigger center position, name it "myGameLogic"

 

Place a trigger, zero radius, and condition is {(_x distance myGameLogic < sizeoftheoldtrigger) and (mineActive _x)} count allMines == 0

 

Not tested.

Share this post


Link to post
Share on other sites

TY Sir, that did work.  Didnt even think about that  (still a noob here)

  • Like 1

Share this post


Link to post
Share on other sites

Could also use (in trigger condition field):

{    
    ([thisTrigger,getPos _x,false] call BIS_fnc_inTrigger) && mineActive _x
} count allMines == 0
This can be used outside of the trigger condition as well, simply replace "thisTrigger" with the name of the trigger and you can do your own custom loop or whatever pleases you :p.

Share this post


Link to post
Share on other sites

I would not chose a trigger for that. Not sure thisList will contain the mines. Do the following:

 

Try the following.

 

Put a game logic in the trigger center position, name it "myGameLogic"

 

Place a trigger, zero radius, and condition is {(_x distance myGameLogic < sizeoftheoldtrigger) and (mineActive _x)} count allMines == 0

 

Not tested.

Yeah, triggers don't pick up mines. Only units and game logics, AFAIK.

 

You don't need the game logic here, by the way. You could just use  _x distance thistrigger

Share this post


Link to post
Share on other sites

count (( thisTrigger nearObjects[ "TimeBombCore", (triggerArea thisTrigger) select 0 ] ) + ( thisTrigger nearObjects[ "MineBase", (triggerArea thisTrigger) select 0 ] )) isEqualTo 0
As a trigger condition will check for mines/explosives in a radius around the trigger of the triggers largest axis.

Or you could write it like

{
	count ( thisTrigger nearObjects[ _x, ( triggerArea thisTrigger ) select 0 ] ) isEqualTo 0 	
}count [ "TimeBombCore", "MineBase" ] isEqualTo 2
May look a little cleaner

Share this post


Link to post
Share on other sites

larrows code is allways the cleanest

 

But performance wise, I think ONLY THIS TIME, I have something better. I will dare to try.

 

A GL with this on it's init field:

 

mineArray = []; {if (_x distance this < desiredDistance) then {mineArray pushBack _x}} forEach allMines;// this way we only iterate through a small number of mines and not the whole mission mines. No looped searches, no looped allMines.

 

Now in the trigger: {if (mineActive _x) exitWith {1}} count mineArray == 0;

 

This said will not check if someone has planted a new mine in the zone we want it clean but.... fastest?

Share this post


Link to post
Share on other sites

Just a thought, How are you spawning your mines? Are they laid down via the module? IF so THIS may be worth a read.

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

×