Home   Help Search Login Register  

Author Topic: Why is this script so slow?  (Read 681 times)

0 Members and 1 Guest are viewing this topic.

Pravit

  • Guest
Why is this script so slow?
« on: 21 Jul 2005, 04:28:27 »
I'm doing a loop to check on how many of the enemy are left using "count." If there are less than 5 alive, I want to break the loop. However, the script seems to work extremely slowly, that is, I have to wait maybe 30 seconds until after the required number is dead before it works. Any idea why?

Here's my script:
#theloop
?( (count units enemies1) + (count units enemies2)  < 5) : goto "beatthem"
~.5
goto "theloop"
#beatthem
(do other stuff)

I'm thinking perhaps the count of how many units in the group is not updated until the leader notices they're dead(Oh no...7! is down!).

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Why is this script so slow?
« Reply #1 on: 21 Jul 2005, 05:36:17 »
Quote
I'm thinking perhaps the count of how many units in the group is not updated until the leader notices they're dead
You're right. It takes some time for the dead people get removed from arrays and count command doesn't check wether the unit in array is dead or alive.. it just counts him as one.

You could pharhaps consider another way of doing it?


#reset
_counter = 0
_grp = enemies1
_max1 = count enemies1
_max2 = count enemies2
_allmax = _max1 + _max2
#check
?!alive (_grp select _counter): _allmax = _allmax -1
?_allmax < 5: goto "continue"
?_counter == _max1: _grp = enemies2
?_counter == _max2: goto "reset"
_counter = _counter +1
~0.1
goto "check"

#continue

I'm probably showing you the most difficult and complicated way, but I'm very sleepy at the moment. Have a go at it and see what it does.  :)
Not all is lost.

Pravit

  • Guest
Re:Why is this script so slow?
« Reply #2 on: 21 Jul 2005, 05:53:46 »
Ah, I suspected I would have to loop through them and use the "alive" command. Thanks!