Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.skills.Skill;
- 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 java.awt.*;
- import java.util.*;
- import java.util.List;
- /**
- * Created by Hitsuu on 11/14/2015.
- */
- @ScriptManifest(author = "Hitsuu", name = "Advanced Miner Script", category = Category.MINING, version = 1.0)
- public class stateminer extends AbstractScript implements PaintListener{
- private boolean startScript;
- private String oreName;
- private ArrayList<GameObject> ourRocks;
- private long startTime = System.currentTimeMillis();
- private boolean started = false;
- private GameObject ourRock;
- private boolean drop;
- public State state;
- public enum State{
- MINE, BANK, GET_PICKAXE, DROP
- }
- @Override
- public void onStart() {
- super.onStart();
- stateminerGUI gui = new stateminerGUI(this);
- gui.setVisible(true);
- getCamera().rotateToPitch(383);
- getSkillTracker().start(Skill.MINING);
- startTime = System.currentTimeMillis();
- setStartTile(getLocalPlayer().getTile());
- }
- public State getState() {
- if (getInventory().isFull() && !drop) {
- return State.BANK;
- }
- else if(!getInventory().contains(item -> item.getName().contains("pickaxe"))) {
- return State.GET_PICKAXE;
- }
- else if(drop && getInventory().contains(oreName)){
- return State.DROP;
- }
- else return State.MINE;
- }
- private String stateParser() {
- if (state == State.MINE) {
- return "Mining";
- }
- else if (state == State.BANK) {
- return "Banking";
- }
- else if (state == State.GET_PICKAXE) {
- return "Getting Pickaxe";
- }
- else if (state == State.DROP){
- return "Dropping";
- }
- return "Thanks DreamLick!";
- }
- @Override
- public int onLoop() {
- if(startScript) {
- if (started) {
- if (!getWalking().isRunEnabled() && getWalking().getRunEnergy() > Calculations.random(30, 70)) {
- getWalking().toggleRun();
- }
- if (getLocalPlayer().isMoving() && getClient().getDestination() != null && getClient().getDestination().distance(getLocalPlayer()) > 5)
- return Calculations.random(300, 600);
- if (getLocalPlayer().isInCombat())
- return Calculations.random(300, 600);
- }
- state = getState();
- switch (state) {
- case MINE:
- //something regarding PareRocks?
- int oreCount = getInventory().count(oreName);
- if ((getStartTile()).distance(getLocalPlayer()) > 8) {
- getWalking().walk(getStartTile());
- sleepUntil(() -> getClient().getDestination().distance(getLocalPlayer()) < 8, Calculations.random(4500, 6500));
- } else if (getLocalPlayer().distance(ourRock) > 3) {
- getWalking().walk(ourRock);
- sleepUntil(() -> !getLocalPlayer().isMoving() || getClient().getDestination().distance(getLocalPlayer()) < 8, Calculations.random(4500, 6500));
- } else if (ourRock.exists() && ourRock.isOnScreen()) {
- ourRock.interact("Mine");
- sleepUntil(() -> getInventory().count(oreName)> oreCount || !ourRock.exists(), Calculations.random(10000, 15000));
- sleepUntil(() -> ourRock.exists(), Calculations.random(2000, 4000));
- }
- break;
- case BANK:
- if (getBank().isOpen()) {
- sleepUntil(() -> getBank().isOpen(), Calculations.random(800, 1000));
- getBank().depositAllExcept(f -> f.getName().contains("pickaxe"));
- getBank().close();
- sleepUntil(() -> !getBank().isOpen(), Calculations.random(800, 1000));
- } else {
- if ((getLocalPlayer().distance(getBank().getClosestBankLocation().getCenter()) > 5)) {
- if (getWalking().walk(getBank().getClosestBankLocation().getCenter())) {
- sleepUntil(() -> !getLocalPlayer().isMoving()
- || getLocalPlayer().distance(getClient().getDestination()) < 8
- , Calculations.random(1500, 3500));
- if (getBank().open()) {
- sleepUntil(() -> getBank().isOpen(), Calculations.random(800, 1000));
- getBank().depositAllExcept(f -> f.getName().contains("pickaxe"));
- getBank().close();
- sleepUntil(() -> !getBank().isOpen(), Calculations.random(800, 1000));
- }
- }
- } else {
- if (getBank().open()) {
- sleepUntil(() -> getBank().isOpen(), Calculations.random(800, 1000));
- getBank().depositAllExcept(f -> f.getName().contains("pickaxe"));
- getBank().close();
- sleepUntil(() -> !getBank().isOpen(), Calculations.random(800, 1000));
- }
- }
- }
- break;
- case GET_PICKAXE:
- if (getLocalPlayer().distance(getBank().getClosestBankLocation().getCenter()) > 5) {
- if (getWalking().walk(getBank().getClosestBankLocation().getCenter())) {
- sleepUntil(() -> !getLocalPlayer().isMoving() || getClient().getDestination().distance(getLocalPlayer()) < 8, Calculations.random(4500, 6500));
- }
- }
- if (getBank().isOpen()) {
- if (getBank().withdraw(i -> i.getName().contains("pickaxe"))) {
- sleep(Calculations.random(400, 800));
- getBank().close();
- }
- }
- if (getBank().open()) {
- sleepUntil(() -> getBank().isOpen(), Calculations.random(2000, 2500));
- if (getBank().withdraw(i -> i.getName().contains("pickaxe"))) {
- sleep(Calculations.random(400, 800));
- getBank().close();
- }
- }
- break;
- case DROP:
- getInventory().dropAll(oreName);
- sleepUntil(() -> !getInventory().contains(oreName), Calculations.random(200, 600));
- }
- }return 200;
- }
- //----Not used yet?? Is it needed?----\\
- private void setMineRocktoOurRocks(int mineRock){
- List<GameObject> allmineRocks = getGameObjects().all("Rocks");
- allmineRocks.stream().filter(g0 -> g0.getTile().equals(ourRocks.get(mineRock).getTile())).forEach(g0 -> ourRock = g0);
- }
- @Override
- public void onExit() {
- }
- private double progressBar() {
- return ((double) (getSkills().getExperience(Skill.MINING) - getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING)))
- / (getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING) + 1) - getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.MINING)))) * 100;
- }
- @Override
- public void onPaint(Graphics g)
- {
- g.setColor(new Color(48, 48, 48, 180));
- g.fillRect(5, 240, 370, 99);
- g.setFont(new Font(Font.MONOSPACED, Font.ROMAN_BASELINE, 14));
- g.setColor(Color.WHITE);
- g.drawString("Private Miner -", 10, 260);
- g.drawString("Runtime: " + Timer.formatTime(System.currentTimeMillis() - startTime), 220, 260);
- g.drawString("Exp/hr: " + getSkillTracker().getGainedExperiencePerHour(Skill.MINING) , 10, 280);
- g.drawString("Exp gained: " + getSkillTracker().getGainedExperience(Skill.MINING), 10, 300);
- g.drawString("Levels gained: " + getSkillTracker().getGainedLevels(Skill.MINING) , 220, 320);
- g.drawRect(10, 310, 100, 15);
- g.fillRect(10, 310, (int) progressBar(), 15);
- //g.drawString("Ores mined: " + oresmined, 220, 300);
- g.drawString("State: " + stateParser(), 220, 280);
- }
- public void setStartScript(boolean startScript) {
- this.startScript = startScript;
- }
- public void setOreName (String name){
- oreName = name;
- }
- public void setOurRocks(ArrayList<GameObject> ourRocks){
- this.ourRocks = ourRocks;
- }
- public void setRockWireFrame(GameObject RockWireFrame){GameObject rockWireFrame = RockWireFrame;
- }
- public List<GameObject> getNearbyRocks(){return getGameObjects().all(rocks -> rocks.getName().contains("Rocks") && rocks.distance(getLocalPlayer())<10);}
- public void setDrop(boolean drop) {this.drop = drop;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement