Skip 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.

[Open source] Barbarian Plank looter

Featured Replies

Wrote this quickly in 15min, hope somebody can learn something from it :)

.jar file is at end of topic.
-Rare

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BooleanSupplier;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Rare Scripts", name = "Plank Looter", info = "Loot planks at Barbarian Outpost", version = 1, logo = "")
public final class PlankLooter extends Script {

	String currentState;
	public final Position bankTile = new Position(2536, 3572, 0);
	public final Position plankTile = new Position(2553, 3575, 0);

	@Override
	public final void onStart() {
		currentState = "Starting script...";
	}

	public void hopWorld() throws InterruptedException {
		int oldWorld = getWorlds().getCurrentWorld();
		if (getWorlds().hopToP2PWorld()) {
			Sleep.sleepUntil(() -> getWorlds().getCurrentWorld() != oldWorld && getClient().isLoggedIn(), 7000);
		}
	}

	public void handleBank() throws InterruptedException {
		if (getBank().getDepositBox().open()) {
			Sleep.sleepUntil(() -> getBank().getDepositBox().isOpen(), 9000);
			if (getBank().getDepositBox().isOpen()) {
				getBank().getDepositBox().depositAll();
				if (getBank().getDepositBox().close()) {
					Sleep.sleepUntil(() -> !getBank().getDepositBox().isOpen(), 9000);
				}
			}
		}
	}

	public boolean findPlanks() {
		GroundItem i = getGroundItems().closest("Plank");
		return i != null && map.canReach(i) && map.distance(i) <= 15;
	}

	public void lootPlanks() {
		GroundItem i = getGroundItems().closest("Plank");
		if (i != null && map.canReach(i) && map.distance(i) <= 15) {
			if (i.interact("Take")) {
				Sleep.sleepUntil(() -> !i.exists() || i == null || getInventory().isFull(), 9000);
			}
		}
	}

	@Override
	public final int onLoop() throws InterruptedException {

		if (getInventory().isFull()) {
			if (bankTile.distance(myPlayer().getPosition()) <= 2) {
				currentState = "Banking";
				handleBank();
			} else {
				currentState = "Running to Bank";
				getWalking().webWalk(bankTile);
			}
		} else {
			if (plankTile.distance(myPlayer().getPosition()) <= 7) {
				if (findPlanks()) {
					currentState = "Looting Planks";
					lootPlanks();
				} else {
					currentState = "No Planks, hop world";
					hopWorld();
				}
			} else {
				currentState = "Running to Planks";
				getWalking().webWalk(plankTile);
			}
		}

		return random(50, 500);
	}

	@Override
	public final void onExit() {
		log("Script terminated! :)");
	}

	@Override
	public final void onMessage(final Message message) {
		// log("New msg: " + message.getMessage());
	}

	@Override
	public void onPaint(final Graphics2D g) {
		g.drawString("Rare Plank Looter", 12, 130);
		g.drawString("State: " + currentState, 12, 150);
	}

}



Sleep class (Special thanks to Explv):

 


import java.util.function.BooleanSupplier;
import org.osbot.rs07.utility.ConditionalSleep;

//Thanks to Explv:
class Sleep extends ConditionalSleep {

	private final BooleanSupplier condition;

	public Sleep(final BooleanSupplier condition, final int timeout) {
		super(timeout);
		this.condition = condition;
	}

	@Override
	public final boolean condition() throws InterruptedException {
		return condition.getAsBoolean();
	}

	public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) {
		return new Sleep(condition, timeout).sleep();
	}
}

 

PlankLooter.jar

Edited by Rare scripts

  • 1 year later...

hello i kinda wrote whole script over so i can learn from it but my problem is now that it doesnt run to the bank but the currentState says it is at that state

this is what i got:

 

if (getInventory().isFull()) {
    if (bankTile.distance(myPlayer().getPosition()) <= 2) {
        currentState = "Banking";
        hb();
    } else {
        currentState = "Running to Bank";
        getWalking().webWalk(bankTile);
    }
public void hb() throws InterruptedException {
    if (getBank().getDepositBox().open()) {
        Sleep.sleepUntil(() -> getBank().getDepositBox().isOpen(), 9000);
        if (getBank().getDepositBox().isOpen()) {
            getBank().getDepositBox().depositAll();
            if (getBank().getDepositBox().close()) {
                Sleep.sleepUntil(() -> !getBank().getDepositBox().isOpen(), 8000);
            }
        }
    }
}

its the Deposit box at BA..

  • 1 month later...
On 9/12/2020 at 6:04 AM, Lecune said:

hello i kinda wrote whole script over so i can learn from it but my problem is now that it doesnt run to the bank but the currentState says it is at that state

this is what i got:

 


if (getInventory().isFull()) {
    if (bankTile.distance(myPlayer().getPosition()) <= 2) {
        currentState = "Banking";
        hb();
    } else {
        currentState = "Running to Bank";
        getWalking().webWalk(bankTile);
    }

public void hb() throws InterruptedException {
    if (getBank().getDepositBox().open()) {
        Sleep.sleepUntil(() -> getBank().getDepositBox().isOpen(), 9000);
        if (getBank().getDepositBox().isOpen()) {
            getBank().getDepositBox().depositAll();
            if (getBank().getDepositBox().close()) {
                Sleep.sleepUntil(() -> !getBank().getDepositBox().isOpen(), 8000);
            }
        }
    }
}

its the Deposit box at BA..

I ended up changing the banking part to this:

 

public void handleBank() throws InterruptedException {
    if (!getBank().isOpen()){ //If the bank is not open
        getBank().open(); //Opens bank chests, booths, etc.
        if (getBank().isOpen()) {
            getBank().depositAll();
            if (getBank().close()) {
                Sleep.sleepUntil(() -> !getBank().isOpen(), 4000);
            }
        }
    }
}

 

hope that helps you.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.