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.

Need help with walking a path

Featured Replies

Right now I've a Position array to my destination and am iterating through it and using localwalker to walk to that tile. However, it will walk that path in reverse after finishing.

 

db6e1ca967.png

 

f8532005db.png

I know xD

 

Which method you use to walk ?

 

Not my greatest snippet :p

	public static boolean traversePath(Script script, Position[] path, boolean reversed, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat, long timeout) throws InterruptedException {
		Timer timer = new Timer();
		while (!reversed ? script.map.distance(path[path.length - 1]) > 4 : script.map.distance(path[0]) > 4 && timer.getElapsed() < timeout) {
			PathWalkMethods.runManager(script, toggleRunOnAt, toggleRunOffAt, toggleRunOnInCombat);
			Position bestPosition = null;
			int attempts = 0;
			if (!reversed) {
				for (int i = 1; i < path.length; i++) {
					if (script.map.canReach(path[i])) {
						MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO
						if (mmtd != null && mmtd.isVisible()) {
							bestPosition = path[i];
						}
					}
				}
			} else {
				for (int i = path.length - 1; i > 0; i--) {
					if (script.map.canReach(path[i])) {
						MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO
						if (mmtd != null && mmtd.isVisible()) {
							bestPosition = path[i];
						}
					}
				}
			}
			if (bestPosition != null) {
				script.mouse.click(new MiniMapTileDestination(script.bot, bestPosition));
				int failsafe = 0;
				while (failsafe < 10 && script.myPlayer().getPosition().distance(bestPosition) > 2) {
					MethodProvider.sleep(600);
					failsafe++;
					if (script.myPlayer().isMoving()) {
						failsafe = 0;
					}
				}
				return true;
			}
			else {
				attempts++;
				if (attempts > 5) {
					return false;
				}
				script.camera.moveYaw(script.camera.getYawAngle() + MethodProvider.random(60,80));
			}
		}
		return true;
	}

	public static void runManager(Script script, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat) {
		if (script.settings.getRunEnergy() >= toggleRunOnAt || (toggleRunOnInCombat ? script.settings.getRunEnergy() > 0 && script.myPlayer().isUnderAttack() : false)) {
			script.settings.setRunning(true);
		}
		if (script.settings.getRunEnergy() <= toggleRunOffAt && (toggleRunOnInCombat ? !script.myPlayer().isUnderAttack() : true)) {
			script.settings.setRunning(false);
		}
	}

 

Not my greatest snippet tongue.png

	public static boolean traversePath(Script script, Position[] path, boolean reversed, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat, long timeout) throws InterruptedException {
		Timer timer = new Timer();
		while (!reversed ? script.map.distance(path[path.length - 1]) > 4 : script.map.distance(path[0]) > 4 && timer.getElapsed() < timeout) {
			PathWalkMethods.runManager(script, toggleRunOnAt, toggleRunOffAt, toggleRunOnInCombat);
			Position bestPosition = null;
			int attempts = 0;
			if (!reversed) {
				for (int i = 1; i < path.length; i++) {
					if (script.map.canReach(path[i])) {
						MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO
						if (mmtd != null && mmtd.isVisible()) {
							bestPosition = path[i];
						}
					}
				}
			} else {
				for (int i = path.length - 1; i > 0; i--) {
					if (script.map.canReach(path[i])) {
						MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO
						if (mmtd != null && mmtd.isVisible()) {
							bestPosition = path[i];
						}
					}
				}
			}
			if (bestPosition != null) {
				script.mouse.click(new MiniMapTileDestination(script.bot, bestPosition));
				int failsafe = 0;
				while (failsafe < 10 && script.myPlayer().getPosition().distance(bestPosition) > 2) {
					MethodProvider.sleep(600);
					failsafe++;
					if (script.myPlayer().isMoving()) {
						failsafe = 0;
					}
				}
				return true;
			}
			else {
				attempts++;
				if (attempts > 5) {
					return false;
				}
				script.camera.moveYaw(script.camera.getYawAngle() + MethodProvider.random(60,80));
			}
		}
		return true;
	}

	public static void runManager(Script script, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat) {
		if (script.settings.getRunEnergy() >= toggleRunOnAt || (toggleRunOnInCombat ? script.settings.getRunEnergy() > 0 && script.myPlayer().isUnderAttack() : false)) {
			script.settings.setRunning(true);
		}
		if (script.settings.getRunEnergy() <= toggleRunOffAt && (toggleRunOnInCombat ? !script.myPlayer().isUnderAttack() : true)) {
			script.settings.setRunning(false);
		}
	}

 

