OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Cheetah on 24 Feb 2007, 12:48:58

Title: Speeding up unit counting
Post by: Cheetah on 24 Feb 2007, 12:48:58
Some may have noticed this issue before, the situation:
a script which outputs the number of living squad members

Code: [Select]
_squadName = GroupAlpha;
#loop
_alive = count units _squadName;
hint format ["%1", _alive];
~1
goto "loop"

A squad of men, all with names (not that it matters), and the leader has:
Code: [Select]
GroupAlpha = group this;

The problem
The output of the "hint format" isn't up to date with the situation. For example, if I kill a soldier, it takes about 5 seconds or so to change the group count. Killing whole the squad in seconds, results in waiting over 30 seconds before the count says 0.

Question
Is there an easy method to speed this command up? It's too easy for what I have in my mind. I hope that there is a simple way to make it faster, or a way, involving the groupname to count units but faster than using the code I use now.
Title: Re: Speeding up unit counting
Post by: Mandoble on 24 Feb 2007, 12:52:56
You may try:

Code: [Select]
squadName = GroupAlpha;
#loop
_alive = {alive _x} count units _squadName
hint format ["%1", _alive];
~1
goto "loop"
Title: Re: Speeding up unit counting
Post by: Cheetah on 24 Feb 2007, 13:10:31
Great thanks Mandoble, works perfectly. Thought that I tried that one, it's just that I didn't use the curled brackets, used "" instead. Gave me an error.

Locking.
Title: Re: Speeding up unit counting
Post by: h- on 24 Feb 2007, 13:26:43
Bah, this is ArmA, use the sqf format and drop the sqs already

Code: [Select]
while {true}
 do {
_alive = {alive _x} count units _squadName;
hint format ["%1", _alive];
sleep 1;
    };
Title: Re: Speeding up unit counting
Post by: Terox on 24 Feb 2007, 21:21:02
for anything like this, i tend to use one  large trigger encompassing the entire playing area
named tx_maintrig

set to:
Activation: Anybody, Repeatedly

I dont have anything in the "On activation field etc

and then from this i simply run scripts, which use "list tx_maintrig"  for calculating casualty rates, unit lists, vehicle lists etc

the trigger used in this way is remarkably efficient imo
however its more efficient / useful when gathering data on multi arrays, objects in mp than for a simple group as would seem to be your requirement here