Jump to content

Miner/Smither


Recommended Posts

This bot will mine Tin & Copper in Rimmington then navigate to Falador smelter, create bronze bars, bank.

Start script with empty inventory and desired pickaxe in equipment slot, only start the script in either Rimmington or Falador East Bank.

image.png.f7c95ad1be28561191fbf868100fbe19.png

 

import com.epicbot.api.shared.APIContext;
import com.epicbot.api.shared.GameType;
import com.epicbot.api.shared.entity.SceneObject;
import com.epicbot.api.shared.entity.WidgetGroup;
import com.epicbot.api.shared.model.Area;
import com.epicbot.api.shared.model.Tile;
import com.epicbot.api.shared.script.LoopScript;
import com.epicbot.api.shared.script.ScriptManifest;
import com.epicbot.api.shared.util.paint.frame.PaintFrame;
import com.epicbot.api.shared.util.time.Time;
import com.epicbot.api.shared.webwalking.model.RSBank;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

@ScriptManifest(name = "Private Miner & Smither", gameType = GameType.OS)
public class main extends LoopScript {

    private Area BANK_AREA = new Area(new Tile(3008, 3359, 0), new Tile(3019, 3352, 0));
    private Area TIN_AREA = new Area(new Tile(2983, 3238, 0), new Tile(2987, 3234, 0));
    private Area COPPER_AREA = new Area(new Tile(2975, 3248, 0), new Tile(2980, 3244, 0));
    private Area FURNACE_AREA = new Area(new Tile(2969, 3371, 0), new Tile(2978, 3367, 0));

    private long startTime;
    private int counter = 0;

    @Override
    public boolean onStart(String... strings) {
        startTime = System.currentTimeMillis();
        return true;
    }

    @Override
    protected int loop() {

        WidgetGroup LevelUpInterface = getAPIContext().widgets().get(233);

        if (LevelUpInterface.isVisible()) {
            levelup();
        } else {
            if (getAPIContext().inventory().getCount("Uncut sapphire", "Uncut emerald", "Uncut ruby", "Uncut diamond", "Clue geode (beginner)") > 0) {
                drop();
            } else if (getAPIContext().inventory().getCount("Bronze bar") == 14) {
                bank();
            } else if (FURNACE_AREA.contains(getAPIContext().localPlayer().getLocation())) {
                smelt();
            } else if (getAPIContext().inventory().getCount("Tin ore") == 14 && (getAPIContext().inventory().getCount("Copper ore") == 14)) {
                smelt();
            } else if (getAPIContext().inventory().getCount("Tin ore") != 14) {
                mine_tin();
            } else if (getAPIContext().inventory().getCount("Copper ore") != 14) {
                mine_copper();
            }
        }
        return 100;
    }

    private boolean isActioning() {
        return getAPIContext().localPlayer().isAnimating() || getAPIContext().localPlayer().isMoving();
    }

    private void bank() {
        if (!BANK_AREA.contains(getAPIContext().localPlayer().getLocation())) {
            getAPIContext().webWalking().walkTo(RSBank.FALADOR_EAST.getTile());
        } else {
            if (BANK_AREA.contains(getAPIContext().localPlayer().getLocation())) {
                if (!getAPIContext().bank().isOpen()) {
                    getAPIContext().bank().open();
                    Time.sleep(1_000, () -> getAPIContext().bank().isOpen());
                }else if (getAPIContext().bank().isOpen()) {
                    getAPIContext().bank().depositInventory();
                    counter = counter + 14;
                    Time.sleep(1_000, () -> !getAPIContext().bank().isOpen());
                }
            }
        }
    }

    private void mine_tin() {
        final SceneObject Rocks = getAPIContext().objects().query().id(11361, 11360).results().nearest();
        if (!TIN_AREA.contains(getAPIContext().localPlayer().getLocation())) {
            getAPIContext().webWalking().walkTo(TIN_AREA.getCentralTile());
        } else if (!isActioning()) {
            if (Rocks != null) {
                Rocks.interact("Mine");
                Time.sleep(2_000, () -> getAPIContext().localPlayer().isAnimating());
            }
        }
    }

    private void mine_copper() {
        final SceneObject Rocks = getAPIContext().objects().query().id(11161, 10943).results().nearest();
        if (!COPPER_AREA.contains(getAPIContext().localPlayer().getLocation())) {
            getAPIContext().webWalking().walkTo(COPPER_AREA.getCentralTile());
        } else if (!isActioning()) {
            if (Rocks != null) {
                Rocks.interact("Mine");
                Time.sleep(2_000, () -> getAPIContext().localPlayer().isAnimating());
            }
        }
    }

    private void smelt() {

        final SceneObject FURNACE = getAPIContext().objects().query().nameContains("Furnace").results().nearest();
        WidgetGroup SmeltInterface = getAPIContext().widgets().get(270);

        if (!FURNACE_AREA.contains(getAPIContext().localPlayer().getLocation())) {
            getAPIContext().webWalking().walkTo(FURNACE_AREA.getCentralTile());
        } else if (isActioning()) {
            Time.sleep(2_000, () -> !getAPIContext().localPlayer().isAnimating());
            Time.sleep(2_000, () -> getAPIContext().localPlayer().isAnimating() && getAPIContext().inventory().getCount("Bronze bar") != 14);
        } else if (SmeltInterface.isVisible()) {
            getAPIContext().keyboard().sendKey(49);
            Time.sleep(2_000, () -> getAPIContext().localPlayer().isAnimating());
        } else if (FURNACE != null) {
            FURNACE.interact("Smelt");
            Time.sleep(1000,2000);
        }
    }

    private void levelup() {
        WidgetGroup LevelUpInterface = getAPIContext().widgets().get(233);
        Time.sleep(500, 1000);
        if (LevelUpInterface.isVisible()) {
            getAPIContext().keyboard().sendKey(32);
        }
    }

    private void drop() {
        if (getAPIContext().inventory().getCount("Uncut sapphire") > 0) {
            getAPIContext().inventory().dropAll("Uncut sapphire");
        }else if (getAPIContext().inventory().getCount("Uncut emerald") > 0) {
            getAPIContext().inventory().dropAll("Uncut emerald");
        }else if (getAPIContext().inventory().getCount("Uncut ruby") > 0) {
            getAPIContext().inventory().dropAll("Uncut ruby");
        }else if (getAPIContext().inventory().getCount("Uncut diamond") > 0) {
            getAPIContext().inventory().dropAll("Uncut diamond");
        }else if (getAPIContext().inventory().getCount("Clue geode (beginner)") > 0) {
            getAPIContext().inventory().dropAll("Clue geode (beginner)");
            Time.sleep(500,1000);
        }
    }

    //define image to display on screen
    private BufferedImage image = downloadImage("https://i.imgur.com/6rfxOOp.jpg");

    @Override
    protected void onPaint(Graphics2D g, APIContext ctx){
        PaintFrame pf = new PaintFrame();
        g.drawImage(image, 0, getAPIContext().game().getViewportHeight() - -5, null);
        pf.addLine("Private Miner/Smither","");
        pf.addLine("","");
        pf.addLine("Runtime: ", Time.getFormattedRuntime(startTime));
        pf.addLine("","");
        pf.addLine("Mining Level: ", getAPIContext().skills().mining().getCurrentLevel());
        pf.addLine("","");
        pf.addLine("Smithing Level: ", getAPIContext().skills().smithing().getCurrentLevel());
        pf.addLine("","");
        pf.addLine("Bronze Bars: ", counter);
        pf.addLine("","");
        pf.addLine("","");
        pf.addLine("","");
        pf.addLine("","");
        pf.draw(g, 195, 339, ctx);

    }

    //download the image to display on screen
    public BufferedImage downloadImage(String url) {
        try {
            HttpURLConnection conn;
            conn = (HttpURLConnection)(new URL(url.replaceAll(" ", "%20")).openConnection());
            conn.setInstanceFollowRedirects(false);
            conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8");
            conn.setRequestProperty("Accept", "ttext/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8");
            conn.setRequestProperty("Accept-Language", "en-us,en;q=0.5");
            conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
            conn.setRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
            conn.setRequestProperty("Keep-Alive", "300");
            conn.setRequestProperty("Connection", "keep-alive");
            conn.setRequestMethod("GET");
            return ImageIO.read(conn.getInputStream());
        } catch(IOException e1) {
            return null;
        }
    }
}

 

Edited by ashgg83
  • Like 3
Link to comment
Share on other sites

Good scrib, just one note on the image downloading, no need for all of that 

 


