Jump to content

getArea of npc?


Recommended Posts

Posted

I don't know if I'm supposed to use a AreaFilter or a NPC Filter for finding which area a npc is contained.

 

the current filter I'm using for selecting npc's.

NPC warrior = getNpcs().closest(new Filter<NPC>() { //Find an NPC matching our filter!
	            public boolean match(NPC npc) {

	                return npc.exists() && npc.getName().equals("Al-Kharid warrior") && npc.getHealthPercent() > 0 && npc.isAttackable(); 
	            }
	        });

Also if AreaFilters are the goto, someone might need to spoon feed the concept to me.

 

I'm dividing the npc's spawns into 3 areas and want to see if NPC's are in the same area as me.

 

All help is greatly appreciated :)

Posted (edited)

return npc.exists() && npc.getName().equals("Al-Kharid warrior") && npc.getHealthPercent() > 0 && npc.isAttackable();

 

add in && area.contains(npc) to this boolean statement

 

 

edit: just realized i might have misinterpreted your question. are you looking for an npc contained within a specific area, or the area that contains a specific npc?

Edited by Imateamcape
Posted (edited)

I don't know if I'm supposed to use a AreaFilter or a NPC Filter for finding which area a npc is contained.

 

the current filter I'm using for selecting npc's.

NPC warrior = getNpcs().closest(new Filter<NPC>() { //Find an NPC matching our filter!
	            public boolean match(NPC npc) {

	                return npc.exists() && npc.getName().equals("Al-Kharid warrior") && npc.getHealthPercent() > 0 && npc.isAttackable(); 
	            }
	        });

Also if AreaFilters are the goto, someone might need to spoon feed the concept to me.

 

I'm dividing the npc's spawns into 3 areas and want to see if NPC's are in the same area as me.

 

All help is greatly appreciated smile.png

 

 

You can use an AreaFilter:

NPC warrior = getNpcs().closest(new NameFilter<>("Al-Kharid warrior"), new AreaFilter<>(area), Character::isAttackable);
Edited by Explv
Posted
return npc.exists() && npc.getName().equals("Al-Kharid warrior") && npc.getHealthPercent() > 0 && npc.isAttackable() && EastPalaceRm.contains(npc) && EastPalaceRm.contains(myPlayer());

I have 3 areas I wan't to be able to count players, npcs, and WebWalk to new area's when one is too full.

 

I'm wondering if I can filter my 3 area's into a single statement?  if not I could copy pasta a bunch and have npc1 npc2 npc3?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...