• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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