Jump to content

Random Event Detector


Iwin

Recommended Posts

  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 by Explv
  • Like 3
Link to comment
Share on other sites

  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



 

Edited by Explv
  • Like 1
Link to comment
Share on other sites

  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



 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...