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.

Making a custom interaction event break condition

Featured Replies

Hello,

Currently I'm trying to make a InteractionEvent break condition and so far it works 50% of the time, the other 50% of the time it fights itself with some kind of event queue?

import org.osbot.rs07.event.Event;

import java.util.function.BooleanSupplier;

class InteractionBreaker {
    private InteractionBreaker() {

    }

    static Event setBreakCondition(Event event, BooleanSupplier breakCondition) {
        return new Event() {
            @Override
            public void onStart() {
                try {
                    super.onStart();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                event.setAsync();
                execute(event);
            }

            @Override
            public int execute() throws InterruptedException {
                boolean failed = breakCondition.getAsBoolean();
                log("InterationBreaker status: " + event.getStatus());//debug never prints this
                if (failed) {
                    log("InterationBreaker failed? " + event.getStatus());//never shows up in debug
                    event.setFailed();
                    setFailed();
                }
                return 100;
            }

            @Override
            public boolean isWorking() {
                log("InteractionBreaker is working");//debug never prints this
                return event.isWorking();
            }

            @Override
            public boolean isQueued() {
                log("InteractionBreaker is queued!");//debug never prints this
                return event.isQueued();
            }

            @Override
            public boolean hasFailed() {
                log("InteractionBreaker hasFailed? " + event.getStatus());//debug never prints this
                boolean failed = breakCondition.getAsBoolean();
                if (failed) {
                    event.setFailed();
                    setFailed();
                }
                return failed || event.hasFailed();
            }

            @Override
            public boolean hasFinished() {
                log("InteractionBreaker hasFinished? " + event.getStatus()); //prints QUEUED for the event status everytime
                event.setFinished();
                setFinished();
                return event.hasFinished();
            }
        };
    }
}

And to use it you would do:

InteractionEvent escape = new InteractionEvent(path);
execute(InteractionBreaker.setBreakCondition(escape.setAction(), () -> escapedAbyss.contains(myPlayer())));

When I'm inside the abyss I spam click the object with a 1 second delay. This usually works unless it's the mine object then it sometimes fights itself when it DOES escape. If I get through the object the script will continue on to the next task, but sometimes it fights itself by running back and fourth between going to the next task and trying to reach an object to interact with. I suspect something is stuck in the queue and I don't know how to proceed.

 

8 hours ago, Hayase said:

Hello,

Currently I'm trying to make a InteractionEvent break condition and so far it works 50% of the time, the other 50% of the time it fights itself with some kind of event queue?

And to use it you would do:


InteractionEvent escape = new InteractionEvent(path);
execute(InteractionBreaker.setBreakCondition(escape.setAction(), () -> escapedAbyss.contains(myPlayer())));

When I'm inside the abyss I spam click the object with a 1 second delay. This usually works unless it's the mine object then it sometimes fights itself when it DOES escape. If I get through the object the script will continue on to the next task, but sometimes it fights itself by running back and fourth between going to the next task and trying to reach an object to interact with. I suspect something is stuck in the queue and I don't know how to proceed.


I'm confused as to why you need a break condition. Could you try to explain it more clearly?

What is the InteractionEvent(path) for?

What exactly is your use case here, what are you trying to achieve? There is a probably a simpler way to achieve it

Edited by Explv

  • Author
7 hours ago, Explv said:

 


I'm confused as to why you need a break condition. Could you try to explain it more clearly?

What is the InteractionEvent(path) for?

What exactly is your use case here, what are you trying to achieve? There is a probably a simpler way to achieve it

Escaping the abyss.

It's because when you are inside the abyss, you want to spam objects if you are in combat so that you don't die. I'm basically trying to click objects to escape and when I escape I want the interaction to end. However with normal interactions it gets "stuck" on reaching an interaction it cannot reach. So interaction events comes in and it works. However I still get "hung up" on interacting because it still wants to go back to interact with some shit it can't reach. It's not like I'm spamming the objects at 1ms ticks I'm just clicking them if I'm in combat at a 1 second delay. It's nothing hardcore.

When I finish Mining through for example, sometimes the script will still be stuck in the interaction and will not want to proceed to the next step of getting inside a rift to craft runes. So normal interactions don't work, I've tried them.

 

if (path != null) {
	status = "Escaping via " + path.getName();
	InteractionEvent escape = new InteractionEvent(path);
	execute(InteractionBreaker.setBreakCondition(escape.setAction(), () -> escapedAbyss.contains(myPlayer())));
	log("Clicked: " + path.getName() + " action(s): " + Arrays.toString(path.getActions()) + " canReach: " + getMap().canReach(path));
	log("Started sleeping");
	if (myPlayer().isUnderAttack() || escapedAbyss.contains(myPlayer()))
		afk(720, 1080);
	new ConditionalSleep(5000) {
		@Override
		public boolean condition() throws InterruptedException {
			return myPlayer().isUnderAttack() || escapedAbyss.contains(myPlayer());
		}
	}.sleep();
	log("Stopped sleeping");
}

 

Edited by Hayase

12 hours ago, Hayase said:

Escaping the abyss.

It's because when you are inside the abyss, you want to spam objects if you are in combat so that you don't die. I'm basically trying to click objects to escape and when I escape I want the interaction to end. However with normal interactions it gets "stuck" on reaching an interaction it cannot reach. So interaction events comes in and it works. However I still get "hung up" on interacting because it still wants to go back to interact with some shit it can't reach. It's not like I'm spamming the objects at 1ms ticks I'm just clicking them if I'm in combat at a 1 second delay. It's nothing hardcore.

When I finish Mining through for example, sometimes the script will still be stuck in the interaction and will not want to proceed to the next step of getting inside a rift to craft runes. So normal interactions don't work, I've tried them.

 


if (path != null) {
	status = "Escaping via " + path.getName();
	InteractionEvent escape = new InteractionEvent(path);
	execute(InteractionBreaker.setBreakCondition(escape.setAction(), () -> escapedAbyss.contains(myPlayer())));
	log("Clicked: " + path.getName() + " action(s): " + Arrays.toString(path.getActions()) + " canReach: " + getMap().canReach(path));
	log("Started sleeping");
	if (myPlayer().isUnderAttack() || escapedAbyss.contains(myPlayer()))
		afk(720, 1080);
	new ConditionalSleep(5000) {
		@Override
		public boolean condition() throws InterruptedException {
			return myPlayer().isUnderAttack() || escapedAbyss.contains(myPlayer());
		}
	}.sleep();
	log("Stopped sleeping");
}

 

Just making an InteractionEvent around a MouseDestination rather than an Entity will probably get your desired result, since it can't verify reachability.

Edited by FrostBug

pretty sure there's a config value for events such as the deteriorating rocks, use this in combination with player position for a check b4 the interaction nd u should be sw33t
 

On 6/24/2018 at 12:59 PM, Hayase said:

Escaping the abyss.

Edited by Slut

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.