Vandermooore Posted July 23, 2022 Share Posted July 23, 2022 Hey EpicBot community, I am fairly new to coding with Java and wanted to post my first successful script. I had an issue with the Pro Fishing script not finding equipped harpoons or anything other than a standard harpoon, so I just decided to write my own script that was tailored to what I wanted (fish for swordfish, drop any tuna I got, and then continue until my inventory was full of swordfish - only at the fishing guild). I would like to eventually become an official script writer for the community once I am skilled enough, so let me know what you think of this so far. Any criticism and critiques is greatly appreciated. import com.epicbot.api.shared.APIContext; import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.NPC; import com.epicbot.api.shared.entity.WidgetGroup; import com.epicbot.api.shared.methods.*; 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 java.awt.*; @ScriptManifest(name = "Fishing Guild - Swordfish Farmer", gameType = GameType.OS) public class fisher_v2 extends LoopScript { /********************************************************** *********************VARIABLES/API******************* **********************************************************/ private String status = ""; private long startTime; private NPC fishSpotNPC; private int fishingLevel; private int xpTNL; private int counter = 0; private final Tile fishGuild = new Tile(2592, 3415); private ISkillsAPI skills() { return getAPIContext().skills(); } private INPCsAPI npc() { return getAPIContext().npcs(); } private ILocalPlayerAPI player() { return getAPIContext().localPlayer(); } private IMouseAPI mouse() { return getAPIContext().mouse(); } private IInventoryAPI myInventory() { return getAPIContext().inventory(); } private IBankAPI myBank() { return getAPIContext().bank(); } private IWebWalkingAPI walk() { return getAPIContext().webWalking(); } /********************************************************** *********************BANKING METHODS******************* **********************************************************/ private void openBank() { setStatus("Banking items"); System.out.println("Opening bank..."); myBank().open(); } private void closeBank() { setStatus("Banking items"); System.out.println("Closing bank..."); myBank().close(); } private void depositItems() { setStatus("Banking items"); System.out.println("Depositing items..."); myBank().depositAllExcept("Dragon harpoon"); } private void walkToBank() { setStatus("Walking to the bank"); System.out.println("Walking to the bank..."); walk().walkToBank(RSBank.FISHING_GUILD); } /********************************************************** *********************FISHING METHODS******************* **********************************************************/ private NPC fishSpot() { return npc().query().id(1510).reachable().results().nearest(); } private void fish() { setStatus("Fishing"); fishSpotNPC.interact("Harpoon"); mouse().moveOffScreen(); } private boolean hasTuna() { return myInventory().contains("Raw tuna"); } private void dropTuna() { myInventory().dropAll("Raw tuna"); } private boolean isInvFull() { return myInventory().isFull(); } private int fishCaught() { return myInventory().getCount("Raw swordfish"); } private boolean onlySwordFish() { return myInventory().onlyContains("Raw swordfish", "Dragon harpoon"); } /********************************************************** *********************STATUS METHODS******************* **********************************************************/ public void setStatus(String status) { this.status = status; } @Override protected void onPaint(Graphics2D g, APIContext ctx) { PaintFrame frame = new PaintFrame(); frame.setTitle("Swordfish farmer"); frame.addLine("Status: ", status); frame.addLine("Time Running: ", Time.getFormattedRuntime(startTime)); frame.addLine("Current Fishing level: ", fishingLevel); frame.addLine("XP till next Level: ", xpTNL); frame.addLine("Swordfish banked: ", counter); frame.draw(g, 0, 170, ctx); } /********************************************************** *********************Bot METHODS******************* **********************************************************/ private void levelUp() { WidgetGroup LevelUpInterface = getAPIContext().widgets().get(233); Time.sleep(500, 1000); if (LevelUpInterface.isVisible()) { getAPIContext().keyboard().sendKey(32); } } @Override public boolean onStart(String... strings) { startTime = System.currentTimeMillis(); System.out.println("Starting Pro Fisher!"); return true; } @Override protected int loop() { // Get and display current fishing level/EXP till next level/get widget for level up chat notification fishingLevel = skills().fishing().getCurrentLevel(); xpTNL = skills().fishing().getTotalExperienceToNextLevel(); WidgetGroup LevelUpInterface = getAPIContext().widgets().get(233); // Check if leveled up message appeared, clear it and continue fishing if (LevelUpInterface.isVisible()) { levelUp(); } // Check if inventory is not full, find fishing spot, fish if (!isInvFull()) { // Find fishing spot for swordfish if (player().getInteracting() == null) { fishSpotNPC = fishSpot(); System.out.println("Nearest fishing spot found..."); // Walk to found spot and start fishing if (fishSpotNPC != null) { System.out.println("Moving to fishing spot..."); walk().walkTo(fishSpotNPC); fish(); } } } // Check if inventory is full if (isInvFull()) { // Check if inventory contains raw tuna if (hasTuna()) { // Drop all raw tuna from inventory dropTuna(); } // Check if we only have a full inventory of raw swordfish if (isInvFull() && onlySwordFish()) { // Walk to bank/open walkToBank(); openBank(); // When bank is open deposit all but Dragon harpoon, add to fish counter if (myBank().open()) { counter = counter + fishCaught(); depositItems(); closeBank(); // To prevent null being return on fishing spots from inside of the bank, walk to edge of the bank for spots to be found walk().walkTo(fishGuild); } } } return 400; } } Quote Link to comment Share on other sites More sharing options...
High Im Joe1 Posted July 23, 2022 Share Posted July 23, 2022 Hello, is there a way you can help me.. I dont know how to get the script into EpicBot.. Quote Link to comment Share on other sites More sharing options...
Vandermooore Posted July 23, 2022 Author Share Posted July 23, 2022 15 minutes ago, High Im Joe1 said: Hello, is there a way you can help me.. I dont know how to get the script into EpicBot.. Hey I directly messaged you on this 👍 As I mentioned in the DM, its very direct, does not look for any equipment right now. Dragon Harpoon is the item included in this and should sit in the inventory prior to running the script. Quote Link to comment Share on other sites More sharing options...
Astral22 Posted July 29, 2022 Share Posted July 29, 2022 Where to need to copy this? Quote Link to comment Share on other sites More sharing options...
Vandermooore Posted July 29, 2022 Author Share Posted July 29, 2022 9 hours ago, Astral22 said: Where to need to copy this? You can place this attached file into: C:\Users\**yourusername**\EpicBot\Scripts If you don't have a "Scripts" folder, you can just create on and place it in there. fisher_v2.class Quote Link to comment Share on other sites More sharing options...
philrd Posted August 23, 2022 Share Posted August 23, 2022 Thanks for the code, pretty clean. That makes a great example for someone looking to start something simple Quote Link to comment Share on other sites More sharing options...
rezzx Posted January 27, 2023 Share Posted January 27, 2023 doesn't bank 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.