ScummyBotter Posted October 2, 2018 Share Posted October 2, 2018 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? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted October 2, 2018 Share Posted October 2, 2018 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 2 Quote Link to comment Share on other sites More sharing options...
ScummyBotter Posted October 2, 2018 Author Share Posted October 2, 2018 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. Quote Link to comment Share on other sites More sharing options...
Juggles Posted October 2, 2018 Share Posted October 2, 2018 (edited) 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 October 2, 2018 by Juggles 1 Quote Link to comment Share on other sites More sharing options...