Jump to content

gavin101

Members
  • Posts

    2
  • Joined

  • Last visited

  • Days Won

    2

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

gavin101's Achievements

Bronze Member

Bronze Member (1/10)

  1. I've updated the script and it ran for about 5 hours flawlessly until someone lured a wizard to the bank and killed me. 😞 I know this script is useless but just to practice I'm thinking of continuing with: Getting the live price of the tinderbox instead of hardcoding an estimated price Handle deaths (the new buying your stuff back from Death and everything is new to me. Can the API already deal with this?) Muling support (Would require the accounts to be 10qp)
  2. I've been learning python for the last year but wanted to try to learn java/scripting so this was a quick project to get familiar with java syntax, scripting api, etc. I know there's a lot to clean up but if you see any bad practices or have any tips I would appreciate it. ❤️ Start with an empty inventory in the draynor village bank. 45 minute progress report: https://imgur.com/lEm8r4g import com.epicbot.api.shared.APIContext; import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.GroundItem; import com.epicbot.api.shared.entity.Player; import com.epicbot.api.shared.entity.SceneObject; 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 javafx.scene.Scene; import java.awt.*; @ScriptManifest(name = "Gavin's Tinderbox Collector", gameType = GameType.OS) public class main extends LoopScript { private final Tile stairsTile = new Tile(3089, 3251, 0); private final Tile bookcaseTile = new Tile(3093, 3253, 1); private final Area mansRoom = new Area (new Tile(3089, 3251, 0), new Tile(3087, 3252, 0)); private final Area draynorBank = new Area (new Tile(3092, 3246, 0), new Tile(3094, 3240, 0)); private final int fullInventory = 10; private int tinderboxes = 0; private int tinderboxCounter = 0; private long startTime; private long profit; public boolean needsToBank() { System.out.println("Checking if we need to bank!"); if (getAPIContext().inventory().getCount() == fullInventory) { System.out.println("We need to bank!"); return true; } else { System.out.println("We dont need to bank"); return false; } } public void bank_tinderboxes() { System.out.println("First line of bank_tinderboxes()"); System.out.println(draynorBank.contains(getAPIContext().localPlayer().getLocation())); if (getAPIContext().localPlayer().getPlane() != 0 && getAPIContext().objects().query().nameMatches("Staircase").results().nearest() != null) { System.out.println("Climbing down the stairs"); getAPIContext().camera().turnTo(getAPIContext().objects().query().id(16669).results().nearest().getLocation()); if (getAPIContext().objects().query().id(16669).results().nearest().interact("Climb-down")) { Time.sleep(5000, () -> getAPIContext().localPlayer().getPlane() == 0); } // Time.sleep(5_000, () -> getAPIContext().objects().query().id(16669).results().nearest().interact("Climb-down")); } if (getAPIContext().objects().query().nameMatches("Door").results().nearest().hasAction("Open") && !draynorBank.contains(getAPIContext().localPlayer().getLocation()) && !getAPIContext().localPlayer().isMoving()) { System.out.println("Opening the door"); getAPIContext().objects().query().nameMatches("Door").results().nearest().interact("Open"); } else if (!draynorBank.contains(getAPIContext().localPlayer().getLocation()) && !getAPIContext().localPlayer().isMoving()){ System.out.println("Door is open, walking to bank."); getAPIContext().webWalking().walkToBank(RSBank.DRAYNOR); Time.sleep(5000, () -> draynorBank.contains(getAPIContext().localPlayer().getLocation())); } else if (draynorBank.contains(getAPIContext().localPlayer().getLocation())){ System.out.println("We're in the bank. Continuing banking."); if (!getAPIContext().bank().isOpen()) { if (getAPIContext().bank().open()) { Time.sleep(5000, () -> getAPIContext().bank().isOpen()); } } else if (getAPIContext().inventory().getCount() == fullInventory) { System.out.println("Depositing items"); if (getAPIContext().bank().depositInventory()) { Time.sleep(5_000, () -> getAPIContext().inventory().isEmpty()); } tinderboxCounter += fullInventory; profit = (tinderboxCounter * 90); } } System.out.println("Banking finished."); tinderboxes = 0; } public boolean needsToTravel() { Tile myTile = getAPIContext().localPlayer().getLocation(); if (getAPIContext().inventory().isEmpty() && !myTile.equals(bookcaseTile)) { return true; } else { return false; } } public void travelToBookcase() { Tile myTile = getAPIContext().localPlayer().getLocation(); Tile outsideTile = new Tile (3088, 3250, 0); if (myTile.equals(bookcaseTile)) { System.out.println("We're at the bookcase tile!"); } else if (getAPIContext().localPlayer().getPlane() == 1 && !myTile.equals(bookcaseTile) && !getAPIContext().localPlayer().isMoving()) { System.out.println("We're walking to the bookcase tile."); if (getAPIContext().walking().walkTo(getAPIContext().objects().query().id(7073).results().nearest().getLocation())) { Time.sleep(1000, 1200, () -> getAPIContext().localPlayer().getLocation().equals(getAPIContext().objects().query().id(7073).results().nearest().getLocation())); } } else if (!mansRoom.contains(myTile) && getAPIContext().objects().query().nameMatches("Door").results().nearest().hasAction("Open")) { getAPIContext().walking().walkTo(outsideTile); getAPIContext().objects().query().nameMatches("Door").results().nearest().interact("Open"); System.out.println("We're walking to the stairs tile."); getAPIContext().webWalking().walkTo(stairsTile); Time.sleep(5_000, () -> getAPIContext().objects().query().nameMatches("Staircase").results().nearest().interact("Climb-up")); } else if (getAPIContext().walking().walkTo(stairsTile)) { Time.sleep(5000, () -> getAPIContext().localPlayer().getLocation().equals(stairsTile)); if (getAPIContext().objects().query().nameMatches("Staircase").results().nearest().interact("Climb-up")) { Time.sleep(7000, () -> getAPIContext().localPlayer().getPlane() == 1); } } } public void gather_tinderboxes() { System.out.println("Time to get our tinderboxes!"); SceneObject Bookshelf = getAPIContext().objects().query().id(7073).results().nearest(); GroundItem Tinderbox = getAPIContext().groundItems().query().nameMatches("Tinderbox").results().nearest(); while (tinderboxes != fullInventory) { // Time.sleep(500, 1000); // It will spam click the bookcase otherwise if (getAPIContext().inventory().isEmpty()) { System.out.println("Searching bookshelf"); getAPIContext().camera().turnTo(getAPIContext().objects().query().id(7073).results().nearest().getLocation()); if (Bookshelf.interact("Search")) { Time.sleep(3000, 4000, () -> getAPIContext().inventory().getCount() == 1); } } if (getAPIContext().inventory().getCount() > 0) { System.out.println("Stole a tinderbox! time to drop it"); if (getAPIContext().inventory().dropItem("Tinderbox")) { Time.sleep(2000,4000, () -> getAPIContext().inventory().getCount() == 0); tinderboxes++; } } } if (getAPIContext().inventory().getCount() <= fullInventory && getAPIContext().groundItems().query().nameMatches("Tinderbox").results().nearest() != null) { System.out.println("Time to pickup our tinderboxes."); getAPIContext().camera().turnTo(getAPIContext().objects().query().id(7082).results().nearest()); if (getAPIContext().groundItems().query().nameMatches("Tinderbox").results().nearest().interact("Take")) { Time.sleep(150, 250, () -> getAPIContext().inventory().getCount() == tinderboxes); } } } @Override protected int loop() { if (needsToBank()) { bank_tinderboxes(); } else if (needsToTravel()){ travelToBookcase(); } else { gather_tinderboxes(); } return 500; } @Override public boolean onStart(String... strings) { System.out.println("Now running: " + getManifest().name()); startTime = System.currentTimeMillis(); if (!getAPIContext().walking().isRunEnabled()) { System.out.println("Turning on running."); if (getAPIContext().walking().setRun(true)) { Time.sleep(2000, () -> getAPIContext().walking().isRunEnabled()); } } return true; } @Override protected void onPaint(Graphics2D g, APIContext ctx){ long runningTime = System.currentTimeMillis() - startTime; long profitPerHour = (int) (profit * 3600000.0D / runningTime); PaintFrame pf = new PaintFrame(); pf.setTitle("Gavin's Tinderbox Collector"); pf.addLine("Runtime: ", Time.getFormattedRuntime(startTime)); pf.addLine("Tinderboxes Collected: ", tinderboxCounter); pf.addLine("GP Earned: ", profit); pf.addLine("GP/Hr: ", profitPerHour); pf.draw(g, 0, 90, ctx); } }
×
×
  • Create New...