All pastes #2064902 Raw Edit

Someone

public text v1 · immutable
#2064902 ·published 2011-05-19 16:57 UTC
rendered paste body
import java.awt.*;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.net.URL;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.Script;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.wrappers.RSTile;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSArea;

@ScriptManifest(authors = {"Inar"}, keywords = {"cutter"}, name = "InarsCutter", version = 1.1, description = "Cuts yews and banks them")
public class InarCutter extends Script implements PaintListener {

    private int[] yewTree = {2767, 1309};
    private int[] hatchet = {1352, 1353, 1359, 1349, 6739, 1361, 1355, 1357};
    private String status = "Loading..."; 
	public long startTime = System.currentTimeMillis();
    private RSArea yewArea = new RSArea(new RSTile(2929, 3236),new RSTile(2937, 3224));
    private RSTile[] walkingPath = {new RSTile(2936, 3233), new RSTile(2948, 3229), new RSTile(2964, 3230), new RSTile(2979, 3226), new RSTile(2994, 3230), new RSTile(3009, 3232), new RSTile(3023, 3241), new RSTile(3038, 3237), new RSTile(3046, 3237)};
    private RSArea BankArea = new RSArea(new RSTile(3046, 3237), new RSTile(3048, 3236));

    public boolean onStart() {
        log("Thanks for using my script!");
        mouse.setSpeed(random(4, 7));
        return true;
    }

    public void antiban() {
        int b = random(0, 10);
        switch (b) {
            case 1:
                if (random(0, 10) == 5) {
                    log("[Antiban] move mouse");
                    mouse.moveSlightly();
					status = "Antiban";
                    sleep(200, 600);
                    mouse.moveRandomly(150, 350);
                }
                break;
            case 2:
                if (random(0, 10) == 10) {
                    log("[Antiban] Turn screen");
                    camera.setAngle(random(30, 70));
					status = "Antiban";
                    sleep(400, 800);
                }
                break;
            case 3:
                if (random(0, 10) == 6) {
                    log("[Antiban] mouse off screen");
                    mouse.moveOffScreen();
					status = "Antiban";
                    sleep(random(600, random(1200, 2000)));
                }
                break;
            case 4:
                if (random(0, 18) == 3) {

                    log("[antiban] Checking Xp.");
                    game.openTab(1);
                    skills.doHover(Skills.INTERFACE_WOODCUTTING);
					status = "Antiban";
                    sleep(random(2100, 3400));
                }
                break;
            default:
                break;
        }
    }
 //START: Code generated using Enfilade's Easel
    private Image getImage(String url) {
        try {
            return ImageIO.read(new URL(url));
        } catch(IOException e) {
            return null;
        }
    }

    private final Color color1 = new Color(255, 51, 51);
    private final Color color2 = new Color(0, 0, 0);

    private final BasicStroke stroke1 = new BasicStroke(1);

    private final Font font1 = new Font("Arial", 0, 18);
    private final Font font2 = new Font("Arial", 0, 12);

    private final Image img1 = getImage("http://runescape-quest.info/wp-content/uploads/runescape.com/img/main/kbase/guides/repeatable/evil_tree/yew_tree.gif");

    public void onRepaint(Graphics g1) {
	
		long millis = System.currentTimeMillis() - startTime;
        long hours = millis / (1000 * 60 * 60);
        millis -= hours * (1000 * 60 * 60);
        long minutes = millis / (1000 * 60);
        millis -= minutes * (1000 * 60);
        long seconds = millis / 1000;
        Graphics2D g = (Graphics2D)g1;
	
        g.setColor(color1);
        g.fillRect(223, 222, 291, 113);
        g.setColor(color2);
        g.setStroke(stroke1);
        g.drawRect(223, 222, 291, 113);
        g.setFont(font1);
        g.drawString("Inar's Cutter", 329, 244);
        g.setFont(font2);
        g.drawString("Time Run:" + hours + ": " + minutes + ": " + seconds, 230, 277);
        g.drawString("Status:" + status, 398, 277);
        g.drawImage(img1, 412, 1, null);
    }
    //END: Code generated using Enfilade's Easel
    
    public int loop() {
        if (inventory.isFull()) {
            if (BankArea.contains(getMyPlayer().getLocation())) {
                if (!bank.isOpen()) {
                    bank.open();
                    return random(500, 700);
                }
                bank.depositAllExcept(hatchet);
                if (bank.isOpen()) {
                    bank.close();
                    return random(500, 700);
                }
            } else {
                if (walking.getDestination() == null || calc.distanceTo(walking.getDestination()) < random(4, 6)) {
                	walking.walkPathMM(walkingPath);
					status = "Walking";
                    return random(300, 600);
                }
            }
        } else {
            if (yewArea.contains(getMyPlayer().getLocation())) {
                if (getMyPlayer().getAnimation() != 867) {
                    RSObject tree = objects.getNearest(yewTree);
                    if (tree != null) {
                        tree.doAction("Chop");
						status = "Chopping";
						antiban();
                        sleep(500, 800);
                    }
                }
            } else {
                if (walking.getDestination() == null || calc.distanceTo(walking.getDestination()) < random(4, 6)) {
                	 if (walking.getDestination() == null || calc.distanceTo(walking.getDestination()) < random(4, 6)) {
                         walking.walkPathMM(walking.reversePath(walkingPath));
     					status = "Walking";
                         return random(300, 600);
                     }
                 }
             }
             return 0;
         }
		return 0;


    }

    public void onFinish() {
        log("Thank you!");
    }