Well thats very good :o

 

How do you walk to something without a path?

Because thats mainly my weak point ...

 

localwalker and map.walk are all bit glitchy and 90% of the time doesn't walk to something you want :s

 

any ideas?

Khaleesi, have you tried osbot pathFinder ? i use iy for walking when i only have one point

Well thats very good ohmy.png

 

How do you walk to something without a path?

Because thats mainly my weak point ...

 

localwalker and map.walk are all bit glitchy and 90% of the time doesn't walk to something you want :s

 

any ideas?

 

You'd have to write a pathfinding algorithm.

 

http://en.wikipedia.org/wiki/Pathfinding

 

Haven't ever needed a custom pathfinding method myself, but I might write on just for challenge of it ;D

  • Author

 

Not my greatest snippet tongue.png

	public static boolean traversePath(Script script, Position[] path, boolean reversed, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat, long timeout) throws InterruptedException {
		Timer timer = new Timer();
		while (!reversed ? script.map.distance(path[path.length - 1]) > 4 : script.map.distance(path[0]) > 4 && timer.getElapsed() < timeout) {
			PathWalkMethods.runManager(script, toggleRunOnAt, toggleRunOffAt, toggleRunOnInCombat);
			Position bestPosition = null;
			int attempts = 0;
			if (!reversed) {
				for (int i = 1; i < path.length; i++) {
					if (script.map.canReach(path[i])) {
						MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO
						if (mmtd != null && mmtd.isVisible()) {
							bestPosition = path[i];
						}
					}
				}
			} else {
				for (int i = path.length - 1; i > 0; i--) {
					if (script.map.canReach(path[i])) {
						MiniMapTileDestination mmtd = new MiniMapTileDestination(script.bot, path[i]);// TODO
						if (mmtd != null && mmtd.isVisible()) {
							bestPosition = path[i];
						}
					}
				}
			}
			if (bestPosition != null) {
				script.mouse.click(new MiniMapTileDestination(script.bot, bestPosition));
				int failsafe = 0;
				while (failsafe < 10 && script.myPlayer().getPosition().distance(bestPosition) > 2) {
					MethodProvider.sleep(600);
					failsafe++;
					if (script.myPlayer().isMoving()) {
						failsafe = 0;
					}
				}
				return true;
			}
			else {
				attempts++;
				if (attempts > 5) {
					return false;
				}
				script.camera.moveYaw(script.camera.getYawAngle() + MethodProvider.random(60,80));
			}
		}
		return true;
	}

	public static void runManager(Script script, int toggleRunOnAt, int toggleRunOffAt, boolean toggleRunOnInCombat) {
		if (script.settings.getRunEnergy() >= toggleRunOnAt || (toggleRunOnInCombat ? script.settings.getRunEnergy() > 0 && script.myPlayer().isUnderAttack() : false)) {
			script.settings.setRunning(true);
		}
		if (script.settings.getRunEnergy() <= toggleRunOffAt && (toggleRunOnInCombat ? !script.myPlayer().isUnderAttack() : true)) {
			script.settings.setRunning(false);
		}
	}

 

 

It works as well as i need it to, thank you! :D

Khaleesi, have you tried osbot pathFinder ? i use iy for walking when i only have one point

That only works for your current region (think it's like 72 tiles?).

 

You'd have to write a pathfinding algorithm.

 

http://en.wikipedia.org/wiki/Pathfinding

 

Haven't ever needed a custom pathfinding method myself, but I might write on just for challenge of it ;D

You also need map data.

That only works for your current region (think it's like 72 tiles?).

 

You also need map data.

 

bc7dad4039b999a4b10c215f9743d24d.png

 

104 tiles,  no ?

Guest
This topic is now closed to further replies.

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.