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

[Trigger] Need help to stop trigger from repeatedly issuing move command to a unit

Status
Not open for further replies.
Level 2
Joined
Apr 24, 2019
Messages
15
Hi! I'm sorry if the title wasn't so understandable or something. I'm not really good at English.

So. I have this simple spell idea where a hawk follows the Hero wherever it goes, the problem is the "move to " command is issued every x periodic time which makes the hawk slower and it looks bad - the hawk just repeating the walk animation every time.

I'm just new to this kind of stuff and just taught myself how to do it by looking at sample triggers so i don't know much of it :( I'm very willing to learn something new every day to improve myself :) That's all thanks

So here is the code:

learn:
  • Regal hawk learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Regal Hawk
    • Actions
      • Set Ranger_hawk_max = (Ranger_hawk_max + 1)
      • Set Regal_hawk_unit[Ranger_hawk_max] = (Learning Hero)
      • -------- creating the hawk --------
      • Unit - Create 1 Hawk for (Owner of Regal_hawk_unit[Ranger_hawk_loop]) at (Position of Regal_hawk_unit[Ranger_hawk_loop]) facing Default building facing degrees
      • Set Ranger_hawk[Ranger_hawk_loop] = (Last created unit)
      • -------- setting the bools --------
      • Set Regal_hawk_free[Ranger_hawk_max] = True
      • Set Regal_hawk_walking[Ranger_hawk_max] = False
      • Set Regal_walkcommand[Ranger_hawk_max] = 0.00
walk command loop
  • Regal hawk walk
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Ranger_hawk_loop) from 1 to Ranger_hawk_max, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Regal_hawk_free[Ranger_hawk_loop] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Regal_hawk_unit[Ranger_hawk_max] is alive) Equal to True
                • Then - Actions
                  • Set Regal_hawk_unitloc[Ranger_hawk_loop] = (Position of Regal_hawk_unit[Ranger_hawk_loop])
                  • Set Regal_hawkloc[Ranger_hawk_loop] = (Position of Ranger_hawk[Ranger_hawk_loop])
                  • Set Regal_hawkdistance[Ranger_hawk_loop] = (Distance between Regal_hawk_unitloc[Ranger_hawk_loop] and Regal_hawkloc[Ranger_hawk_loop])
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • Regal_hawkdistance[Ranger_hawk_loop] Less than or equal to Regal_hawk_walkvar
                    • Then - Actions
                      • Set Regal_hawk_walking[Ranger_hawk_loop] = False
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • And - All (Conditions) are true
                            • Conditions
                              • Regal_hawkdistance[Ranger_hawk_loop] Greater than Regal_hawk_walkvar
                        • Then - Actions
                          • Set Regal_hawk_walking[Ranger_hawk_loop] = True
                          • Unit - Order Ranger_hawk[Ranger_hawk_loop] to Move To Regal_hawk_unitloc[Ranger_hawk_loop]
                        • Else - Actions
                  • Custom script: call RemoveLocation(udg_Regal_hawk_unitloc[udg_Ranger_hawk_loop])
                  • Custom script: call RemoveLocation(udg_Regal_hawkloc[udg_Ranger_hawk_loop])
                • Else - Actions
            • Else - Actions

as you may noticed, Regal_walkcommand is unused, because I've tried something like this :

failed try:
  • Actions
    • For each (Integer Ranger_hawk_loop) from 1 to Ranger_hawk_max, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Regal_hawk_free[Ranger_hawk_loop] Equal to True
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Regal_hawk_unit[Ranger_hawk_max] is alive) Equal to True
              • Then - Actions
                • Set Regal_hawk_unitloc[Ranger_hawk_loop] = (Position of Regal_hawk_unit[Ranger_hawk_loop])
                • Set Regal_hawkloc[Ranger_hawk_loop] = (Position of Ranger_hawk[Ranger_hawk_loop])
                • Set Regal_hawkdistance[Ranger_hawk_loop] = (Distance between Regal_hawk_unitloc[Ranger_hawk_loop] and Regal_hawkloc[Ranger_hawk_loop])
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Or - Any (Conditions) are true
                      • Conditions
                        • Regal_hawkdistance[Ranger_hawk_loop] Less than or equal to Regal_hawk_walkvar
                  • Then - Actions
                    • Set Regal_hawk_walking[Ranger_hawk_loop] = False
                    • Set Regal_walkcommand[Ranger_hawk_loop] = 0.00
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • And - All (Conditions) are true
                          • Conditions
                            • Regal_hawkdistance[Ranger_hawk_loop] Greater than Regal_hawk_walkvar
                            • Regal_walkcommand[Ranger_hawk_loop] Less than 2.00
                      • Then - Actions
                        • Set Regal_hawk_walking[Ranger_hawk_loop] = True
                        • Unit - Order Ranger_hawk[Ranger_hawk_loop] to Move To Regal_hawk_unitloc[Ranger_hawk_loop]
                        • Set Regal_walkcommand[Ranger_hawk_loop] = 2.00
                      • Else - Actions
                • Custom script: call RemoveLocation(udg_Regal_hawk_unitloc[udg_Ranger_hawk_loop])
                • Custom script: call RemoveLocation(udg_Regal_hawkloc[udg_Ranger_hawk_loop])
              • Else - Actions
          • Else - Actions

obviously, it just made things worse :)
Thanks for the help.
 
Level 12
Joined
Feb 5, 2018
Messages
521
Have you tried changing the distance to a greater value? I couldn't see where you initialize Regal_hawk_walkvar.

1) Increase the distance
2) Increase loop time

With the right distance and loop time, I am sure you will get it to work without the unit stuttering.
 
Level 2
Joined
Apr 24, 2019
Messages
15
Have you tried changing the distance to a greater value? I couldn't see where you initialize Regal_hawk_walkvar.

1) Increase the distance
2) Increase loop time

With the right distance and loop time, I am sure you will get it to work without the unit stuttering.

It did work! thank you so much...one less trigger to worry about yay! anyways Regal_hawk_walkvar was preloaded on a different trigger and I forgot to include that. im sorry for that. Thank you so much
 
Status
Not open for further replies.
Top