Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.bot.Bot;
- import org.rsbot.bot.input.CanvasWrapper;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import java.awt.*;
- import java.util.Map;
- @ScriptManifest(authors = { "CuredLamb" }, category = "Money", name = "CuredPotatoes", version = 1.00, description = "" +
- "<html>" +
- "<head>" +
- "</head>" +
- "<body>" +
- "This script automatically picks and (if chosen) bakes potatoes. " +
- "Start the script at Draynor Village's bank. Have fun!" +
- "</body>" +
- "</html\n")
- public class CuredPotatoes extends Script implements PaintListener, ServerMessageListener {
- // Variables //
- private final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
- private final int[] gateid = {45206, 45208};
- private final int potatoid = 312;
- private boolean hasroom = true;
- private boolean resting = false;
- private int picked = 0;
- private String status = "Initialising...";
- public final RSTile[] bankdestination = {new RSTile(3092, 3247), new RSTile(3093, 3247)};
- public final RSTile[] fielddestination = {new RSTile(3145, 3292), new RSTile(3146, 3292)};
- public boolean onStart(Map<String, String> args) {
- return true;
- }
- // Loop //
- public int loop() {
- if (!isLoggedIn()) {
- return random(400,800);
- }
- if (!isRunning() && getEnergy() > random(50, 75)) {
- setRun(true);
- wait(random(400, 800));
- }
- if (!isRunning() && getEnergy() < 50) {
- status = "Resting...";
- rest();
- }
- if (isInventoryFull() && !status.equals("Banking...")) {
- walkTobank();
- return antiban();
- } else if (status.equals("Banking...")) {
- bank();
- return antiban();
- }
- return random(200,400);
- }
- // Detect Message //
- public void serverMessageRecieved(final ServerMessageEvent e) {
- final String message = e.getMessage();
- if (message.contains("You pick a potato.")) {
- picked = picked + 1;
- }
- if (message.contains("You don't have enough room for this potato.")) {
- hasroom = false;
- }
- }
- // Paint //
- public void onRepaint(Graphics g) {
- if(!isLoggedIn()) {
- }
- }
- // Anti-ban (credits to Foulwerp) //
- public int antiban() {
- int i = random(0, 20);
- if (i == 2) {
- moveMouse(random(0, CanvasWrapper.getGameWidth()), random(0,
- CanvasWrapper.getGameHeight()));
- return random(0, 400);
- } else if (i == 3 || i == 12) {
- char dir = 37;
- if (random(0, 3) == 2)
- dir = 39;
- Bot.getInputManager().pressKey(dir);
- wait(random(500, 2000));
- Bot.getInputManager().releaseKey(dir);
- return random(0, 500);
- } else if (i == 7 || i == 4) {
- setCameraAltitude(random(35, 150));
- return random(0, 500);
- } else if (i == 5 || i == 10 || i == 11 || i == 13 || i == 18) {
- moveMouseRandomly(random(-4, 4));
- } else if (i == 1 || i == 8 || i == 15 || i == 20) {
- Thread camera = new Thread() {
- @Override
- public void run() {
- char dir = 37;
- if (random(0, 3) == 2)
- dir = 39;
- Bot.getInputManager().pressKey(dir);
- try {
- Thread.sleep(random(500, 2000));
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- Bot.getInputManager().releaseKey(dir);
- }
- };
- Thread mouse = new Thread() {
- @Override
- public void run() {
- moveMouse(random(0, CanvasWrapper.getGameWidth()), random(0,
- CanvasWrapper.getGameHeight()));
- }
- };
- if (i == 7 || i == 20) {
- camera.start();
- }
- if (i == 1) {
- mouse.start();
- }
- while (camera.isAlive() || mouse.isAlive())
- wait(random(100, 300));
- return random(300, 700);
- }
- return random(1000, 2000);
- }
- // Functions //
- public void pickpotato() {
- status = "Picking potatoes...";
- if (hasroom) {
- final RSObject potato = getNearestObjectByID(potatoid);
- if (potato != null)
- atObject(potato, "Pick Potato");
- }
- }
- public void bank() {
- bank.open();
- while (isInventoryFull()) {
- bank.depositAll();
- wait(random(200,400));
- }
- status = "Walking to field...";
- }
- public void opengate() {
- RSObject gate = getNearestObjectByID(gateid[random(1,2)]);
- if (gate != null) {
- while (gate != null) {
- atObject(gate, "Open Gate");
- gate = getNearestObjectByID(gateid[random(1,2)]);
- }
- }
- }
- public void walkTofield() {
- status = "Walking to field...";
- int i = random(1,2);
- walkTo(fielddestination[i]);
- if (distanceTo(fielddestination[i]) <= random(2,7))
- status = "Picking potatoes...";
- }
- public void walkTobank() {
- status = "Walking to bank...";
- int i = random(1,2);
- walkTo(bankdestination[i]);
- if (distanceTo(fielddestination[i]) <= random(2,7))
- status = "Banking...";
- }
- public void onFinish() {
- }
- }
Add Comment
Please, Sign In to add comment