Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.osbot.rs07.api.map.Position;
- import org.osbot.rs07.api.model.RS2Object;
- import org.osbot.rs07.input.mouse.MiniMapTileDestination;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.Area;
- import java.awt.*;
- @ScriptManifest(author = "You!", info = "I made this script!", name = "Basic Miner", version = 1.0, logo = "")
- public class BasicMiner extends Script {
- private static final int[] TIN_ID = { 7140, 7141, 7142 };
- private Position[] path = {
- new Position(3283, 3363, 0),
- new Position(3290, 3374, 0),
- new Position(3292, 3386, 0),
- new Position(3292, 3392, 0),
- new Position(3291, 3401, 0),
- new Position(3287, 3413, 0),
- new Position(3282, 3427, 0),
- new Position(3270, 3429, 0),
- new Position(3256, 3429, 0),
- new Position(3254, 3421, 0)
- };
- private static final Area MINE_AREA = new Area(3277, 3358, 3293, 3371);
- private static final Area BANK_AREA = new Area(3250, 3419, 3257, 3423);
- private enum State {
- MINE, WALK_TO_BANK, BANK, WALK_TO_MINE
- };
- private State getState() {
- if (inventory.isFull() && MINE_AREA.contains(myPlayer()))
- return State.WALK_TO_BANK;
- if (!inventory.isFull() && BANK_AREA.contains(myPlayer()))
- return State.WALK_TO_MINE;
- if (inventory.isFull() && BANK_AREA.contains(myPlayer()))
- return State.BANK;
- return State.MINE;
- }
- private void traversePath(Position[] path, boolean reversed) throws InterruptedException {
- if (!reversed) {
- for (int i = 1; i < path.length; i++)
- if (!walkTile(path[i]))
- i--;
- } else {
- for (int i = path.length-2; i > 0; i--)
- if (!walkTile(path[i]))
- i--;
- }
- }
- private boolean walkTile(Position p) throws InterruptedException {
- mouse.move(new MiniMapTileDestination(bot, p), false);
- sleep(random(150, 250));
- mouse.click(false);
- int failsafe = 0;
- while (failsafe < 10 && myPlayer().getPosition().distance(p) > 2) {
- sleep(200);
- failsafe++;
- if (myPlayer().isMoving())
- failsafe = 0;
- }
- if (failsafe == 10)
- return false;
- return true;
- }
- @Override
- public void onStart() {
- log("I can't believe script writing is this easy! I love learning!");
- }
- @Override
- public int onLoop() throws InterruptedException {
- switch (getState()) {
- case MINE:
- if (!myPlayer().isAnimating()) {
- RS2Object vein = objects.closest(TIN_ID);
- if (vein != null) {
- if (vein.interact("Mine"))
- sleep(random(1000, 1500));
- }
- }
- break;
- case WALK_TO_BANK:
- traversePath(path, false);
- sleep(random(1500, 2500));
- break;
- case WALK_TO_MINE:
- traversePath(path, true);
- sleep(random(1500, 2500));
- break;
- case BANK:
- RS2Object bankBooth = objects.closest("Bank booth");
- if (bankBooth != null) {
- if (bankBooth.interact("Bank")) {
- while (!bank.isOpen())
- sleep(250);
- bank.depositAll();
- }
- }
- break;
- }
- return random(200, 300);
- }
- @Override
- public void onExit() {
- log("Thanks for using this wonderful script!");
- }
- @Override
- public void onPaint(Graphics2D g) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement