WindPower Posted September 19, 2017 Share Posted September 19, 2017 (edited) Hello all, This is my first script that I'm posting on OSBot, enjoy. ; all feedback, requests and progress images are welcome. To Start: Spoiler It web walks to the correct area & checks for fly fishing rod & feathers. To start fishing the quickest, start with the rod & feathers at the barb village fishing spot. If you don't start that way, the logic should handle it for you & it shouldn't be a problem. ChangeLog: Spoiler V 1.0 Luring trout and salmon in barbarian village. Banking fish in Edgeville. Custom randomization of clicking frequency. Paint showing runtime and some information about your fishing stats. Checks for presence of fly fishing rod & feathers in inventory before trying to fish. Will logout when you run out of feathers. To Add: Spoiler Custom walking Powerfishing Source Code: Spoiler Sleep Class : EdgeFisher Class: i import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; import java.util.Random; @ScriptManifest(name = "EdgevilleFisher", author = "WindPower", version = 1.0, info = "", logo = "") public class EdgeFisher extends Script { private final Area EDGEFISHINGAREA1 = new Area(3104,3431,3109,3435); private final Area EDGEFISHINGAREA2 = new Area(3100,3424,3103,3426); private long startTime; private final String formatTime(final long ms){ long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } private long probableSleep(long lastClick) { Random generator = new Random(System.currentTimeMillis()); long randomNum = (long)(generator.nextDouble() * 100); if(lastClick < 4000) return random(1000, 3000); else if(randomNum <= 10) return random(1500, 3000); else if (randomNum > 10 && randomNum <= 35) return random(2500, 3350); else if (randomNum > 35 && randomNum <= 80) return random(4000, 7500); else if (randomNum > 80 && randomNum <= 95) return random(7000, 9000); else return random(6000, 10000); } private void bank() throws InterruptedException { if (!Banks.EDGEVILLE.contains(myPosition())) { getWalking().webWalk(Banks.EDGEVILLE); } else if (!getBank().isOpen()) { getBank().open(); } else if (!getInventory().isEmptyExcept(309, 314)) { getBank().depositAllExcept(309, 314); } else if (!getInventory().contains(309) || !getInventory().contains(314)) { if (!getInventory().contains(309)) { if(getBank().contains(309)) getBank().withdraw(309, 1); else { log("No fly fishing rod in bank"); stop(true); } } if (!getInventory().contains(314)) { if(getBank().contains(314)) if(getBank().getAmount(314) > 1) getBank().withdrawAllButOne(314); else { log("Only one feather in the bank"); stop(true); } else { log("No feathers in bank"); stop(true); } } } else { stop(true); } } private void fish() throws InterruptedException { if (!(EDGEFISHINGAREA1.contains(myPosition())) && !(EDGEFISHINGAREA2.contains(myPosition()))) { getWalking().webWalk(EDGEFISHINGAREA1); } else if (getNpcs().closest(1526) != null) { NPC fishingSpot = getNpcs().closest(1526); Position fishPos = fishingSpot.getPosition(); if (fishingSpot.interact("Lure")) { Sleep.sleepUntil(() -> (myPlayer().isInteracting(fishingSpot) && myPlayer().isAnimating()), 5000); long lastClick = System.currentTimeMillis(); Sleep.sleepUntil(() -> (!(myPlayer().isAnimating()) || getDialogues().isPendingContinuation() || getInventory().isFull()) || !(fishPos.equals(fishingSpot.getPosition())), 480000); sleep(probableSleep(System.currentTimeMillis() - lastClick)); } } else { if (EDGEFISHINGAREA1.contains(myPosition())) getWalking().webWalk(EDGEFISHINGAREA2); else if (EDGEFISHINGAREA2.contains(myPosition())) getWalking().webWalk(EDGEFISHINGAREA1); } } private enum State { FISH, BANK } private State getState() { if (getInventory().isFull() || (!getInventory().contains(309) || !getInventory().contains(314))) return State.BANK; else return State.FISH; } @Override public void onStart() { log("Welcome!"); startTime = System.currentTimeMillis(); getExperienceTracker().start(Skill.FISHING); } @Override public void onExit() { //Code here will execute after the script ends } @Override public int onLoop() throws InterruptedException { switch (getState()) { case BANK: bank(); break; case FISH: fish(); break; } return 0; //The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) { g.setColor(Color.black); g.fillRect(5, 25, 160, 85); g.setFont(Font.getFont(Font.DIALOG)); g.setFont(g.getFont().deriveFont(12.0f)); g.setColor(Color.white); g.drawString("Time Elapsed: " + formatTime((System.currentTimeMillis() - startTime)), 10, 40); g.drawString("Fishing Levels Gained: " + getExperienceTracker().getGainedLevels(Skill.FISHING), 10, 55); g.drawString("XP per Hr: " + getExperienceTracker().getGainedXPPerHour(Skill.FISHING), 10, 70); g.drawString("Total XP: " + getExperienceTracker().getGainedXP(Skill.FISHING), 10, 85); g.drawString("XP to next level: " + getSkills().experienceToLevel(Skill.FISHING), 10, 100); } } Jar File: Spoiler http://s000.tinyupload.com/index.php?file_id=03081049712531815859 Progress Pics: Spoiler A special thanks to @Explv for his Sleep class as well as @Fruity @Juggles @Viston @Alek and everybody else in the chatbox who take the time to respond to my questions to help me figure things out. Edited September 22, 2017 by WindPower 4 Quote Link to comment Share on other sites More sharing options...
Lost Panda Posted September 19, 2017 Share Posted September 19, 2017 Gz on first release bro 1 Quote Link to comment Share on other sites More sharing options...
no face Posted September 19, 2017 Share Posted September 19, 2017 goodluck and gz 1 Quote Link to comment Share on other sites More sharing options...
Prozen Posted September 19, 2017 Share Posted September 19, 2017 Great work, cute lil paint too. Gratz on the release. 1 Quote Link to comment Share on other sites More sharing options...
TheWind Posted September 19, 2017 Share Posted September 19, 2017 Without "TheWind" you'll get no power ;) Also, nice job on your first release! 1 Quote Link to comment Share on other sites More sharing options...
purplewatilla Posted October 23, 2017 Share Posted October 23, 2017 Great script, love to see new scripters coming the community 1 Quote Link to comment Share on other sites More sharing options...