Oh. I've already created my own working function which is getting the NPC dir:
PHP Code:
//Move one space closer to newx,newy
function MoveTo( newx,newy ) {
temp.angle = getangle((newx - this.x),(newy - this.y));
this.xvel = cos(temp.angle);
this.yvel = sin(temp.angle);
this.x += this.xvel;
this.y -= this.yvel;
this.dir = getDirec( this.xvel , this.yvel );
this.chat = "My dir is " @ this.dir;
}
function getDirec( vx , vy ) {
if ( vy > 0 && abs( vy ) > abs( vx ) ) temp.d = 0;
elseif ( vx < 0 && abs( vx ) > abs( vy ) ) temp.d = 1;
elseif ( vy < 0 && abs( vy ) > abs( vx ) ) temp.d = 2;
elseif ( vx > 0 && abs( vx ) > abs( vy ) ) temp.d = 3;
return temp.d;
}
I know know if it makes a difference whether I use .getdir() or my own function. I've tested mine though and it works perfectly well.