[General] Movement speed control

Level 8
Joined
Oct 6, 2022
Messages
185
Hello guys, i was trying to make a "movement speed" control where if the unit's movement speed is greater then its default speed, increases "+ 150". but if it return to its default speed it resets to its default speed. Here's my trigger, did i did it right?

  • MovementSpeedOnly
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Level of (Leveling Hero)) Greater than 0
          • (Unit-type of (Leveling Hero)) Equal to Number 83 of Genius Society
    • Actions
      • Set Herta[1] = (Leveling Hero)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current movement speed of Herta[1]) Greater than 150.00
        • Then - Actions
          • Game - Display to (All players) the text: start
          • Unit - Set Herta[1] movement speed to ((Current movement speed of Herta[1]) + 150.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current movement speed of Herta[1]) Less than or equal to 150.00
            • Then - Actions
              • Game - Display to (All players) the text: end
              • Unit - Set Herta[1] movement speed to (Default movement speed of (Triggering unit))
            • Else - Actions
 

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
The current trigger that you wrote only runs when your hero levels up, other than that, it will not detect movement speed change from your hero. I would probably use periodic event instead so the game will always check if there is a movement speed change for every X second. But then again, it's too much of a work to keep tracks of each movement speed change and revert them back to their default value.

May I know what do you need this for?

Edit: I tried to look around the hive and this is probably the best I could find: [GUI-friendly] Movement Speed System 2.0.1
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Hello guys, i was trying to make a "movement speed" control where if the unit's movement speed is greater then its default speed, increases "+ 150". but if it return to its default speed it resets to its default speed. Here's my trigger, did i did it right?

  • MovementSpeedOnly
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Level of (Leveling Hero)) Greater than 0
          • (Unit-type of (Leveling Hero)) Equal to Number 83 of Genius Society
    • Actions
      • Set Herta[1] = (Leveling Hero)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current movement speed of Herta[1]) Greater than 150.00
        • Then - Actions
          • Game - Display to (All players) the text: start
          • Unit - Set Herta[1] movement speed to ((Current movement speed of Herta[1]) + 150.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current movement speed of Herta[1]) Less than or equal to 150.00
            • Then - Actions
              • Game - Display to (All players) the text: end
              • Unit - Set Herta[1] movement speed to (Default movement speed of (Triggering unit))
            • Else - Actions
In addition to what Rheiko said:

1) You're SETTING the unit's movement speed to it's Current + 150.00. This means if it's movement speed is reduced by say the Slow ability at the time of this trigger running, you can end up with potentially LESS base movement speed than you had before. Instead, you should rely on Movement Speed abilities like the Item ability that comes with Boots of Speed or a self-targeting Endurance Aura if you're okay with using %.


2) You will hardly ever need this "And" Condition:
  • And - All (Conditions) are true
"And" is how Conditions work by default, so this setup below has the same exact outcome:
  • Conditions
    • (Level of (Leveling Hero)) Greater than 0
    • (Unit-type of (Leveling Hero)) Equal to Number 83 of Genius Society
Triggers execute from top to bottom. An Event occurs -> Conditions are checked one by one (ALL MUST BE TRUE) -> Actions occur if all Conditions were true.

So in your case, it would work like this:
1) Is Level of Hero > 0? If True, proceed to #2. If False, exit from the trigger early.
2) Is Unit-Type of Hero Equal to Number 83 of Genius Society? If True, proceed to the Actions, If False, exit from the trigger early.

