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
  • [Free] Varrock West Basic Clay Miner


    Notorious

    Recommended Posts

    Hello, with the release of the new update today, I wanted to put a free script out so people can see some (not very many) of the new additions in action, and also get some more scripts out there for everyone to use!

     

    If you have any suggestions, edits, really anything let me know and I can edit the code accordingly! :)

     

    Jar File:

    Click Here To Download

     

    Source Code:

     

     

    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.MethodProvider;
    import org.dreambot.api.methods.equipment.Equipment;
    import org.dreambot.api.methods.input.mouse.MouseSetting;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.methods.skills.Skill;
    import org.dreambot.api.methods.walking.web.node.impl.bank.WebBankArea;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.utilities.impl.Filter;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.wrappers.items.Item;
    
    import javax.swing.*;
    import java.awt.*;
    
    
    /**
     * Created with IntelliJ IDEA.
     * User: NotoriousPP
     * Date: 12/13/2014
     * Time: 6:46 PM
     */
    @ScriptManifest(author = "Notorious", name = "Clay Miner", version = 1.0, description = "Basic Clay Mining", category = Category.MINING)
    public class ClayMiner extends AbstractScript {
    
        private Timer timer = new Timer(0);
    
        private String pickaxe;
        private boolean running = true;
        private GameObject currentNode;
    
        public static final Color BACKGROUND = new Color(0, 192, 192, 128);
        public static final int CLAY_ID = 434;
        public static final int CLAY_ROCK_COLOR_ID = 6705;
        public static final Area MINING_AREA = new Area(
                new Tile(3181, 3381, 0),
                new Tile(3176, 3374, 0),
                new Tile(3171, 3369, 0),
                new Tile(3171, 3364, 0),
                new Tile(3177, 3361, 0),
                new Tile(3185, 3367, 0),
                new Tile(3186, 3379, 0)
        );
    
    
        @Override
        public void onStart() {
            getClient().getInstance().getScriptManager().pauseIdleControllers();
            Object[] choices = {"Bronze", "Iron", "Steel", "Mithril", "Adamant", "Rune", "Dragon"};
            pickaxe = JOptionPane.showInputDialog(null, "Pickaxe Type:", "Please Choose", JOptionPane.QUESTION_MESSAGE, null, choices, choices[choices.length - 2]) + " pickaxe";
            log(String.format("Using: %s!", pickaxe));
            getSkillTracker().start(Skill.MINING);
            timer = new Timer(0);
        }
    
        @Override
        public int onLoop() {
            if(running) {
                if (ableToMine()) {
                    handleMining();
                } else if (ableToBank()) {
                    handleBanking();
                } else if (needsToBank()) {
                    getWalking().walk(WebBankArea.VARROCK_WEST.getArea().getCenter());
                } else if (readyToMine()) {
                    getWalking().walk(MINING_AREA.getCenter());
                }
            }
            return running ? getReactionTime() : -1;
        }
    
        private boolean handleMining () {
            boolean result = true;
            if(getLocalPlayer().isStandingStill()){
                if(currentNode == null || !currentNode.exists())
                    currentNode = getGameObjects().getClosest(clayRockFilter());
                if(currentNode != null){
                    boolean event = currentNode.interact("Mine");
                    if(!event){
                        result = currentNode.interact("Mine");
                        sleepUntil(() -> !getLocalPlayer().isStandingStill(), Calculations.random(1200, 1400));
                    }
                }
            }
            return result;
        }
    
        private int getReactionTime () {
            return (int)Calculations.gRandom(Calculations.random(400, 600), Calculations.random(80, 120));
        }
    
        private boolean handleBanking () {
            boolean results = false;
            if(ableToBank()){
                if(getBank().openNearestBank()){
                    if(!hasPickaxe()){
                        if(getBank().contains(pickaxe))
                            getBank().withdraw(pickaxe);
                        else
                            running = false;
                    }
                    if(getInventory().contains(CLAY_ID)){
                        getBank().depositAllExcept(pickaxe);
                    }
                    if(readyToMine() && getBank().close()){
                        results = true;
                    }
                }
            }
            return results;
        }
    
        private Filter<GameObject> clayRockFilter () {
            return gameObject -> {
                short[] color = null;
                boolean accepted = false;
                if(gameObject != null && (currentNode == null
                        || (currentNode.getID() == gameObject.getID()
                        && currentNode.getX() == gameObject.getX()
                        && currentNode.getY() == gameObject.getY()))){
                    color = gameObject.getModelColors();
                    if(color != null && color.length > 1){
                        accepted = color[1] == CLAY_ROCK_COLOR_ID;
                    }
                }
                return accepted;
            };
        }
    
        private boolean ableToMine() {
            return readyToMine() && MINING_AREA.contains(getLocalPlayer());
        }
    
        private boolean readyToMine() {
            return !getInventory().isFull() && hasPickaxe();
        }
    
        private boolean needsToBank () {
            return getInventory().isFull() || !hasPickaxe();
        }
    
        private boolean ableToBank() {
            return needsToBank() && WebBankArea.VARROCK_WEST.getArea().contains(getLocalPlayer());
        }
    
        private boolean hasPickaxe () {
            boolean has = true;
            if(!getInventory().contains(pickaxe)){
                Item weapon = getEquipment().getItemInSlot(Equipment.WEAPON);
                if(weapon != null && weapon.getName() != null){
                    has = weapon.getName().contains("pickaxe");
                }
            }
            return has;
        }
    
        @Override
        public void onPaint(Graphics2D graphics) {
            graphics.setColor(BACKGROUND);
            graphics.fillRect(1, 1, 199, 145);
            graphics.setColor(Color.BLACK);
            graphics.setStroke(new BasicStroke(2));
            graphics.drawRect(1, 1, 200, 145);
            graphics.setColor(Color.WHITE);
            graphics.drawString("Total Time: " + timer.formatTime(), 10, 25);
            graphics.drawString("Exp Gained: " + getSkillTracker().getGainedExperience(Skill.MINING), 10, 50);
            graphics.drawString("Exp Gained Per Hour: " + getSkillTracker().getGainedExperiencePerHour(Skill.MINING), 10, 75);
            graphics.drawString("Levels Gained: " + getSkillTracker().getGainedLevels(Skill.MINING), 10, 100);
            graphics.drawString("Has Target:" + (currentNode != null ? currentNode.exists() : "false"), 10, 120);
    
        }
    
    }
    
    

     

     

     

    Hope you guys enjoy!

    Link to comment
    Share on other sites

    • 3 weeks later...
    • 4 weeks later...

    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.