Quote:
Originally posted by Value
Here is the script for my bow, control-npc and class. Help me find the problem!!!!!
|
NPC Code:
//Script From Class hpfunctions
function attackplayers() {
pid = playerid;
pindexes = getnearestplayers(this.attackx,this.attacky,player id!=pid);
dist = 0;
for (i=0; i<arraylen(pindexes); i++) {
with (players[pindexes[i]]) {
dx = playerx + 1.5 - this.attackx;
dy = playery + 2 - this.attacky;
dist = (dx*dx + dy*dy)^0.5;
if (dist<=2)
hurtplayer();
}
if (dist>2)
break;
}
}
function hurtplayer() {
newhp = playerhearts - this.attackpower;
if (newhp<=0) {
newhp = 3;
setani dead,;
} else {
setani hurt,;
}
playerhearts=#v(newhp);
}
//END
playerhearts = #v(newhp); is wrong, no #v() is needed.