Jump to content
Sign in to follow this  
1para{god-father}

How to check if Group is all dead and also 1st man in group is killed

Recommended Posts

I am trying to work out how to check for 2 things .... 1) if the whole group is dead , 2) when 1 member of the group is dead

Is this correct to check for the Whole group being killed ?

_grppatrol = [getPos testtimer, EAST, (configFile >> "CfgGroups" >> "EAST" >> "INS" >> "Infantry" >> "INS_InfSquad")] call BIS_fnc_spawnGroup;

waitUntil{(!alive _grppatrol)}

How would I check for the first kill in the group by Blue for? Is there a way as I would like to activate something once the first man is killed

Share this post


Link to post
Share on other sites

check the wiki, you can't use alive on a group, only a object

_grppatrol = [getPos testtimer, EAST, (configFile >> "CfgGroups" >> "EAST" >> "INS" >> "Infantry" >> "INS_InfSquad")] call BIS_fnc_spawnGroup;

_Array = units _grppatrol;
waitUntil{!({alive _x}foreach _Array)};
hint "one down";

while{count _Array > 0}do
{
{if(!alive _x)then{_Array = _Array - [_x]}}foreach _Array;
sleep 1;
};
hint "all down";

this will work.

Share this post


Link to post
Share on other sites

I would suggest to use an event handler:

//Create the group (Your code)
_grppatrol = [getPos testtimer, EAST, (configFile >> "CfgGroups" >> "EAST" >> "INS" >> "Infantry" >> "INS_InfSquad")] call BIS_fnc_spawnGroup;

//Add event Handler to each unit of group, do something when all are dead
{
  _x addEventHandler ["killed", 
  {
     _grp = group (_this select 0);
     if ({ alive _x } count units _grp < 1)
     {
        hint "All units from the group have died";
     };
  }];
} forEach units _grppatrol;

Not tested.

_neo_

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  

×