Since Conditions execute from top to bottom and it only takes one failed condition to end the entire process, it's most efficient to order your Conditions in a way where the most common Condition to fail happens first. Here's an example of a poorly structured Conditions block because we ask the complicated question first and the simple and most important question second:
  • Events
    • Unit - A unit Gains a level
  • Conditions
    • ((PaladinScore[(Player number of (Owner of (Leveling Hero))] + Level of (Leveling Hero)) Greater than (10 x PaladinScoreNeeded)
    • (Unit-type of (Leveling Hero)) Equal to Paladin
^ This trigger will run whenever ANY Hero levels up, which asks a complicated question about the PaladinScore variable. This question is only intended for the Paladin, so we don't need to ask it unless we know that our leveling Hero is actually the Paladin.

So it's a simple fix, just put the common Condition first:
  • Conditions
    • (Unit-type of (Leveling Hero)) Equal to Paladin
    • ((PaladinScore[(Player number of (Owner of (Leveling Hero))] + Level of (Leveling Hero)) Greater than (10 x PaladinScoreNeeded)
Now it will only ever run the complicated Condition IF it's actually a Paladin that leveled up in the first place. If your map has say 100 different heroes all gaining levels then this is a nice improvement.

Your computer is like a human whose performance depends on how stressed they are. If you ask a person 1000 questions at once they will struggle to answer them, but by organizing your questions in a logical way and reducing the number asked, you can reduce the amount of stress they're put under.

The less stress -> The faster the computer will process everything.
The faster the computer processes everything -> The better your game performs (more FPS).


3) You don't need this Condition:
  • (Level of (Leveling Hero)) Greater than 0
This Condition refers to the Hero Level, not the Unit Level if that's what confused you (the "gains a level" Event is poorly worded). Also, a Hero cannot ever be less than Level 1.
 
Last edited:
Level 8
Joined
Oct 6, 2022
Messages
185
The current trigger that you wrote only runs when your hero levels up, other than that, it will not detect movement speed change from your hero. I would probably use periodic event instead so the game will always check if there is a movement speed change for every X second. But then again, it's too much of a work to keep tracks of each movement speed change and revert them back to their default value.

May I know what do you need this for?

Edit: I tried to look around the hive and this is probably the best I could find: [GUI-friendly] Movement Speed System 2.0.1
I only need it for a certain heroes that needs it.

as for the "[GUI-friendly] Movement Speed System 2.0.1", i'll analyze it on how this thing works.

In addition to what Rheiko said:

1) You're SETTING the unit's movement speed to it's Current + 150.00. This means if it's movement speed is reduced by say the Slow ability at the time of this trigger running, you can end up with potentially LESS base movement speed than you had before. Instead, you should rely on Movement Speed abilities like the Item ability that comes with Boots of Speed or a self-targeting Endurance Aura if you're okay with using %.


2) You will hardly ever need this "And" Condition:
  • And - All (Conditions) are true
"And" is how Conditions work by default, so this setup below has the same exact outcome:
  • Conditions
    • (Level of (Leveling Hero)) Greater than 0
    • (Unit-type of (Leveling Hero)) Equal to Number 83 of Genius Society
Triggers execute from top to bottom. An Event occurs -> Conditions are checked one by one (ALL MUST BE TRUE) -> Actions occur if all Conditions were true.

So in your case, it would work like this:
1) Is Level of Hero > 0? If True, proceed to #2. If False, exit from the trigger early.
2) Is Unit-Type of Hero Equal to Number 83 of Genius Society? If True, proceed to the Actions, If False, exit from the trigger early.

Since Conditions execute from top to bottom and it only takes one failed condition to end the entire process, it's most efficient to order your Conditions in a way where the most common Condition to fail happens first. Here's an example of a poorly structured Conditions block because we ask the complicated question first and the simple and most important question second:
  • Events
    • Unit - A unit Gains a level
  • Conditions
    • ((PaladinScore[(Player number of (Owner of (Leveling Hero))] + Level of (Leveling Hero)) Greater than (10 x PaladinScoreNeeded)
    • (Unit-type of (Leveling Hero)) Equal to Paladin
^ This trigger will run whenever ANY Hero levels up, which asks a complicated question about the PaladinScore variable. This question is only intended for the Paladin, so we don't need to ask it unless we know that our leveling Hero is actually the Paladin.

So it's a simple fix, just put the common Condition first:
  • Conditions
    • (Unit-type of (Leveling Hero)) Equal to Paladin
    • ((PaladinScore[(Player number of (Owner of (Leveling Hero))] + Level of (Leveling Hero)) Greater than (10 x PaladinScoreNeeded)
Now it will only ever run the complicated Condition IF it's actually a Paladin that leveled up in the first place. If your map has say 100 different heroes all gaining levels then this is a nice improvement.

Your computer is like a human whose performance depends on how stressed they are. If you ask a person 1000 questions at once they will struggle to answer them, but by organizing your questions in a logical way and reducing the number asked, you can reduce the amount of stress they're put under.

The less stress -> The faster the computer will process everything.
The faster the computer processes everything -> The better your game performs (more FPS).


3) You don't need this Condition:
  • (Level of (Leveling Hero)) Greater than 0
This Condition refers to the Hero Level, not the Unit Level if that's what confused you (the "gains a level" Event is poorly worded). Also, a Hero cannot ever be less than Level 1.
as for uncle said, yeah the "All multiple conditions are true" is somewhat hardly ever need, i didn't realized that i've made an error using it. i better be cautious whenever i try to use that condition.

---Thanks again guys, i'll make an update towards it if any case.
 

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
as for the "[GUI-friendly] Movement Speed System 2.0.1", i'll analyze it on how this thing works.
According to the description of that system, you will still have to keep track of bonuses that have been added and reduce the same amount when it is required, so make sure to do that. And also be aware that although the system is GUI friendly, the main code is written in vJASS, if you have not grasped a good understanding of GUI yet, you might get even more confused at how things work. So feel free to ask again, I'm sure some people around here can help you out.
 
Top