- import java.awt.*;
- import java.util.*;
- import java.util.List;
- import java.lang.reflect.Method;
- import java.util.logging.Level;
- import javax.accessibility.*;
- import javax.swing.*;
- import org.rsbot.bot.*;
- import org.rsbot.bot.input.*;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.accessors.*;
- import org.rsbot.event.listeners.*;
- import org.rsbot.event.events.*;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.util.ScreenshotUtil;
- @ScriptManifest(authors = { "Charlie" }, category = "CSeries", name = "CMonkGrabber", version = 1.00, description
- = "Start in Edgeville bank or near Monastery!")
- public class CMonkGrabber extends Script implements PaintListener {
- private final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
- private final RSTile[] toChurch = new RSTile[] { new RSTile(3092, 3497), new RSTile(3085, 3503), new
- RSTile(3073, 3505), new RSTile(3068, 3512), new RSTile(3058, 3512), new RSTile(3051, 3507), new RSTile(3051,
- 3500), new RSTile(3053, 3491), new RSTile(3058, 3485)};
- private final RSTile[] toBank = new RSTile[] {new RSTile(3058, 3485), new RSTile(3053, 3491), new RSTile
- (3051, 3500), new RSTile(3051, 3507),new RSTile(3058, 3512), new RSTile(3068, 3512), new RSTile(3073, 3505), new
- RSTile(3085, 3503), new RSTile(3092, 3497), new RSTile(3097, 3496)};
- private final RSArea roomArea = new RSArea(new RSTile(3056, 3486), new RSTile(3059, 3492));
- private final RSTile ladderTile = new RSTile(3057, 3483);
- public int robesGrabbed;
- //private int bottomPrice, topPrice, missed, stung; //needed for paint & such
- private int randCam;
- public long startTime = System.currentTimeMillis();
- private long idleStart;
- @Override
- protected int getMouseSpeed() {
- return random(5, 7);
- }
- private enum State {
- ANTI_BAN, WALK_TO_CHURCH, CLIMB_UP, CLIMB_DOWN, OPEN_DOOR, PICK_ROBES, WALK_TO_ROBES,
- WALK_TO_BANK, BANK
- }
- private State getState() {
- if(getPlane() == 1) {
- if(roomArea.contains(getLocation())) {
- if(isInventoryFull()) {
- if(getObjectAt(3058, 3486) != null) {
- //log("CLIMB DOWN2");
- return State.CLIMB_DOWN;
- } else {
- //log("OPEN DOOR - CLIMB DOWN");
- return State.OPEN_DOOR;
- }
- } else if(getNearestGroundItemByID(542, 544) == null) {
- RSTile myLoc = getLocation();
- if(myLoc.getX() != 3058 || myLoc.getY() != 3488 || myLoc.getY() != 3489)
- {
- onTile(new RSTile(3058, random(3487, 3488)), "Scorp", "Walk ");
- wait(random(100, 350));
- }
- //log("ANTIBAN 2");
- return State.ANTI_BAN;
- } else {
- //log("PICK ROBES");
- return State.PICK_ROBES;
- }
- } else {
- if(getObjectAt(3058, 3485) != null) {
- //log("OPEN DOOR");
- return State.OPEN_DOOR;
- } else if(getObjectAt(3058, 3486) != null) {
- if(isInventoryFull()) {
- //log("CLIMB DOWN");
- return State.CLIMB_DOWN;
- } else {
- //log("WALK TO ROBES");
- return State.WALK_TO_ROBES;
- }
- }
- }
- } else if(getNearestNPCByName("Banker") != null) {
- if(getInventoryCount() > 0) {
- //log("BANK");
- return State.BANK;
- } else {
- //log("WALK CHURCH");
- return State.WALK_TO_CHURCH;
- }
- } else if(tileOnScreen(ladderTile) && getPlane() == 0 && !isInventoryFull()) {
- //log("CLIMB UP 1");
- return State.CLIMB_UP;
- } else if(!isIdle()) {
- if(getDestination() != null && distanceTo(getDestination()) <= random(6, 8) && !
- isLastTile()) {
- if(isInventoryFull()) {
- //log("WALK BANK");
- return State.WALK_TO_BANK;
- } else {
- //log("WALK CHURCH");
- return State.WALK_TO_CHURCH;
- }
- }
- } else if(isInventoryFull() && getPlane() == 0) {
- //log("WALK BANK 3");
- return State.WALK_TO_BANK;
- }
- //log("ANTIBAN 1");
- return State.ANTI_BAN;
- }
- private boolean isLastTile() {
- return distanceBetween(getDestination(), toChurch[toChurch.length-1]) < 5 || distanceBetween
- (getDestination(), toBank[toBank.length-1]) < 5;
- }
- public int loop() {
- if(getPlane() == 1) {
- idleStart = -1;
- if(getCameraAngle() > 3 && getCameraAngle() < 355) {
- //log("setrot");
- setCameraRotation((random(1,6) == 2 ? random(0, 3) : random(355, 359)));
- return random(25, 100);
- }
- }
- if(random(1, 15) == 3) {
- //log("mouse speed");
- getMouseSpeed();
- return random(10,30);
- }
- if(getPlane() == 0) {
- if(isIdle()) {
- //log("isIdle() == true");
- if(idleStart == -1) {
- //log("idleStart set");
- idleStart = System.currentTimeMillis();
- } else {
- //log("idleTime = "+(System.currentTimeMillis() - idleStart));
- if(System.currentTimeMillis() - idleStart >= random(3000, 5000)) {
- if(isInventoryFull()) {
- //log("walktobank");
- walkTo(toBank[toBank.length-1]);
- } else {
- //log("walktochurch");
- walkTo(toChurch[toChurch.length-1]);
- }
- return random(100, 300);
- }
- }
- } else {
- idleStart = -1;
- }
- } else {
- Point m = getMouseLocation();
- if(getPlane() == 1 && (((m.x < 280 || m.x > 305) || (m.y < 155 || m.y > 175)) || random
- (1,50) == 3)) {
- //log("fix mouse");
- moveMouse(random(280, 305), random(155, 175));
- return random(20, 70);
- }
- }
- if(randCam == -1 || randCam == random(1, 75)) {
- randCam = random(1, 75);
- //log("cam alt");
- setCameraAltitude(true);
- }
- final int invCount = getInventoryCount();
- switch(getState()) {
- case ANTI_BAN:
- antiban();
- return random(50, 300);
- case WALK_TO_CHURCH:
- walkPathMM(toChurch);
- return random(50, 150);
- case CLIMB_UP:
- if(atTile(ladderTile, "Climb-up")) {
- return random(750, 1500);
- } else {
- return random(100, 300);
- }
- case CLIMB_DOWN:
- if(!tileOnScreen(ladderTile)) {
- walkTo(ladderTile);
- return random(100, 400);
- }
- if(atTile(ladderTile, "Climb-down")) {
- return random(750, 1500);
- } else {
- return random(100, 300);
- }
- case OPEN_DOOR:
- atDoor(30864, 'N');
- return random(100, 300);
- case PICK_ROBES:
- RSItemTile toPick = getNearestGroundItemByID(542, 544);
- if(toPick != null && onTile(toPick, "Scorp", "Take")) {
- wait(random(7500, 17500));
- onTile(new RSTile(3058, (getLocation().getY() == 3488 ? 3487 : 3488)),
- "Scorp", "Walk ");
- return random(100, 400);
- } else {
- return random(100, 300);
- }
- case WALK_TO_ROBES:
- walkTo(new RSTile(3058, random(3487, 3488)));
- return random(100, 300);
- case WALK_TO_BANK:
- walkPathMM(toBank);
- return random(50, 150);
- case BANK:
- if(getInventoryCount() == 0) {
- if(bank.isOpen() && random(1, 9) == 7) {
- bank.close();
- return random(100, 300);
- }
- return random(50, 100);
- }
- if(!bank.isOpen()) {
- if(bank.open()) {
- return random(700, 1400);
- } else {
- return random(100, 300);
- }
- }
- bank.depositAll();
- robesGrabbed++;
- return random(300, 750);
- }
- return random(100, 750);
- }
- public void antiban() {
- if(getPlane() == 1) {
- return;
- }
- int random = random(1, 24);
- switch (random) {
- case 1:
- if (random(1, 10) != 1)
- break;
- moveMouse(random(10, 750), random(10, 495));
- break;
- case 2:
- if (random(1, 40) != 1)
- break;
- int angle = getCameraAngle() + random(-90, 90);
- if (angle < 0 || angle > 359) {
- angle = random(0, 10);
- }
- if(angle > 3 && angle < 355) {
- setCameraRotation(angle);
- }
- break;
- case 3:
- if (random(1, 3) != 1)
- break;
- moveMouseSlightly();
- break;
- default:
- break;
- }
- }
- public boolean onStart(Map<String, String> args) {
- return true;
- }
- public void onRepaint(Graphics g) {
- long millis = System.currentTimeMillis() - startTime;
- int y = 211;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- g.setFont(new Font("Arial", Font.BOLD, 12));
- g.setColor(Color.green);
- g.setColor(Color.black);
- g.drawString("CMonkGrabber - Beta Runtime: " + hours + ":" + minutes + ":" +
- seconds,
- 15, y += 14);
- g.drawString("Trips: " + robesGrabbed, 15, y += 14);
- }
- public void onFinish() {
- }
- }
