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.

Small Walking snippet

Featured Replies


# Package name here..

import java.awt.Color;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Point;

import java.awt.RenderingHints;

import java.util.ArrayList;

import org.osbot.script.MethodProvider;

import org.osbot.script.Script;

import org.osbot.script.rs2.map.Position;

import org.osbot.script.rs2.utility.Utilities;

public class Walking {

/*

* Does not contain obstacle handling or path finding.

*/

private Script script;

public Walking(Script script) {

this.script = script;

}

/*

* Used in the drawing method returns the minimap position of the farthest

* away position in the array.

*/

private Point getNextPoint(Position[] positions) {

if (positions != null && positions.length > 0) {

Point last = null;

for (Position p : positions) {

Point point = Utilities.getMinimapScreenCoordinate(script.bot,

p.getX(), p.getY());

if (point != null) {

// checks if it's in the minimap section

if (point.x > 500)

last = point;

}

}

return last;

}

return null;

}

private Position getNextPosition(Position[] positions) {

if (positions != null && positions.length > 0) {

Position next = null;

for (Position p : positions) {

Point point = Utilities.getMinimapScreenCoordinate(script.bot,

p.getX(), p.getY());

if (point != null) {

// checking the point is valid.

if (point.x > 500)

next = p;

}

}

return next;

}

return null;

}

/*

* Path Walking method will require a path array.

*/

public void walkPath(Position[] path) throws InterruptedException {

setRun();

if (path != null && path.length > 0) {

Position n = getNextPosition(path);

// Checking if were not at the last position and if were along the path

if (n != null

&& script.myPosition().distance(path[path.length - 1]) > 7

|| n != null && alongPath(path)) {

script.log("Walking to Position: " + n.toString());

long t = System.currentTimeMillis();

n.walkMinimap(script.bot);

// ghetto dynamic sleep.

while (getNextPosition(path) != null

&& getNextPosition(path).equals(n)

&& System.currentTimeMillis() - t < 4000) {

script.sleep(20);

}

}

}

}

/*

* Used to set the run.

*/

private void setRun() throws InterruptedException {

if (script.client.getRunEnergy() > (20 + MethodProvider.random(20, 25))

&& !script.isRunning()) {

script.setRunning(true);

}

}

/*

* checks if the player is along the path based on distance

*/

public boolean alongPath(Position[] path) {

Position me = script.client.getMyPlayer().getPosition();

if (path != null && path.length > 0)

for (int i = 0; i < path.length; i++) {

if (i != path.length - 1)

if (me.distance(path) < 8) {

return true;

}

}

return false;

}

/*

* Just reverses a position array.

*/

public Position[] reversePath(Position[] path) {

ArrayList<Position> pos = new ArrayList<Position>();

Position[] target = null;

if (path != null && path.length > 0) {

for (int i = 0; i < path.length; i++) {

pos.add(path[path.length - i - 1]);

}

}

target = pos.toArray(new Position[pos.size()]);

return target;

}

/*

* Testing method.

*/

public void drawPoints(Position[] path, Graphics g) {

Point p = getNextPoint(path);

if (p != null) {

Graphics2D g2d = (Graphics2D) g;

g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,

RenderingHints.VALUE_ANTIALIAS_ON);

g2d.setColor(Color.BLACK);

g2d.drawOval(p.x - 1, p.y - 1, 5, 5);

g2d.setColor(Color.MAGENTA);

g2d.fillOval(p.x, p.y, 4, 4);

}

}

}

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.