Thread: gani help
View Single Post
  #4  
Old 06-21-2002, 04:02 AM
haunter haunter is offline
Registered User
haunter's Avatar
Join Date: Mar 2001
Posts: 7,989
haunter is on a distinguished road
Quote:
Originally posted by Falcor
Why use a whole sin-cos forumla? Distance formula would work too, and require far less effort.

just check all the players around you to see if they are in your area, and hit them if they are there. Rather then sending unneccessary actions to the server

NPC Code:

for(i=0;i<playerscount;i++) {
dist = ((players[i].x+1-playerx+1)^2+(players[i].y+1-playery+1)^2)^.5;
if(dist < 5) {
hitobjects power,players[i].x+1,players[i].y+1;
}
}


as long as there arent 100 players on the same level, you should have a problem with lag, and it would be far less error ridden than using something in a circle.

If you would like to only hit players in a certain area away from you, you could also try

if(dist in |3,5|) or so. People close to you wouldnt get hit, however people farther away would.

the blue text you must edit
What is "dist" mesured in?