Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Walking from Varrock east mine to Varrock east bank


    Kirito

    Recommended Posts

     

    solved ot but now everytime it has to walk back it walks between the east gate and the bank then keeps turning the screen over and over again -.-

     

     

    Edit:

    it runs till it is here

    2dee033566d154170533916a45b2ffaa.png

     

    then just thinks that it should look for bushs :(

     

     

    Edit 2:

    forgot to include what i changed

    case BANK:
    if (getInventory().isFull()){
    Tile BankArea = new Tile(3253, 3422, 0);
    getWalking().walk(BankArea);
    }
    case OPENBANK:
    if (getInventory().isFull() && getLocalPlayer().isStandingStill()){
    getBank().open();
    getBank().depositAllItems();
    getBank().close();
    }
    case WALKBACK:
    if (getInventory().isEmpty() && getLocalPlayer().isStandingStill()){
    Tile Back = new Tile(3273, 3370, 0);
    getWalking().walk(Back);
    }

     

    :D glad to see you fixed that part bro. can you copy and paste the full code so i can see where it goes wrong?

    Link to comment
    Share on other sites

    :D glad to see you fixed that part bro. can you copy and paste the full code so i can see where it goes wrong?

    sure :P i have been looking and removing things then re-adding them in ended up the bank walk worked but now for the walk back part -.- i have been looking since your last post and i cant get this thing solved out -.-

     

     

    i also cleaned up the code for unused parts 

     

     

    i'l add the code here and post a pastebin link 2 :)

    http://pastebin.com/TuquUk9Z

    package berrypickerpro;
     
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.io.IOException;
    import java.net.URL;
    import java.text.DecimalFormat;
    import javax.imageio.ImageIO;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.input.mouse.MouseSettings;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.methods.walking.pathfinding.impl.web.WebFinder;
    import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
    import org.dreambot.api.methods.walking.web.node.impl.BasicWebNode;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.listener.PaintListener;
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import BerryPicker.BerryPicker.State;
    import sun.font.Script;
    import java.io.IOException;
    import java.net.URL;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Scanner;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
     
    @ScriptManifest(author = "Kirito", name = "Berry Picker Pro 1", version = 0.01, description = "Picks Berries east off Varrock.", category = Category.MONEYMAKING)
    public class BerryPickerPro extends AbstractScript implements PaintListener {
     
    private long startTime = System.currentTimeMillis();
    private int cost;
    private int costph;
    private int picked;
    private int pickedph;
    private double gpGained;
    private double totalGpGained;
    private int gpPerHour;
    private int totalGpPerHour;
        private long timeRan;
    private long timeBegan;
    public State State;
     
    Area BankArea = new Area(3257, 3419, 3250, 3424, 0);
    //Area Bush = new Area(new Tile(3268, 3367), new Tile(3268, 3374), new Tile(3278, 3374), new Tile(3278, 3367));
     
    @Override
    public void onStart() {
    timeBegan = System.currentTimeMillis();
    getCamera().rotateToPitch(383);
            setStartTime(System.currentTimeMillis());
            getClient().getMethodContext().getMouse().getMouseSettings();
    MouseSettings.setSpeed(10);
    cost = 0; 
    Tile test = new Tile(3278, 3374);
    getWalking().walk(test);
    }
    public enum State {
    PICK, BANK, OPENBANK, WALKBACK, HOPWORLD, NO_STATE};
     
    Area Bush = new Area(new Tile(3268, 3367), new Tile(3268, 3374), new Tile(3278, 3374), new Tile(3278, 3367));
     
    private State getState() {
    GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush != null && bush.isOnScreen() && !getInventory().isFull()){ //&& getInventory().contains(item -> item != null && item.getName() != null && item.getName().contains("axe"))) {
           {
               return State.PICK;
           } 
    }
           else if (getInventory().isFull())
           {
               return State.BANK;
           }
           return State.NO_STATE;
       }
    private String stateParser() {
            if (State == State.PICK) {
               return "Picking";
           } else if (State == State.BANK) {
               return "Banking";
           } else if (State == State.WALKBACK) {
               return "Walking to bushes";
           } else if (State == State.NO_STATE) {
               return "No idea";
       }
    return null;}
     
     
    @Override
    public int onLoop() {
    switch (getState()) {
    case PICK:
    GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush != null && getLocalPlayer().isStandingStill()) {
    bush.interact("Pick-from");
    picked += 1;
    cost += 354;
    getCamera().rotateToEntity(getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626));
    break;
    }
     
    case BANK:
    if (getInventory().isFull()){
    Tile BankArea = new Tile(3253, 3422, 0);
    getWalking().walk(BankArea);
    }
    case OPENBANK:
    if (getInventory().isFull() && getLocalPlayer().isStandingStill()){
    getBank().open();
    getBank().depositAllItems();
    getBank().close();
    }
    case WALKBACK:
    GameObject bush1 = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush1 != null && getLocalPlayer().isStandingStill()) {
    Tile Back = new Tile(3268, 3371, 0);
    getWalking().walk(Back);
    }
    case HOPWORLD:
    if (getLocalPlayer().isStandingStill()) {
    }
    break;
    case NO_STATE:
    getCamera().rotateTo(Calculations.random(2400), Calculations.random(getClient().getLowestPitch(), 384));
    sleep(Calculations.random(1000, 2500));
    break;
    default:
    break;
    }GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush != null && getLocalPlayer().isStandingStill()) {
    }
    return 300;
    }
     
     
    private int F2PWorld() {
    int random = Calculations.random(1, 12);
    // 1|8|16|26|35|81|82|83|84|85|93|94
    int world = 0;
     
    if (random == 1) {
    world = 1;
    } else if (random == 2) {
    world = 8;
    } else if (random == 3) {
    world = 16;
    } else if (random == 4) {
    world = 26;
    } else if (random == 5) {
    world = 35;
    } else if (random == 6) {
    world = 81;
    } else if (random == 7) {
    world = 82;
    } else if (random == 8) {
    world = 83;
    } else if (random == 9) {
    world = 84;
    } else if (random == 10) {
    world = 85;
    } else if (random == 11) {
    world = 93;
    } else if (random == 12) {
    world = 94;
    }
     
    if (world != getClient().getCurrentWorld()) {
    return world;
    } else {
    return F2PWorld();
    }
    }
     
    private void hopWorlds() {
    if (getWorldHopper().hopWorld(F2PWorld())) {
    sleep(Calculations.random(1000, 2500));
    sleepUntil(() -> getLocalPlayer().exists()
    && getClient().isLoggedIn(),
    Calculations.random(5000, 8500));
    }
    } 
     
     
    private void walkbank() {
    Tile BankArea = new Tile(3253, 3422, 0);
    getWalking().walk(BankArea);
    } 
     
    private void walkbush() {
    Tile test = new Tile(3278, 3374);
    getWalking().walk(test);
    //getWalking.walk(Bush.getRandomTile());
       // sleepUntil(() -> Bush.contains(getLocalPlayer()), Calculations.random(100, 900));
    } 
     
       private Image getImage(String url) {
           try {
               return ImageIO.read(new URL(url));
           } catch(IOException e) {
               return null;
           }
       }
     
       private final Color color1 = new Color(255, 255, 255);
     
       private final Font font1 = new Font("Arial", 0, 14);
     
       private final Image img1 = getImage("http://i64.tinypic.com/2hcohuu.png");
     
       public void onRepaint(Graphics g1) {
           Graphics2D g = (Graphics2D)g1;
           g.drawImage(img1, -5, -1, null);
           g.setFont(font1);
           g.setColor(color1);
           g.drawString("Berry Picker Pro V0.01", 546, 461);
       }
       
       public void pick(GameObject bush) {
           int bID = 753;
           if (getInventory().isFull()){
                   if (getLocalPlayer().distance(bush) >16) {
                       getWalking().walk(bush);
                       sleepUntil(() ->!getLocalPlayer().isMoving(), 300);
                   }else if (!getLocalPlayer().isAnimating() && !getLocalPlayer().isMoving() && bush.exists() && bush.isOnScreen()) {
                       int bCount = getInventory().count(438);
                       bush.interact("Pick-from");
                           if(getLocalPlayer().isAnimating()) {
                               sleepUntil(() -> getInventory().count(bID) > bCount, Calculations.random(10000, 15000));
                               picked += 1;
                               cost += 241;
                           }
                   }else getCamera().rotateToEntity(getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626));
               }else if (getInventory().isFull()) {
               }
           }
     
    public long getTimeRan() {
    return timeRan;
    }
     
    public void setTimeRan(long timeRan) {
    this.timeRan = timeRan;
    }
     
    public long getStartTime() {
    return startTime;
    }
     
    public void setStartTime(long startTime) {
    this.startTime = startTime;
    }
     
     
    @Override
       public void onPaint(Graphics g)
       {
    timeRan = System.currentTimeMillis() - timeBegan;
    pickedph = (int)(picked / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    costph = (int)(cost / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    gpGained = picked - cost;
    totalGpGained = gpGained / 1000;
    DecimalFormat df = new DecimalFormat("#");
    g.drawString(" "+ df.format(totalGpGained) + " ", 1,1);
    gpPerHour = (int)(gpGained / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    totalGpPerHour = gpPerHour / 1000;
    //g.drawString("GP Per hour:" + df.format(totalGpPerHour) + "", 10, 320);
    g.drawImage(img1, 4, -1, null);
    g.drawString("Runtime: " + Timer.formatTime(System.currentTimeMillis() - startTime), 10, 240);
    g.drawString("Berries Picked/ph: " + picked +  " ["+ pickedph + "]", 10, 280);
    g.drawString("Status: " + stateParser(), 10, 260);
    g.drawString("Profit/ph: " + cost +  " ["+ costph + "]", 10, 300);
       }
    }
    
    Link to comment
    Share on other sites

     

    sure :P i have been looking and removing things then re-adding them in ended up the bank walk worked but now for the walk back part -.- i have been looking since your last post and i cant get this thing solved out -.-

     

     

    i also cleaned up the code for unused parts 

     

     

    i'l add the code here and post a pastebin link 2 :)

    http://pastebin.com/TuquUk9Z

    package berrypickerpro;
     
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.io.IOException;
    import java.net.URL;
    import java.text.DecimalFormat;
    import javax.imageio.ImageIO;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.input.mouse.MouseSettings;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.methods.walking.pathfinding.impl.web.WebFinder;
    import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
    import org.dreambot.api.methods.walking.web.node.impl.BasicWebNode;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.listener.PaintListener;
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import BerryPicker.BerryPicker.State;
    import sun.font.Script;
    import java.io.IOException;
    import java.net.URL;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Scanner;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
     
    @ScriptManifest(author = "Kirito", name = "Berry Picker Pro 1", version = 0.01, description = "Picks Berries east off Varrock.", category = Category.MONEYMAKING)
    public class BerryPickerPro extends AbstractScript implements PaintListener {
     
    private long startTime = System.currentTimeMillis();
    private int cost;
    private int costph;
    private int picked;
    private int pickedph;
    private double gpGained;
    private double totalGpGained;
    private int gpPerHour;
    private int totalGpPerHour;
        private long timeRan;
    private long timeBegan;
    public State State;
     
    Area BankArea = new Area(3257, 3419, 3250, 3424, 0);
    //Area Bush = new Area(new Tile(3268, 3367), new Tile(3268, 3374), new Tile(3278, 3374), new Tile(3278, 3367));
     
    @Override
    public void onStart() {
    timeBegan = System.currentTimeMillis();
    getCamera().rotateToPitch(383);
            setStartTime(System.currentTimeMillis());
            getClient().getMethodContext().getMouse().getMouseSettings();
    MouseSettings.setSpeed(10);
    cost = 0; 
    Tile test = new Tile(3278, 3374);
    getWalking().walk(test);
    }
    public enum State {
    PICK, BANK, OPENBANK, WALKBACK, HOPWORLD, NO_STATE};
     
    Area Bush = new Area(new Tile(3268, 3367), new Tile(3268, 3374), new Tile(3278, 3374), new Tile(3278, 3367));
     
    private State getState() {
    GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush != null && bush.isOnScreen() && !getInventory().isFull()){ //&& getInventory().contains(item -> item != null && item.getName() != null && item.getName().contains("axe"))) {
           {
               return State.PICK;
           } 
    }
           else if (getInventory().isFull())
           {
               return State.BANK;
           }
           return State.NO_STATE;
       }
    private String stateParser() {
            if (State == State.PICK) {
               return "Picking";
           } else if (State == State.BANK) {
               return "Banking";
           } else if (State == State.WALKBACK) {
               return "Walking to bushes";
           } else if (State == State.NO_STATE) {
               return "No idea";
       }
    return null;}
     
     
    @Override
    public int onLoop() {
    switch (getState()) {
    case PICK:
    GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush != null && getLocalPlayer().isStandingStill()) {
    bush.interact("Pick-from");
    picked += 1;
    cost += 354;
    getCamera().rotateToEntity(getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626));
    break;
    }
     
    case BANK:
    if (getInventory().isFull()){
    Tile BankArea = new Tile(3253, 3422, 0);
    getWalking().walk(BankArea);
    }
    case OPENBANK:
    if (getInventory().isFull() && getLocalPlayer().isStandingStill()){
    getBank().open();
    getBank().depositAllItems();
    getBank().close();
    }
    case WALKBACK:
    GameObject bush1 = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush1 != null && getLocalPlayer().isStandingStill()) {
    Tile Back = new Tile(3268, 3371, 0);
    getWalking().walk(Back);
    }
    case HOPWORLD:
    if (getLocalPlayer().isStandingStill()) {
    }
    break;
    case NO_STATE:
    getCamera().rotateTo(Calculations.random(2400), Calculations.random(getClient().getLowestPitch(), 384));
    sleep(Calculations.random(1000, 2500));
    break;
    default:
    break;
    }GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush != null && getLocalPlayer().isStandingStill()) {
    }
    return 300;
    }
     
     
    private int F2PWorld() {
    int random = Calculations.random(1, 12);
    // 1|8|16|26|35|81|82|83|84|85|93|94
    int world = 0;
     
    if (random == 1) {
    world = 1;
    } else if (random == 2) {
    world = 8;
    } else if (random == 3) {
    world = 16;
    } else if (random == 4) {
    world = 26;
    } else if (random == 5) {
    world = 35;
    } else if (random == 6) {
    world = 81;
    } else if (random == 7) {
    world = 82;
    } else if (random == 8) {
    world = 83;
    } else if (random == 9) {
    world = 84;
    } else if (random == 10) {
    world = 85;
    } else if (random == 11) {
    world = 93;
    } else if (random == 12) {
    world = 94;
    }
     
    if (world != getClient().getCurrentWorld()) {
    return world;
    } else {
    return F2PWorld();
    }
    }
     
    private void hopWorlds() {
    if (getWorldHopper().hopWorld(F2PWorld())) {
    sleep(Calculations.random(1000, 2500));
    sleepUntil(() -> getLocalPlayer().exists()
    && getClient().isLoggedIn(),
    Calculations.random(5000, 8500));
    }
    } 
     
     
    private void walkbank() {
    Tile BankArea = new Tile(3253, 3422, 0);
    getWalking().walk(BankArea);
    } 
     
    private void walkbush() {
    Tile test = new Tile(3278, 3374);
    getWalking().walk(test);
    //getWalking.walk(Bush.getRandomTile());
       // sleepUntil(() -> Bush.contains(getLocalPlayer()), Calculations.random(100, 900));
    } 
     
       private Image getImage(String url) {
           try {
               return ImageIO.read(new URL(url));
           } catch(IOException e) {
               return null;
           }
       }
     
       private final Color color1 = new Color(255, 255, 255);
     
       private final Font font1 = new Font("Arial", 0, 14);
     
       private final Image img1 = getImage("http://i64.tinypic.com/2hcohuu.png");
     
       public void onRepaint(Graphics g1) {
           Graphics2D g = (Graphics2D)g1;
           g.drawImage(img1, -5, -1, null);
           g.setFont(font1);
           g.setColor(color1);
           g.drawString("Berry Picker Pro V0.01", 546, 461);
       }
       
       public void pick(GameObject bush) {
           int bID = 753;
           if (getInventory().isFull()){
                   if (getLocalPlayer().distance(bush) >16) {
                       getWalking().walk(bush);
                       sleepUntil(() ->!getLocalPlayer().isMoving(), 300);
                   }else if (!getLocalPlayer().isAnimating() && !getLocalPlayer().isMoving() && bush.exists() && bush.isOnScreen()) {
                       int bCount = getInventory().count(438);
                       bush.interact("Pick-from");
                           if(getLocalPlayer().isAnimating()) {
                               sleepUntil(() -> getInventory().count(bID) > bCount, Calculations.random(10000, 15000));
                               picked += 1;
                               cost += 241;
                           }
                   }else getCamera().rotateToEntity(getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626));
               }else if (getInventory().isFull()) {
               }
           }
     
    public long getTimeRan() {
    return timeRan;
    }
     
    public void setTimeRan(long timeRan) {
    this.timeRan = timeRan;
    }
     
    public long getStartTime() {
    return startTime;
    }
     
    public void setStartTime(long startTime) {
    this.startTime = startTime;
    }
     
     
    @Override
       public void onPaint(Graphics g)
       {
    timeRan = System.currentTimeMillis() - timeBegan;
    pickedph = (int)(picked / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    costph = (int)(cost / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    gpGained = picked - cost;
    totalGpGained = gpGained / 1000;
    DecimalFormat df = new DecimalFormat("#");
    g.drawString(" "+ df.format(totalGpGained) + " ", 1,1);
    gpPerHour = (int)(gpGained / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    totalGpPerHour = gpPerHour / 1000;
    //g.drawString("GP Per hour:" + df.format(totalGpPerHour) + "", 10, 320);
    g.drawImage(img1, 4, -1, null);
    g.drawString("Runtime: " + Timer.formatTime(System.currentTimeMillis() - startTime), 10, 240);
    g.drawString("Berries Picked/ph: " + picked +  " ["+ pickedph + "]", 10, 280);
    g.drawString("Status: " + stateParser(), 10, 260);
    g.drawString("Profit/ph: " + cost +  " ["+ costph + "]", 10, 300);
       }
    }
    

     

    It doesn't look like you're using those other states, so your getState() could just be:

    private State getState() {
       if(getInventory().isFull()) {
           return State.BANK;
        }
       return State.PICK;
    }

    in PICK, you could say something like:

    if(bushArea.contains(getLocalPlayer()) {
         if(there is a valid bush) {
            pick bush;
         } else {
           hop worlds;
         }
    } else {
        getWalking().walk(bushArea.getRandomTile());
    }

    in BANK you could say something like:

    if(bankArea.contains(getLocalPlayer()) {
       if(getBank().isOpen()) {
          getBank().depositAll();
      } else {
          getBank().open();
      }
    } else {
       getWalking().walk(bankArea.getRandomTile());
    }
       
    Link to comment
    Share on other sites

     

    It doesn't look like you're using those other states, so your getState() could just be:

    private State getState() {
       if(getInventory().isFull()) {
           return State.BANK;
        }
       return State.PICK;
    }

    in PICK, you could say something like:

    if(bushArea.contains(getLocalPlayer()) {
         if(there is a valid bush) {
            pick bush;
         } else {
           hop worlds;
         }
    } else {
        getWalking().walk(bushArea.getRandomTile());
    }

    in BANK you could say something like:

    if(bankArea.contains(getLocalPlayer()) {
       if(getBank().isOpen()) {
          getBank().depositAll();
      } else {
          getBank().open();
      }
    } else {
       getWalking().walk(bankArea.getRandomTile());
    }
       

    yeh for some reason it dosn't reconize the other states :(

    Link to comment
    Share on other sites

    yes.. thats because they're not in your getState() like I said. Read out my full suggestion.

    hmm ok so i copied what you said about the getState() and i still get that same error lol but gonna fix the other parts first ^^

     

     

     

    Edit:

    Testing it :) gotta take a look about the getState() and stateparser() tough :/

    yes.. thats because they're not in your getState() like I said. Read out my full suggestion.

    Next problem :) now it hops worlds even tough a bush is on screen

     

    Edit:

     

    Adding 

     

    if (bush != null && getLocalPlayer().isStandingStill()) {
    just makes the localplayer stand there till all bush's have been regrown

    should have kept my hands off it -.- now it won't run to bank 

     

     

     

     

    package berrypickerpro;
     
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.io.IOException;
    import java.net.URL;
    import java.text.DecimalFormat;
    import javax.imageio.ImageIO;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.input.mouse.MouseSettings;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.listener.PaintListener;
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.wrappers.interactive.GameObject;
     
    @ScriptManifest(author = "Kirito", name = "Berry Picker Pro 1", version = 0.01, description = "Picks Berries east off Varrock.", category = Category.MONEYMAKING)
    public class BerryPickerPro extends AbstractScript implements PaintListener {
     
    private long startTime = System.currentTimeMillis();
    private int cost;
    private int costph;
    private int picked;
    private int pickedph;
    private double gpGained;
    private double totalGpGained;
    private int gpPerHour;
    private int totalGpPerHour;
        private long timeRan;
    private long timeBegan;
    public State State;
     
    //Area Bush = new Area(new Tile(3268, 3367), new Tile(3268, 3374), new Tile(3278, 3374), new Tile(3278, 3367));
     
    @Override
    public void onStart() {
    timeBegan = System.currentTimeMillis();
    getCamera().rotateToPitch(383);
            setStartTime(System.currentTimeMillis());
            getClient().getMethodContext().getMouse().getMouseSettings();
    MouseSettings.setSpeed(10);
    cost = 0; 
     
    }
    public enum State {
    PICK, BANK, OPENBANK, WALKBACK, HOPWORLD, NO_STATE};
     
    Area Bush = new Area(new Tile(3268, 3367), new Tile(3268, 3374), new Tile(3278, 3374), new Tile(3278, 3367));
    Area BankArea = new Area(3257, 3419, 3250, 3424, 0);
     
    private State getState() {
      if(getInventory().isFull()) {
          return State.BANK;
       }else{
      return State.PICK;
    }
    }
    private String stateParser() {
            if (State == State.PICK) {
               return "Picking";
           } else if (State == State.BANK) {
               return "Banking";
           } else if (State == State.WALKBACK) {
               return "Walking to bushes";
           } else if (State == State.NO_STATE) {
               return "No idea";
       }
    return null;}
     
     
    @Override
    public int onLoop() {
    switch (getState()) {
    case PICK:
    if(Bush.contains(getLocalPlayer())) {
    GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush != null && getLocalPlayer().isStandingStill()) {
           pickbush();
        } else {
         if (bush != null && getLocalPlayer().isStandingStill()) {
         hopWorlds();
    }
        }
    }else {
    if (Bush != null && getLocalPlayer().isStandingStill()) {
       getWalking().walk(Bush.getRandomTile());
    }
    }
    case BANK:
    if(BankArea.contains(getLocalPlayer())){
    if(getInventory().isFull()) {
      if(getBank().isOpen()) {
         getBank().depositAllItems();
     } else {
         getBank().open();
     }
    } else {
      getWalking().walk(BankArea.getRandomTile());
    }
    }
    case NO_STATE:
    //getCamera().rotateTo(Calculations.random(2400), Calculations.random(getClient().getLowestPitch(), 384));
    break;
    default:
    break;
    }
    return 300;
    }
     
    private void pickbush() {
    GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
    if (bush != null && getLocalPlayer().isStandingStill()) {
    bush.interact("Pick-from");
    picked += 1;
    cost += 354;
    getCamera().rotateToEntity(getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626));
    }
    }
     
    private int F2PWorld() {
    int random = Calculations.random(1, 12);
    // 1|8|16|26|35|81|82|83|84|85|93|94
    int world = 0;
     
    if (random == 1) {
    world = 1;
    } else if (random == 2) {
    world = 8;
    } else if (random == 3) {
    world = 16;
    } else if (random == 4) {
    world = 26;
    } else if (random == 5) {
    world = 35;
    } else if (random == 6) {
    world = 81;
    } else if (random == 7) {
    world = 82;
    } else if (random == 8) {
    world = 83;
    } else if (random == 9) {
    world = 84;
    } else if (random == 10) {
    world = 85;
    } else if (random == 11) {
    world = 93;
    } else if (random == 12) {
    world = 94;
    }
     
    if (world != getClient().getCurrentWorld()) {
    return world;
    } else {
    return F2PWorld();
    }
    }
     
    private void hopWorlds() {
    if (getWorldHopper().hopWorld(F2PWorld())) {
    sleep(Calculations.random(1000, 2500));
    sleepUntil(() -> getLocalPlayer().exists()
    && getClient().isLoggedIn(),
    Calculations.random(5000, 8500));
    }
    } 
     
     
    private void walkbank() {
    Tile BankArea = new Tile(3253, 3422, 0);
    getWalking().walk(BankArea);
    } 
     
    private void walkbush() {
    Tile test = new Tile(3278, 3374);
    getWalking().walk(test);
    //getWalking.walk(Bush.getRandomTile());
       // sleepUntil(() -> Bush.contains(getLocalPlayer()), Calculations.random(100, 900));
    } 
     
       private Image getImage(String url) {
           try {
               return ImageIO.read(new URL(url));
           } catch(IOException e) {
               return null;
           }
       }
     
       private final Color color1 = new Color(255, 255, 255);
     
       private final Font font1 = new Font("Arial", 0, 14);
     
       private final Image img1 = getImage("http://i64.tinypic.com/2hcohuu.png");
     
       public void onRepaint(Graphics g1) {
           Graphics2D g = (Graphics2D)g1;
           g.drawImage(img1, -5, -1, null);
           g.setFont(font1);
           g.setColor(color1);
           g.drawString("Berry Picker Pro V0.01", 546, 461);
       }
       
       public void pick(GameObject bush) {
           int bID = 753;
           if (getInventory().isFull()){
                   if (getLocalPlayer().distance(bush) >16) {
                       getWalking().walk(bush);
                       sleepUntil(() ->!getLocalPlayer().isMoving(), 300);
                   }else if (!getLocalPlayer().isAnimating() && !getLocalPlayer().isMoving() && bush.exists() && bush.isOnScreen()) {
                       int bCount = getInventory().count(438);
                       bush.interact("Pick-from");
                           if(getLocalPlayer().isAnimating()) {
                               sleepUntil(() -> getInventory().count(bID) > bCount, Calculations.random(10000, 15000));
                               picked += 1;
                               cost += 241;
                           }
                   }else getCamera().rotateToEntity(getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626));
               }else if (getInventory().isFull()) {
               }
           }
     
    public long getTimeRan() {
    return timeRan;
    }
     
    public void setTimeRan(long timeRan) {
    this.timeRan = timeRan;
    }
     
    public long getStartTime() {
    return startTime;
    }
     
    public void setStartTime(long startTime) {
    this.startTime = startTime;
    }
     
     
    @Override
       public void onPaint(Graphics g)
       {
    timeRan = System.currentTimeMillis() - timeBegan;
    pickedph = (int)(picked / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    costph = (int)(cost / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    gpGained = picked - cost;
    totalGpGained = gpGained / 1000;
    DecimalFormat df = new DecimalFormat("#");
    g.drawString(" "+ df.format(totalGpGained) + " ", 1,1);
    gpPerHour = (int)(gpGained / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
    totalGpPerHour = gpPerHour / 1000;
    //g.drawString("GP Per hour:" + df.format(totalGpPerHour) + "", 10, 320);
    g.drawImage(img1, 4, -1, null);
    g.drawString("Runtime: " + Timer.formatTime(System.currentTimeMillis() - startTime), 10, 240);
    g.drawString("Berries Picked/ph: " + picked +  " ["+ pickedph + "]", 10, 280);
    g.drawString("Status: " + stateParser(), 10, 260);
    g.drawString("Profit/ph: " + cost +  " ["+ costph + "]", 10, 300);
       }
    }
     
    
    why did i even touch the code when it was working -.-
    Link to comment
    Share on other sites

     

    why did i even touch the code when it was working -.-

     

     

    This was getting tiring so I just decided to write it up myself, took like 5 minutes, and another 5 minutes to test. Works flawlessly. If you have any questions, ask me.

    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.utilities.impl.Condition;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    @ScriptManifest(author = "Im A Baller", name = "Here you go", version = 1.0, description = "", category = Category.MISC)
    public class Main extends AbstractScript {
    	private final int[] f2pWorlds = {1, 8, 26, 35, 82, 83, 84, 93, 94};
    	
    	private Area bankArea = new Area(3250, 3423, 3257, 3419);
    	private Area bushArea = new Area(3280, 3375, 3267, 3366);
    
    	private enum State {
    		PICK,BANK
    	};
    
    	private State getState() {
    		if (getInventory().isFull()) {
    			return State.BANK;
    		}
    		return State.PICK;
    	}
    
    	@Override
    	public int onLoop() {
    		switch (getState()) {
    		case BANK:
    			if (bankArea.contains(getLocalPlayer())) {
    				if (getBank().isOpen()) {
    					getBank().depositAllItems();
    				} else {
    					getBank().open();
    				}
    				return Calculations.random(400, 800);
    			}
    			getWalking().walk(bankArea.getRandomTile());
    			break;
    		case PICK:
    			if(bushArea.contains(getLocalPlayer())) {
    				GameObject myBush = getGameObjects().closest(23625, 23626);
    				if (myBush != null) {
    					long berryCount = getInventory().count("Cadava berries");
    					if (myBush.interact("Pick-from")) {
    						sleepUntil(new Condition() {
    							@Override
    							public boolean verify() {
    								return getInventory().count("Cadava berries") > berryCount;
    							}
    						}, 4000);
    						return Calculations.random(200, 300);
    					}
    				} else {
    					getWorldHopper().hopWorld(getF2pWorld());
    				}
    			} else {
    				getWalking().walk(bushArea.getRandomTile());
    			}
    			break;
    		}
    		return Calculations.random(400, 800);
    	}
    	
    	private int getF2pWorld() {
    		int myWorld = f2pWorlds[Calculations.random(0, f2pWorlds.length - 1)];
    		while(myWorld == getClient().getCurrentWorld()) {
    			myWorld = f2pWorlds[Calculations.random(0, f2pWorlds.length - 1)];
    		}
    		return myWorld;
    	}
    }
    
    Link to comment
    Share on other sites

     

    This was getting tiring so I just decided to write it up myself, took like 5 minutes, and another 5 minutes to test. Works flawlessly. If you have any questions, ask me.

    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.utilities.impl.Condition;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    @ScriptManifest(author = "Im A Baller", name = "Here you go", version = 1.0, description = "", category = Category.MISC)
    public class Main extends AbstractScript {
    	private final int[] f2pWorlds = {1, 8, 26, 35, 82, 83, 84, 93, 94};
    	
    	private Area bankArea = new Area(3250, 3423, 3257, 3419);
    	private Area bushArea = new Area(3280, 3375, 3267, 3366);
    
    	private enum State {
    		PICK,BANK
    	};
    
    	private State getState() {
    		if (getInventory().isFull()) {
    			return State.BANK;
    		}
    		return State.PICK;
    	}
    
    	@Override
    	public int onLoop() {
    		switch (getState()) {
    		case BANK:
    			if (bankArea.contains(getLocalPlayer())) {
    				if (getBank().isOpen()) {
    					getBank().depositAllItems();
    				} else {
    					getBank().open();
    				}
    				return Calculations.random(400, 800);
    			}
    			getWalking().walk(bankArea.getRandomTile());
    			break;
    		case PICK:
    			if(bushArea.contains(getLocalPlayer())) {
    				GameObject myBush = getGameObjects().closest(23625, 23626);
    				if (myBush != null) {
    					long berryCount = getInventory().count("Cadava berries");
    					if (myBush.interact("Pick-from")) {
    						sleepUntil(new Condition() {
    							@Override
    							public boolean verify() {
    								return getInventory().count("Cadava berries") > berryCount;
    							}
    						}, 4000);
    						return Calculations.random(200, 300);
    					}
    				} else {
    					getWorldHopper().hopWorld(getF2pWorld());
    				}
    			} else {
    				getWalking().walk(bushArea.getRandomTile());
    			}
    			break;
    		}
    		return Calculations.random(400, 800);
    	}
    	
    	private int getF2pWorld() {
    		int myWorld = f2pWorlds[Calculations.random(0, f2pWorlds.length - 1)];
    		while(myWorld == getClient().getCurrentWorld()) {
    			myWorld = f2pWorlds[Calculations.random(0, f2pWorlds.length - 1)];
    		}
    		return myWorld;
    	}
    }
    

    lol ur code is lots smaller than mine o_O

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.