Jump to content

Guranteed Dismissal of Random Events


Recommended Posts

Posted (edited)

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
Posted

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?

Posted (edited)

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
Posted

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())

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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