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

[GUI] Run Walk Movement System 1.01b

  • Like
Reactions: sonofjay
Run Walk Movement System
aka. DOUBLE CLICK MOVE

Description
A simple system that intercepts movement orders into two types:
Walking - point or target is clicked once, unit moves at reduced speed
Running - point or target is double-clicked, unit moves at full speed and loses mana per second

Works for both point targets and unit targets.

Requires Bribe's Unit Indexer and Is Unit Moving

Disclaimer: Untested in a delayed environment like Battle.net, but it should work based on how orders work.

Triggers


  • RWM Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- The maximum distance two points can be to be considered a "double click" --------
      • Set RWM_DoubleClickThreshold = 10.00
      • -------- The maximum time between orders for it to be considered a "double click" --------
      • Set RWM_DoubleClickTime = 0.40
      • -------- How fast units walk as a percentage of their regular speed --------
      • Set RWM_WalkSpeedPercent = 0.50
      • -------- How much mana a unit loses per second while running --------
      • Set RWM_RunManaPerSecond = 1.00
      • -------- What percentage of a unit's total mana it loses per second while running --------
      • Set RWM_RunManaPercentPerSecond = 0.05
      • -------- How often the system checks and removes mana for running --------
      • Set RWM_ManaCheckPeriod = 0.10
      • -------- ----- These values are adjusted accordingly ----- --------
      • Set RWM_RunManaPerSecond = (RWM_RunManaPerSecond x RWM_ManaCheckPeriod)
      • Set RWM_RunManaPercentPerSecond = (RWM_RunManaPercentPerSecond x RWM_ManaCheckPeriod)
      • Trigger - Add to RWM Run Loop <gen> the event (Time - Every RWM_ManaCheckPeriod seconds of game time)
  • RWM New Unit
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Set RWM_TargetCoordX[UDex] = RWM_SafeCoordX
      • Set RWM_TargetCoordY[UDex] = RWM_SafeCoordY
      • Set RWM_TargetUnit[UDex] = No unit


  • RWM Point Order
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(move))
          • (Issued order) Equal to (Order(smart))
    • Actions
      • Set RWM_Unit = (Triggering unit)
      • Set tempId = (Custom value of RWM_Unit)
      • Set tempLoc1 = (Target point of issued order)
      • -------- 1 - No point for the unit --------
      • Custom script: if ((udg_RWM_TargetCoordX[udg_tempId] == udg_RWM_SafeCoordX) and (udg_RWM_TargetCoordY[udg_tempId] == udg_RWM_SafeCoordY)) then
      • Set RWM_TargetCoordX[tempId] = (X of tempLoc1)
      • Set RWM_TargetCoordY[tempId] = (Y of tempLoc1)
      • Unit Group - Add RWM_Unit to RWM_CheckForDoubleClickTime
      • Set RWM_UnitDoubleClickTime[tempId] = RWM_DoubleClickTime
      • -------- unit is now walking --------
      • Set RWM_RunWalkEvent = 0.00
      • Set RWM_RunWalkEvent = 2.00
      • Unit - Set RWM_Unit movement speed to ((Default movement speed of RWM_Unit) x RWM_WalkSpeedPercent)
      • Unit Group - Remove RWM_Unit from RWM_RunningUnits
      • -------- 2 - Unit has a previously clicked point --------
      • Custom script: else
      • -------- check if the point is within range of previous point --------
      • Set tempLoc2 = (Point(RWM_TargetCoordX[tempId], RWM_TargetCoordY[tempId]))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between tempLoc1 and tempLoc2) Less than or equal to RWM_DoubleClickThreshold
        • Then - Actions
          • -------- Unit is now running --------
          • Set RWM_RunWalkEvent = 0.00
          • Set RWM_RunWalkEvent = 1.00
          • Unit - Set RWM_Unit movement speed to (Default movement speed of RWM_Unit)
          • Set RWM_TargetCoordX[tempId] = RWM_SafeCoordX
          • Set RWM_TargetCoordY[tempId] = RWM_SafeCoordY
          • Unit Group - Add RWM_Unit to RWM_RunningUnits
        • Else - Actions
      • Custom script: call RemoveLocation(udg_tempLoc2)
      • Custom script: endif
      • Custom script: call RemoveLocation(udg_tempLoc1)
  • RWM Unit Order
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(attack))
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(patrol))
    • Actions
      • Set RWM_Unit = (Triggering unit)
      • Set tempId = (Custom value of RWM_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RWM_TargetUnit[tempId] Equal to No unit
        • Then - Actions
          • -------- 1 - No target for the unit --------
          • Set RWM_TargetUnit[tempId] = (Target unit of issued order)
          • Unit Group - Add RWM_Unit to RWM_CheckForDoubleClickTime
          • Set RWM_UnitDoubleClickTime[tempId] = RWM_DoubleClickTime
          • -------- unit is now walking --------
          • Set RWM_RunWalkEvent = 0.00
          • Set RWM_RunWalkEvent = 2.00
          • Unit - Set RWM_Unit movement speed to ((Default movement speed of RWM_Unit) x RWM_WalkSpeedPercent)
          • Unit Group - Remove RWM_Unit from RWM_RunningUnits
        • Else - Actions
          • -------- 2 - Unit has a target --------
          • -------- Unit is now running --------
          • Set RWM_RunWalkEvent = 0.00
          • Set RWM_RunWalkEvent = 1.00
          • Unit - Set RWM_Unit movement speed to (Default movement speed of RWM_Unit)
          • Unit Group - Add RWM_Unit to RWM_RunningUnits
          • Set RWM_TargetUnit[tempId] = No unit
  • RWM Item Target
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(attack))
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(patrol))
      • (Target item of issued order) Not equal to No item
    • Actions
      • Set RWM_Unit = (Triggering unit)
      • Set tempId = (Custom value of RWM_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RWM_TargetItem[tempId] Equal to No item
        • Then - Actions
          • -------- 1 - No target for the unit --------
          • Set RWM_TargetItem[tempId] = (Target item of issued order)
          • Unit Group - Add RWM_Unit to RWM_CheckForDoubleClickTime
          • Set RWM_UnitDoubleClickTime[tempId] = RWM_DoubleClickTime
          • -------- unit is now walking --------
          • Set RWM_RunWalkEvent = 0.00
          • Set RWM_RunWalkEvent = 2.00
          • Unit - Set RWM_Unit movement speed to ((Default movement speed of RWM_Unit) x RWM_WalkSpeedPercent)
          • Unit Group - Remove RWM_Unit from RWM_RunningUnits
        • Else - Actions
          • -------- 2 - Unit has a target --------
          • -------- Unit is now running --------
          • Set RWM_RunWalkEvent = 0.00
          • Set RWM_RunWalkEvent = 1.00
          • Unit - Set RWM_Unit movement speed to (Default movement speed of RWM_Unit)
          • Unit Group - Add RWM_Unit to RWM_RunningUnits
          • Set RWM_TargetItem[tempId] = No item
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (RWM Run Loop <gen> is on) Equal to False
            • Then - Actions
              • Trigger - Turn on RWM Run Loop <gen>
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (RWM Double Click Checker <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on RWM Double Click Checker <gen>
        • Else - Actions


  • RWM Double Click Checker
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RWM_CheckForDoubleClickTime and do (Actions)
        • Loop - Actions
          • Set tempId = (Custom value of (Picked unit))
          • Set RWM_UnitDoubleClickTime[tempId] = (RWM_UnitDoubleClickTime[tempId] - 0.05)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RWM_UnitDoubleClickTime[tempId] Less than or equal to 0.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from RWM_CheckForDoubleClickTime
              • Set RWM_TargetCoordX[tempId] = RWM_SafeCoordX
              • Set RWM_TargetCoordY[tempId] = RWM_SafeCoordY
              • Set RWM_TargetUnit[tempId] = No unit
            • Else - Actions
  • RWM Run Loop
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in RWM_RunningUnits and do (Actions)
        • Loop - Actions
          • Set tempId = (Custom value of (Picked unit))
          • Set RWM_Unit = (Picked unit)
          • -------- Check if the unit is moving --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UnitMoving[tempId] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Mana of RWM_Unit) Not equal to 0.00
                • Then - Actions
                  • -------- Reduce mana --------
                  • Unit - Set mana of RWM_Unit to ((Mana of RWM_Unit) - RWM_RunManaPerSecond)
                  • Unit - Set mana of RWM_Unit to ((Mana of RWM_Unit) - ((Max mana of RWM_Unit) x RWM_RunManaPercentPerSecond))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Mana of RWM_Unit) Less than or equal to 0.00
                    • Then - Actions
                      • Set RWM_RunWalkEvent = 0.00
                      • Set RWM_RunWalkEvent = 2.00
                      • -------- Remove from running group --------
                      • Unit Group - Remove RWM_Unit from RWM_RunningUnits
                      • Unit - Set RWM_Unit movement speed to ((Default movement speed of RWM_Unit) x RWM_WalkSpeedPercent)
                      • Set RWM_TargetCoordX[tempId] = RWM_SafeCoordX
                      • Set RWM_TargetCoordY[tempId] = RWM_SafeCoordY
                      • Set RWM_TargetUnit[tempId] = No unit
                    • Else - Actions
                • Else - Actions
                  • -------- Exclude units without mana --------
            • Else - Actions
              • Set RWM_RunWalkEvent = 0.00
              • Set RWM_RunWalkEvent = 2.00
              • -------- Remove from running group --------
              • Unit Group - Remove RWM_Unit from RWM_RunningUnits
              • Unit - Set RWM_Unit movement speed to ((Default movement speed of RWM_Unit) x RWM_WalkSpeedPercent)
              • Set RWM_TargetCoordX[tempId] = RWM_SafeCoordX
              • Set RWM_TargetCoordY[tempId] = RWM_SafeCoordY
              • Set RWM_TargetUnit[tempId] = No unit

Changelog
1.01
  • Looping triggers are now turned off when unused.
  • Added support for running to items.
  • Fixed mana drain being based on current mana instead of max mana.

Credits
Bribe for Unit Indexer and Is Unit Moving.

Keywords:
run walk, run, walk, movement, run movement, walk movement, double click movement, double click
Contents

Run Walk Movement System 1.01b (Map)

Reviews
Required changes: Turn off RWM Double Click Checker and RWM Run Loop when there are no units in the groups Suggested changes: Add support for running to items Ordering multiple selected units to run can cause them not to run afterall due...

Moderator

M

Moderator

Reviewed by Maker, Run Walk Movement System 1.01, 5th Jan 2013

Required changes:
  • Turn off RWM Double Click Checker and RWM Run Loop
    when there are no units in the groups

Suggested changes:
  • Add support for running to items
  • Ordering multiple selected units to run can cause them not to run afterall
    due to formations used
  • If a unit is running and I double click, the unit will walk for a brief moment
 
Level 4
Joined
Nov 13, 2012
Messages
28
I don't know how this system can be used, but it can be used for make somes spells/systems using double-click, btw the coding is decent and the system works properly as I seen, but you're leaking because you use an unitgroup better add

JASS:
call bj_WantDestroyGroup == true
or destroy it when it's empty.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
No, I'm not leaking any groups.

Both unit groups used by the system must exist through the game for the system to work.

I don't know how this system can be used, but it can be used for make somes spells/systems using double-click

I thought it might be useful for Hero-vs-hero maps.

Good idea with the spells double click, I'll add that functionality.
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
The system is really neat. You can't stop making systems, bruh!
I don't know why but i have a headache and i haven't looked at the code, so i don't know if you check whether or not a unit has a specific walk animation (like Magtheridon96, the Pit Lord) and play it, instead of just slowing the run animation.
If the system has this function, it's just profit. Good job! :ogre_hurrhurr:
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
The system is really neat. You can't stop making systems, bruh!
I don't know why but i have a headache and i haven't looked at the code, so i don't know if you check whether or not a unit has a specific walk animation (like Magtheridon96, the Pit Lord) and play it, instead of just slowing the run animation.
If the system has this function, it's just profit. Good job! :ogre_hurrhurr:

I didn't consider that, I'll definitely look into adding that.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Draining mana isn't working properly.

It is working properly I believe. Notice that it drains a flat amount and a percentage amount by default. Thus when you have lots of mana, it drains more mana than when you have only little mana left. You can set the percentage drain to 0 in the configuration trigger.

If this is not what you mean, then please alaborate.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
I tested it with the paladin on the map.

Its mana pool is 255

When I order the paladin to run, the mana go down to 253 but that is it. It will regen again and won't drain anything again unless you order the unit to run again.

EDIT:

Re-download, still the same. Am I missing something or is it really bugged?

I'll take a look again.

Thanks for point out, it was indeed bugged. Fixed version has been uploaded. When I "fixed" the % mana drain to be based on max mana instead of current mana, I made an error with the action.
 
Top