Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

As title says, this is because the closest npc is already in combat, so i'd like the bot to find the second closest npc to attack.

Rather than sit there until a new close npc spawns xD

 

- Thank you for your time

There's better way. Don't use closest at all.

Filter through all the npcs and find ones that are not in combat.

use npcs.getAll()

 

for example :

For(NPC n : npcs.getAll()) {

if (!n.isincombat... etc

}

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.

  • 2 weeks later...
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)

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

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

 

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

 

cheers anyway!

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

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.