Use PHP tags for code.
PHP Code:
function getTarget() {
temp.bestTarget = null;
temp.bestValue = 0;
for (temp.pl: findnearestplayers(this.x, this.y)) {
temp.pIds = temp.pl.account;
}
//temp.pIds = getnearestplayers(this.x, this.y, player.hp > 0);
for (temp.pId: pIds) {
temp.pl = players[pId];
temp.dx = pl.x - this.x;
temp.dy = pl.y - this.y;
//temp.distance = abs(dx) + abs(dy); // manhattan distance
temp.distance = (dx * dx + dy * dy) ^ 0.5; // Euclidean distance
//pl.chat = distance @ " " @ dx @ " " @ dy;
// Ensure the following are true:
// within maximum distance, in front of us, and not behind a wall
if (distance > this.maxdist) {
continue;
}
findAreaPlayers returns an array of players, therefore you want to do this in order to loop through them:
PHP Code:
function getTarget() {
temp.bestTarget = null;
temp.bestValue = 0;
for (temp.pl: findnearestplayers(this.x, this.y)) {
temp.dx = pl.x - this.x;
temp.dy = pl.y - this.y;
//temp.distance = abs(dx) + abs(dy); // manhattan distance
temp.distance = (dx * dx + dy * dy) ^ 0.5; // Euclidean distance
//pl.chat = distance @ " " @ dx @ " " @ dy;
// Ensure the following are true:
// within maximum distance, in front of us, and not behind a wall
if (distance > this.maxdist) {
continue;
}
Not sure if you're using this in a player class or a monster or so, but if it's not working make sure you meant to use
this.x and
this.y.