ID:144135
 
Code:
mob/proc/DIR()
var/mob/M = src.Target
var/D = get_dir(src.loc,M.loc)
src.dir = D
if(src.dir == NORTH)
src.Direction = "North"
if(src.dir == SOUTH)
src.Direction = "South"
if(src.dir == EAST)
src.Direction = "East"
if(src.dir == WEST)
src.Direction = "West"
if(src.dir == SOUTHWEST)
src.Direction = "SouthWest"
if(src.dir == SOUTHEAST)
src.Direction = "SouthEast"
if(src.dir == NORTHEAST)
src.Direction = "NorthEast"
if(src.dir == NORTHWEST )
src.Direction = "NorthWest"


Problem description:

I have a quest system where I want it to display the direction a player should head in rather than the exact cords of the target the player is hunting, is there a way to make it disply the direction the player must head in inorder to find the target?
Well you would "have" to use the coordinates of the target mob and compare them to the players coordinates...

You would "have" to do something similar to this.

if(target.x > src.x)
if(target.y > src.y)
target_direction="Northeast"
else if(target.y < src.y)
target_direction="Southeast"
else
target_direction="East"
else if(target.x < src.x)
if(target.y > src.y)
target_direction="Northwest"
else if(target.y < src.y)
target_direction="Southwest"
else
target_direction="West"
else if(target.x == src.x)
if(target.y > src.y)
target_direction="North"
else if(target.y < src.y)
target_direction="South"
else
target_direction="Where you are!"


Thats not perfect, considering you may want to make a range for the Cardinal directions. Maybe you wanted to make North be 2 blocks to the right and left of you and up, you would have to change it around.

-KirbyAllStar
In response to KirbyAllStar
Or, ya know, just use get_dir().
In response to Popisfizzy
lol that works too, I'll have to look into it and see if it says Northeast even if its only one block to the right.