Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-24-2011, 11:04 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Question

temp.pIds = getnearestplayers(this.x, this.y, player.hp > 0);

does getnearestplayers grab a players community name as well. Because it seems like every time a Graal##### account enters the level they stop working, like there confused?
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
  #2  
Old 04-24-2011, 11:15 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Use findnearestplayers instead.

PHP Code:
// Loops through list of players by distance (closest first)
for (temp.plfindnearestplayers(this.xthis.y)) {
  echo(
temp.pl.account);

__________________
Quote:
Reply With Quote
  #3  
Old 04-24-2011, 11:36 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
ahh thank you it worked.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
  #4  
Old 04-25-2011, 12:11 AM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Well I thought it worked lol. It works better then before, now it grabs the player that's the furthest from the NPC.

Snapshots are attached
Attached Thumbnails
Click image for larger version

Name:	delteria1.png
Views:	174
Size:	106.3 KB
ID:	52737   Click image for larger version

Name:	delteria2.png
Views:	160
Size:	61.6 KB
ID:	52738  
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]




Last edited by MysticalDragon; 04-25-2011 at 12:33 AM.. Reason: Added Snapshots
Reply With Quote
  #5  
Old 04-25-2011, 02:04 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
Quote:
Originally Posted by MysticalDragon View Post
Well I thought it worked lol. It works better then before, now it grabs the player that's the furthest from the NPC.

Snapshots are attached
Post your code.
__________________
Reply With Quote
  #6  
Old 04-25-2011, 07:41 AM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Quote:
function getTarget() {
temp.bestTarget = null;
temp.bestValue = 0;

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

for (temp.pId: pIds) {
temp.pl = players[pId];

temp.dx = pl.x - this.x;
temp.dy = pl.y - 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;
}
Here is the part of the code im having issues with.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
  #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
  #8  
Old 04-25-2011, 08:39 AM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Thank you so much Jerret and Chris it works like a charm.
REP + REP but unfortunately I can only do 1 every 24 hours.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:53 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.