Advertisement
Guest User

Untitled

a guest
Nov 20th, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.24 KB | None | 0 0
  1. import org.dreambot.api.methods.Calculations;
  2.     import org.dreambot.api.methods.skills.Skill;
  3.     import org.dreambot.api.script.AbstractScript;
  4.     import org.dreambot.api.script.Category;
  5.     import org.dreambot.api.script.ScriptManifest;
  6.     import org.dreambot.api.script.listener.PaintListener;
  7.     import org.dreambot.api.utilities.Timer;
  8.     import org.dreambot.api.wrappers.interactive.GameObject;
  9.     import java.awt.*;
  10.     import java.util.*;
  11.     import java.util.List;
  12.  
  13.     /**
  14.      * Created by Hitsuu on 11/14/2015.
  15.      */
  16.  
  17.     @ScriptManifest(author = "Hitsuu", name = "Advanced Miner Script", category = Category.MINING, version = 1.0)
  18.  
  19.     public class stateminer extends AbstractScript implements PaintListener{
  20.  
  21.         private boolean startScript;
  22.         private String oreName;
  23.         private ArrayList<GameObject> ourRocks;
  24.         private long startTime = System.currentTimeMillis();
  25.         private boolean started = false;
  26.         private GameObject ourRock;
  27.         private boolean drop;
  28.  
  29.  
  30.  
  31.         public State state;
  32.         public enum State{
  33.             MINE, BANK, GET_PICKAXE, DROP
  34.         }
  35.  
  36.         @Override
  37.         public void onStart() {
  38.             super.onStart();
  39.             stateminerGUI gui = new stateminerGUI(this);
  40.             gui.setVisible(true);
  41.             getCamera().rotateToPitch(383);
  42.             getSkillTracker().start(Skill.MINING);
  43.             startTime = System.currentTimeMillis();
  44.             setStartTile(getLocalPlayer().getTile());
  45.         }
  46.  
  47.  
  48.         public State getState() {
  49.             if (getInventory().isFull() && !drop) {
  50.                 return State.BANK;
  51.             }
  52.             else if(!getInventory().contains(item -> item.getName().contains("pickaxe"))) {
  53.                 return State.GET_PICKAXE;
  54.             }
  55.             else if(drop && getInventory().contains(oreName)){
  56.                 return State.DROP;
  57.             }
  58.             else return State.MINE;
  59.         }
  60.  
  61.         private String stateParser() {
  62.             if (state == State.MINE) {
  63.                 return "Mining";
  64.             }
  65.             else if (state == State.BANK) {
  66.                 return "Banking";
  67.             }
  68.             else if (state == State.GET_PICKAXE) {
  69.                 return "Getting Pickaxe";
  70.             }
  71.             else if (state == State.DROP){
  72.                 return "Dropping";
  73.             }
  74.             return "Thanks DreamLick!";
  75.         }
  76.  
  77.         @Override
  78.         public int onLoop() {
  79.             if(startScript) {
  80.                 if (started) {
  81.                     if (!getWalking().isRunEnabled() && getWalking().getRunEnergy() > Calculations.random(30, 70)) {
  82.                         getWalking().toggleRun();
  83.                     }
  84.                     if (getLocalPlayer().isMoving() && getClient().getDestination() != null && getClient().getDestination().distance(getLocalPlayer()) > 5)
  85.                         return Calculations.random(300, 600);
  86.                     if (getLocalPlayer().isInCombat())
  87.                         return Calculations.random(300, 600);
  88.                 }
  89.                 state = getState();
  90.                 switch (state) {
  91.                     case MINE:
  92.                         //something regarding PareRocks?
  93.                         int oreCount = getInventory().count(oreName);
  94.                         if ((getStartTile()).distance(getLocalPlayer()) > 8) {
  95.                             getWalking().walk(getStartTile());
  96.                             sleepUntil(() -> getClient().getDestination().distance(getLocalPlayer()) < 8, Calculations.random(4500, 6500));
  97.                         } else if (getLocalPlayer().distance(ourRock) > 3) {
  98.                             getWalking().walk(ourRock);
  99.                             sleepUntil(() -> !getLocalPlayer().isMoving() || getClient().getDestination().distance(getLocalPlayer()) < 8, Calculations.random(4500, 6500));
  100.                         } else if (ourRock.exists() && ourRock.isOnScreen()) {
  101.                             ourRock.interact("Mine");
  102.                             sleepUntil(() -> getInventory().count(oreName)> oreCount || !ourRock.exists(), Calculations.random(10000, 15000));
  103.                             sleepUntil(() -> ourRock.exists(), Calculations.random(2000, 4000));
  104.                         }
  105.                         break;
  106.                     case BANK:
  107.                         if (getBank().isOpen()) {
  108.                             sleepUntil(() -> getBank().isOpen(), Calculations.random(800, 1000));
  109.                             getBank().depositAllExcept(f -> f.getName().contains("pickaxe"));
  110.                             getBank().close();
  111.                             sleepUntil(() -> !getBank().isOpen(), Calculations.random(800, 1000));
  112.                         } else {
  113.                             if ((getLocalPlayer().distance(getBank().getClosestBankLocation().getCenter()) > 5)) {
  114.                                 if (getWalking().walk(getBank().getClosestBankLocation().getCenter())) {
  115.                                     sleepUntil(() -> !getLocalPlayer().isMoving()
  116.                                                     || getLocalPlayer().distance(getClient().getDestination()) < 8
  117.                                             , Calculations.random(1500, 3500));
  118.                                     if (getBank().open()) {
  119.                                         sleepUntil(() -> getBank().isOpen(), Calculations.random(800, 1000));
  120.                                         getBank().depositAllExcept(f -> f.getName().contains("pickaxe"));
  121.                                         getBank().close();
  122.                                         sleepUntil(() -> !getBank().isOpen(), Calculations.random(800, 1000));
  123.                                     }
  124.                                 }
  125.                             } else {
  126.                                 if (getBank().open()) {
  127.                                     sleepUntil(() -> getBank().isOpen(), Calculations.random(800, 1000));
  128.                                     getBank().depositAllExcept(f -> f.getName().contains("pickaxe"));
  129.                                     getBank().close();
  130.                                     sleepUntil(() -> !getBank().isOpen(), Calculations.random(800, 1000));
  131.                                 }
  132.                             }
  133.                         }
  134.                         break;
  135.                     case GET_PICKAXE:
  136.                         if (getLocalPlayer().distance(getBank().getClosestBankLocation().getCenter()) > 5) {
  137.                             if (getWalking().walk(getBank().getClosestBankLocation().getCenter())) {
  138.                                 sleepUntil(() -> !getLocalPlayer().isMoving() || getClient().getDestination().distance(getLocalPlayer()) < 8, Calculations.random(4500, 6500));
  139.                             }
  140.                         }
  141.                         if (getBank().isOpen()) {
  142.                             if (getBank().withdraw(i -> i.getName().contains("pickaxe"))) {
  143.                                 sleep(Calculations.random(400, 800));
  144.                                 getBank().close();
  145.                             }
  146.                         }
  147.                         if (getBank().open()) {
  148.                             sleepUntil(() -> getBank().isOpen(), Calculations.random(2000, 2500));
  149.                             if (getBank().withdraw(i -> i.getName().contains("pickaxe"))) {
  150.                                 sleep(Calculations.random(400, 800));
  151.                                 getBank().close();
  152.                             }
  153.                         }
  154.                         break;
  155.                     case DROP:
  156.                         getInventory().dropAll(oreName);
  157.                         sleepUntil(() -> !getInventory().contains(oreName), Calculations.random(200, 600));
  158.                 }
  159.             }return 200;
  160.         }
  161.         //----Not used yet?? Is it needed?----\\
  162.         private void setMineRocktoOurRocks(int mineRock){
  163.             List<GameObject> allmineRocks = getGameObjects().all("Rocks");
  164.             allmineRocks.stream().filter(g0 -> g0.getTile().equals(ourRocks.get(mineRock).getTile())).forEach(g0 -> ourRock = g0);
  165.         }
  166.  
  167.  
  168.         @Override
  169.         public void onExit() {
  170.         }
  171.  
  172.         private double progressBar() {
  173.             return ((double) (getSkills().getExperience(Skill.MINING) - getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING)))
  174.                     / (getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING) + 1) - getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING)))) * 100;
  175.         }
  176.  
  177.         @Override
  178.         public void onPaint(Graphics g)
  179.         {
  180.  
  181.             g.setColor(new Color(48, 48, 48, 180));
  182.             g.fillRect(5, 240, 370, 99);
  183.             g.setFont(new Font(Font.MONOSPACED, Font.ROMAN_BASELINE, 14));
  184.             g.setColor(Color.WHITE);
  185.             g.drawString("Private Miner   -", 10, 260);
  186.             g.drawString("Runtime: " + Timer.formatTime(System.currentTimeMillis() - startTime), 220, 260);
  187.             g.drawString("Exp/hr: " + getSkillTracker().getGainedExperiencePerHour(Skill.MINING) , 10, 280);
  188.             g.drawString("Exp gained: " + getSkillTracker().getGainedExperience(Skill.MINING), 10, 300);
  189.             g.drawString("Levels gained: " + getSkillTracker().getGainedLevels(Skill.MINING) , 220, 320);
  190.             g.drawRect(10, 310, 100, 15);
  191.             g.fillRect(10, 310, (int) progressBar(), 15);
  192.             //g.drawString("Ores mined: " + oresmined, 220, 300);
  193.             g.drawString("State: " + stateParser(), 220, 280);
  194.         }
  195.  
  196.         public void setStartScript(boolean startScript) {
  197.             this.startScript = startScript;
  198.         }
  199.         public void setOreName (String name){
  200.             oreName = name;
  201.         }
  202.         public void setOurRocks(ArrayList<GameObject> ourRocks){
  203.             this.ourRocks = ourRocks;
  204.         }
  205.         public void setRockWireFrame(GameObject RockWireFrame){GameObject rockWireFrame = RockWireFrame;
  206.         }
  207.         public List<GameObject> getNearbyRocks(){return getGameObjects().all(rocks -> rocks.getName().contains("Rocks") && rocks.distance(getLocalPlayer())<10);}
  208.         public void setDrop(boolean drop) {this.drop = drop;}
  209.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement