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

Movement Speed with Real Variable

Status
Not open for further replies.
Level 7
Joined
May 30, 2018
Messages
290
Hello guys,

I have an old trigger, which amplifies movement speed whenever a hero levels up, but since it was to static the way I did it I wanted to translate it into a real variable (which I wanted to have the same effect, but more flexible)

Here is the old trigger (static):
  • Movement Speed Copy
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has buff Cripple) Equal to False
          • ((Triggering unit) has buff Berserk) Equal to False
        • Then - Actions
          • Unit - Set (Triggering unit) movement speed to ((Current movement speed of (Triggering unit)) - 2.50)
        • Else - Actions

and here is the new one I tried

  • Set Up MovementSpeed
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet MovementSpeed_REAL = ((Default movement speed of (Triggering unit)) - (2.50 x (Real((Hero level of (Triggering unit))))))
  • Movement Speed
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Unit - Set (Triggering unit) movement speed to MovementSpeed_REAL
        • Else - Actions
Unfortunately the new trigger doesn't work as anticipated and slows down the heroes waaaay to much on level up. Can somebody enlighten me on what I have to adjust here?

Its important to mention, that I don't want temporary speed amplifications like buffs or debuffs to be calculated when reducing the movement speed (ignored when leveling up under the effect of buff/debuffs)
 
Last edited:
Level 5
Joined
Jul 31, 2020
Messages
103
Your old trigger doesn't seem like it "amplifies" movement speed in the first place, since you're reducing it by 2.5. And your new setup sets a variable at map initialization, then always uses that very same value. Additionally, the value is most probably 0 since Triggering Unit returns null in an init trigger, since no unit triggers it. And since the value assigned to MovementSpeed_REAL is 0, then you set the movement speed on level up of any unit to 0, they will move at your preset minimum movement speed, which is 150 by default, and can be changed in gameplay constants.

Scrap the first trigger, and add the variable set before setting the unit's movement speed to the second trigger instead. There, you set it to whatever you want. I admit I don't exactly understand how you want to alter it.
 
Level 19
Joined
Feb 27, 2019
Messages
590
If every player only has 1 hero you could use Player Number as your index and index the Hero if you want.

Using player number as index

On indexing ( You can index even more stuff and use the Hero variable even so often )
Set PlayerInt = (Player Number of (Triggering player))
Set Hero[PlayerInt] = Triggering unit
Set MoveSpeed[PlayerInt] = ((Default movement speed of (Hero[PlayerInt]))

On Level up
Set PlayerInt = (Player Number of (Triggering player))
Set MoveSpeed[PlayerInt] = MoveSpeed[PlayerInt] - 2.50
Unit - Set (Hero[PlayerInt]) movement speed to MoveSpeed[PlayerInt])

Using custom value as index

On indexing
Set a = a + 1
Set Custom value of (Triggering unit) = a
Set MoveSpeed[a] = ((Default movement speed of (Triggering unit))

On level up
Set MoveSpeed[Custom value of (Triggering unit)] = MoveSpeed[Custom value of (Triggering unit)] - 2.50
Unit - Set (Triggering unit) movement speed to MoveSpeed[Custom value of (Triggering unit)]

However the simplest solution would be:
Set Hero = Triggering unit
Unit - Set (Hero) movement speed to ((Default movement speed of (Hero)) - (2.50 x (Real((Hero level of (Hero))))))
Set Hero = No unit
 
Status
Not open for further replies.
Top