- //---------------------------------------------------------------------------
- //***************************************************************************
- //***************************************************************************
- //
- // * BE ORIGINAL *
- // * DON'T COPY WORK THAT'S NOT YOURS *
- // * xScriptx *
- //
- // You may learn from this script, but not copy.
- //
- //***************************************************************************
- //***************************************************************************
- //---------------------------------------------------------------------------
- //IMPORTS RSBOT
- import org.rsbot.script.wrappers.*;
- import org.rsbot.script.methods.*;
- import org.rsbot.script.util.*;
- import org.rsbot.event.listeners.*;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.util.WindowUtil;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.util.GlobalConfiguration;
- //IMPORTS JAVA
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import java.awt.*;
- import java.lang.String.*;
- import java.io.*;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.event.*;
- import java.awt.image.BufferedImage;
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.io.IOException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.net.MalformedURLException;
- import javax.imageio.ImageIO;
- @ScriptManifest(authors = {"<html><style>div{color:green;}</tyle><div><h3>xScriptx<h3></div></html>"}, keywords = {"Chopper"}, name = "xScriptxChopper", description = "<html><style>div{background-color:blue; color:white;}</tyle><div><h3>PowerChops any Willow Tree - By xScriptx<h3></div></html>", version = 3.0)
- public class xScriptxChopper extends Script implements PaintListener, MouseListener, MessageListener {
- /* Variables & Constants */
- //ETC
- private gui gui;
- private Point mousePoint;
- private static final Pattern UPDATER_VERSION_PATTERN = Pattern.compile("version\\s*=\\s*([0-9.]+)");
- //BOOLEAN
- private boolean hide = false, logout = false, dropping = false;
- private boolean startScript = false;
- //IMAGES
- private Rectangle closeFixed = new Rectangle(480, 459, 30, 13), close = new Rectangle(466, 111, 30, 13);
- private BufferedImage normal = null, clicked = null;
- private final Image logo = getImage("http://img156.imageshack.us/img156/763/xscriptx.png");
- private final Image back = getImage("http://img573.imageshack.us/img573/7755/backr.png");
- //INT
- private int WillowTrees[] = {5551, 5552, 5553}, Hatchets[] = {1349, 1351, 1353, 1355, 1357, 1359, 1361, 6739, 13470};
- private int levelsGained;
- private int storeNpc = 531;
- private int bankMode;
- private int mode;
- private int BankId;
- private int startexp = 0;
- private int startlevel;
- //STRING
- private String scriptVersion = "v3.0";
- private String status;
- private static final String UPDATER_FILE_NAME = "xScriptxChopper.java";
- private static final String UPDATER_URL = "http://xscriptx.atwebpages.com/xScriptxChopper.java";
- //FLOAT & DOUBLE
- private float xpGained = 0;
- private double xpsec;
- private double xpmin;
- private double logs = 0;
- private double xphour;
- private double currentVer = xScriptxChopper.class.getAnnotation(ScriptManifest.class).version();
- //LONG
- private long startTime = System.currentTimeMillis();
- private long millis;
- private long hours;
- private long minutes;
- private long seconds;
- //RSBOT API
- private RSObject Willow;
- private RSObject secondTree;
- private RSTile[] portSarimPath = {new RSTile(3058, 3253), new RSTile(3048, 3246), new RSTile(3042, 3242), new RSTile(3047, 3236)};
- private RSTile[] DraynorPath = {new RSTile(3086, 3234), new RSTile(3085, 3239), new RSTile(3087, 3247), new RSTile(3092, 3243)};
- private RSTile[] rimmingtonPath = {new RSTile(2969, 3195), new RSTile(2968, 3198), new RSTile(2962, 3203), new RSTile(2956, 3208), new RSTile(2951, 3214), new RSTile(2949, 3216)};
- private RSTile[] path;
- private RSArea areaWillow;
- private RSArea areaBank;
- /* START OF GUI */
- public class gui extends javax.swing.JFrame {
- public gui() {
- initComponents();
- }
- @SuppressWarnings("unchecked")
- private void initComponents() {
- this.setTitle("xScriptx - Universal Willow Chopper");
- WindowUtil.position(this);
- label1 = new java.awt.Label();
- label2 = new java.awt.Label();
- jComboBox1 = new javax.swing.JComboBox();
- jLabel1 = new javax.swing.JLabel();
- jSlider1 = new javax.swing.JSlider();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel4 = new javax.swing.JLabel();
- button1 = new java.awt.Button();
- setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
- setResizable(false);
- label1.setAlignment(java.awt.Label.CENTER);
- label1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- label1.setFont(new java.awt.Font("Verdana", 1, 36));
- label1.setForeground(new java.awt.Color(255, 51, 51));
- label1.setText("xScriptx");
- label2.setAlignment(java.awt.Label.CENTER);
- label2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- label2.setFont(new java.awt.Font("Verdana", 1, 24));
- label2.setForeground(new java.awt.Color(102, 255, 102));
- label2.setText("Willow Chopper");
- jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PowerChop", "PortSarim", "Draynor", "Rimmington" }));
- jComboBox1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jComboBox1ActionPerformed(evt);
- }
- });
- jLabel1.setText("Location/Powerchop:");
- jSlider1.setMaximum(3);
- jSlider1.setMinimum(1);
- jSlider1.setPaintTicks(true);
- jSlider1.setSnapToTicks(true);
- jSlider1.setValue(2);
- jLabel2.setText("Optimized");
- jLabel3.setText("Human");
- jLabel4.setText("Fast");
- button1.setFont(new java.awt.Font("Verdana", 1, 18));
- button1.setLabel("Start");
- button1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- button1ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(label1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(label2, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(10, 10, 10)
- .addComponent(jSlider1, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jLabel3)
- .addGap(78, 78, 78)
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 84, Short.MAX_VALUE)
- .addComponent(jLabel4))
- .addGroup(layout.createSequentialGroup()
- .addGap(93, 93, 93)
- .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(4, 4, 4)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3)
- .addComponent(jLabel2)
- .addComponent(jLabel4))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- pack();
- }
- private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
- }
- private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
- gui.setVisible(false);
- startScript = true;
- }
- private java.awt.Button button1;
- private javax.swing.JComboBox jComboBox1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JSlider jSlider1;
- private java.awt.Label label1;
- private java.awt.Label label2;
- }
- /* END OF GUI */
- /* START OF METHODS */
- private boolean checkForUpdates() {
- try {
- double newVer = -1;
- URL url = new URL(UPDATER_URL);
- BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
- String line, lines = "";
- Matcher m;
- while ((line = in.readLine()) != null) {
- lines += line + "\n";
- if ((m = UPDATER_VERSION_PATTERN.matcher(line)).find()) {
- newVer = Double.parseDouble(m.group(1));
- break;
- }
- }
- if (newVer < 0) {
- in.close();
- log("Unable to find the new version - update failed");
- return false;
- }
- if (currentVer == newVer) {
- in.close();
- log("You have the latest script version");
- return false;
- }
- log("Update found! Downloading version " + newVer);
- String scriptFilePath = GlobalConfiguration.Paths.getScriptsSourcesDirectory() + "\\" + UPDATER_FILE_NAME;
- PrintWriter out = new PrintWriter(scriptFilePath);
- out.print(lines);
- while ((line = in.readLine()) != null) {
- out.println(line);
- }
- out.close();
- in.close();
- log("Successfully saved " + UPDATER_FILE_NAME + " to " + GlobalConfiguration.Paths.getScriptsSourcesDirectory());
- log.warning("Please compile scripts to run the latest version.");
- logout = true;
- return true;
- } catch (IOException e) {
- log(e.toString());
- log("Update failed.");
- }
- return false;
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (IOException e) {
- return null;
- }
- }
- public void messages() {
- URLConnection url = null;
- BufferedReader in = null;
- try {
- url = new URL("http://xscriptx.atwebpages.com/messages.txt").openConnection();
- in = new BufferedReader(new InputStreamReader(url.getInputStream()));
- String message = in.readLine();
- if (message != null) {
- log.warning(message);
- }
- in.close();
- } catch (IOException e) {
- }
- }
- public boolean shopIsOpen(RSInterface shop, int millis) {
- if (millis < 0) {
- return false;
- }
- if (shop == null) {
- return false;
- }
- long startTime = System.currentTimeMillis();
- while (System.currentTimeMillis() - startTime <= millis) {
- if (shop.isValid()) {
- return true;
- }
- sleep(200);
- }
- return false;
- }
- public void useBank() {
- try{
- status = "I am Banking";
- if (bankMode == 1 || bankMode == 2) {
- RSObject banker = objects.getNearest(BankId);
- if (banker != null && !banker.isOnScreen()) {
- camera.turnToObject(banker);
- }
- if (bankMode == 1) {
- if(!bank.isOpen() && banker != null){
- banker.doAction("Use-quickly");
- sleep(random(800, 1000));
- }if(bank.isOpen() && inventory.isFull()){
- bank.depositAllExcept(Hatchets);
- sleep(random(800, 1000));
- sleep(random(800, 1000));
- }if (bank.isOpen() && !inventory.isFull()){
- bank.close();
- sleep(random(800, 1000));
- }
- } else if (bankMode == 2) {
- if(!bank.isDepositOpen() && !getMyPlayer().isMoving() && banker != null){
- banker.doAction("Deposit");
- sleep(random(3000, 4000));
- } if(bank.isDepositOpen() && bank.getBoxCount() == 28){
- bank.depositAllExcept(Hatchets);
- sleep(random(800, 1000));
- }if (bank.isDepositOpen()&& bank.getBoxCount() != 28){
- bank.close();
- sleep(random(1000, 1500));
- }
- }
- } else if(bankMode == 3) {
- RSNPC shoper = npcs.getNearest(storeNpc);
- if (!shoper.isOnScreen() && shoper != null) {
- camera.turnToCharacter(shoper);
- }
- if (shoper.isOnScreen() && shoper != null) {
- if (!store.isOpen()) {
- shoper.doAction("Trade");
- sleep(random(800, 1000));
- shopIsOpen(store.getInterface(), random(3000, 3500));
- }
- if (store.isOpen()) {
- inventory.getItem(1519).doAction("Sell 50");
- if (inventory.contains(1511)) {
- inventory.getItem(1511).doAction("Sell 5");
- }
- sleep(random(800, 1000));
- sleep(random(800, 1000));
- cameraHandler();
- }
- }
- }
- }catch(Exception e){
- log.warning("Error at useBank() - Please report to thread.");
- }
- }
- public void walkToTrees() {
- status = "I am going to the Willow trees";
- RSTilePath willow = walking.newTilePath(path);
- willow.reverse();
- willow.traverse();
- sleep(1000);
- }
- private void walkToBank() {
- status = "I am going to bank";
- RSTilePath banking = walking.newTilePath(path);
- banking.traverse();
- sleep(1000);
- }
- private boolean atWillowTrees() {
- return areaWillow.contains(getMyPlayer().getLocation());
- }
- private boolean atBank() {
- return areaBank.contains(getMyPlayer().getLocation());
- }
- private void bank() {
- try{
- if (!atBank() && inventory.isFull() && !bank.isOpen()){
- while (!atBank()) {
- walkToBank();
- }
- }
- if (atBank() && inventory.isFull()) {
- sleep(random(800, 1100));
- useBank();
- }
- if(!bank.isOpen() && !bank.isDepositOpen()){
- if(!inventory.isFull())
- walkToTrees();
- }
- }catch(Exception e){
- log.warning("Error at Bank() - Please report to thread.");
- }
- }
- public void configureMode() {
- if (gui.jComboBox1.getSelectedItem() == "PowerChop") {
- mode = 1;
- }
- if (gui.jComboBox1.getSelectedItem() == "PortSarim") {
- bankMode = 2;
- areaBank = new RSArea(new RSTile(3043, 3235), new RSTile(3050, 3237));
- areaWillow = new RSArea(new RSTile(3056, 3250), new RSTile(3064, 3256));
- path = portSarimPath;
- mode = 2;
- BankId = 36788;
- }
- if (gui.jComboBox1.getSelectedItem() == "Draynor") {
- bankMode = 1;
- areaBank = new RSArea(new RSTile(3092, 3240), new RSTile(3095, 3246));
- areaWillow = new RSArea(new RSTile(3080, 3225), new RSTile(3091, 3239));
- path = DraynorPath;
- mode = 2;
- BankId = 2213;
- }
- if (gui.jComboBox1.getSelectedItem() == "Rimmington") {
- bankMode = 3;
- areaBank = new RSArea(new RSTile(2946, 3214), new RSTile(2949, 3218));
- areaWillow = new RSArea(new RSTile(2966, 3190), new RSTile(2976, 3198));
- path = rimmingtonPath;
- mode = 2;
- }
- }
- public RSObject findSecondTree(final RSObject nearestTree, final int... treeIDs) {
- return objects.getNearest(new Filter<RSObject>() {
- public boolean accept(RSObject trees) {
- if (nearestTree.equals(trees)) {
- return false;
- }
- for (int id : treeIDs) {
- if (trees.getID() == id) {
- return true;
- }
- }
- return false;
- }
- });
- }
- public void dropWillows() {
- try{
- if(gui.jSlider1.getValue() == 1)
- mouse.setSpeed(random(6, 7));
- if(gui.jSlider1.getValue() == 2)
- mouse.setSpeed(random(5, 6));
- if(gui.jSlider1.getValue() == 3)
- mouse.setSpeed(random(1 ,2));
- dropping = true;
- status = "I am Dropping The willow logs";
- int randomnum = random(0, 20);
- if (randomnum != 5) {
- inventory.dropAllExcept(Hatchets);
- } else {
- inventory.dropAllExcept(true, Hatchets);
- }
- mouse.setSpeed(random(6, 7));
- cameraHandler();
- dropping = false;
- }catch(Exception e){
- log.warning("Error at Drop Method - Please report to thread.");
- }
- }
- public void chop() {
- try {
- RSObject willowtree = objects.getNearest(WillowTrees);
- if (willowtree != null && getMyPlayer().getAnimation() == -1 && !getMyPlayer().isMoving()) {
- status = "I am Chopping the Willow tree";
- if (!willowtree.isOnScreen() && willowtree != null) {
- camera.turnToTile(willowtree.getLocation());
- if (calc.distanceTo(willowtree) > 3) {
- walking.walkTileMM(willowtree.getLocation());
- }
- }
- willowtree.doAction("Chop down");
- if (random(0, 3) != 1) {
- mouseHandler();
- cameraHandler();
- }
- Willow = objects.getNearest(WillowTrees);
- secondTree = findSecondTree(Willow, WillowTrees);
- int randomNum = random(1, 15);
- if (randomNum == 8) {
- camera.turnToObject(Willow);
- }
- status = "I am Chopping the Willow tree";
- int randomNum2 = random(0, 5);
- if (randomNum2 != 0) {
- sleep(random(1000, 1200));
- if (secondTree != null) {
- sleep(1000);
- secondTree.doHover();
- }
- }
- }
- sleep(random(500, 1000));
- } catch (Exception e) {
- log.warning("error at chop() - Please report to thread");
- }
- }
- /* END OF METHODS */
- /* Paint */
- public void onRepaint(Graphics g1) {
- if (game.isLoggedIn()) {
- if (startexp == 0) {
- startexp = skills.getCurrentExp(Skills.getIndex("Woodcutting"));
- }
- if (startlevel == 0) {
- startlevel = skills.getCurrentLevel(Skills.getIndex("Woodcutting"));
- }
- logs = xpGained / 67.5;
- logs = Math.round(logs);
- int CurrentWcLevel = skills.getCurrentLevel(Skills.getIndex("Woodcutting"));
- xpGained = skills.getCurrentExp(Skills.getIndex("Woodcutting")) - startexp;
- levelsGained = CurrentWcLevel - startlevel;
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- xpsec = 0;
- final int percent = skills.getPercentToNextLevel(Skills.getIndex("Woodcutting"));
- int nextlevel = CurrentWcLevel + 1;
- if ((minutes > 0 || hours > 0 || seconds > 0) && xpGained > 0) {
- xpsec = ((float) xpGained) / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
- xpmin = xpsec * 60;
- xphour = xpmin * 60;
- xphour = Math.round(xphour * 100.0) / 100.0;
- }
- Graphics2D g = (Graphics2D) g1;
- RSObject[] allObjects = objects.getAll();
- RSObject Trees = objects.getNearest(WillowTrees);
- for (int i = 0; i < allObjects.length; i++) {
- if (allObjects[i].getID() == 5551 || allObjects[i].getID() == 5552 || allObjects[i].getID() == 5553) {
- g.setColor(Color.green);
- g.fillOval(calc.tileToMinimap(allObjects[i].getLocation()).x - 6, calc.tileToMinimap(allObjects[i].getLocation()).y - 4, 10, 10);
- } else if (allObjects[i].getID() == 5554) {
- g.setColor(Color.red);
- g.fillOval(calc.tileToMinimap(allObjects[i].getLocation()).x - 6, calc.tileToMinimap(allObjects[i].getLocation()).y - 4, 10, 10);
- }
- }
- g.setColor(Color.orange);
- g.fillOval(calc.tileToMinimap(Trees.getLocation()).x - 6, calc.tileToMinimap(Trees.getLocation()).y - 4, 10, 10);
- g.setColor(Color.blue);
- g.drawLine(0, (int) (mouse.getLocation().getY()), 2000, (int) (mouse.getLocation().getY()));
- g.drawLine((int) (mouse.getLocation().getX()), 0, (int) (mouse.getLocation().getX()), 2000);
- g.drawLine(0, (int) (mouse.getLocation().getY() + 3), 2000, (int) (mouse.getLocation().getY() + 3));
- g.drawLine((int) (mouse.getLocation().getX() + 3), 0, (int) (mouse.getLocation().getX() + 3), 2000);
- if (normal != null) {
- final int mouse_x = mouse.getLocation().x;
- final int mouse_y = mouse.getLocation().y;
- final int mouse_x2 = mouse.getPressLocation().x;
- final int mouse_y2 = mouse.getPressLocation().y;
- final long mpt = System.currentTimeMillis()
- - mouse.getPressTime();
- if (mouse.getPressTime() == -1 || mpt >= 1000) {
- g.drawImage(normal, mouse_x - 8, mouse_y - 8, null);
- }
- if (mpt < 1000) {
- g.drawImage(clicked, mouse_x2 - 8, mouse_y2 - 8, null);
- g.drawImage(normal, mouse_x - 8, mouse_y - 8, null);
- }
- }
- if (game.isFixed()) {
- if (!hide) {
- g.drawImage(back, 9, 346, null);
- g.setColor(new Color(233, 224, 192));
- g.setColor(new Color(223, 214, 179));
- g.setStroke(new BasicStroke(1));
- g.drawRect(9, 346, 500, 127);
- g.setFont(new Font("Comic Sans MS", 0, 13));
- g.setColor(new Color(1, 1, 1));
- g.drawString("Runtime:" + hours + ":" + minutes + ":" + seconds + ".", 10, 361);
- g.drawString(scriptVersion, 480, 361);
- g.drawString("Current level: " + CurrentWcLevel, 10, 381);
- g.drawString("Exp gained: " + xpGained, 10, 402);
- g.drawString("Exp p/h: " + xphour, 10, 422);
- g.drawString("Levels gained: " + levelsGained, 10, 442);
- g.drawString("Logs: " + logs, 10, 464);
- g.setFont(new Font("Comic Sans MS", 1, 12));
- g.drawString(status, 217, 461);
- g.drawImage(logo, 200, 340, null);
- g.setColor(new Color(223, 214, 179));
- g.fillRoundRect(249, 417, 100, 11, 20, 0);
- g.setColor(Color.blue);
- g.fillRoundRect(249, 417, percent, 11, 20, 0);
- g.setColor(Color.black);
- g.drawRoundRect(249, 417, 100, 11, 20, 0);
- g.drawRoundRect(249, 417, percent, 11, 20, 0);
- g.drawString(percent + "% till level " + nextlevel, 253, 442);
- }
- g.setColor(Color.BLACK);
- g.drawRect(closeFixed.x, closeFixed.y, closeFixed.width, closeFixed.height);
- g.setColor(Color.red);
- g.fillRect(closeFixed.x, closeFixed.y, closeFixed.width, closeFixed.height);
- g.setColor(Color.white);
- g.setFont(new Font("Comic Sans MS", 0, 20));
- g.drawString("_", 489, 467);
- } else if (!game.isFixed()) {
- if (!hide) {
- g.drawImage(back, 2, 2, null);
- g.setColor(new Color(233, 224, 192));
- g.setColor(new Color(223, 214, 179));
- g.setStroke(new BasicStroke(1));
- g.drawRect(2, 2, 500, 127);
- g.setFont(new Font("Comic Sans MS", 0, 13));
- g.setColor(new Color(1, 1, 1));
- g.drawString("Runtime:" + hours + ":" + minutes + ":" + seconds + ".", 10, 20);
- g.drawString(scriptVersion, 475, 20);
- g.drawString("Current level: " + CurrentWcLevel, 10, 40);
- g.drawString("Exp gained: " + xpGained, 10, 60);
- g.drawString("Exp p/h: " + xphour, 10, 80);
- g.drawString("Levels gained: " + levelsGained, 10, 100);
- g.drawString("Logs: " + logs, 10, 120);
- g.setFont(new Font("Comic Sans MS", 1, 12));
- g.drawString(status, 217, 120);
- g.drawImage(logo, 200, 0, null);
- g.setColor(new Color(223, 214, 179));
- g.fillRoundRect(249, 75, 100, 11, 20, 0);
- g.setColor(Color.blue);
- g.fillRoundRect(249, 75, percent, 11, 20, 0);
- g.setColor(Color.black);
- g.drawRoundRect(249, 75, 100, 11, 20, 0);
- g.drawRoundRect(249, 75, percent, 11, 20, 0);
- g.drawString(percent + "% till level " + nextlevel, 253, 100);
- }
- g.setColor(Color.BLACK);
- g.drawRect(close.x, close.y, close.width, close.height);
- g.setColor(Color.red);
- g.fillRect(close.x, close.y, close.width, close.height);
- g.setColor(Color.white);
- g.setFont(new Font("Comic Sans MS", 0, 20));
- g.drawString("_", 476, 118);
- }
- if (hide) {
- }
- //Mouse
- }
- }
- /*On Start*/
- @Override
- public boolean onStart() {
- status = "Waking up...";
- log("Welcome to xScriptx Chopper");
- checkForUpdates();
- gui = new gui();
- gui.setVisible(true);
- while (!startScript) {
- sleep(100);
- }
- log("Loading paint, this may take some seconds...");
- startTime = System.currentTimeMillis();
- try {
- final URL cursorURL = new URL(
- "http://img440.imageshack.us/img440/9669/mouse.png");
- final URL cursor80URL = new URL(
- "http://img217.imageshack.us/img217/5293/mouseclicked.png");
- normal = ImageIO.read(cursorURL);
- clicked = ImageIO.read(cursor80URL);
- } catch (MalformedURLException e) {
- log("Unable to buffer cursor.");
- } catch (IOException e) {
- log("Unable to open cursor image.");
- }
- mouse.setSpeed(random(5, 7));
- messages();
- configureMode();
- return true;
- }
- /*Main Loop*/
- public int loop() {
- if (logout) {
- return -1;
- }
- if (mode == 1) {
- if (!inventory.isFull() && !dropping) {
- chop();
- }
- if (getMyPlayer().getAnimation() == 867) {
- status = "I am Chopping the Willow tree";
- int random3 = random(0, 70);
- if (random3 == 1 || random3 == 2) {
- mouseHandler();
- cameraHandler();
- }
- }
- sleep(random(200, 800));
- if (inventory.isFull() && !dropping) {
- dropWillows();
- }
- }
- if (mode == 2) {
- if (!inventory.isFull() && atWillowTrees() && !getMyPlayer().isMoving()) {
- chop();
- }
- if (getMyPlayer().getAnimation() == 867) {
- status = "I am Chopping the Willow tree";
- int random3 = random(0, 70);
- if (random3 == 1 || random3 == 2) {
- mouseHandler();
- cameraHandler();
- }
- }
- sleep(random(200, 800));
- if (inventory.isFull() || !atWillowTrees()) {
- bank();
- }
- }
- return 1;
- }
- /*On Finish*/
- @Override
- public void onFinish() {
- log("xScriptxChopper ran for " + hours + ":" + minutes + ":" + seconds + " and gained " + xpGained + " exp.");
- }
- //START: EVENTS
- public void mouseClicked(MouseEvent o) {
- mousePoint = o.getPoint();
- if (close.contains(mousePoint) && !hide) {
- hide = true;
- } else if (close.contains(mousePoint) && hide) {
- hide = false;
- }
- mousePoint = o.getPoint();
- if (closeFixed.contains(mousePoint) && !hide) {
- hide = true;
- } else if (closeFixed.contains(mousePoint) && hide) {
- hide = false;
- }
- }
- public void mouseEntered(MouseEvent o) {
- }
- public void mouseExited(MouseEvent o) {
- }
- public void mouseReleased(MouseEvent o) {
- }
- public void mousePressed(MouseEvent o) {
- }
- public void messageReceived(MessageEvent e) {
- String lastMessage = e.getMessage().toLowerCase();
- if (lastMessage.contains("you do not have a hatchet which you have the")) {
- log.warning("Error - No hatchet found");
- logout = true;
- }
- }
- //END:EVENTS
- /* START OF ANTIBAN */
- private void mouseHandler() {
- try {
- int randomNum = random(0, 50);
- if (randomNum <= 6) {
- int randomNum2 = random(0, 10);
- if (randomNum2 == 3) {
- if (game.getCurrentTab() != 1) {
- mouse.setSpeed(random(4, 9));
- status = "I am checking my wc exp";
- game.openTab(1);
- sleep(random(350, 500));
- skills.doHover(Skills.INTERFACE_WOODCUTTING);
- sleep(random(1000, 2000));
- game.openTab(4);
- mouse.moveSlightly();
- cameraHandler();
- mouse.setSpeed(random(5, 7));
- }
- } else {
- sleep(random(500, 800));
- }
- }
- if (randomNum == 30 || randomNum == 31) {
- mouse.moveOffScreen();
- sleep(random(1000, 2500));
- }
- if (randomNum >= 40) {
- status = "I am moving the mouse";
- mouse.setSpeed(random(4, 8));
- mouse.moveSlightly();
- mouse.moveRandomly(65, 250);
- mouse.setSpeed(random(6, 7));
- } else {
- sleep(random(50, 800));
- }
- sleep(random(100, 800));
- if (randomNum == 36) {
- mouse.move(random(678, 728), random(213, 232));
- }
- } catch (Exception e) {
- log.warning("Error at mouseHandler() - Trying again");
- }
- }
- private void cameraHandler() {
- try {
- int randomNum = random(0, 45);
- if (randomNum == 16 || randomNum == 12) {
- status = "I am changing camera position";
- camera.setAngle(random(100, 200));
- camera.setPitch(random(45, 90));
- camera.setAngle(random(100, 300));
- }
- if (randomNum == 10 || randomNum == 15) {
- status = "I am changing camera position";
- camera.setAngle(random(10, 100));
- }
- if (randomNum == 6) {
- status = "I am changing camera position";
- camera.setPitch(random(60, 90));
- camera.setAngle(random(50, 86));
- }
- if (randomNum == 17) {
- status = "I am changing camera position";
- camera.setPitch(random(50, 90));
- }
- if (randomNum == 38) {
- status = "I am changing camera position";
- camera.setPitch(random(68, 90));
- } else {
- sleep(random(50, 70));
- }
- } catch (Exception e) {
- log.warning("Error at cameraHandler - Trying again");
- }
- }
- /* END OF ANTIBAN */
- }