• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Movement Speed Issues

Status
Not open for further replies.
Level 8
Joined
Oct 2, 2013
Messages
288
I would like to be able to adjust movement speed for units without unwanted bugs, interference or limits.

I tried testing around with some movement speed functions, where I basically mixed functions from triggers, abilities and item abilities.

I found out that some of these functions interfere with each other and causes major bugs.

For instance: Changing a units current or default MS by trigger, while having ability functions such as "Slow" affecting the unit, can cause unintended permanent changes of movement speed.

Luckily the item ability "Item Move Speed Bonus" doesn't seem to interfere with ability effects such as "Slow". I also tested "Engineering Upgrade" as well, but that ability crashed when used by Non-Hero units, even as a Non-Hero ability.

Unfortunately, “Item Move Speed Bonus” does not work as a negative effect. Even through Shift-B the effective value is still 0 in spite of being set to a negative value.

I have also considered the disabled spellbook trick with auras, since auras stacks. But I would like to find a solution without the use of visible/valid buffs - since buffs plays an important part in my map.

In conclusion, I would like to adjust MS where I can still have abilities and item abilities working without bugs. Abilities alone aren't enough because they dont stack unlimited :(

Do tell if I need to explain better. Thanks in advance :)
 
Last edited:
Level 8
Joined
Oct 2, 2013
Messages
288
Time Elapsed - 2 seconds

Set Unit ms to (Current ms of Unit - 100)
Wait - 10 sec
Set Unit ms to (Current ms of Unit + 100)

This is how the test trigger looks, very simple.
The problem appears if Unit has "Slow" casted upon it. After "Slow" ends the unit has a different ms than it started with.

Same trigger with "default ms" causes bugs as well.

The only way this works is by adding the passive "Move Speed Bonus" ability and removing it again. However, as said earlier, it doesn't provide negative features.

Is this okay, or is it still unclear? :/
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Where you suspect a bug there is none. Here is how wc3 movement speed works:

ms = ( base + x + flatBonus ) * ( 1 + percentageBonus1 + percentageBonus2 + ...)

ms: min and max can be set in the gameplay constants as well as in the unit properties. Absolute min is 1, absolute max is 522. Exceptions are units with base 0 or certain abilities like Purge, Entangling Roots or Root setting it to 0 temporary.
base: spd value in the object editor.
x: used by SetUnitMoveSpeed and flat movement speed upgrades.
flatBonus: used by AIms based abilities (boots). Ability with highest value is used, minimum of 0.

GetUnitDefaultMoveSpeed returns base
GetUnitMoveSpeed returns ms
SetUnitMoveSpeed with parameter y sets x to (y-base)

There are a lot more corner cases and small info bits but those are the basics.

So what should you do?

If you want a change in the flat bonus section:
If permanent, use an upgrade. If non-permanent, use one of the two following systems:
a) give the unit a very low base and one ability based on AIms. Change the ability level to alter ms. Of course you have to trigger all boots in your map, so that your AIms ability is set to the right level.
b) if you understand how everything interacts, use SetUnitMoveSpeed. You have to keep track of the x and y values ofc.

If you want a change in the percentage bonus section:
As you have a non-hero unit and you dont want an icon in the units status bar, the only thing left is the Defend ability. For a very nice system I advise you to make a Defend ability with different lvls having different movement speed values, then at unit birth add it in a hidden spellbook and order the unit to use Defend. Then all you have to do is to change the level of Defend to adjust movement speed.
 
Level 8
Joined
Oct 2, 2013
Messages
288
This is indeed the kind of information I need.

I consider my issue solved for now. I will repost if I run into trouble.

Thanks a lot for your effort and help!
 
Level 8
Joined
Oct 2, 2013
Messages
288
Okay so basicly what I've done is that I've set every unit's ms to 1.

Next thing I added two triggers.
- One that picks every unit on map.
- And another that picks every unit that enters playable map (gotta ask about leaks on that one later).

The picked units get "Item Move Speed Bonus" (with 522 different levels that scales from 1 to 522) and has it's level set to average amount (level 270 for instance).

It works on all pre-spawned units (the first trigger). But it doesn't work on newly spawned units (the second trigger). All of them move with 1 ms.

This is how the trigger 2 looks (it's combined with a damage detection trigger):

  • UnitTakeDamageDetector
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Triggering unit) is in TakeDamGroup) Equal to False
    • Actions
      • Unit - Add The Move Speed to (Triggering unit)
      • Unit - Set level of The Move Speed for (Triggering unit) to 270
      • Unit Group - Add (Triggering unit) to TakeDamGroup
      • Trigger - Add to UnitTakeDamage <gen> the event (Unit - (Triggering unit) Takes damage)
