• 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.

A trigger to make all vehicles accelerate when moving.

Status
Not open for further replies.
Level 8
Joined
Dec 9, 2005
Messages
523
The thing about RTS games is that all similar units move at the same speed at all time. I am constructing a map with several vehicles and I'd like them to move from 0 to the unit's max speed as it moves. So that it will be somewhat "realistic"...

Could be in JASS though I'm a massive noob when it comes to JASS so you might have to explain how to implement it as well :)

This trigger/system would probably work and be useful in all maps involving vehicles too, like tank wars etc.

Thanks in advance.
 
Level 8
Joined
Dec 9, 2005
Messages
523
Hi, mckill2009. I've seen that system before, but I was under the impression that that's just to bypass the speed limit (of 522) of units. Not to accelerate unit movements like real life vehicles.

I mean, basically the trigger should make every unit's MS into a curve where they start with 0 (or 1?) MS which will then gradually increase up to its max MS. And when it stops it will either stop abruptly or slow down as well. But when it starts moving again the speed increase will be the same, 0 to max speed in perhaps 5 seconds or something.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Combine that system with IsUnitMoving system, surely you can achieve the acceleration.

When the unit is moving, keep increase the counter value (starts from current speed of the unit)
While it is moving, gradually increase it per interval of your trigger (Time - Periodic Event), it is up to you to accelerate the vehicle once per X second (if you want near-realistic acceleration, make it a 0.03 of updating trigger interval, it will make a smooth acceleration

To update the speed, just update the value

JASS:
call SetUnitMoveSpeedX(udg_u, udg_speed)
u is Unit variable
speed is Real variable

With an update counter per 0.03 second

  • Set speed = speed + 10.00
By setting it to +10 movespeed per interval, you will accelerate by 300 (approximately) in 10 seconds

The best part in using SetUnitMoveSpeedX is that you can go beyond 522 maximum speed but don't make it too high to prevent bug from occuring
 
you do not need IsUnitMoving system for that, you may adjust the movement speed from 0 to xxx by making a condition;
JASS:
//hashtables update here...
set maxspeed = maxspeed + 10
if maxspeed > 500 then
   call SetUnitMoveSpeedX(UNIT, maxspeed) 
else
   call SetUnitMoveSpeed(UNIT, maxspeed)
endif

whether you accelerate via arrowkey or starts ability, you need a hashtable to
update the maxspeed for every unit...
 
Level 8
Joined
Dec 9, 2005
Messages
523
Ah, yes, periodic [hashtables] + [if move speed less than]. Though I do think "isunitmoving" is required because otherwise wouldn't it then retain its MS once it's reached its max speed?

Also I'm considering using a trigger not unsimilar to those bash knockback ones to have the units slow down before stopping.

Anyway, +Rep for you two, you quickened the process of thinking about all this :)
 
Status
Not open for further replies.
Top