Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement