Iwin Posted January 25, 2019 Share Posted January 25, 2019 I was wondering if anyone had a snippet of a random event solver/dismisser, I searched the forums and googled it, with no success. I know OSBot has a built in dismisser, but I want to solve the no-brainer ones such as Rick and Genie. I just need a snippet to check if a random event is mine. Quote Link to comment Share on other sites More sharing options...
Explv Posted January 25, 2019 Share Posted January 25, 2019 (edited) On 1/25/2019 at 9:14 PM, Iwin said: I was wondering if anyone had a snippet of a random event solver/dismisser, I searched the forums and googled it, with no success. I know OSBot has a built in dismisser, but I want to solve the no-brainer ones such as Rick and Genie. I just need a snippet to check if a random event is mine. Expand I think you can check that the NPC is interacting with you, and that it has mentioned your player's name in the last x seconds, and has a certain action, like Dismiss. Maybe something like this (note completely untested): Optional<NPC> randomNPCOpt = getNpcs().getAll().stream().filter(npc -> npc.getActions() != null && Arrays.asList(npc.getActions()).contains("Dismiss") && // NOT SURE WHAT THE ACTION IS HERE npc.isInteracting(myPlayer()) && npc.hasMentionedPhrase(myPlayer().getName(), 30000) && // check the NPC is saying our name npc.getModel() != null ).findAny(); if (randomNPCOpt.isPresent()) { NPC randomNPC = randomNPCOpt.get(); switch (randomNPC.getName()) { case "Genie": handleGenie(); break; default: randomNPC.interact("Dismiss"); // NOT SURE WHAT THE ACTION IS HERE break; } } Edited January 25, 2019 by Explv 3 Quote Link to comment Share on other sites More sharing options...
Iwin Posted January 25, 2019 Author Share Posted January 25, 2019 @Patrick are you able to help a little more? How does OSBot know if you have a random event? Quote Link to comment Share on other sites More sharing options...
Explv Posted January 25, 2019 Share Posted January 25, 2019 (edited) On 1/25/2019 at 10:59 PM, Iwin said: @Patrick are you able to help a little more? How does OSBot know if you have a random event? Expand .......using the exact method I just showed you. There is a class called DismissRandom which is an extension of RandomSolver. The RandomExecutor runs it every few seconds, and each time it runs it checks if an NPC exists with the criteria I just showed you. If the NPC exists, it dismisses it. Here's the decompiled class if for some strange reason you still don't believe me: Reveal hidden contents @ScriptManifest( name = "Dismiss Random", author = "OSBot", version = 1.2D, info = "Dismisses random events", logo = "" ) public class DismissRandom extends RandomSolver { private NPC IiIiIiiiiIiI = null; private NPC iIIiIiiiiiii() { Optional var1; return (var1 = IiIiIiiiiIiI.getNpcs().getAll().stream().filter((IiIiIiiiiIiIx) -> { String[] var2; return (var2 = IiIiIiiiiIiIx.getActions()) != null && Arrays.asList(var2).contains(Utilities.iIIiIiiiiiii("\u0005N2J(T2")) && (IiIiIiiiiIiIx.hasMentionedPhrase(IiIiIiiiiIiI.myPlayer().getName(), 30000L) || IiIiIiiiiIiIx.isInteracting(IiIiIiiiiIiI.myPlayer()) && IiIiIiiiiIiIx.getModel() != null); }).findFirst()).isPresent() ? (NPC)var1.get() : null; } public int onLoop() throws InterruptedException { if (!IiIiIiiiiIiI.getWidgets().closeOpenInterface()) { return 2000; } else { if (IiIiIiiiiIiI.IiIiIiiiiIiI != null && IiIiIiiiiIiI.IiIiIiiiiIiI.exists()) { boolean var10001 = IiIiIiiiiIiI.inventory.deselectItem(); IiIiIiiiiIiI.magic.deselectSpell(); if (var10001.IiIiIiiiiIiI.interact(new String[]{LPT6.iIIiIiiiiiii("#\u0010\u0014\u0014\u000e\n\u0014")})) { (new ConditionalSleep(7000, 500) { public boolean condition() throws InterruptedException { return IiIiIiiiiIiI.getMap().getDestination() == null; } }).sleep(); } } return 2000; } } public boolean shouldActivate() { NPC var1; if (IiIiIiiiiIiI.client.isLoggedIn() && (var1 = IiIiIiiiiIiI.iIIiIiiiiiii()) != null && IiIiIiiiiIiI.getMap().canReach(var1)) { IiIiIiiiiIiI.IiIiIiiiiIiI = var1; return true; } else { return false; } } public void onExit() { IiIiIiiiiIiI.logger.info((new StringBuilder()).insert(0, LPT6.iIIiIiiiiiii("*\b\u0015\u0011\u001c\u0003YG")).append(IiIiIiiiiIiI.IiIiIiiiiIiI.getName()).append(Utilities.iIIiIiiiiiii("\u0007%N2J(T2F-\u00073F/C.Jo")).toString()); } public DismissRandom() { super(RandomEvent.DISMISS_RANDOM); } } Edited January 25, 2019 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Iwin Posted January 26, 2019 Author Share Posted January 26, 2019 On 1/25/2019 at 11:26 PM, Explv said: .......using the exact method I just showed you. There is a class called DismissRandom which is an extension of RandomSolver. The RandomExecutor runs it every few seconds, and each time it runs it checks if an NPC exists with the criteria I just showed you. If the NPC exists, it dismisses it. Here's the decompiled class if for some strange reason you still don't believe me: Reveal hidden contents @ScriptManifest( name = "Dismiss Random", author = "OSBot", version = 1.2D, info = "Dismisses random events", logo = "" ) public class DismissRandom extends RandomSolver { private NPC IiIiIiiiiIiI = null; private NPC iIIiIiiiiiii() { Optional var1; return (var1 = IiIiIiiiiIiI.getNpcs().getAll().stream().filter((IiIiIiiiiIiIx) -> { String[] var2; return (var2 = IiIiIiiiiIiIx.getActions()) != null && Arrays.asList(var2).contains(Utilities.iIIiIiiiiiii("\u0005N2J(T2")) && (IiIiIiiiiIiIx.hasMentionedPhrase(IiIiIiiiiIiI.myPlayer().getName(), 30000L) || IiIiIiiiiIiIx.isInteracting(IiIiIiiiiIiI.myPlayer()) && IiIiIiiiiIiIx.getModel() != null); }).findFirst()).isPresent() ? (NPC)var1.get() : null; } public int onLoop() throws InterruptedException { if (!IiIiIiiiiIiI.getWidgets().closeOpenInterface()) { return 2000; } else { if (IiIiIiiiiIiI.IiIiIiiiiIiI != null && IiIiIiiiiIiI.IiIiIiiiiIiI.exists()) { boolean var10001 = IiIiIiiiiIiI.inventory.deselectItem(); IiIiIiiiiIiI.magic.deselectSpell(); if (var10001.IiIiIiiiiIiI.interact(new String[]{LPT6.iIIiIiiiiiii("#\u0010\u0014\u0014\u000e\n\u0014")})) { (new ConditionalSleep(7000, 500) { public boolean condition() throws InterruptedException { return IiIiIiiiiIiI.getMap().getDestination() == null; } }).sleep(); } } return 2000; } } public boolean shouldActivate() { NPC var1; if (IiIiIiiiiIiI.client.isLoggedIn() && (var1 = IiIiIiiiiIiI.iIIiIiiiiiii()) != null && IiIiIiiiiIiI.getMap().canReach(var1)) { IiIiIiiiiIiI.IiIiIiiiiIiI = var1; return true; } else { return false; } } public void onExit() { IiIiIiiiiIiI.logger.info((new StringBuilder()).insert(0, LPT6.iIIiIiiiiiii("*\b\u0015\u0011\u001c\u0003YG")).append(IiIiIiiiiIiI.IiIiIiiiiIiI.getName()).append(Utilities.iIIiIiiiiiii("\u0007%N2J(T2F-\u00073F/C.Jo")).toString()); } public DismissRandom() { super(RandomEvent.DISMISS_RANDOM); } } Expand Oooh, thank you. It wasn't that I didn't believe you, I just figured maybe there was some config I wasn't aware of or some other flag. This helps a ton. Quote Link to comment Share on other sites More sharing options...