private Image background = null;

        try {
            URL url = new URL(image URL here);
            background = ImageIO.read(url); Set 
        } catch (IOException e) {
            e.printStackTrace();
        }

and in on paint

g.drawImage(background, 1, 1, null);

 

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Copy the code, compile it to a runable file and deposite it in the epicbot folder with a new folder named Scripts.

And for everyone: Enough my Work i done on this.

import com.epicbot.api.shared.APIContext;
import com.epicbot.api.shared.GameType;
import com.epicbot.api.shared.entity.SceneObject;
import com.epicbot.api.shared.entity.WidgetGroup;
import com.epicbot.api.shared.model.Area;
import com.epicbot.api.shared.model.Tile;
import com.epicbot.api.shared.script.LoopScript;
import com.epicbot.api.shared.script.ScriptManifest;
import com.epicbot.api.shared.util.paint.frame.PaintFrame;
import com.epicbot.api.shared.util.time.Time;
import com.epicbot.api.shared.webwalking.model.RSBank;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

@ScriptManifest(name = "Private Miner & Smither", gameType = GameType.OS)
public class Mine_Smelt extends LoopScript {

    //define image to display on screen
    private final BufferedImage image = downloadImage("https://i.imgur.com/6rfxOOp.jpg");

    private final Area BANK_AREA = new Area(new Tile(3008, 3359, 0), new Tile(3019, 3352, 0));
    private final Area TIN_AREA = new Area(new Tile(2983, 3238, 0), new Tile(2987, 3234, 0));
    private final Area COPPER_AREA = new Area(new Tile(2975, 3248, 0), new Tile(2980, 3244, 0));
    private final Area FURNACE_AREA = new Area(new Tile(2969, 3371, 0), new Tile(2978, 3367, 0));

    private long startTime;
    private int counter = 0;

    @Override
    public boolean onStart(String... strings) {
        startTime = System.currentTimeMillis();
        return true;
    }

    @Override
    protected int loop() {

        WidgetGroup LevelUpInterface = getAPIContext().widgets().get(233);

        if(!getAPIContext().inventory().contains("Bronze Pickaxe", "Iron Pickaxe", "Steel Pickaxe", "Black Pickaxe", "Mithril Pickaxe", "Adamant Pickaxe", "Rune Pickaxe", "Gilded Pickaxe", "Dragon Pickaxe", "3rd age Pickaxe", "Infernal Pickaxe", "Crystal Pickaxe") && !getAPIContext().equipment().contains("Bronze Pickaxe", "Iron Pickaxe", "Steel Pickaxe", "Black Pickaxe", "Mithril Pickaxe", "Adamant Pickaxe", "Rune Pickaxe", "Gilded Pickaxe", "Dragon Pickaxe", "3rd age Pickaxe", "Infernal Pickaxe", "Crystal Pickaxe"))
        {
            getPickAxe();
        }

        else
        {

            if (LevelUpInterface.isVisible()) {
                levelup();
            }
            else {
                if (getAPIContext().inventory().getCount("Uncut sapphire", "Uncut emerald", "Uncut ruby", "Uncut diamond", "Clue geode (beginner)") > 0) {
                    drop();
                } else if (getAPIContext().inventory().getCount("Bronze bar") == 14) {
                    bank();
                } else if (FURNACE_AREA.contains(getAPIContext().localPlayer().getLocation())) {
                    smelt();
                } else if (getAPIContext().inventory().getCount("Tin ore") == 14 && (getAPIContext().inventory().getCount("Copper ore") == 14)) {
                    smelt();
                } else if (getAPIContext().inventory().getCount("Tin ore") != 14) {
                    mine_tin();
                } else if (getAPIContext().inventory().getCount("Copper ore") != 14) {
                    mine_copper();
                }
            }
        }
        return 100;
    }


