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.

Random Event Detector

Featured Replies

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.

52 minutes ago, 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.


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 by Explv

  • Author

@Patrick are you able to help a little more? How does OSBot know if you have a random event?

28 minutes ago, Iwin said:

@Patrick are you able to help a little more? How does OSBot know if you have a random event?


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

 

@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 by Explv

  • Author
1 hour ago, 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:

 

 

  Hide 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);
    }
}

 



 

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.

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.