• 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.

[Solved] Default hold position

Status
Not open for further replies.
Level 2
Joined
Mar 21, 2020
Messages
13
Hello there,
Is there a simple way to make units hold position by default instead of just stop?
Or automatically hold position after a movement or attack/autoattack order?
I tried to trigger it but I didn't find any event that detects a unit finishing an order : /
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Didn't test it but it should work.
  • Example
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(stop))
    • Actions
      • Unit - Order (Triggering unit) to Hold Position.
Edit: It doesn't work. Maybe it needs a delay or something, hold on.

So this works, but only if the user manually orders the Stop.
  • Example 2
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(stop))
    • Actions
      • Wait 0.00 seconds
      • Unit - Order (Triggering unit) to Hold Position.
I think you'll need to use a timer and periodically check if units are moving or not. This system works to keep track of whether or not a unit is moving (it might be a little out of date but it should work): Is Unit Moving 2.1.0.0

Once the unit stops moving you order it to Hold Position.
 
Last edited:
Level 2
Joined
Mar 21, 2020
Messages
13
Ohh that wait there, thanks!
Just to check, is there a string order for the autostop?
I tried an empty string but it didn't work
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Nope, unfortunately not. You'll probably have to do something like this:
  • Detect Idle Units
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Current order of (Picked unit)) Equal to (Order(stand down))
                  • (Current order of (Picked unit)) Equal to (Order(stop))
            • Then - Actions
              • Unit - Order (Picked unit) to Hold Position.
            • Else - Actions
I'm not entirely sure what you're trying to achieve though, so if you can go into greater detail maybe there is an alternative.
 
Last edited:
Level 2
Joined
Mar 21, 2020
Messages
13
Humm almost works. The problem is that units won't autoattack with this.
I just want the heroes on my map to stop following enemies to attack them, but would like to keep the autoattack (it's a zombie defense).
No big deal though. It's just a little annoying to keep pressing H all the time.
 
Level 2
Joined
Mar 21, 2020
Messages
13
Hey, I combined a version of your trigger:
  • Auto Hold
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set TempUniG = (Units in (Playable map area) matching (((Matching unit) is A Hero) Equal to True))
      • Unit Group - Pick every unit in TempUniG and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of (Picked unit)) Equal to (Order(stand down))
            • Then - Actions
              • Unit - Order (Picked unit) to Hold Position
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempUniG)
With another one:
  • Auto Hold Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) is A Hero) Equal to True
      • (Current order of (Attacking unit)) Equal to (Order(stand down))
    • Actions
      • Set Loc = (Position of (Attacking unit))
      • Unit - Order (Attacking unit) to Attack-Move To Loc
      • Custom script: call RemoveLocation(udg_Loc)
It's working now in case anyone needs it.
Thanks for all your help Uncle!
 
Status
Not open for further replies.
Top