• 🏆 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!

Detect if unit is walking

Status
Not open for further replies.
Hello there, it's me again, i would like to ask how do i (properly) detect if the unit (var Global_MainHero [Single Character / Specific]) is moving or not. This is how i made it, unfortunately i can't turn off the loop. The goal is to decrease the dehydration level (var Thirst_Thirstval) when the unit is walking, and when the unit is in idle the dehydration level should stay to current level / should not decrease.

EDIT: It does turn off (when you ordered the unit to stop), but when you ordered him to move from point A to point B, when he reach the point B and stopped by itself, the loop does not stop.

  • Thirst Enable Loop When Ordered
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Owner of (Ordered unit)) Equal to Player 1 (Red)
          • (Unit-type of (Ordered unit)) Equal to (Unit-type of Global_MainHero)
          • Or - Any (Conditions) are true
            • Conditions
              • (Issued order) Equal to (Order(move))
              • (Issued order) Equal to (Order(harvest))
              • (Issued order) Equal to (Order(smart))
              • (Issued order) Equal to (Order(attack))
              • (Issued order) Equal to (Order(patrol))
    • Actions
      • Trigger - Turn on Thirst Loop <gen>
  • Thirst Disable Loop When Idle
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Owner of (Ordered unit)) Equal to Player 1 (Red)
          • (Unit-type of (Ordered unit)) Equal to (Unit-type of Global_MainHero)
          • Or - Any (Conditions) are true
            • Conditions
              • (Issued order) Equal to (Order(stop))
              • (Issued order) Equal to (Order(holdposition))
    • Actions
      • Trigger - Turn off Thirst Loop <gen>
  • Thirst Loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Thirst_ThirstVal Greater than or equal to 0
        • Then - Actions
          • Set Thirst_ThirstVal = (Thirst_ThirstVal - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • Thirst_ThirstVal Equal to 25
            • Then - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: Your character is t...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Thirst_ThirstVal Equal to 10
                • Then - Actions
                  • Game - Display to Player Group - Player 1 (Red) the text: Your character is s...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Thirst_ThirstVal Equal to 0
                    • Then - Actions
                      • Game - Display to Player Group - Player 1 (Red) the text: Your character is n...
                      • Unit - Create 1 Undead Death for Neutral Hostile at (Random point in EvilSpawnRegion1 <gen>) facing (Random angle) degrees
                      • Set Thirst_DeathFollow = (Last created unit)
                      • Trigger - Turn on Thirst Hunt Character <gen>
                      • Trigger - Turn on Thirst Character Death <gen>
                    • Else - Actions
        • Else - Actions
  • Thirst Setup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Thirst_ThirstVal = 50
 
Level 12
Joined
Jun 15, 2016
Messages
472
There are 2 possibilities:

1. There's some order given when the unit reaches its destination, you just can't see that order. To check if that happens (I don't remember) try any of the maps here: the first mission in jass class is to track unit orders around the map. You can just download a complete map and check the orders(of course it would be better if you did jass class.do jass class :grin:)

2. You can keep the position of all units you're tracking in an array, and see if they changed position in the last x seconds. You can do that with dynamic indexing
 
Status
Not open for further replies.
Top