Advertisement
Guest User

BerryPickerPro

a guest
Dec 27th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package berrypickerpro;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Image;
  8. import java.io.IOException;
  9. import java.net.URL;
  10. import java.text.DecimalFormat;
  11. import javax.imageio.ImageIO;
  12. import org.dreambot.api.methods.Calculations;
  13. import org.dreambot.api.methods.input.mouse.MouseSettings;
  14. import org.dreambot.api.methods.map.Area;
  15. import org.dreambot.api.methods.map.Tile;
  16. import org.dreambot.api.methods.walking.pathfinding.impl.web.WebFinder;
  17. import org.dreambot.api.methods.walking.web.node.AbstractWebNode;
  18. import org.dreambot.api.methods.walking.web.node.impl.BasicWebNode;
  19. import org.dreambot.api.script.AbstractScript;
  20. import org.dreambot.api.script.Category;
  21. import org.dreambot.api.script.ScriptManifest;
  22. import org.dreambot.api.script.listener.PaintListener;
  23. import org.dreambot.api.utilities.Timer;
  24. import org.dreambot.api.wrappers.interactive.GameObject;
  25. import BerryPicker.BerryPicker.State;
  26. import sun.font.Script;
  27. import java.io.IOException;
  28. import java.net.URL;
  29. import java.util.HashMap;
  30. import java.util.Map;
  31. import java.util.Scanner;
  32. import java.util.regex.Matcher;
  33. import java.util.regex.Pattern;
  34.  
  35. @ScriptManifest(author = "Kirito", name = "Berry Picker Pro 1", version = 0.01, description = "Picks Berries east off Varrock.", category = Category.MONEYMAKING)
  36. public class BerryPickerPro extends AbstractScript implements PaintListener {
  37.    
  38.     private long startTime = System.currentTimeMillis();
  39.     private int cost;
  40.     private int costph;
  41.     private int picked;
  42.     private int pickedph;
  43.     private double gpGained;
  44.     private double totalGpGained;
  45.     private int gpPerHour;
  46.     private int totalGpPerHour;
  47.     private long timeRan;
  48.     private long timeBegan;
  49.     public State State;
  50.  
  51.     Area BankArea = new Area(3257, 3419, 3250, 3424, 0);
  52.     //Area Bush = new Area(new Tile(3268, 3367), new Tile(3268, 3374), new Tile(3278, 3374), new Tile(3278, 3367));
  53.    
  54.     @Override
  55.     public void onStart() {
  56.         timeBegan = System.currentTimeMillis();
  57.         getCamera().rotateToPitch(383);
  58.         setStartTime(System.currentTimeMillis());
  59.         getClient().getMethodContext().getMouse().getMouseSettings();
  60.         MouseSettings.setSpeed(10);
  61.         cost = 0;
  62.         Tile test = new Tile(3278, 3374);
  63.         getWalking().walk(test);
  64.     }
  65.     public enum State {
  66.         PICK, BANK, OPENBANK, WALKBACK, HOPWORLD, NO_STATE};
  67.    
  68.         Area Bush = new Area(new Tile(3268, 3367), new Tile(3268, 3374), new Tile(3278, 3374), new Tile(3278, 3367));
  69.    
  70.         private State getState() {
  71.             GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
  72.             if (bush != null && bush.isOnScreen() && !getInventory().isFull()){ //&& getInventory().contains(item -> item != null && item.getName() != null && item.getName().contains("axe"))) {
  73.             {
  74.                 return State.PICK;
  75.             }
  76.             }
  77.             else if (getInventory().isFull())
  78.             {
  79.                 return State.BANK;
  80.             }
  81.             return State.NO_STATE;
  82.         }
  83.         private String stateParser() {
  84.              if (State == State.PICK) {
  85.                 return "Picking";
  86.             } else if (State == State.BANK) {
  87.                 return "Banking";
  88.             } else if (State == State.WALKBACK) {
  89.                 return "Walking to bushes";
  90.             } else if (State == State.NO_STATE) {
  91.                 return "No idea";
  92.         }
  93.             return null;}
  94.    
  95.    
  96.         @Override
  97.         public int onLoop() {
  98.             switch (getState()) {
  99.             case PICK:
  100.                 GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
  101.                 if (bush != null && getLocalPlayer().isStandingStill()) {
  102.                     bush.interact("Pick-from");
  103.                     picked += 1;
  104.                     cost += 354;
  105.                     getCamera().rotateToEntity(getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626));
  106.                     break;
  107.                 }
  108.                
  109.             case BANK:
  110.                 if (getInventory().isFull()){
  111.                 Tile BankArea = new Tile(3253, 3422, 0);
  112.                 getWalking().walk(BankArea);
  113.                 }
  114.                 case OPENBANK:
  115.                 if (getInventory().isFull() && getLocalPlayer().isStandingStill()){
  116.                 getBank().open();
  117.                 getBank().depositAllItems();
  118.                 getBank().close();
  119.                 }
  120.                 case WALKBACK:
  121.                     GameObject bush1 = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
  122.                     if (bush1 != null && getLocalPlayer().isStandingStill()) {
  123.                 Tile Back = new Tile(3268, 3371, 0);
  124.                 getWalking().walk(Back);
  125.                 }
  126.             case HOPWORLD:
  127.                 if (getLocalPlayer().isStandingStill()) {
  128.                 }
  129.                 break;
  130.             case NO_STATE:
  131.                     getCamera().rotateTo(Calculations.random(2400), Calculations.random(getClient().getLowestPitch(), 384));
  132.                     sleep(Calculations.random(1000, 2500));
  133.                     break;
  134.             default:
  135.                 break;
  136.             }GameObject bush = getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626);
  137.             if (bush != null && getLocalPlayer().isStandingStill()) {
  138.             }
  139.             return 300;
  140.         }
  141.  
  142.        
  143.         private int F2PWorld() {
  144.             int random = Calculations.random(1, 12);
  145.             // 1|8|16|26|35|81|82|83|84|85|93|94
  146.             int world = 0;
  147.  
  148.             if (random == 1) {
  149.             world = 1;
  150.             } else if (random == 2) {
  151.             world = 8;
  152.             } else if (random == 3) {
  153.             world = 16;
  154.             } else if (random == 4) {
  155.             world = 26;
  156.             } else if (random == 5) {
  157.             world = 35;
  158.             } else if (random == 6) {
  159.             world = 81;
  160.             } else if (random == 7) {
  161.             world = 82;
  162.             } else if (random == 8) {
  163.             world = 83;
  164.             } else if (random == 9) {
  165.             world = 84;
  166.             } else if (random == 10) {
  167.             world = 85;
  168.             } else if (random == 11) {
  169.             world = 93;
  170.             } else if (random == 12) {
  171.             world = 94;
  172.             }
  173.  
  174.             if (world != getClient().getCurrentWorld()) {
  175.             return world;
  176.             } else {
  177.             return F2PWorld();
  178.             }
  179.             }
  180.  
  181.             private void hopWorlds() {
  182.                 if (getWorldHopper().hopWorld(F2PWorld())) {
  183.                 sleep(Calculations.random(1000, 2500));
  184.                 sleepUntil(() -> getLocalPlayer().exists()
  185.                 && getClient().isLoggedIn(),
  186.                 Calculations.random(5000, 8500));
  187.                 }
  188.                 }
  189.        
  190.            
  191.             private void walkbank() {
  192.                 Tile BankArea = new Tile(3253, 3422, 0);
  193.                 getWalking().walk(BankArea);
  194.                 }
  195.            
  196.             private void walkbush() {
  197.                 Tile test = new Tile(3278, 3374);
  198.                 getWalking().walk(test);
  199.                 //getWalking.walk(Bush.getRandomTile());
  200.                 // sleepUntil(() -> Bush.contains(getLocalPlayer()), Calculations.random(100, 900));
  201.                 }
  202.        
  203.         private Image getImage(String url) {
  204.             try {
  205.                 return ImageIO.read(new URL(url));
  206.             } catch(IOException e) {
  207.                 return null;
  208.             }
  209.         }
  210.  
  211.         private final Color color1 = new Color(255, 255, 255);
  212.  
  213.         private final Font font1 = new Font("Arial", 0, 14);
  214.  
  215.         private final Image img1 = getImage("http://i64.tinypic.com/2hcohuu.png");
  216.  
  217.         public void onRepaint(Graphics g1) {
  218.             Graphics2D g = (Graphics2D)g1;
  219.             g.drawImage(img1, -5, -1, null);
  220.             g.setFont(font1);
  221.             g.setColor(color1);
  222.             g.drawString("Berry Picker Pro V0.01", 546, 461);
  223.         }
  224.            
  225.             public void pick(GameObject bush) {
  226.                 int bID = 753;
  227.                 if (getInventory().isFull()){
  228.                         if (getLocalPlayer().distance(bush) >16) {
  229.                             getWalking().walk(bush);
  230.                             sleepUntil(() ->!getLocalPlayer().isMoving(), 300);
  231.                         }else if (!getLocalPlayer().isAnimating() && !getLocalPlayer().isMoving() && bush.exists() && bush.isOnScreen()) {
  232.                             int bCount = getInventory().count(438);
  233.                             bush.interact("Pick-from");
  234.                                 if(getLocalPlayer().isAnimating()) {
  235.                                     sleepUntil(() -> getInventory().count(bID) > bCount, Calculations.random(10000, 15000));
  236.                                     picked += 1;
  237.                                     cost += 241;
  238.                                 }
  239.                         }else getCamera().rotateToEntity(getGameObjects().closest(berry -> berry.getID() == 23625 || berry.getID() == 23626));
  240.                     }else if (getInventory().isFull()) {
  241.                     }
  242.                 }
  243.  
  244.             public long getTimeRan() {
  245.                 return timeRan;
  246.             }
  247.  
  248.             public void setTimeRan(long timeRan) {
  249.                 this.timeRan = timeRan;
  250.             }
  251.  
  252.             public long getStartTime() {
  253.                 return startTime;
  254.             }
  255.  
  256.             public void setStartTime(long startTime) {
  257.                 this.startTime = startTime;
  258.             }
  259.  
  260.  
  261.             @Override
  262.             public void onPaint(Graphics g)
  263.             {
  264.                 timeRan = System.currentTimeMillis() - timeBegan;
  265.                 pickedph = (int)(picked / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
  266.                 costph = (int)(cost / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
  267.                 gpGained = picked - cost;
  268.                 totalGpGained = gpGained / 1000;
  269.                 DecimalFormat df = new DecimalFormat("#");
  270.                 g.drawString(" "+ df.format(totalGpGained) + " ", 1,1);
  271.                 gpPerHour = (int)(gpGained / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
  272.                 totalGpPerHour = gpPerHour / 1000;
  273.                 //g.drawString("GP Per hour:" + df.format(totalGpPerHour) + "", 10, 320);
  274.                 g.drawImage(img1, 4, -1, null);
  275.                  g.drawString("Runtime: " + Timer.formatTime(System.currentTimeMillis() - startTime), 10, 240);
  276.                  g.drawString("Berries Picked/ph: " + picked +  " ["+ pickedph + "]", 10, 280);
  277.                  g.drawString("Status: " + stateParser(), 10, 260);
  278.                  g.drawString("Profit/ph: " + cost +  " ["+ costph + "]", 10, 300);
  279.             }
  280.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement