KhalDrogonerr 0 Share Posted March 11 Hi everyone, today I wanted to try to write a mining script....but everything went well until I had to deposit...the bot approaches and makes many attempts before managing to deposit...how can I avoid it this and have it deposited on the first try?I tried to get some pieces from gpt chat for the solution but nothing has changed....I think the problem is in BANKING and USE_BANK import org.dreambot.api.methods.container.impl.bank.Bank; import org.dreambot.api.methods.container.impl.Inventory; import org.dreambot.api.methods.interactive.GameObjects; import org.dreambot.api.methods.interactive.Players; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.walking.impl.Walking; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.methods.map.Tile; import org.dreambot.api.utilities.Sleep; import org.dreambot.api.methods.input.Camera; @ScriptManifest(author = "KhalDrogonerr", name = "Iron", version = 1.0, description = "Simple Iron Miner", category = Category.MINING) public class Main extends AbstractScript { State state; Area bankArea = new Area( new Tile(3012, 3359, 0), new Tile(3012, 3353, 0), new Tile(3011, 3356, 0), new Tile(3009, 3353, 0), new Tile(3012, 3356, 0), new Tile(3016, 3353, 0) ); Area ironOre = new Area(2977, 3231, 2967, 3243); Area muleZone= new Area(3175, 3501, 3154, 3477); public enum State { WALKING_TO_BANK,USE_BANK,BANKING,TAKE_PICKAXE,FINDING_ORE,MINING_ORE}; public void onStart() { log("Welcome to Simple Mining Script."); log("If you experience any issues while running this script please report them to me on the forums."); log("Enjoy the script!.");} @Override public int onLoop() { switch (getState()) { case WALKING_TO_BANK: Tile destination = bankArea.getRandomTile(); if (!Players.getLocal().isMoving() && !Players.getLocal().getTile().equals(destination)) { Walking.walk(destination.getRandomized()); } break; case USE_BANK: if (!Bank.isOpen() || !Players.getLocal().isMoving()) { GameObject bankBooth = GameObjects.closest("Bank booth"); if (bankBooth != null) { if (!bankBooth.isOnScreen()) { Walking.walkOnScreen(bankBooth.getTile()); Camera.rotateToEntity(bankBooth); } else { bankBooth.interact("Bank"); Sleep.sleepUntil(() -> Bank.isOpen(), 6000); Sleep.sleep(1000, 2000); if (bankArea.contains(Players.getLocal().getTile())) { break; } } } } break; case BANKING: if (!Bank.isOpen()) { Bank.open(); Sleep.sleepUntil(Bank::isOpen, 6000); } else { if (!Inventory.isEmpty()) { Bank.depositAll("Iron ore"); Sleep.sleepUntil(() -> Inventory.isEmpty(), 6000); } else { Bank.close(); Sleep.sleepUntil(() -> !Bank.isOpen(), 6000); } } break; case TAKE_PICKAXE: if (!Inventory.contains("Bronze pickaxe")) { if (Bank.open()) { if (Bank.contains("Bronze pickaxe")) { Bank.withdraw("Bronze pickaxe", 1); Sleep.sleepUntil(() -> Inventory.contains("Bronze pickaxe"), 6000); } else { log("Bronze pickaxe not found in bank!"); } Bank.close(); } } break; case FINDING_ORE: destination = ironOre.getRandomTile(); if (!Players.getLocal().isMoving() && !Players.getLocal().getTile().equals(destination)) { Walking.walk(destination.getRandomized()); } break; case MINING_ORE: if (!Players.getLocal().isAnimating() && !Players.getLocal().isMoving()) { GameObject ironRocks = GameObjects.closest(t -> t.getName().equalsIgnoreCase("iron rocks") && ironOre.contains(t.getTile())); if (ironRocks != null && ironRocks.interact("Mine")) { Sleep.sleepUntil(() -> Players.getLocal().isAnimating(), 4000); } } break; } return 1000; } private State getState() { if (Inventory.isFull() && !bankArea.contains(Players.getLocal().getTile())) { return State.WALKING_TO_BANK; } else if (Inventory.isFull() && bankArea.contains(Players.getLocal().getTile()) && !Bank.isOpen()) { return State.USE_BANK; } else if (Bank.isOpen() && Inventory.isFull()) { return State.BANKING; } else if (!Inventory.contains("Bronze pickaxe")) { return State.TAKE_PICKAXE; } else if (!Inventory.isFull() && !ironOre.contains(Players.getLocal().getTile())) { return State.FINDING_ORE; } else if (!Inventory.isFull() && ironOre.contains(Players.getLocal().getTile())) { return State.MINING_ORE; } return state; } } Link to comment Share on other sites More sharing options...
Deep Slayer 21 Share Posted March 12 (edited) if(!Bank.isOpen() && Inventory.isFull()){ if(Walking.shouldWalk()){ Bank.open(); } return; } just do this if you want to open the closest bank from anywhere in the game. this will combine your WALKING_TO_BANK and USE_BANK case into one Edited March 12 by Deep Slayer Link to comment Share on other sites More sharing options...
KhalDrogonerr 0 Author Share Posted March 12 thanks very much! I'll do some testing today and update you! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now