Thread: baddie tutorial
View Single Post
  #5  
Old 04-09-2006, 05:12 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by Googi
...
That's great if you're trying to crash your NPC Server.

EDIT: I should probably help. This is the function I use for chasing, assuming you understand how to implement it. It's called on a .5 second timer, the gettarget() function isn't the one I use, because I'm using a more complex aggression system to pick a target. I changed it to target the nearest player, here.

PHP Code:
function Chase(dx,dy) {
  
dx limit(dx,-6,6);
  
dy limit(dy,-6,6);
  
len = (dx^dy^2) ^ .5;
  
mx = (dx len) * 1.5;
  
my = (dy len) * 1.5;
  
steps 6;
  
target gettarget();
  for (
1<= 6a++) {
    
temp.tdx target.- (mx a);
    
temp.tdy target.- (my a);
    
temp.tlen = (temp.tdx^temp.tdy^2) ^ .5;
    if (
onwall2(.5 mx amy a22) || temp.tlen 2) {
      
steps a-1;
      break;
    }
  }
  
setcharani("walk",NULL);
  
dir getdir(mx,my);
  if (
steps <= 0) return;
  if (
steps == 6move(mx*6,my*6,.6,0);
  else 
move(mx*steps,my*steps,((steps-1)/10)+.1,0+8);
}

function 
gettarget() {
  return 
findnearestplayers(x,y)[0];

Reply With Quote