# Make units slow down before stopping?

#### HelloFlighty

Level 8
I have a helicopter unit in my map and i'm wondering if you can make a unit slow down before abruptly stopping, it looks silly when a unit like a jet or helicopter instantly stops moving so i'm trying to figure out how to make them gradually reduce speed then stop like in real life, all help is greatly appreciated.

#### TheLordOfChaos201

Level 19
You could try it one of two ways.

One is to use a spell that stacks slow...

or two use a trigger that reduces movement speed every second of elapsed game time until the unit stops.

I would suggest the trigger because it is less searching

____

On further review of your question I see your dilemma. Your units speed has to gradually build as they take off and gradually slow down as they stop. Hmm... The only idea I can think off is to have a timer set in from when the unit is issued the order to move, to where it will stop, at first the timer loops a speed up routine and then later a slow down routine

hmm... but I don't believe warcraft has a method for determining where an issued order is targeted in relation to locations

Last edited:

#### BloodSoul

Level 13
hmm... but I don't believe warcraft has a method for determining where an issued order is targeted in relation to locations

• Set point = (Target point of issued order)
`constant native GetOrderPointLoc takes nothing returns location`
or
`constant native GetOrderPointX takes nothing returns real`
`constant native GetOrderPointY takes nothing returns real`

#### TheLordOfChaos201

Level 19
• Set point = (Target point of issued order)
`constant native GetOrderPointLoc takes nothing returns location`
or
`constant native GetOrderPointX takes nothing returns real`
`constant native GetOrderPointY takes nothing returns real`
Ok that solved the problem.

Use the above trigger with the two other triggers.

To clarify:

Trig speed up;

This trig waits for an issued order of move/attack(targeting a place or otherwise)

condition is that the unit type is one of your flying units

action, speed unit up over an elapsed time(use a for loop with an in game timer in it)
Give unit custom value

Trig slow down:

This trig compares the ordered point location to the location the unit is ordered to go.

event; every 1 second game time

condition unit is a flying unit with a custom number value of *

if compared order point location is within 50 meters of ordered point location
{
action; slow unit down after 5 seconds
}

#### HelloFlighty

Level 8
Ok that solved the problem.

Use the above trigger with the two other triggers.

To clarify:

Trig speed up;

This trig waits for an issued order of move/attack(targeting a place or otherwise)

condition is that the unit type is one of your flying units

action, speed unit up over an elapsed time(use a for loop with an in game timer in it)
Give unit custom value

Trig slow down:

This trig compares the ordered point location to the location the unit is ordered to go.

event; every 1 second game time

condition unit is a flying unit with a custom number value of *

if compared order point location is within 50 meters of ordered point location
{
action; slow unit down after 5 seconds
}
i'm sorry but i don't understand much of what you're asking me to do, speeding the unit up with a loop, i have no idea how to do that, and giving a unit a custom value, i don't understand this either, sorry for being really dumb, without actually seeing a trigger, i cannot understand

#### TheLordOfChaos201

Level 19
for setting a custom value simple go to the trigger and search for units

in the unit action area there should be an option, set custom value.

for the loop.

for 1-10
set unit speed (again in trigger unit area) +1 of the current units speed
wait in game 1 second
end loop

#### HelloFlighty

Level 8
for setting a custom value simple go to the trigger and search for units

in the unit action area there should be an option, set custom value.

for the loop.

for 1-10
set unit speed (again in trigger unit area) +1 of the current units speed
wait in game 1 second
end loop
like this? i'm really not good at this, sorry
• For each (Integer A) from 1 to 10, do (Unit - Set SS_movingUnit[(Player number of (Triggering player))] movement speed to ((Current movement speed of SS_movingUnit[(Player number of (Triggering player))]) + 1.00))
EDIT: also an issue i'm having with my editor is if in a trigger i put a "wait" action longer than 0.50, the actions after that delay never take place, they never happen, that same bug is also causing issues with other triggers like the speed trigger i have made
• Slowtakeoff
• Events
• Time - Every 0.01 seconds of game time
• Conditions
• Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Or - Any (Conditions) are true
• Conditions
• (Current order of SS_movingUnit[(Player number of (Triggering player))]) Equal to (Order(none))
• (Current order of SS_movingUnit[(Player number of (Triggering player))]) Equal to (Order(stop))
• Then - Actions
• Unit - Set SS_movingUnit[(Player number of (Triggering player))] movement speed to 0.00
• Else - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Current movement speed of SS_movingUnit[(Player number of (Triggering player))]) Equal to 10000.00
• Then - Actions
• Else - Actions
• Unit - Set SS_movingUnit[(Player number of (Triggering player))] movement speed to ((Current movement speed of SS_movingUnit[(Player number of (Triggering player))]) + 1.00)
even though i've set the gameplay constants for max speed to something like 999999 the trigger still doesn't seem to increase the units movement speed past a certain value(which is unknown to me) :/ i have no idea why this bug is happening

PS:There is another trigger which sets SS_movingUnit.

Last edited:

#### TheLordOfChaos201

Level 19
@orcling3

I feel ill equipped to help you with this problem, but it seems no one else is available so I will not shelter myself from my responsibilities.

For now forget the if statement... you one is wrong because it would only activate when the unit has already stopped.

Now What I want you to do is create a for loop. Go to the actions and search for a for loop, click enter.

Now you should have for loop that looks like this.

For 1-10 do action...

now in the action of he for loop I want you to create two actions.

set unit movement speed to (unit movement speed+1)
wait in game 1 second

Now this trig should speed up the unit +10 speed units over 10 seconds

Could you do that for me?

#### HelloFlighty

Level 8
@orcling3

I feel ill equipped to help you with this problem, but it seems no one else is available so I will not shelter myself from my responsibilities.

For now forget the if statement... you one is wrong because it would only activate when the unit has already stopped.

Now What I want you to do is create a for loop. Go to the actions and search for a for loop, click enter.

Now you should have for loop that looks like this.

For 1-10 do action...

now in the action of he for loop I want you to create two actions.

set unit movement speed to (unit movement speed+1)
wait in game 1 second

Now this trig should speed up the unit +10 speed units over 10 seconds

Could you do that for me?
this is all i could come up with
• Slowtakeoff
• Events
• Unit - A unit Is issued an order targeting a point
• Conditions
• (Unit-type of (Triggering unit)) Equal to Cobra Assault Chopper
• Actions
• For each (Integer A) from 1 to 10, do (Actions)
• Loop - Actions
• Unit - Set (Triggering unit) movement speed to ((Current movement speed of (Triggering unit)) + 1.00)
• Wait 1.00 game-time seconds
no results come up when i search "for loop" so i used for each, but still this trigger doesn't seem to do anything

#### TheLordOfChaos201

Level 19
@orcling3

Ha! Ok sorry I'm a java programmer... well never mind that.

Ok so you have successfully found your loop

Now in the conditions of this trigger add:

Unit has custom value of 80

Now duplicate this trig and change the +1.00 in set unit speed to -1.00
also change the condition of custom value to 70

event: unit is issued an order targeting a point

condition: unit is a flying unit and unit doesn't have custom value.

action: Set value(is the trig you want to find)

create a custom 2 location to be used for the above value set.

set location to location of unit issued order
set location2 to the location of point of issued order.

#### doom_sheep

Level 22
you can save the target point of the order as a hashtable value on a unit when it's given, and periodically check the distance. orders targeting other units, items, trees may be bit of a headache but the same principle will deal with it in most or all cases.

of course nothing will stop players from just giving the initial order to a further location, then pressing stop when they are where they want to be.

modifying a unit's movement speed seems to also affects it walk animation speed. if you want to fix these issues, you'd have to make a system that periodically moves the unit forwards or backwards to artificially modify the movement speed, then pressing stop could be made to cause it to continue forwards a little bit.

