Thread: Npc to Npc
View Single Post
  #3  
Old 02-03-2011, 03:52 AM
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
You can use getareanpcs(float, float, float, float) and loop through and find the NPC by a unique id or joined class even.

Baddies find other baddies, I.e:

PHP Code:
// Loop through NPCs in a 64x64 square around the npc.
for (temp.ngetareanpcs(this.32this.326464)) {
  
// Check if NPC is part of the Baddy class
  
if (temp.n.joinedclasses.index("baddy") >= 0) {
    
// Add NPC to Baddies Array for Further Processing
    
temp.baddies.add(temp.n);
  }
}
for (
temp.baddytemp.baddies) {
  echo(
"Baddy Found: " temp.baddy.nick);

When you have the NPC object, you can simply send triggers or call public functions. I.e:

PHP Code:
// Loop through NPCs in a 64x64 square around the npc.
for (temp.ngetareanpcs(this.32this.326464)) {
  
temp.n.trigger("Found""");

then in the other NPCs:

PHP Code:
function onFound() {
  echo(
"Found: " this.nick);

__________________
Quote:
Reply With Quote