Jump to content

getNPCS().closest, i want to find the second closest npc cause closest is in combat


MGT Madness

Recommended Posts

Without using OSBot filters/DIY: You can do this by grabbing all the NPCs and then sorting the collection with a Comparator. Once you have this sorted collection you can iterate through them to check for everything else such as already in combat, health, etc. Of course you can do this in reverse and filter NPCs that aren't in combat, have high health, etc. and then go on to sort the collection.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

For some reason im getting an error in eclipse im not sure if im using it correctly.

NPC npc;npc = script.getNpcs().closest(target,(n) -> (!n.isUnderAttack()));
(script is being passed into the constructor and save in a private variable)
Your fine then. Booby rocket wrote it like that assuming the class extended script. But if you are using a private field it's ok.

The error is probably because your project isn't compile under java 8

Edited by Joseph
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...