Home   Help Search Login Register  

Author Topic: Count Units Gorup  (Read 850 times)

0 Members and 1 Guest are viewing this topic.

Offline Rommel92

  • Members
  • *
Count Units Gorup
« on: 02 Jun 2008, 05:39:19 »
Code: [Select]
_grp = _this select 0;

while {count units _grp > 0} do
{
sleep 1.0;
player globalchat format["%1",count units _grp];
};

9 civilians in the editor (in a group). I shoot one, about 7 seconds later I hear them call out "OH NO... 5 IS DOWN". Then the counter drops down to 8... is there any instantaneous way to check groups for sizes?

Code: [Select]
_grp = _this select 0;
_counter = 0;
{if (alive _x) then {_counter = _counter + 1};} forEach units _group;

while {true} do
{
sleep 1.0;
_counter = 0;
{if (alive _x) then {_counter = _counter + 1};} forEach units _group;
player globalchat format["%1",count units _grp];
};

Even this does not work too well, there is a large gap between "alive" and "dead" notions, and it can take up to 20 seconds for the game to realise that there is 0 units left in the group.
« Last Edit: 02 Jun 2008, 05:44:01 by Rommel92 »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Count Units Gorup
« Reply #1 on: 02 Jun 2008, 08:01:58 »
Your global chat is not showing _counter but count units _grp
You might also use a simpler way to count them:
Code: [Select]
{alive _x} count units _grp

Offline Rommel92

  • Members
  • *
Re: Count Units Gorup
« Reply #2 on: 02 Jun 2008, 08:11:10 »
I'm a tool. Thanks Mando.  :good:


Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Count Units Gorup
« Reply #3 on: 02 Jun 2008, 15:17:34 »
Note that this isn't the game noticing anything : it's the squad leader! Using count units group will yield the SUPPOSED amount of units alive in the group, not the actual. Sort of like when you've positioned a guy somewhere far far off out of sight, and he gets wasted by a spetznatz, you won't actually know about it (and your group indicator at the bottom will still show him as alive and well). Can be used for all kinds of of situations where you don't need precise data, but supposed  :good:

Otherwise use the {alive _X} suggestion, yes.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"