View Single Post
  #6  
Old 05-07-2004, 01:49 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
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 /
Reply With Quote