Jump to content

getArea of npc?


Cmontryme

Recommended Posts

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 :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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