    public void getPickAxe() {

        if (!BANK_AREA.contains(getAPIContext().localPlayer().getLocation()))
        {
            getAPIContext().walking().walkTo(BANK_AREA.getCentralTile());
            System.out.println("Walking to bank");
            Time.sleep(10_000);
        }
        else if (BANK_AREA.contains(getAPIContext().localPlayer().getLocation()))
        {

            if (!getAPIContext().bank().isOpen()) {
                System.out.println("Trying to open bank");
                getAPIContext().bank().open();
                Time.sleep(5_000, () -> getAPIContext().bank().isOpen());
            }

            if (getAPIContext().bank().isOpen()) {
                System.out.println("Bank is open");
                getAPIContext().bank().depositInventory();
                getAPIContext().bank().depositEquipment();
                getAPIContext().bank().withdraw(1,"Bronze Pickaxe", "Iron Pickaxe", "Steel Pickaxe", "Black Pickaxe", "Mithril Pickaxe", "Adamant Pickaxe", "Rune Pickaxe", "Gilded Pickaxe", "Dragon Pickaxe", "3rd age Pickaxe", "Infernal Pickaxe", "Crystal Pickaxe");
                Time.sleep(4000, () -> APIContext.get().inventory().contains("Bronze Pickaxe", "Iron Pickaxe", "Steel Pickaxe", "Black Pickaxe", "Mithril Pickaxe", "Adamant Pickaxe", "Rune Pickaxe", "Gilded Pickaxe", "Dragon Pickaxe", "3rd age Pickaxe", "Infernal Pickaxe", "Crystal Pickaxe"));
                System.out.println("Closing bank");

                if(getAPIContext().bank().isOpen()) {
                    getAPIContext().bank().close();
                    Time.sleep(1000);
                }

                if (getAPIContext().inventory().contains("Rune Pickaxe")){
                    getAPIContext().inventory().interactItem("Wield" ,"Rune Pickaxe");
                    Time.sleep(2000);
                }
                else if(getAPIContext().inventory().contains("Adamant Pickaxe")){
                    getAPIContext().inventory().interactItem("Wield" ,"Adamant Pickaxe");
                    Time.sleep(2000);
                }
                else if(getAPIContext().inventory().contains("Mithril Pickaxe")){
                getAPIContext().inventory().interactItem("Wield" ,"Mithril Pickaxe");
                Time.sleep(2000);
                }
                else {
                    getAPIContext().inventory().interactItem("Wield" ,"Bronze Pickaxe");
                    Time.sleep(2000);
                }
            }
        }
    }

    private boolean isActioning() {
        return getAPIContext().localPlayer().isAnimating() || getAPIContext().localPlayer().isMoving();
    }

    private void bank() {
        if (!BANK_AREA.contains(getAPIContext().localPlayer().getLocation())) {
            getAPIContext().webWalking().walkTo(RSBank.FALADOR_EAST.getTile());
        } else {
            if (BANK_AREA.contains(getAPIContext().localPlayer().getLocation())) {
                if (!getAPIContext().bank().isOpen()) {
                    getAPIContext().bank().open();
                    Time.sleep(1_000, () -> getAPIContext().bank().isOpen());
                }else if (getAPIContext().bank().isOpen()) {
                    getAPIContext().bank().depositInventory();
                    counter = counter + 14;
                    Time.sleep(1_000, () -> !getAPIContext().bank().isOpen());
                }
            }
        }
    }

    private void mine_tin() {
        final SceneObject Rocks = getAPIContext().objects().query().id(11361, 11360).results().nearest();
        if (!TIN_AREA.contains(getAPIContext().localPlayer().getLocation())) {
            getAPIContext().webWalking().walkTo(TIN_AREA.getCentralTile());
        } else if (!isActioning()) {
            if (Rocks != null) {
                Rocks.interact("Mine");
                Time.sleep(2_000, () -> getAPIContext().localPlayer().isAnimating());
            }
        }
    }

    private void mine_copper() {
        final SceneObject Rocks = getAPIContext().objects().query().id(11161, 10943).results().nearest();
        if (!COPPER_AREA.contains(getAPIContext().localPlayer().getLocation())) {
            getAPIContext().webWalking().walkTo(COPPER_AREA.getCentralTile());
        } else if (!isActioning()) {
            if (Rocks != null) {
                Rocks.interact("Mine");
                Time.sleep(2_000, () -> getAPIContext().localPlayer().isAnimating());
            }
        }
    }

