• 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] Order unit

Status
Not open for further replies.
Level 3
Joined
Nov 1, 2013
Messages
26
How to order all unit to walk around map?

i do like this but it won't work

  • Explore
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Current order of (Matching unit)) Equal to (Order(stop)))) and do (Unit - Order (Picked unit) to Attack-Move To (Random point in (Playable map area)))
 
Level 4
Joined
May 25, 2009
Messages
100
Units are doing the "stop"order just in the moment they actually turn from doing something to stop doing anything. You should try the ability animals have. I can't look it up atm..."foray" or something like that.
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
The animal ability is called "Wander" (since all it does is makes the animal wander around the map).

As Cataract92 pointed out, the "Stop" order happens exactly the moment unit stops. Then there's no order - or better said, "null" order.

The trigger you have there is very inefficient and after few minutes will most likely freeze your map.

Some actions cause leaks (memory leaks), which are little pieces of memory that take up memory space for your WCIII. They are called leaks because they are of no use to anything, but they still remain and still take up space.
Of course, there are ways to get rid of them, but it has to be done in time.

Unit group leaks and also points leaks.
So when you create unit group, you create 1 leak. When you order picked unit to go to *some point*, you cause leak as well.

Let's say you have 25 units in your map. Your trigger will cause 26 leaks every 0,01 seconds (1 for unit group, 25 for creating points). That's 2600 leaks every second and 156000 leaks after a minute. That is really lot and only for 25 units.

Also, there's no need to run this trigger every 0,01 seconds. I daresay 0,2-0,25 second are enough. It won't really be noticeable that the unit stopped for such small interval.

To fix this, you will need "point" variable. Variables are created in Variable editor (accessed by pressing the golden "X" button in Trigger Editor).
I'll name my variable "loc".

  • Trigger
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • -------- Just write the custom script below exactly like I have it. --------
      • -------- It will take care of memory leak from creating unit group --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Current order of (Matching unit)) Equal to (Order(<Empty String>)))) and do (Actions)
        • Loop - Actions
          • -------- save the location inside "loc" variable --------
          • Set loc = (Random point in (Playable map area))
          • Unit - Order (Picked unit) to Attack-Move To loc
          • -------- --------------------------------------------------------------------------------------------------- --------
          • -------- Now use "loc" variable to remove the location to prevent leak --------
          • Custom script: call RemoveLocation(udg_loc)
          • -------- If your variable was named e.g. Location, then the custom script would look like this: --------
          • -------- call RemoveLocation(udg_Location) --------
          • -------- notice how everything remained the same, except that I changed "loc" for "Location" inside brackets --------
 
Status
Not open for further replies.
Top