mob
var
angle = 0
speed = 5
proc/Test(d)
if(d==EAST)
usr.angle = 0
usr.dir = d
else if(d==NORTHEAST)
usr.angle = 45
usr.dir= d
else if(d==NORTH)
usr.angle = 90
usr.dir= d
else if(d==NORTHWEST)
usr.angle = 135
usr.dir= d
else if(d==WEST)
usr.angle = 180
usr.dir= d
else if(d==SOUTHWEST)
usr.angle = 225
usr.dir= d
else if(d==SOUTH)
usr.angle = 270
usr.dir= d
else if(d==SOUTHEAST)
usr.angle = 315
usr.dir= d
var/dx = round(cos(usr.angle) * usr.speed)
var/dy = round(sin(usr.angle) * usr.speed)
usr.pixel_move(dx, dy)
turf
icon_state = "floor"
wall
density = 1
icon_state = "wall"
MouseEntered()
var/d = get_dir(usr,src)
usr.Test(d)
Problem description:
I am trying to make a system where mob will walk to the mouse location. I know this might not be the best solution but I manage to make it right somehow. The problem with it is that once you enter the turf with a mouse it wont update MouseEntered() proc so if the mouse is not moved to the other turf, the mob will not move.
Let's just go ahead and set up the client to your specifications. MouseMove() is a far better function to bind than MouseEntered(), and tracking based on the screen position of the mouse is far better than tracking based on objects within the map.
And here's a code snippet that will implement smooth subpixel movement and give you an easy helper function that will let you move your mob by a set number of pixels or subpixels on each x/y axis.