I'm trying to figure out a way to tell in scripting if a creature is currently moving. Preferably I'd also be able to break it down by running vs walking.
I was thinking about using GetCommandByIndex(0) but the description says this will be the command at the top of the queue that is not yet being run; I need to tell if the command currently being done is a move. Furthermore, I'm not sure how movement controlled by WASD ties into this; is it a constant stream of commands each unit of time that W is held down?
An approach I'm thinking about is using the creature script and each time EVENT_TYPE_COMMAND_PENDING is fired, check if it's a walk/run and if so setting a flag on the creature. Then when EVENT_TYPE_COMMAND_COMPLETE fires, I unset the flag. Is PENDING fired just before the command starts, or when it is first issued?
How to tell if the player (or creature) is moving?
Débuté par
FergusM
, août 03 2010 09:11
#1
Posté 03 août 2010 - 09:11
#2
Posté 03 août 2010 - 10:26
I have never tried it, but there is a function called
IsMoving()
Modifié par _L_o_B_o_, 03 août 2010 - 10:26 .
#3
Posté 03 août 2010 - 11:09
Ah yes, I forgot about that. Doesn't seem to distinguish between running and walking though.
#4
Posté 03 août 2010 - 12:06
Could it use a parameter, like IsMoving(run)?
#5
Posté 03 août 2010 - 09:02
It just takes the creature as a parameter and the return type is true/false.
#6
Posté 04 août 2010 - 08:37
Hmm, just brainstorming, but once IsMoving returns true, you could grab the location, wait for 1-2 heartbeats, and grab the new location. If the delta is > than the walk distance, then it was running. Not sure how easy/hard this would be to script though.
#7
Posté 04 août 2010 - 09:35
I've contemplated doing this, but it is a little messy, especially if the player is running in circles.
(or running stop start, etc).





Retour en haut






