ID:161931
 
I've been trying to figure out how I would go about a targeting system that constantly updates the person's angle to be facing whatever is being targeted. The angles are based off of byond's native angle system, 90 is east, 180 is south 270 is west and 360/0 is north. Also, the movement system is pixel based. I'm not so great at math, well trig in this case, so that is why I need some direction (no pun intended)
I believe this function will do what you want:

/* Determines the direction from point A to point B */
proc/get_exact_dir(atom/Ref,atom/Target)
if(!Ref || !Target) return 0
var/dx = ((Target.x*32) + Target.pixel_x - 16) - ((Ref.x*32) + Ref.pixel_x - 16)
var/dy = ((Target.y*32) + Target.pixel_y - 16) - ((Ref.y*32) + Ref.pixel_y - 16)
var/dev = sqrt(dx * dx + dy * dy)
var/angle = 0
if(dev > 0) angle = arccos(dy / sqrt(dx * dx + dy * dy))
return (dx>=0) ? (angle) : (360-angle)


You may also want to visit [link] for some other functions along those lines.
In response to Foomer
I appreciate you finding that for me. A lot of the functions in your linked post will come in handy for me, thanks!