
05-07-2004, 01:49 PM
|
Graalian since 1998
|
 |
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
|
|
If you read Stefan's hp document, it explains that:
Quote:
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 = strtofloat(#s(clientr.hp)) - this.attackpower;
if (newhp<=0) {
newhp = 3;
setani dead,;
} else {
setani hurt,;
}
setstring clientr.hp,#v(newhp);
}
The script uses the function getnearestplayers(x,y,condition)
to find the near players. The function gives an array
of player indexes, starting with the index of the nearest player.
By using the script command 'with' you can then manipulate
those players directly. Instead of changing the hitpoints of
the attacker, you will so change the variables of the
victim. The function hurtplayer() is setting an animation
and updating the string variable 'clientr.hp'.
|
|
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
|
|
|