Thread: Question
View Single Post
  #7  
Old 04-25-2011, 08:15 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Use PHP tags for code.

PHP Code:
function getTarget() {
  
temp.bestTarget null;
  
temp.bestValue 0;

  for (
temp.plfindnearestplayers(this.xthis.y)) {
    
temp.pIds temp.pl.account;
  }
  
//temp.pIds = getnearestplayers(this.x, this.y, player.hp > 0);

  
for (temp.pIdpIds) {
    
temp.pl players[pId];

    
temp.dx pl.this.x;
    
temp.dy pl.this.y;
    
//temp.distance = abs(dx) + abs(dy); // manhattan distance
    
temp.distance = (dx dx dy dy) ^ 0.5// Euclidean distance
    //pl.chat = distance @ " " @ dx @ " " @ dy;
    // Ensure the following are true: 
    // within maximum distance, in front of us, and not behind a wall

    
if (distance this.maxdist) {
      continue;
    } 
findAreaPlayers returns an array of players, therefore you want to do this in order to loop through them:

PHP Code:
function getTarget() {
  
temp.bestTarget null;
  
temp.bestValue 0;

  for (
temp.plfindnearestplayers(this.xthis.y)) {
    
temp.dx pl.this.x;
    
temp.dy pl.this.y;
    
    
//temp.distance = abs(dx) + abs(dy); // manhattan distance
    
temp.distance = (dx dx dy dy) ^ 0.5// Euclidean distance
    //pl.chat = distance @ " " @ dx @ " " @ dy;
    // Ensure the following are true: 
    // within maximum distance, in front of us, and not behind a wall

    
if (distance this.maxdist) {
      continue;
    } 
Not sure if you're using this in a player class or a monster or so, but if it's not working make sure you meant to use this.x and this.y.
__________________
Reply With Quote