Here's how Zodiac's baddy movement works. It doesn't move directly to the player in one step but instead takes it in strides of 0.5 seconds of movement at max.
PHP Code:
// Removed Zodiac Specific Code
function onPlayerEnters() {
if (!this.on) {
this.on = true;
onTimeout();
}
}
function onTimeout() {
if (players.size() < 1) {
this.on = false;
return;
}
chase(players[0]);
}
function chase(target) {
// Set Speed
temp.speed = .3;
// Calculate Position in front of Target
temp.tpos = {target.x - vecx(this.dir)*2.5, target.y - vecy(this.dir)*2.5};
// Calculate Distance to Target
temp.dist = ((temp.tpos[0] - x)^2 + (temp.tpos[1] - y)^2)^.5;
// Calculate Steps Required
temp.steps = temp.dist / temp.speed;
// Avoid Too Many Steps
if (temp.steps > 10)
temp.steps = 10;
// Calculate Angle towards Target
// Random helps prevent clumping of npcs
temp.angle = getangle(temp.tpos[0] - x, temp.tpos[1] - y) + random(-0.2,0.2);
// Calculate the Delta
temp.dx = cos(temp.angle) * temp.speed;
temp.dy = -sin(temp.angle) * temp.speed;
setcharani("walk", this.attr[2]);
move(temp.dx * temp.steps, temp.dy * temp.steps, int(temp.steps) * .05, 8);
setTimer(int(temp.steps) * .05);
}
function onMovementFinished() {
setcharani("idle", "");
}
Sure it still allows baddies to walk over walls but it's an even bigger issue when players can glitch them into corners and abuse the situation.