alex_unique_modifi Posted August 1, 2022 Share Posted August 1, 2022 Start the script in varrock south east mine. it will mine the copper / iron ore automatically and drop the ores on the ground when inventory is full. does not drop gems/geodes. demo: glhf 🙂  import com.epicbot.api.shared.APIContext; import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.details.Locatable; 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 com.epicbot.api.shared.webwalking.model.WebPath; import java.awt.Graphics2D; @ScriptManifest(name = "VarrockEastMine", gameType = GameType.OS) public class VarrockEastMine extends LoopScript { // constants private final int DELAY_BETWEEN_ORE_CLICKS = 900; private final Tile TILE_MINE_AREA = new Tile(3287,3364); // varrock east mine private final int[] COPPER_ROCKS = {11161,10943}; private final int[] IRON_ROCKS = {11364,11365}; // global variables private String status = "Starting"; private int[] currentRocks = {}; boolean settedOres = false; String currentOre = "Copper"; private int invtSpace = 28; @Override public boolean onStart(String... strings) { Time.sleep(20000); return true;//getAPIContext().client().isLoggedIn() ; } @Override protected int loop() { setOres(); if ( isInvtFull()) { dropOres(); }else{ doMine(); } return 1337; // delay for 1.337 seconds } // tasks private void doMine(){ status = "Mining "+currentOre; while (!isInvtFull() && isRunning() && !isPaused() && !isStopping()){ if ( !getAPIContext().localPlayer().isAnimating() && !getAPIContext().localPlayer().isMoving() ) { getAPIContext().objects().query().id(currentRocks).results().nearest().interact("Mine"); Time.sleep(1800); //System.out.println("Mining. Free invt="+(28-getAPIContext().inventory().getCount())); } Time.sleep(DELAY_BETWEEN_ORE_CLICKS); } //if (isInvtFull()) { // System.out.println("Full invt"); //} }; private void dropOres(){ status = "Dropping ores"; getAPIContext().inventory().dropAll(436,440); // copper and iron ores } private void setOres(){ if (settedOres) return; if (getAPIContext().skills().mining().getCurrentLevel()>14){ currentRocks = IRON_ROCKS; settedOres = true; currentOre ="Iron"; }else{ currentRocks = COPPER_ROCKS; } } // checks private boolean isInvtFull(){ invtSpace = 28-getAPIContext().inventory().getCount(); return invtSpace ==0; }; //todo worldHopIfCrowded //todo dismissRandomEvent @Override protected void onPaint(Graphics2D g, APIContext ctx) { PaintFrame frame = new PaintFrame("VarrockE mine"); frame.addLine("Status", status); frame.addLine("Free space", invtSpace); frame.draw(g, 0, 170, ctx); } }  1 Quote Link to comment Share on other sites More sharing options...
alex_unique_modifi Posted August 1, 2022 Author Share Posted August 1, 2022 now with added banking ability & ore per hr tracking! import com.epicbot.api.shared.APIContext; import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.details.Locatable; 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.util.time.Timer; import com.epicbot.api.shared.webwalking.model.RSBank; import com.epicbot.api.shared.webwalking.model.WalkState; import com.epicbot.api.shared.webwalking.model.WebPath; import java.awt.Graphics2D; @ScriptManifest(name = "VarrockEastMine", gameType = GameType.OS) public class VarrockEastMine extends LoopScript { // constants private final int[] f2pworlds = {380,382,383,394,397,398,399,417,418,430,433,434,435,436,437,451,452,453,454,455,456,470, 471,472,473,475,476,483,498,499,500,501,536,537,542,543,544,545,546,547,552,553,554,555,556,557,562,563,564,565, 566,567,571,573,574,575,576 }; private final int DELAY_BETWEEN_ORE_CLICKS = 900; //private final Tile TILE_MINE_AREA = new Tile(3287,3364); // varrock east mine private final Area AREA_MINE = new Area(new Tile(3280,3360),new Tile(3290,3370)); private final int[] COPPER_ROCKS = {11161,10943}; private final int[] IRON_ROCKS = {11364,11365}; private final Timer runTimer = new Timer(0); // global variables private String status = "Starting"; private int[] currentRocks = {}; boolean settedOres = false; String currentOre = "Copper"; private int invtSpace = 28; private int prevInvtSpace = 28; private int minedOres = 0; @Override public boolean onStart(String... strings) { if (!getAPIContext().client().isLoggedIn()){ Time.sleep(15000); } Time.sleep(5000); return true;// ; } @Override protected int loop() { setOres(); setInvtSpace(); if ( isInvtFull()){ System.out.println("bag is full"); goBanknDesposit(); } else if (isNearMine()){ System.out.println("start mining"); doMine(); } else { System.out.println("head to mine"); goNearMine(); } return 1337; // delay for 1.337 seconds } // tasks private void doMine(){ status = "Mining "+currentOre; while (!isInvtFull() && isRunning() && !isPaused() && !isStopping()){ if ( !getAPIContext().localPlayer().isAnimating() && !getAPIContext().localPlayer().isMoving() ) { getAPIContext().objects().query().id(currentRocks).results().nearest().interact("Mine"); Time.sleep(1800); } Time.sleep(DELAY_BETWEEN_ORE_CLICKS); } }; private void dropOres(){ status = "Dropping ores"; getAPIContext().inventory().dropAll(436,440); // copper and iron ores } private void goBanknDesposit(){ status = "Going to bank"; if ( !getAPIContext().localPlayer().isAnimating() && !getAPIContext().localPlayer().isMoving() ) { getAPIContext().webWalking().walkToBank(RSBank.VARROCK_EAST); } // deposit ores n gems status = "Despositing"; if ( !getAPIContext().localPlayer().isAnimating() && !getAPIContext().localPlayer().isMoving() ) { if (getAPIContext().bank().isReachable()) { getAPIContext().bank().open(); Time.sleep(2000); getAPIContext().bank().depositAllExcept("Bronze Pickaxe", "Iron Pickaxe", "Steel Pickaxe", "Black Pickaxe", "Mithril Pickaxe", "Adamant Pickaxe", "Rune Pickaxe"); Time.sleep(2000); } } // close bank if (getAPIContext().bank().isOpen()){ getAPIContext().bank().close(); } setInvtSpace(); }; private void goNearMine(){ System.out.println("starting go near mine"); status = "Going to mine"; if ( getAPIContext().localPlayer().isAnimating() || getAPIContext().localPlayer().isMoving() ) { System.out.println("exiting goNearMine with failure, sleep for 14secs"); Time.sleep(14000); return; } WebPath path = getAPIContext().webWalking().getPath(AREA_MINE.getCentralTile()); System.out.println("path status "+path.getPathStatus().toString()); WalkState ws = getAPIContext().webWalking().walkPath(path); System.out.println("walk state "+ws.toString()); if(ws == WalkState.SUCCESS){ System.out.println("exiting goNearMine with success"); }else { System.out.println("exiting goNearMine with failure, sleep for 15secs"); Time.sleep(15000); } //Time.sleep(5000, () -> AREA_MINE.contains(getAPIContext().localPlayer().getLocation())); }; private void setOres(){ if (settedOres) return; if (getAPIContext().skills().mining().getCurrentLevel()>14){ currentRocks = IRON_ROCKS; settedOres = true; currentOre ="Iron"; }else{ currentRocks = COPPER_ROCKS; } } private void setInvtSpace(){ prevInvtSpace = getAPIContext().inventory().getEmptySlotCount(); invtSpace = prevInvtSpace; } // checks private boolean isNearMine(){ Locatable playerLocation = getAPIContext().localPlayer().get().getLocation(); boolean nearmine = AREA_MINE.contains( playerLocation ); System.out.println("near mine boolean"+nearmine); return nearmine; }; private boolean isInvtFull(){ invtSpace = 28-getAPIContext().inventory().getCount(); if (invtSpace!=prevInvtSpace){ minedOres++; prevInvtSpace=invtSpace; } return invtSpace ==0; }; //todo worldHopIfCrowded //todo dismissRandomEvent @Override protected void onPaint(Graphics2D g, APIContext ctx) { PaintFrame frame = new PaintFrame("VarrockE mine"); frame.addLine("Time",runTimer.toElapsedString()); frame.addLine("Mined ores",minedOres); frame.addLine("Ores/h",getHourlyRate(minedOres)); frame.addLine("Status", status); frame.addLine("Free space", invtSpace); frame.draw(g, 0, 170, ctx); } private int getHourlyRate(int i) { return (int) (i / (runTimer.getElapsed() / 3600000.0D)); } } Â 1 Quote Link to comment Share on other sites More sharing options...
mortty Posted August 11, 2022 Share Posted August 11, 2022 I'm going to give it a shot, thank you very much for your hard work Quote Link to comment Share on other sites More sharing options...
3oro Posted July 28 Share Posted July 28 On 8/11/2022 at 10:42 AM, mortty said: I'm going to give it a shot, thank you very much for your hard work Is it working still. ? Anyone? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.