Code:
var
is_moving = 0
base_delay = 3
move_delay = 3
tmp
next_move = 0 //the world.time value of the next allowed self movement
last_move = 0 //the world.time value of the last self moveme
Move()
for(var/mob/monster/target in view(loc))
walk_to(target, loc, 1, 5)
var/time = world.time
if(next_move>time)
return
if(disabled)
return
glide_size = ICON_SIZE / max(move_delay,TICK_LAG) * TICK_LAG
last_move = time //set the last movement time
next_move = time+move_delay
..()
if (src.current_state == walking_state_1) //if already walking, ignore
return
else if (src.current_state == running_state_1) //if already walking, ignore
return
else
if(move_delay < base_delay) //trigger to toggle to running mode
src.Change_State(running_state_1)
else
src.Change_State(walking_state_1)
spawn(3) Is_Moving()
if(!is_moving)
world << "oi"
src.Change_State(idle_state_1)
proc
Is_Moving(last_move)
if(world.time-last_move > move_delay )
is_moving = 0
else
is_moving = 1
return is_moving
Problem description:
I got back on coding DM and this project after a long time, and I may missing some minor clues.
I want to know if the mob is in constant motion or not to change its state.
Something like:
if is_moving then
current_state = walking_state
else
current_state = idle_state
In my current code, when I'm walking, the states go:
walking -> idle -> walking
This happens for every tile.
I would like to know if it is possible to only leave the walking state on the "movement keys up"
This is for movement fluency. It looks good, but I'm afraid if I try something more elaborate than what I have now, it may look glitchy.
I tried a few solutions, but this one seems to be closer.
It get stuck on idle_state.
I don't know if I coded around a limitation from DM or if I just revisited an already fully flawed piece of code from my past self.
Either way I am stuck on this problem.
And it looks like I coded around this seemed limitation.