Thread: getDir()
View Single Post
  #12  
Old 08-01-2008, 10:55 PM
The_Kez The_Kez is offline
N-Pulse Asst. Manager
The_Kez's Avatar
Join Date: Dec 2007
Posts: 106
The_Kez is on a distinguished road
Send a message via MSN to The_Kez
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 MoveTonewx,newy ) {
  
temp.angle getangle((newx this.x),(newy this.y));
  
this.xvel cos(temp.angle);
  
this.yvel sin(temp.angle);
  
this.+= this.xvel;
  
this.-= this.yvel;
  
this.dir getDirecthis.xvel this.yvel );
  
this.chat "My dir is " this.dir;
}

function 
getDirecvx vy ) {
if ( 
vy && absvy ) > absvx ) ) temp.0;
elseif ( 
vx && absvx ) > absvy ) ) temp.1;
elseif ( 
vy && absvy ) > absvx ) ) temp.2;
elseif ( 
vx && absvx ) > absvy ) ) temp.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.
Reply With Quote