Strangely, I can see that all spawned units (trigger 2) actually have the ability. Their movement speed says "Average" with green text, but they move with 1 ms only.

I should probably note that those units are Computer controlled. Perhaps they need to be re-ordered or something?
 
Last edited:
Level 8
Joined
Oct 2, 2013
Messages
288
Yeap they do... Man this is strange. So apparently if the order happens before the ability adjustment, they will still move with 1 ms until ordered anew.
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Thats one of the info bits I left out. Movement speed change from flatBonus will update the ms but for some strange reason not the actual speed the unit is moving at until a new command. All other ms modifications work instantly.

Now Back to your problem.
An obvious solution would be to reoder the current command after modifying the ms ability. This will only work fine in most cases though.
Also if you don't care you can make an ability with 522 levels and the map will work perfectly but generally it's not recommended. If you need such small gradation, don't want to use SetUnitMoveSpeed (which is the way I would go) and are not opposed to modifying the percentage section of ms, you could also use multiple Defend abilities. Smallest steps can be achieved by basing the ms speed values of the different abilities on a binary system. If you have never done such a thing (especially in wc3) it involves a lot of thinking though..
 
Level 8
Joined
Oct 2, 2013
Messages
288
Thats one of the info bits I left out. Movement speed change from flatBonus will update the ms but for some strange reason not the actual speed the unit is moving at until a new command. All other ms modifications work instantly.

Now Back to your problem.
An obvious solution would be to reoder the current command after modifying the ms ability. This will only work fine in most cases though.
Also if you don't care you can make an ability with 522 levels and the map will work perfectly but generally it's not recommended. If you need such small gradation, don't want to use SetUnitMoveSpeed (which is the way I would go) and are not opposed to modifying the percentage section of ms, you could also use multiple Defend abilities. Smallest steps can be achieved by basing the ms speed values of the different abilities on a binary system. If you have never done such a thing (especially in wc3) it involves a lot of thinking though..

Yes, the 522-leveled-ability is what I'm using. The idea I have now is that I will not used Unit - Set Movement Speed at all. - Because that will cause bugs with ability affections.

I am still worried about some situations though:

For instance:
Step 1 - Unit is slowed through trigger (ability level reduced).
Step 2 - Unit is attacking a target.
Step 3 - Unit recovers movement speed (ability level increased to normal).
Step 4 - If unit is still attacking same target the order has not changed.

And as a result it will still move as if slowed, even though it's not supposed to. Or perhaps there is a way to reorder current order?

Perhaps I should try using the Defend ability as you suggest. But what if some of my units already have a valid Defend ability?

I would love to use "Unit - Set Movement Speed" though. But from what I have tested it interferes with ability affections, resulting in bugs.

Should I consider using the trigger function only, and add functions to all abilities that are supposed to slow? Seems easier at this point imo.

Again thanks for your help on the matter! I really need this.
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
And as a result it will still move as if slowed, even though it's not supposed to. Or perhaps there is a way to reorder current order?
There is no easy way. Found something nice though, any ms change will update also the boots ms change. So after changing the lvl of your ability do something like that:

  • Actions
    • Unit - Add Endurance Aura to unit
    • Unit - Remove Endurance Aura from unit
    • Unit - Remove Endurance Aura buff from unit
Perhaps I should try using the Defend ability as you suggest. But what if some of my units already have a valid Defend ability?
It will mess up. There is another workaround to make it work, were sailing in depths resulting in work you don't wanna go though I think..
I would love to use "Unit - Set Movement Speed" though. But from what I have tested it interferes with ability affections, resulting in bugs.
I can not see a bug, only incorrect use of the function.
 
Level 8
Joined
Oct 2, 2013
Messages
288
There is no easy way. Found something nice though, any ms change will update also the boots ms change. So after changing the lvl of your ability do something like that:

  • Actions
    • Unit - Add Endurance Aura to unit
    • Unit - Remove Endurance Aura from unit
    • Unit - Remove Endurance Aura buff from unit

Ah this looks nice. I assume this will solve the re-order issue?

I can not see a bug, only incorrect use of the function.
I would like to show you my test process and results. Perhaps you can point out what I have done wrong :)
 
Level 8
Joined
Oct 2, 2013
Messages
288
This is how I tested it.

  • Trigger
    • Events
      • Time - Elapsed game time is 3.00 seconds
    • Conditions
    • Actions
      • Unit - Set Peasant 0000 <gen> movement speed to ((Current movement speed of Peasant 0000 <gen>) - 100.00)
      • Wait 10.00 seconds
      • Unit - Set Peasant 0000 <gen> movement speed to ((Current movement speed of Peasant 0000 <gen>) + 100.00)
In addition, I had a trigger informing me of the peasant's current ms every second.

-At first, the peasant has it's base ms of 190.
-After the trigger starts, it shows 90 ms.
-Then "Slow" is casted, reducing it's ms to 36.
-Then the trigger finished, and ms now shows 54 ms ("Slow" is still in effect).
-"Slow" runs out, and the peasant now has 136 ms by the end.

So it started with 190 and ended with 136 :/
It also bugs when using default ms.
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
Reread the formula on the last page what SetUnitMoveSpeed sets. The following trigger should work right. If its somehow not what you want please tell me.
  • Trigger
    • Events
      • Time - Elapsed game time is 3.00 seconds
    • Conditions
    • Actions
      • Unit - Set Peasant 0000 <gen> movement speed to ((Default movement speed of Peasant 0000 <gen>) - 100.00)
      • Wait 10.00 seconds
      • Unit - Set Peasant 0000 <gen> movement speed to ((Default movement speed of Peasant 0000 <gen>))
 
Level 8
Joined
Oct 2, 2013
Messages
288
Reread the formula on the last page what SetUnitMoveSpeed sets. The following trigger should work right. If its somehow not what you want please tell me.
  • Trigger
    • Events
      • Time - Elapsed game time is 3.00 seconds
    • Conditions
    • Actions
      • Unit - Set Peasant 0000 <gen> movement speed to ((Default movement speed of Peasant 0000 <gen>) - 100.00)
      • Wait 10.00 seconds
      • Unit - Set Peasant 0000 <gen> movement speed to ((Default movement speed of Peasant 0000 <gen>))

Yes this should work indeed. However, if I have more than one trigger doing this, they will eventually interfere with each other right?

I will explain what I need this for:
Basicly I wanna make abilities that are trigger-based in terms of slow/speed-up effects (because ability-based dont stack, and I dont want buffs involved as they play an important part in my map)

So if I have two abilities with trigger-based slow effects, cast on the same unit, it will become a problem if a function returns ms to default/base purely. Or have I misunderstood how default ms works?
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
However, if I have more than one trigger doing this, they will eventually interfere with each other right?
That may very well be. Thats why you need to keep track of the x value and stuff.


Or have I misunderstood how default ms works?
I think you understand it. All you need is a global variable for storing a units x and some functions that use it. With JASS it becomes a lot easier.

because ability-based dont stack
There are (buff based) abilities which can have sort of stacking slow. Remember, quite everything in wc3 got exceptions :).
 
Level 8
Joined
Oct 2, 2013
Messages
288
There are (buff based) abilities which can have sort of stacking slow. Remember, quite everything in wc3 got exceptions :).

Please do tell which ones thanks! :D I hope u mean unlimited and unbuffed stacking potential.

Well I have never used jass before. Would it be difficult to handle in my case?
 
Last edited:
Level 12
Joined
Mar 13, 2012
Messages
1,121
Please do tell which ones thanks! :D I hope you mean unlimited stacking potential?

Abilities being able to stack using the same buff are Envenomed Spears (which got Attack Speed Factor and Movement Speed Factor confused) and Cold Arrows. Actually there are a lot more but they are basically replications of these two, as they all are either passive or an orb arrow effect.
If you enable their stacking flags they can stack to a certain extent, namely that every unit can apply the effect once. Making a system for this you would create a different dummy unit for every instance of slow to be applied, order it to attack the target and then be destroyed (if the buff deals no damage over time, else you have to keep it ofc).

Well I have never used jass before. Would it be difficult to handle in my case?
For a beginner it might be difficult, as you have to start thinking more like a programmer when creating such things. It certainly is possible in GUI too though..
 
Level 8
Joined
Oct 2, 2013
Messages
288
Abilities being able to stack using the same buff are Envenomed Spears (which got Attack Speed Factor and Movement Speed Factor confused) and Cold Arrows. Actually there are a lot more but they are basically replications of these two, as they all are either passive or an orb arrow effect.
If you enable their stacking flags they can stack to a certain extent, namely that every unit can apply the effect once. Making a system for this you would create a different dummy unit for every instance of slow to be applied, order it to attack the target and then be destroyed (if the buff deals no damage over time, else you have to keep it ofc).

Hmmm but either stack type still creates a buff right?

Haven't used GUI either. All though I feel I should get started, it would probably make things a lot easier for me.

Well, for now I'll try out a few things, but I am considering transitioning into using trigger based slows/speeds only.
 
Status
Not open for further replies.
Top