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.

Walking snippet OSB2

Featured Replies

It uses the local path finder. When using entity, they must have been loaded. Also canReach() is bugged when checking to see if your on top of the position. So i tweaked it a bit.

 

This doesnt contain obstacle handling, im still a bit confused on how im going to add it in. If you have an idea i would love to hear it.

import java.util.LinkedList;

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.util.LocalPathFinder;
import org.osbot.rs07.input.mouse.MiniMapTileDestination;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;

public class Walking {
	
	/*
	 * Doesn't contain obstacle handling.
	 */
	private LocalPathFinder pathFinder;
	private Script script;
	
	public Walking(Script script)	{
		this.script = script;
		this.pathFinder = new LocalPathFinder(script.bot);
	}
	
	public boolean canReach(Position pos)	{
		if (script.myPlayer().getPosition().equals(pos))
			return true;
		else
			return script.map.canReach(pos);
	}

	public boolean setRun(int amount)	{
		if (script.settings.getRunEnergy() >= amount && !script.settings.isRunning())	{
			if (script.settings.isDataOrbsActive())
				return script.interfaces.getChild(548, 39).interact();
			else
				return	script.settings.setRunning(true);
		}
		return script.settings.getRunEnergy() >= amount && script.settings.isRunning();
	}
	
	public boolean walkMiniMap(int threshold, Position pos) throws InterruptedException	{
		MiniMapTileDestination des = new MiniMapTileDestination(script.bot, pos);
	
		if (canReach(pos))	{
		    int fail = 0;
			script.mouse.click(des);
			//script.log("tries: " +fail);
		    while (script.myPosition().distance(pos) > threshold && fail < 10)	{
		    	MethodProvider.sleep(500);
		    	if (!script.myPlayer().isMoving())
		    		fail++;
		    }
		    return fail != 10;
		}
		return false;
	}
	
	public void walkPath(int threshold, Entity entity) throws InterruptedException	{
		LinkedList<Position> path = pathFinder.findPath(entity);
		
		if (pathFinder.foundPath())	{
			for (Position pos: path)	{
				if (pos != null && script.myPosition().distance(pos) > threshold)	{
					if (canReach(pos)) {
						this.walkMiniMap(threshold, pos);
					}else{
						script.log("cant reach pos: " +pos.toString());
					}
				}
			}
		}else
			script.log("error looking for path");
	}
	
	public void walkPath(int threshold, Position endPos) throws InterruptedException	{
		LinkedList<Position> path = pathFinder.findPath(endPos);
		
		if (pathFinder.foundPath())	{
			for (Position pos: path)	{
				if (pos != null && script.myPosition().distance(pos) > threshold)	{
					if (canReach(pos)) {
						this.walkMiniMap(threshold, pos);
					}else{
						script.log("cant reach pos: " +pos.toString());
					}
				}
			}
		}else
			script.log("error looking for path");
		
	}
	
}

Edited by josedpay

  • Author

Looks like you put a decent amount of time making this up. Good job, hopefully you can get obstacle handling added into it. happy.png

i really would like that, i know you could use clipping flags, for obstacle handling but ive never used them so i dont know

I actually made something that uses same algo for finding the position ur at in path. Then, I created a class Node, which is just liek a tile. Node has 2 functions: atNode() and interact() the default interact() for a node is to walk The constructor for this class contains the position of the node. Then I have two more classes NPCNode and ObjectNode that extend node. These 2 classes extend node and override interact method to itneract with the specified object, with the specified verb. (They take id/name and a verb as constructor + the Position for Node.) Also, with the ObjectNodes and NPCNodes i sometimes override the interact() or atNode() methods if i need a more complex interaction.

 

Finally, I got a class called NodePath which traverses the a list of NPC's (Which includes objectNodes and npcNodes's since they extend node.)

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.