--

don't use "wait" actions, those fuck up everything because they don't work properly. you have to simulate them by saving values somewhere, reducing those periodically and doing the actions when they're at zero.

#### HelloFlighty

Level 8
you can save the target point of the order as a hashtable value on a unit when it's given, and periodically check the distance. orders targeting other units, items, trees may be bit of a headache but the same principle will deal with it in most or all cases.

of course nothing will stop players from just giving the initial order to a further location, then pressing stop when they are where they want to be.

modifying a unit's movement speed seems to also affects it walk animation speed. if you want to fix these issues, you'd have to make a system that periodically moves the unit forwards or backwards to artificially modify the movement speed, then pressing stop could be made to cause it to continue forwards a little bit.

--

don't use "wait" actions, those fuck up everything because they don't work properly. you have to simulate them by saving values somewhere, reducing those periodically and doing the actions when they're at zero.
thanks for the info man also i don't mind having issues with the animation speed because the only models using the system are a helicopter and a jet. Slow animation speed on the helicopters doesn't do anything major because the blades seem to still spin very fast and as for the jet, there aren't any moving parts so it's all good

EDIT: So i had a go at the triggers lordofchaos wanted me to make and this is what i come up with but i'm not sure how to make the 3rd trigger
Trigger 1
• Trigger 1
• Events
• Unit - A unit Is issued an order targeting a point
• Conditions
• (Unit-type of (Triggering unit)) Equal to Cobra Assault Chopper
• (Custom value of (Triggering unit)) Equal to 80
• Actions
• For each (Integer A) from 1 to 10, do (Actions)
• Loop - Actions
• Unit - Set (Triggering unit) movement speed to ((Current movement speed of (Triggering unit)) + 1.00)
• Wait 1.00 game-time seconds
Trigger 2
• Trigger 2
• Events
• Unit - A unit Is issued an order targeting a point
• Conditions
• (Unit-type of (Triggering unit)) Equal to Cobra Assault Chopper
• (Custom value of (Triggering unit)) Equal to 70
• Actions
• For each (Integer A) from 1 to 10, do (Actions)
• Loop - Actions
• Unit - Set (Triggering unit) movement speed to ((Current movement speed of (Triggering unit)) - 1.00)
• Wait 1.00 game-time seconds

RE-EDIT: @Fruit Forest can you help here? do you know how to do what i'm asking?

Last edited:

#### Fruit Forest

Level 11
RE-EDIT: @Fruit Forest can you help here? do you know how to do what i'm asking?
Chip and Dale comes to help.
FADE SPEED RATE - The decreasing of speed while coming on minimal distance. The more rate the faster unit stops.
DISTANCE OF SLOWING - Start to slow down while reaches the minimal distance.
MINIMAL SPEED (1-522) - After the slowing down unit must have the minimal movement speed to reach the point or unit.
P.S. If you use the "Patrol" order then unit will slow down in targeted point AND in point where the unit got the order.

#### Attachments

• movement speed option.w3x
17.4 KB · Views: 31
Last edited:

#### HelloFlighty

Level 8
Chip and Dale comes to help.
FADE SPEED RATE - The decreasing of speed while coming on minimal distance. The more rate the faster unit stops.
DISTANCE OF SLOWING - Start to slow down while reaches the minimal distance.
MINIMAL SPEED (1-522) - After the slowing down unit must have the minimal movement speed to reach the point or unit.
P.S. If you use the "Patrol" order then unit will slow down in targeted point AND in point where the unit got the order.
Thanks again man

#### Fruit Forest

Level 11
Thanks again man
This template is a general one, it spreads on all moving units and reacts on all orders including abilities. It doesn't have any limiting conditions. You may add more conditions to trigger only certain units or reacts only on certain orders.

Last edited:

Replies
5
Views
644
Replies
2
Views
587
Replies
3
Views
1K
Replies
3
Views
388
Replies
17
Views
800