OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Hartza on 22 Aug 2002, 19:20:55

Title: Counting troops
Post by: Hartza on 22 Aug 2002, 19:20:55
I know how to check if specific unit is dead or alive using !(alive MyGuy) command.

But, how to check if any member of 4 groups ( 6 men on each group = 24 men) is still alive  ???

My mission should end if all my men are dead, but I can't use "west not present" because I have men on the map which dont participate to combat.

I could use that !(alive MyGuy) commad 24 times but it feels little bit too complex way to do it ...
Title: Re:Counting troops
Post by: Bremmer on 22 Aug 2002, 19:30:11
Your right Hartza - Using the same condition 24 times is just bad editing  :(

Try this:

First name all the groups (using group1 = group this, group2 = group this etc)

[edit]Set up a trigger with a couple of seconds delay and condition true. Set On Activation as myunits = (units group1) + (units group2) + (units group3) + (units group4).  This creates an array of all the units in all the groups. [/edit]

Now set up a trigger with condition "alive _x" count myunits <= 1. Now when only only one unit is left alive (you) then the trigger will go off.

Cheers

Edited due so that the array is created properly - If this is done in an init field or file then the array is not properly defined  :-[

ps. if the players unit isn't in the groups you are checking then use the condition "alive _x" count myunits == 0. I'm sure you spotted that anyway.
Title: Re:Counting troops
Post by: Hartza on 24 Aug 2002, 18:51:33
Thanks Bremmer, that seems to work ( again)

 :thumbsup: