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

[Solved] ascending movement speed for unit

Status
Not open for further replies.
Level 17
Joined
Aug 19, 2007
Messages
1,380
Hi all,

Is it possible to let the movement speed of an unit increase as soon as it begins to move? Just like e.g. vehicles in the rts Company of Hero's, they need to start up their movement and do not move right way at 100% speed when ordered.

I know it is possible to change the movement speed, but I don't know which event I need to use for this.

Maybe something in the lines of a periodic event that picks every unit that has a specific buff (or maybe checks if the units casts an ability) and the unit gets the buff (or casts the ability) only when it moves. But what ability I could use for this I dont know :\.

But maybe I am thinking to complex now.

It is for a rts map by the way, so not things like holding down W or S etc.

Thanks for taking the time!
 
Level 6
Joined
Oct 1, 2012
Messages
166
You could make a dummy unit, which buffs the unit every given moment. You can make dummy haste skill with more than one lvl. As I believe you want a few steps-acceleration, correct?

As an example
The haste skill would have 10 lvls, every would increase the speed by 10%, 20%, 30% and so on until 100%

The you can make a trigger. Every 0.5 sec it would record unit's loc and then wait 0.1 sec and see, whether the new loc is different that the recorded. If it is, the trigger would create a dummy unit buffing the accelerating unit with dummy haste spell level depending on the buff on accelerating unit. I don't thing you can check buff lvl on unit, so you would have to make 10 different buffs for each acceleration lvl.

Do you want me to script it?
 
Level 25
Joined
Sep 26, 2009
Messages
2,377
Hmm an easy, but lacking way would be through order event. You could fire the even when a certain unit/unit-type is issued move order, then periodically check if the order is still "move" and increase/decrease speed.
This, however, would not work if your unit is issued any other orders (like attack - you will move to the attack range, so you should speed up, but you will still retain the same order even when you get in attack range - i.e. when you have already stopped moving).

Another way would be to periodically check position of unit using 2 point arrays.
One would be something like Point1 and the other Point2.
The first time unit spawns/when map starts, you will save position of that unit in Point1, then in periodic event save the units position into Point2 and compared distance between Point1 and Point2, speed up if the distance is greater than 10 (or so I think), or dont if not. Then save Point1 = Point2. etc.

Edit: Rybak, I think it would be a lot easier to change movement speed via triggers. You could have unlimited speed up and it's less stressful for PC than using ability with lots of levels
 
Level 18
Joined
May 11, 2012
Messages
2,103
well, I guess you can make variable ''MS'' and use periodical trig to make ti MS + 1 (or 2, 3 idk what's best for ya) and set the ms of your unit to that. Then event when that real becomes equal to MS you want it to be, then turn off the loop and set the MS of the unit to that real variable.

Use event:
  • MS Acceleration Start
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Current order of (Triggering unit)) Equal to (Order(smart))
          • (Current order of (Triggering unit)) Equal to (Order(smart,attack))
Something Like this yeah. Hope it helped :)
 
Level 17
Joined
Aug 19, 2007
Messages
1,380
I almost have it working. The increasing speed of the unit works now but reseting its movement speed to default does not work 100% yet. I have 2 functions for it, one that checks if the unit is ordered to stop (this works perfectly) and one that periodically checks if the unit has an order equal to smart or smart,attack (this one lacks):

This one works:
  • Dreadnoughts Stopping
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Dreadnought
      • Or - Any (Conditions) are true
        • Conditions
          • (Current order of (Triggering unit)) Equal to (Order(stop))
    • Actions
      • Unit - Set (Triggering unit) movement speed to (Default movement speed of (Triggering unit))
The one below lacks. Apperently when you smart move (/right mouse button) a unit and even though the unit has reached its destination, warcraft 3 still reads its order as 'smart' instead of 'stop' :eekani:.

  • Dreadnoughts Stopping2
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Dreadnought) and (((Current order of (Matching unit)) Not equal to (Order(smart))) and ((Current order of (Matching unit)) Not equal to (Order(smart,attack)))))) and do (Actions)
        • Loop - Actions
          • Unit - Set (Picked unit) movement speed to 0.00 //for easy testing purposes it is now set to zero
So the unit's movement is not reset to zero after it has reached its destination after being smart ordered (not very smart :p).

Anyone has an idea? Thanks for helpfull information so far by the way.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240

  • On Move
    • Events
      • Game - UnitMovingEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Unit Group - Add UDexUnits[UDex] to MoveGroup
      • Set MoveSpeed[(Custom value of UDexUnits[UDex])] = 150.00
      • Unit - Set UDexUnits[UDex] movement speed to 150.00
      • Trigger - Turn on MoveLoop <gen>
  • On Stop
    • Events
      • Game - UnitMovingEvent becomes Equal to 2.00
    • Conditions
    • Actions
      • Unit Group - Remove UDexUnits[UDex] from MoveGroup
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (MoveGroup is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off MoveLoop <gen>
        • Else - Actions
  • MoveLoop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MoveGroup and do (Actions)
        • Loop - Actions
          • Set i = (Custom value of (Picked unit))
          • Set MoveSpeed[i] = (MoveSpeed[i] + 10.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MoveSpeed[i] Less than 400.00
            • Then - Actions
              • Unit - Set (Picked unit) movement speed to MoveSpeed[i]
            • Else - Actions
              • Unit - Set (Picked unit) movement speed to 400.00
              • Unit Group - Remove (Picked unit) from MoveGroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (MoveGroup is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off MoveLoop <gen>
                • Else - Actions

You could use different max speed, initial speed and acceleration for different units.

Copy the unit indexer and Is Unit Moving triggers into your map.

Min/max move speed are defined in Advanced - Gameplay constants, you can't go over 522 without triggering.
 

Attachments

  • Is Unit Moving with events.w3x
    23.1 KB · Views: 131
Status
Not open for further replies.
Top