Alias Posted January 4, 2021 Share Posted January 4, 2021 package cannonballer; import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.SceneObject; import com.epicbot.api.shared.model.Area; import com.epicbot.api.shared.script.LoopScript; import com.epicbot.api.shared.script.ScriptManifest; import com.epicbot.api.shared.util.time.Time; @ScriptManifest(name = "CB Smither", gameType = GameType.OS) public class AliasCannonballer extends LoopScript { private final static Area SMITH_AREA = new Area(3109, 3501, 3105, 3497); private final static Area EDGE_BANK = new Area(3098, 3499, 3092, 3493); private long animationTime = 0; @Override public boolean onStart(String... strings) { return true; } @Override protected int loop() { if (canSmith()) { smith(); } else { bank(); } return 100; } private boolean canSmith() { return getAPIContext().inventory().contains("Steel bar") && getAPIContext().inventory().contains("Ammo mould"); } private boolean smithInterfaceOpen() { return !getAPIContext().widgets().query().group(270).textContains("How many bars").results().isEmpty(); } private void smith() { SceneObject furnace = getAPIContext().objects().query().nameContains("Furnace").results().nearest(); if (furnace != null) { if (getAPIContext().calculations().distanceTo(furnace.getLocation()) > 5) { getAPIContext().walking().walkOnMap(SMITH_AREA.getCentralTile()); } else if (getAPIContext().localPlayer().isAnimating()) { this.animationTime = System.currentTimeMillis(); } else if (smithInterfaceOpen()) { getAPIContext().keyboard().sendText("1", false); Time.sleep(5_000, () -> getAPIContext().localPlayer().isAnimating()); } else if (System.currentTimeMillis() > animationTime + 3_000) { if (furnace.interact("Smelt")) { Time.sleep(5_000, this::smithInterfaceOpen); } } } } private void bank() { if (getAPIContext().calculations().distanceTo(EDGE_BANK.getCentralTile()) > 5) { getAPIContext().walking().walkTo(EDGE_BANK.getCentralTile()); } else if (!getAPIContext().bank().isOpen()) { if (getAPIContext().bank().open()) { Time.sleep(5_000, () -> getAPIContext().bank().isOpen(), 5_000); } } else if (!getAPIContext().inventory().contains("Ammo mould")) { withdrawItem(1, "Ammo mould"); } else if (!getAPIContext().inventory().contains("Steel bar")) { withdrawItem(27, "Steel bar"); } } private void withdrawItem(final int amount, final String item) { if (!getAPIContext().bank().contains(item)) { stop("No " + item + "...cannot run script."); } else if (getAPIContext().bank().withdraw(amount, item)) { Time.sleep(5_000, () -> getAPIContext().inventory().contains(item)); } } } 2 Quote Link to comment Share on other sites More sharing options...
Koala Posted January 4, 2021 Share Posted January 4, 2021 Nice 🙂 Quote Link to comment Share on other sites More sharing options...
Sellout Posted January 4, 2021 Share Posted January 4, 2021 thanks fot the share ❤️ Quote Link to comment Share on other sites More sharing options...
smile Posted January 5, 2021 Share Posted January 5, 2021 Nice release :) 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.