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.

Farming leprechaun ToolShed

Featured Replies

Bit Picture

7Ya4L.png

 

etc...

 

 

ToolShed class

package com.scrub.farming.leprechaun;

import org.osbot.script.Script;

public class ToolShed {
    private final int SHED_CONFIG = 615;
    private Script script;

    public ToolShed(Script script) {
        this.script = script;
    }

    public boolean contains(Tool t) {
        return  getCurrentAmount(t) > 0;
    }

    public int getCurrentAmount(Tool t) {
        return (script.client.getConfig(SHED_CONFIG) & t.getBitMask()) / t.getDecimalValue();
    }
    
    public int getSpaceLeft(Tool t){
        return t.getMaxAmount() - getCurrentAmount(t);
    }

}

 

Tool enum

 

package com.scrub.farming.leprechaun;

public enum Tool {

    RAKE("Rake", 1, 1, 0b1), SEED_DRIBBER("Seed dibber", 1, 2, 0b10), SPADE(
            "Spade", 1, 4, 0b100), SECATEURS("Secateurs", 1, 8, 0b1000), WATERING_CAN(
            "Watering can", 1, 16, 0b10000), GARDENING_TROWEL(
            "Gardening trowel", 1, 256, 0b100000000), BUCKET("Bucket", 31, 512,
            0b1111100000000), COMPOST("Compost", 255, 16384,
            0b111111100000000000000), SUPER_COMPOST("Super compost", 255,
            4194304, 0b11111111000000000000000000000);

    private final String name;
    private final int maxAmount;
    private final int decimalValue;
    private final int bitMask;

    Tool(final String name, final int maxAmount, final int decimalValue,
            final int bitMask) {
        this.name = name;
        this.maxAmount = maxAmount;
        this.decimalValue = decimalValue;
        this.bitMask = bitMask;
    }

    public String getName() {
        return name;
    }

    public int getMaxAmount() {
        return maxAmount;
    }

    public int getDecimalValue() {
        return decimalValue;
    }

    public int getBitMask() {
        return bitMask;
    }

    public int getSlotNumber() {
        for (int i = 0; i < Tool.values().length; i++) {
            if (equals(Tool.values()[i])) {
                return i;
            }
        }
        return -1;
    }

}



 

ShedContainer class

 

package com.scrub.farming.leprechaun;

import java.awt.Point;
import java.awt.Rectangle;

import org.osbot.script.Script;
import org.osbot.script.mouse.RectangleDestination;
import org.osbot.script.rs2.ui.RS2InterfaceChild;

public class ShedContainer {

	private Script script;

	private final int START_WIDTH = 172;
	private final int START_HEIGHT = 105;
	private final int WIDTH = 95;
	private final int HEIGHT = 64;

	private Point getPoint(int slot) {
		int column = slot / 3;
		int row = slot % 3;
		int x = (int) (START_WIDTH + (row * WIDTH));
		int y = (int) START_HEIGHT + (column * HEIGHT);
		return new Point(x, y);
	}

	private Rectangle getRectangle(int slot) {
		Point p = getPoint(slot);
		return new Rectangle(p.x, p.y, 35, 44);
	}

	public ShedContainer(Script script) {
		this.script = script;
	}

	private boolean interact(Rectangle rec, String action)
			throws InterruptedException {
		return script.selectOption(null, new RectangleDestination(rec), action);
	}

	public boolean interact(Tool t, String action) throws InterruptedException {
		return interact(getRectangle(t.getSlotNumber()), action);
	}
	
	public boolean closeScreen() throws InterruptedException{
		return isOpen() && getChild(125,88) !=null && getChild(125,88).interact("Close");
	}

	public boolean isOpen(){
		return getChild(125,67) !=null;
	}
	
	private RS2InterfaceChild getChild(int parent, int child) {
		if (script.client.getInterface(parent) != null) {
			RS2InterfaceChild c = script.client.getInterface(parent).getChild(child);
			if (c != null && c.isVisible()) {
				return c;
			}
		}
		return null;
	}


}

7ZB8A.png

Edited by TheScrub

Awesome stuff, mind explaining to me why you grab the binary value and divide it by decimal value for grabCurrentAmount()?

  • Author

Awesome stuff, mind explaining to me why you grab the binary value and divide it by decimal value for grabCurrentAmount()?

 

grabbing the total value of the bits in the bitmask then i divide by the worth of one item

grabbing the total value of the bits in the bitmask then i divide by the worth of one item

 

Ah alright makes sense! Nice snippet ^_^

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.