Jump to content

Guranteed Dismissal of Random Events


swiffyp

Recommended Posts

Lately I've noticed that some random events aren't properly dismissed by the bot client. So I added this simple snippet into my script to ensure that they are.

 

onLoop:

if(dismissRandom()) {

                sleep(random(600, 800));

                while(myPlayer().isMoving()) {

                    sleep(600);

                }

                sleep(400);

            }

boolean:

    private boolean dismissRandom() {

        for(NPC npc : npcs.getAll()) {

            

            if(npc == null || npc.getInteracting() == null

                || npc.getInteracting() != myPlayer()) {

                continue;

            }

            

            if(npc.hasAction("Dismiss")) {

                npc.interact("Dismiss");

                return true;

            }

            

        }

        return false;

    }

This basically checks if there are any npcs with the "dismiss" option interacting with you and if so, they'll be dismissed.

Edited by swiffyp
Link to comment
Share on other sites

Highly doubt that it's okay to not dismiss/attend random events.

I'm pretty sure the built in solver does the same thing as your code, have you tested this with the same random events that the built in solver doesn't work for? Did you file a bug report detailing the case where it didn't work so that the devs can fix it?

Link to comment
Share on other sites

I'm pretty sure the built in solver does the same thing as your code, have you tested this with the same random events that the built in solver doesn't work for? Did you file a bug report detailing the case where it didn't work so that the devs can fix it?

 

The built-in solver is not always triggered. It happens to me very often, which is why I decided to write this quickly.

I haven't filed a bug report but I will do that.

 

Now if you don't like this, don't use it. It's that simple. smile.png

Edited by swiffyp
Link to comment
Share on other sites

this is a really handy snippet. but i would add a tiny piece of logic to prevent the very awkward snap run to dismiss issue. where your bot is say running to the bank. the random spawns 50 feet back and your bot clicks "dismiss" and sprint turns and runs back to the now far away random NPC to dismiss them. its always been a behavior that bothered me. Unless you have a long run back to the bank this change should be of little consequence.

if(npc == null || npc.getInteracting() == null || npc.getInteracting() != myPlayer() && !api.myPlayer.isMoving())
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...