Advertisement
Guest User

Untitled

a guest
May 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.53 KB | None | 0 0
  1. long GetNearestPlayerNumberToCoords(word playerNum, float x, float y){
  2.     float aDistance = 2500000000;
  3.     float aTemp = 0;
  4.    
  5.     long lLowest = 0;
  6.     __try {
  7.  
  8.         for(unsigned int i = 1;i < maxAgent;i++){
  9.             if(Agents[i] == NULL){continue;}
  10.             if(Agents[i]->PlayerNumber != playerNum){continue;}
  11.             if(Agents[i]->HP == 0){continue;}
  12.  
  13.             aTemp = (pow((Agents[i]->Y - y), 2) + pow((Agents[i]->X - x), 2));
  14.             if(aDistance > aTemp){
  15.                 lLowest = i;
  16.                 aDistance = aTemp;
  17.             }
  18.         }
  19.     }
  20.     __except(1) {
  21.         return false;
  22.     }
  23.     return lLowest;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement