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...
  On 11/15/2015 at 2:57 PM, Bobrocket said:
getNpcs().closest(NPC NAME, (n) -> (!n.isUnderAttack()));

 

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)

Link to comment
Share on other sites

  On 11/27/2015 at 12:53 AM, Codex said:

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

  On 11/27/2015 at 1:15 AM, Codex said:

Oh right.. I'm sure I have Java 8.

 

cheers anyway!

you need java 8 to run the apps and jdk 1.8 to be able to code with java 8. Once you have both installed you just change the setting your ide.

 

im on the phone so i can show you right now

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...