    private void smelt() {

        final SceneObject FURNACE = getAPIContext().objects().query().nameContains("Furnace").results().nearest();
        WidgetGroup SmeltInterface = getAPIContext().widgets().get(270);

        if (!FURNACE_AREA.contains(getAPIContext().localPlayer().getLocation())) {
            getAPIContext().webWalking().walkTo(FURNACE_AREA.getCentralTile());
        } else if (isActioning()) {
            Time.sleep(2_000, () -> !getAPIContext().localPlayer().isAnimating());
            Time.sleep(2_000, () -> getAPIContext().localPlayer().isAnimating() && getAPIContext().inventory().getCount("Bronze bar") != 14);
        } else if (SmeltInterface.isVisible()) {
            getAPIContext().keyboard().sendKey(49);
            Time.sleep(2_000, () -> getAPIContext().localPlayer().isAnimating());
        } else if (FURNACE != null) {
            FURNACE.interact("Smelt");
            Time.sleep(1000,2000);
        }
    }

    private void levelup() {
        WidgetGroup LevelUpInterface = getAPIContext().widgets().get(233);
        Time.sleep(500, 1000);
        if (LevelUpInterface.isVisible()) {
            getAPIContext().keyboard().sendKey(32);
        }
    }

    private void drop() {
        if (getAPIContext().inventory().getCount("Uncut sapphire") > 0) {
            getAPIContext().inventory().dropAll("Uncut sapphire");
        }else if (getAPIContext().inventory().getCount("Uncut emerald") > 0) {
            getAPIContext().inventory().dropAll("Uncut emerald");
        }else if (getAPIContext().inventory().getCount("Uncut ruby") > 0) {
            getAPIContext().inventory().dropAll("Uncut ruby");
        }else if (getAPIContext().inventory().getCount("Uncut diamond") > 0) {
            getAPIContext().inventory().dropAll("Uncut diamond");
        }else if (getAPIContext().inventory().getCount("Clue geode (beginner)") > 0) {
            getAPIContext().inventory().dropAll("Clue geode (beginner)");
            Time.sleep(500,1000);
        }
    }


    @Override
    protected void onPaint(Graphics2D g, APIContext ctx){
        PaintFrame pf = new PaintFrame();
        g.drawImage(image, 0, getAPIContext().game().getViewportHeight() - -5, null);
        pf.addLine("Private Miner/Smither","");
        pf.addLine("","");
        pf.addLine("Runtime: ", Time.getFormattedRuntime(startTime));
        pf.addLine("","");
        pf.addLine("Mining Level: ", getAPIContext().skills().mining().getCurrentLevel());
        pf.addLine("","");
        pf.addLine("Smithing Level: ", getAPIContext().skills().smithing().getCurrentLevel());
        pf.addLine("","");
        pf.addLine("Bronze Bars: ", counter);
        pf.addLine("","");
        pf.addLine("","");
        pf.addLine("","");
        pf.addLine("","");
        pf.draw(g, 195, 339, ctx);

    }

    //download the image to display on screen
    public BufferedImage downloadImage(String url) {
        try {
            HttpURLConnection conn;
            conn = (HttpURLConnection)(new URL(url.replaceAll(" ", "%20")).openConnection());
            conn.setInstanceFollowRedirects(false);
            conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8");
            conn.setRequestProperty("Accept", "ttext/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8");
            conn.setRequestProperty("Accept-Language", "en-us,en;q=0.5");
            conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
            conn.setRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
            conn.setRequestProperty("Keep-Alive", "300");
            conn.setRequestProperty("Connection", "keep-alive");
            conn.setRequestMethod("GET");
            return ImageIO.read(conn.getInputStream());
        } catch(IOException e1) {
            return null;
        }
    }
}

 

Mine_Smelt.class

Edited by TheKevin
Free script :ooooooooooooooo
Link to comment
Share on other sites

  • 3 weeks later...

So I read the script and it doesn't seem to have randomized clicks and auto logout features, is it incorporated in any of the imports? If not I was considering to add it, although I would make this an iron mining script.

Link to comment
Share on other sites

2 hours ago, SunIsLegit said:

So I read the script and it doesn't seem to have randomized clicks and auto logout features, is it incorporated in any of the imports? If not I was considering to add it, although I would make this an iron mining script.

That is all handled by the client

Link to comment
Share on other sites

On 6/29/2021 at 6:11 PM, SunIsLegit said:

So I read the script and it doesn't seem to have randomized clicks and auto logout features, is it incorporated in any of the imports? If not I was considering to add it, although I would make this an iron mining script.

The script has to be prepared for different szenarios and events that can happen to look like a "normal" player, the mouse stuff comes from the client and it hasnt a stop/logout reason so no need for this like when you want to enchant stuff, maybe people want to run this script over hours.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...