Guard Position GUI

Level 5
Joined
Feb 22, 2025
Messages
78
Created a system that sometimes works in the way intended but sometimes not:cry:
Any suggestions or help are very welcome, tnx!
------------------------
  • GuardIni
    • Events
      • Map initialization
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set Guard_Counter = 0
      • Set Guard_Group = (Create new unit group)
      • Unit Group - Add |cffb40000Elite Dreadguard|r 0063 <gen> to Guard_Group
      • Unit Group - Add Forsaken Dreadguard 0053 <gen> to Guard_Group
      • Unit Group - Add Forsaken Dreadguard 0054 <gen> to Guard_Group
      • Unit Group - Pick every unit in Guard_Group and do (Actions)
        • Loop - Actions
          • Set Guard_Unit = (Picked unit)
          • Set Guard_Index = (Custom value of Guard_Unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Guard_Index Equal to 0
            • Then - Actions
              • Set Guard_Counter = (Guard_Counter + 1)
              • Set Guard_Index = Guard_Counter
              • Unit - Set the custom value of Guard_Unit to Guard_Index
              • Set Guard_Position[Guard_Index] = (Position of Guard_Unit)
              • Set Guard_Facing[Guard_Index] = (Facing of Guard_Unit)
              • Set Guard_SpeedBoost[Guard_Index] = False
            • Else - Actions
      • Trigger - Turn on Guard Behaviour <gen>
      • Custom script: call DestroyGroup( udg_Guard_Group)
----------------------------------------------
  • Guard Behaviour
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Guard_Group = (Units of type Forsaken Dreadguard)
      • Unit Group - Add |cffb40000Elite Dreadguard|r 0063 <gen> to Guard_Group
      • Unit Group - Pick every unit in Guard_Group and do (Actions)
        • Loop - Actions
          • Set Guard_Unit = (Picked unit)
          • Set Guard_Index = (Custom value of Guard_Unit)
          • Set Guard_Temp_Point = (Position of Guard_Unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current order of Guard_Unit) Equal to (Order(smart))
          • (Current order of Guard_Unit) Equal to (Order(attack))
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Guard_Temp_Point and Guard_Position[Guard_Index]) Greater than 400.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Guard_Unit is in Guard_MovingGroup.) Equal to False
                • Then - Actions
                  • Unit Group - Add Guard_Unit to Guard_MovingGroup
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between Guard_Temp_Point and Guard_Position[Guard_Index]) Greater than or equal to 50.00
                  • (Current order of Guard_Unit) Not equal to (Order(smart))
                  • (Current order of Guard_Unit) Not equal to (Order(attack))
                  • (Current order of Guard_Unit) Not equal to (Order(move))
                  • (Current order of Guard_Unit) Not equal to (Order(spell))
                • Then - Actions
                  • Animation - Change Guard_Unit's animation speed to 100.00% of its original speed
                  • Unit - Make Guard_Unit face Guard_Facing[Guard_Index] over 0.50 seconds
                  • Unit Group - Remove Guard_Unit from Guard_MovingGroup.
                • Else - Actions
        • Else - Actions
      • Custom script: call RemoveLocation( udg_Guard_Temp_Point)
      • Custom script: call DestroyGroup( udg_Guard_Group)
---------------
  • Guard Movement
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Guard_MovingGroup and do (Actions)
        • Loop - Actions
          • Set Guard_Unit = (Picked unit)
          • Set Guard_Index = (Custom value of Guard_Unit)
          • Set Guard_Temp_Point = (Position of Guard_Unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between Guard_Temp_Point and Guard_Position[Guard_Index]) Greater than 10.00
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Guard_SpeedBoost[Guard_Index] Equal to False
                • Then - Actions
                  • Set Guard_SpeedBoost[Guard_Index] = True
                  • Animation - Change Guard_Unit's animation speed to 200.00% of its original speed
                  • Unit - Set Guard_Unit movement speed to ((Default movement speed of Guard_Unit) + 150.00)
                  • Set Guard_Temp_Point = (Guard_Position[Guard_Index] offset by 10.00 towards (Angle from Guard_Temp_Point to Guard_Position[Guard_Index]) degrees.)
                  • Unit - Order Guard_Unit to Move To Guard_Temp_Point
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Guard_SpeedBoost[Guard_Index] Equal to True
                    • Then - Actions
                      • Set Guard_SpeedBoost[Guard_Index] = False
                      • Animation - Change Guard_Unit's animation speed to 100.00% of its original speed
                      • Unit - Set Guard_Unit movement speed to (Default movement speed of Guard_Unit)
                      • Unit Group - Remove Guard_Unit from Guard_MovingGroup.
                    • Else - Actions
            • Else - Actions
      • Custom script: call RemoveLocation( udg_Guard_Temp_Point)
-----------------------------------------
  • Guard Mech
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Guard_MovingGroup) Greater than 0
        • Then - Actions
          • Trigger - Turn on Guard Movement <gen>
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in Guard_MovingGroup) Equal to 0
            • Then - Actions
              • Trigger - Turn off Guard Movement <gen>
            • Else - Actions
 
Level 5
Joined
Feb 22, 2025
Messages
78
Try increasing the point distance?

Additionally, please specify what happen when it doesn't work
Actually I’ve noticed that the Elite Dreadguard is behaving accordingly. On the other hand units of type( forsaken death guard) sometimes stay put and don’t return to the original location even when attacking if the distance is past limit . I’m guessing maybe it has to do with intervals or overriding their location, sometimes it happens after they get knockback from spells.
* Maybe I can make this smoother by creating a delay before adding them to Guard_MoveGroup
 
Top