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

Best way to select an NPC?

Featured Replies

Currently I'm doing something like this for every single (unique) NPC in the script I'm making, since I don't want to identify them using their id's in case Jagex change them:

NPC npcOne = npcs.closest(npc -> npc.getName().equals(NAME) && area.contains(elemental));

I'm making a sorceress's garden script, so I need to make one of these for every single elemental and need to store their areas too, as I'm writing this I just notice that their areas can overlap too, so there is a chance I get the wrong elemental in that case. Should I just identify them by their id's and update them if Jagex ever change the ids? Do Jagex change the id's?

Even if their IDs were to change (which I somewhat doubt they will, but who knows), their IDs relative to eachother will probably remain the same, since they seem to count from X to X+1, X+2, X+3 in order of their progression.

There are many ways you could do it, but I'd probably try with their relative ID offset. Something like this:

private final static int IDOFFSET_SUMMER_SECTION1 = 0;
private final static int IDOFFSET_SUMMER_SECTION2 = 1;
private final static int IDOFFSET_SUMMER_SECTION3 = 2;

int baseId = getNpcs().filter(npc -> npc.getName().equals(NAME)).stream().min(Comparator.comparing(NPC::getId)).getId();
NPC npcSection1 = getNpcs().singleFilter(npc -> npc.getId() == (baseId + IDOFFSET_SUMMER_SECTION1));

Ofc. you will only need to find the base ID once, and should add various checks; this is only a pseudo example

  • Author
18 minutes ago, FrostBug said:

Even if their IDs were to change (which I somewhat doubt they will, but who knows), their IDs relative to eachother will probably remain the same, since they seem to count from X to X+1, X+2, X+3 in order of their progression. 

There are many ways you could do it, but I'd probably try with their relative ID offset. Something like this: 


private final static int IDOFFSET_SUMMER_SECTION1 = 0;
private final static int IDOFFSET_SUMMER_SECTION2 = 1;
private final static int IDOFFSET_SUMMER_SECTION3 = 2;

int baseId = getNpcs().filter(npc -> npc.getName().equals(NAME)).stream().min(Comparator.comparing(NPC::getId)).getId();
NPC npcSection1 = getNpcs().singleFilter(npc -> npc.getId() == (baseId + IDOFFSET_SUMMER_SECTION1));

Ofc. you will only need to find the base ID once, and should add various checks; this is only a pseudo example 

That's a good observation and it makes sense, thanks a lot! I was under the impression that the id's were something that gets changed frequently, seems like that's not the case then.

Haven't seen a NPC ID change in my 3 years of being on osbot with over 300 scripts written. Take that as you will. Widgets change a little more frequently and stuff of tut island every once in a while but outside of that things rarely change. And if they do, it takes two seconds to get the new ID

Edited by Juggles

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.