Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package choptree;
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.model.Entity;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import java.util.concurrent.TimeUnit;
- import javax.imageio.ImageIO;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.event.MouseEvent;
- import java.io.IOException;
- import java.net.URL;
- @ScriptManifest(author = "Slasher", info = "My first script", name = "Tree chopper", version = 0, logo = "")
- public class main extends Script {
- Area GEtrees = new Area(3145, 3492, 3141, 3500);
- Area WVoak = new Area(3159, 3420, 3169, 3412);
- Area GEbank = new Area(3162, 3489, 3162, 3490);
- Area WVbank = new Area(3183, 3441, 3182, 3440);
- private long timeBegan;
- private long timeRan;
- private boolean hide = false;
- private boolean dropit = false; //This boolean determines if the script will drop the logs or naw.
- private boolean GEtreecutter = false;
- private boolean WVoakcutter = false;
- private boolean Banktime = false;
- private boolean optionb = false;
- private boolean walkback = false;
- private boolean determine = true;
- private final Image bg = getImage("http://i.imgur.com/xLlbzks.png");
- @Override
- public void onStart() { //runs once
- timeBegan = System.currentTimeMillis();
- this.bot.addMouseListener(new java.awt.event.MouseListener() {
- @Override
- public void mouseReleased(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent e) {
- Point clicked = e.getPoint();;
- Rectangle paintButton = new Rectangle(405, 459, 108, 15);
- Rectangle optionbutton = new Rectangle(488, 346, 19, 18);
- Rectangle gelogs = new Rectangle(80, 370, 40, 13);
- Rectangle wvoaks = new Rectangle(160, 370, 55, 13);
- Rectangle BankDrop = new Rectangle(320, 390, 55, 13);
- if (paintButton.contains(clicked)){
- if(hide == false){
- hide = true;
- } else {
- hide = false;
- }
- }
- if(hide == false){
- if (optionbutton.contains(clicked)){
- if(optionb == false){
- optionb = true;
- } else {
- optionb = false;
- }
- }
- if(optionb == true && gelogs.contains(clicked)){
- GEtreecutter = true;
- WVoakcutter = false;
- determine = true;
- log("Gelogs have been clicked");
- }
- }
- if(optionb == true && wvoaks.contains(clicked)){
- WVoakcutter = true;
- GEtreecutter = false;
- determine = true;
- log("WVoakcutter has been clicked");
- }
- if(optionb == true && BankDrop.contains(clicked)){
- if(dropit == false){
- dropit = true;
- } else {
- dropit = false;
- }
- }
- }
- @Override
- public void mouseExited(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- // TODO Auto-generated method stub
- /*
- *
- * GUI ON/OFF
- *
- */
- }
- });
- if(GEtreecutter == true){
- if(!GEtrees.contains(myPlayer())){
- getWalking().webWalk(GEtrees);
- }
- }
- if(WVoakcutter == true){
- getWalking().webWalk(WVoak);
- }
- }
- private enum State { //What state is the bot in
- CHOPPING_GETREES, CHOPPING_WVOAKS, DROPPING, WAIT, BANKING, WALKING_FRA_BANK, DETERMINELOCATION
- };
- private State getState() { //Determine what state the bot should be in
- Entity tree = objects.closest( "Tree" ); //The closest tree
- Entity oak = objects.closest("Oak");
- if(inventory.isFull() && dropit == true) //If the inv is full and dropit is on, it will go to state DROPPING
- return State.DROPPING;
- if(inventory.isFull() && dropit == false || Banktime == true)//If the inv is full and dropit is off and its in the bank area, bank
- return State.BANKING;
- if(inventory.isEmptyExcept("Silver axe", "Bronze axe", "Black axe", "Iron axe", "Rune axe", "Steel", "Mithril axe", "Dragon axe") && walkback == true) //todo isEmptyExcept(axes) .... Tells script to walk back from bank
- return State.WALKING_FRA_BANK;
- if(tree != null && GEtreecutter == true && determine == false) //if there are trees around and none of the other states are active, cut them trees.
- return State.CHOPPING_GETREES;
- if(oak != null && WVoakcutter == true && determine == false)
- return State.CHOPPING_WVOAKS;
- if(determine == true)
- return State.DETERMINELOCATION;
- return State.WAIT; //default
- }
- @Override
- public int onLoop() throws InterruptedException { //Below is where the script actually does stuff
- switch (getState()) {
- case CHOPPING_GETREES:
- log("State.CHOPPING_GETREES");
- Entity tree = objects.closest(GEtrees, "Tree");
- if(tree != null && !myPlayer().isAnimating() ){
- tree.interact("Chop Down");
- sleep(random(1000,1200));
- }
- if(!GEtrees.contains(myPlayer()) && Banktime == false){
- determine = true;
- }
- break;
- case CHOPPING_WVOAKS:
- Entity oak = objects.closest(WVoak, "Oak");
- if(oak != null && !myPlayer().isAnimating()){
- oak.interact("Chop Down");
- sleep(random(1000,1200));
- }
- break;
- case DROPPING:
- if(dropit == true){
- inventory.dropAllExcept("Silver axe", "Bronze axe", "Black axe", "Iron axe", "Rune axe", "Steel", "Mithril axe", "Dragon axe"); //put the axe id's where the 0 is
- }
- break;
- case BANKING:
- log("Banking");
- if(GEtreecutter == true){
- getWalking().webWalk(GEbank);
- Entity banker = objects.closest("Grand Exchange Booth");
- if(banker != null){
- banker.interact("Bank");
- sleep(random(1000,1100));
- } else {
- log("No banker found");
- }
- }
- if(WVoakcutter == true){
- getWalking().webWalk(WVbank);
- Entity banker = objects.closest("Bank booth");
- if(banker != null){
- banker.interact("Bank");
- sleep(random(1000,1100));
- } else {
- log("No banker found");
- }
- }
- sleep(random(600,700));
- getBank().depositAllExcept("Silver axe", "Bronze axe", "Black axe", "Iron axe", "Rune axe", "Steel", "Mithril axe", "Dragon axe");
- log("walkback = true");
- determine = true;
- Banktime = false;
- break;
- case WALKING_FRA_BANK:
- log("Walk back from bank");
- if(GEtreecutter == true){
- getWalking().webWalk(GEtrees);
- walkback = false;
- }
- if(WVoakcutter == true){
- log("Walk back from oaks");
- getWalking().webWalk(WVoak);
- walkback = false;
- }
- break;
- case DETERMINELOCATION:
- log("State.DETERMINELOCATION");
- if(GEtreecutter == true){
- log("Determinelocation walking to getrees");
- getWalking().webWalk(GEtrees);
- log("Determine = false");
- determine = false;
- }
- if(WVoakcutter == true){
- log("WVoakcutter webwalk");
- getWalking().webWalk(WVoak);
- determine = false;
- }
- break;
- case WAIT:
- break;
- } //above is where the script actually does stuff
- if(random(1,7) == 4){
- getMouse().moveRandomly();
- } else if(random(7,20) == 9){
- getMouse().moveOutsideScreen();
- }
- if(random(1,9) == 4){
- getCamera().moveYaw(random(10,140));
- }
- //antiban above
- return random(700, 900);
- }
- @Override
- public void onExit() { //what to do when the script stops
- }
- @Override
- public void onPaint(Graphics2D g) { //Beautiful banters and such
- timeRan = System.currentTimeMillis() - this.timeBegan;
- if(hide == false){
- if(optionb == false){
- g.drawImage(bg, 2, 340, null);
- g.drawString(ft(timeRan), 100, 470);
- g.drawString("Bot Time:", 20, 470);
- if(dropit == false){
- g.drawString("Banking", 97, 400);
- } else {
- g.drawString("Dropping", 97, 400);
- }
- }
- }
- if(hide == true){
- g.drawRect(405, 459, 108, 15);
- }
- //////////////////////////////////////////////////////
- if(optionb == true){
- g.drawRect(488, 346, 19, 18);
- g.drawRect(80, 370, 45, 13);
- g.drawString("Choose Location And Log", 180, 359);
- g.drawString("GE logs", 80, 380);
- g.drawString("WV oaks", 160, 380);
- g.drawString("Toggle Bank", 320, 402);
- g.drawRect(160, 370, 55, 13);
- g.drawRect(320, 390, 75, 15); //Banking dropping rect
- }
- }
- private String ft(long duration)
- {
- String res = "";
- long days = TimeUnit.MILLISECONDS.toDays(duration);
- long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
- long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration));
- long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration));
- if (days == 0)
- {
- res = (hours + ":" + minutes + ":" + seconds);
- }
- else
- {
- res = (days + ":" + hours + ":" + minutes + ":" + seconds);
- }
- return res;
- }
- private Image getImage(String url)
- {
- try
- {
- return ImageIO.read(new URL(url));
- }
- catch (IOException e) {}
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment