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.

Setting a break condition for WalkEvent

Featured Replies

So I'm trying to use path walking instead of webwalking wherever I can. The problem I'm facing is what if a bot enters a location accidentally from which it can't go out without handling obstacles?

WalkingEvent walkEvent = new WalkingEvent();
			walkEvent.setPath(path);
//			walkEvent.setBreakCondition(new Condition() {
//				@Override
//				public boolean evaluate() {
//					return (?????????);
//				}
//			});
			s.execute(walkEvent);
			if (walkEvent.hasFailed())
				s.log("Walk event failed");

Seems like hasFailed() never really fires. Event just clicks on the minimap on the next position.

Planning to use webwalking if path walking fails.

So the question is:

 Is it possible to evaluate if a bot can reach the next desired position in WalkingEvents' position list? Would like not to do calculations of which position the bot is currently closest to in the provided list myself, the idea here is to save cpu power. Maybe set the break condition to check if the bot is not moving for more than, say, 5 seconds and then break the event?

So basically, what would be the cleanest, most efficient way in doing this?

	public static WalkingEvent wEvent;
	
	public static boolean walkPath(Script script, LinkedList<Position> path) {
		Paint.action = "Walk path";
		wEvent = new WalkingEvent();
		wEvent.setPath(path);
		wEvent.setBreakCondition(new Condition() {
			public boolean evaluate() {
				List<Position> eventPath = wEvent.getPath().stream()
						.sorted((a, b) -> Integer.compare(script.getMap().distance(a), script.getMap().distance(b)))
						.collect(Collectors.toList());
				Position p = eventPath.get(0);
				return !script.getMap().canReach(p);
			}
		});
		script.execute(wEvent);
		return false;
	}

before you start walkPath() you should do a check to see if the next point on the path can be reached. use the sorter i provided to do that and then handle the obstacle if you cannot reach the next position.

edit: this snippet is designed to handle paths without obstacles on it but should function the way you need it to. you'll have to create the obstacle handling part yourself. with that said, there is a way to combine them both together but that is a whole new can of worms and something that i don't want to share :p

Edited by superuser

  • Author

Thanks, exactly what I needed

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.