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^2 + dy^2) ^ .5;
mx = (dx / len) * 1.5;
my = (dy / len) * 1.5;
steps = 6;
target = gettarget();
for (a = 1; a <= 6; a++) {
temp.tdx = target.x - (x + mx * a);
temp.tdy = target.y - (y + my * a);
temp.tlen = (temp.tdx^2 + temp.tdy^2) ^ .5;
if (onwall2(x + .5 + mx * a, y + 1 + my * a, 2, 2) || temp.tlen < 2) {
steps = a-1;
break;
}
}
setcharani("walk",NULL);
dir = getdir(mx,my);
if (steps <= 0) return;
if (steps == 6) move(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];
}