Jump to content
Sign in to follow this  
Evilhardt

check if element of list !alive

Recommended Posts

Hey,

I want a trigger that fires, when one element of a list is not alive.

I got a bunch of bots named "bot1", "bot1_1", ..., "bot1_7" in a trigger area. I wrote a short fragment of code of which I don't know if it's logical:

_bots = [bot1,bot1_1, bot1_2, bot1_3, bot1_4, bot1_5, bot1_6, bot1_7];

(!alive _x) forEach _bots;

I put this in the condition field of the trigger. The trigger was meant to fire as soon as one of the bots gets shot. But not unexpectedly it does not work. Can you tell me how this code is supposed to look to make it work?

Share this post


Link to post
Share on other sites

init line

bots = [bot1,bot1_1, bot1_2, bot1_3, bot1_4, bot1_5, bot1_6, bot1_7];

cond

{alive _x} count bots != count bots

it counts the number of units in the array and checks the number that are alive.

Share this post


Link to post
Share on other sites

thx, but init line of a trigger? I don't see an init line with triggers.

Share this post


Link to post
Share on other sites

that would go in a gamelogic or object init box

but you could have it in the trigger line

bot=[bot1,bot1_1, bot1_2, bot1_3, bot1_4, bot1_5, bot1_6, bot1_7];{alive _x} count bots != count bots

I don't know if it would be less efficient that way.

Edited by F2k Sel

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  

×