Home   Help Search Login Register  

Author Topic: Speeding up unit counting  (Read 2000 times)

0 Members and 1 Guest are viewing this topic.

Offline Cheetah

  • Former Staff
  • ****
Speeding up unit counting
« 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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Speeding up unit counting
« Reply #1 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"

Offline Cheetah

  • Former Staff
  • ****
Re: Speeding up unit counting
« Reply #2 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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Speeding up unit counting
« Reply #3 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;
    };
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: Speeding up unit counting
« Reply #4 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
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123