So this is going to be a beginners guide into utilizing a walking function.
This is by all means a standard walker and doesn't support any objects blocking path, different types of objects could be in your way so for sake of simplicity i'll leave it out and if you'd like just request me to do a snippet on walking with object interacts, etc..
Suggest me any script and I can probably do it (still learning some small stuff, but majority is pretty ez pz).
Firstly, i'd like you to just read the bullet points below, then read the code and understand the functions, and not get overwhelmed by something that you may not understand at first okay; take your time to understand the functions and ways around the OSB API.
If you have any questions feel free to PM me or post on my profile wall, etc.. always willing to help with my current knowledge.
For coordinations I just use: https://explv.github.io/ (source code Javascript: https://github.com/Explv/Explv.github.io)
credits: Explv
Position (this is our destination in where we're trying to head towards automatically for us instead of that long grind in walking.
Includes a script run time length
Supports the Run function for the player (set Run on startup, also comes with a random chance for run checking)
Dismisses the pesky random events that pop up sometimes, also stores an integer value that increments every time we dismiss one
For sake of a anti ban like method moving our Mouse to -1,-1 coordinates will make it look like a human like AFK (TODO: Test)
If the player is under attack, the player will activate Run mode and will continue to run to destination regardless
Standard String drawing for paint (displays any info we collect through variables(example: run time, events dismissed))
package main.script.Bot_Walker;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.text.NumberFormat;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
public class AutoWalker extends Script {
private long timeStarting = System.currentTimeMillis();
private int randomsDismissed;
private Position destination = new Position(3222, 3222, 0);
@[member=Override]
public void onStart() throws InterruptedException {
log("Starting up the bot walking");
timeStarting = System.currentTimeMillis();
getSettings().setRunning(true);
}
private boolean dismissRandom() {
for (NPC randomEvent : npcs.getAll()) {
if (randomEvent == null || randomEvent.getInteracting() == null
|| randomEvent.getInteracting() != myPlayer()) {
continue;
}
if (randomEvent.hasAction("Dismiss")) {
randomEvent.interact("Dismiss");
randomsDismissed++;
return true;
}
}
return false;
}
@[member=Override]
public int onLoop() throws InterruptedException {
int randomRun = random(5);
if (randomRun == 1) {
getSettings().setRunning(getSettings().getRunEnergy() < 25 ? false : true);
}
if (dismissRandom()) {
while (myPlayer().isMoving()) {
sleep(random(600, 800));
}
}
while (myPlayer().isAnimating()) {
mouse.move(-1, -1);
}
if (myPlayer().isUnderAttack()) {
getSettings().setRunning(true);
getWalking().webWalk(destination);
}
getWalking().webWalk(destination);
return random(200, 300);
}
@[member=Override]
public void onPaint(Graphics2D graphics) {
drawMouse(graphics);
Font font = new Font("TimesRoman", Font.PLAIN, 12);
graphics.setFont(font);
graphics.setColor(Color.WHITE);
graphics.drawString("Auto Walker script created by: Booleans Yay", 140, 325);
graphics.drawString("Randoms Dismissed: " + formatIntegers(randomsDismissed), 5, 55);
long runTime = System.currentTimeMillis() - timeStarting;
graphics.drawString("Script Runtime: " + formatTime(runTime), 5, 85);
}
private void drawMouse(Graphics graphics) {
((Graphics2D) graphics).setRenderingHints(
new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
Point pointer = mouse.getPosition();
Graphics2D spinG = (Graphics2D) graphics.create();
Graphics2D spinGRev = (Graphics2D) graphics.create();
spinG.setColor(new Color(255, 255, 255));
spinGRev.setColor(Color.cyan);
spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2 * Math.PI / 180.0, pointer.x, pointer.y);
spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d) * 2 * Math.PI / 180.0, pointer.x, pointer.y);
final int outerSize = 20;
final int innerSize = 12;
spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
spinG.drawArc(pointer.x - (outerSize / 2), pointer.y - (outerSize / 2), outerSize, outerSize, 100, 75);
spinG.drawArc(pointer.x - (outerSize / 2), pointer.y - (outerSize / 2), outerSize, outerSize, -100, 75);
spinGRev.drawArc(pointer.x - (innerSize / 2), pointer.y - (innerSize / 2), innerSize, innerSize, 100, 75);
spinGRev.drawArc(pointer.x - (innerSize / 2), pointer.y - (innerSize / 2), innerSize, innerSize, -100, 75);
}
public static String formatIntegers(int number) {
return NumberFormat.getInstance().format(number);
}
public final String formatTime(final long milisecond) {
long s = milisecond / 1000, m = s / 60, h = m / 60, d = h / 24;
s %= 60;
m %= 60;
h %= 24;
return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s)
: h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s);
}
}