• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

trigger to detect idle units- help

Status
Not open for further replies.
Level 1
Joined
Mar 1, 2006
Messages
3
I want to make a trigger that will detect units that are not doing anything and give them an order. However, it is terribly laggy to periodically pick every applicable unit and then check to see what its order is (there are large numbers of units on the map, but few will not have orders). I can't find an event that will work better than periodic event. Issued order with no target doesn't seem to work for this. Any suggestions for an alternative to this trigger that lags less?

the current trigger looks like this:

(attack is an order variable set to "attack", to prevent leaking)

events- time, every 10 seconds
actions- pick every unit in a certain group and do actions:
if current order of picked unit not equal to attack
then: order picked unit to attack-move to a certain point
 
Level 4
Joined
Nov 9, 2005
Messages
113
That looks good to me.
What's going wrong?

ps.: dont use a variable but use:
- If current order of [Picked Unit] is not equal to Order[attack] then order [Picked Unit] to attack-move to a certain point
 
Level 10
Joined
Jul 14, 2004
Messages
463
Well this trigger doesn't cause much memory leak, and there is no much better way I think - I wanted such a trigger for my own map some time ago.

You could optimize it a little as follows:
Code:
Actions:
  Pick every unit in unit group matching (current order of (matching unit) is not equal to Order(attack)) and do
      set unitvariable = (Picked unit)
      order unitvariable to attack-move to a certain point
I think if it did cause any lag, then it definetaly won't from now on.
 
Level 7
Joined
Jul 30, 2004
Messages
451
Waldbär said:
Well this trigger doesn't cause much memory leak, and there is no much better way I think - I wanted such a trigger for my own map some time ago.

You could optimize it a little as follows:
Code:
Actions:
  Pick every unit in unit group matching (current order of (matching unit) is not equal to Order(attack)) and do
      set unitvariable = (Picked unit)
      order unitvariable to attack-move to a certain point
I think if it did cause any lag, then it definetaly won't from now on.

removing the memory leak would just be setting the unit ground matching etc... to a variable ugroupTEMP first and then picking every unit in ugroupTEMP and then after DestroyGroup( ugroupTEMP )

and also in the middle of the enumeration set 'certain point' to location X and then after RemoveLocation( X )

i believe that should be all the cleanup necessary
 
Status
Not open for further replies.
Top