Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.osbot.rs07.api.ui.Skill;
- import org.osbot.rs07.api.util.Utilities;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.ConditionalSleep;
- import java.awt.*;
- @ScriptManifest(name = "Rod Fishing", author = "Sonysi", version = 1.0, info = "", logo = "")
- public class rodFishing extends Script {
- public enum State {
- Idle, Fishing, Dropping
- }
- String state = "initializing";
- private long startTime;
- int startLevel, curLevel;
- int[] fishingSpots = {1542};
- public void onStart() {
- startTime = System.currentTimeMillis();
- experienceTracker.start(Skill.FISHING);
- startLevel = skills.getStatic(Skill.FISHING);
- }
- private State getState() throws InterruptedException {
- if (map.isWithinRange(npcs.closest(fishingSpots[0]), 10)) {
- if (!inventory.isFull() && !isAnimating()) {
- state = "Fishing";
- return State.Fishing;
- }
- }
- if (!inventory.contains("Feather")) {
- stop();
- }
- if (inventory.isFull()) {
- return State.Dropping;
- }
- if (isAnimating() && getMap().isWithinRange(npcs.closest(fishingSpots[0]), 3)) {
- return State.Idle;
- }
- return State.Idle;
- }
- public int onLoop() throws InterruptedException {
- if (dialogues.isPendingContinuation()) {
- Utilities.takeScreenshot();
- dialogues.clickContinue();
- new ConditionalSleep(2000) {
- @Override
- public boolean condition() throws InterruptedException {
- return !dialogues.isPendingContinuation();
- }
- }.sleep();
- }
- switch (getState()) {
- case Dropping:
- state = "Dropping";
- inventory.dropAllExcept("Feather", "Barbarian rod");
- break;
- case Fishing:
- if (map.isWithinRange(npcs.closest(fishingSpots[0]), 10)) {
- if (!inventory.isFull() && !isAnimating()) {
- state = "Fishing";
- npcs.closest(fishingSpots[0]).interact("Use-rod");
- sleep(random(1500, 2500));
- }
- }
- break;
- case Idle:
- new ConditionalSleep(5000) {
- @Override
- public boolean condition() throws InterruptedException {
- return !isAnimating() || inventory.isFull();
- }
- }.sleep();
- break;
- }
- return 100;
- }
- public boolean isAnimating() throws InterruptedException {
- int i = 0;
- while (i < 20) {
- if (myPlayer().isAnimating() || players.myPlayer().isMoving()) {
- return true;
- }
- i++;
- }
- return false;
- }
- public 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 final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- private final Color color1 = new Color(60, 60, 60, 150);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(255, 255, 255);
- private final Color color4 = new Color(50, 50, 50);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Estrangelo Edessa", 0, 13);
- public void onPaint(Graphics2D g) {
- final long runTime = System.currentTimeMillis() - startTime;
- g.setRenderingHints(antialiasing);
- g.setColor(color1);
- g.fillRect(385, 45, 128, 80);
- g.setColor(color4);
- g.setStroke(stroke1);
- g.drawRect(385, 45, 128, 80);
- g.setFont(font1);
- g.setColor(color2);
- g.drawString("Runtime: " + formatTime(runTime), 393, 60);
- g.drawString("State: " + state, 393, 75);
- g.drawString("Exp gained: " + experienceTracker.getGainedXP(Skill.FISHING), 393, 90);
- g.drawString("Exp / hour: " + experienceTracker.getGainedXPPerHour(Skill.FISHING), 393, 105);
- g.drawString("Levels gained: " + (getSkills().getStatic(Skill.FISHING) - startLevel), 393, 120);
- g.setColor(color3);
- g.drawString("Runtime: " + formatTime(runTime), 392, 59);
- g.drawString("State: " + state, 392, 74);
- g.drawString("Exp gained: " + experienceTracker.getGainedXP(Skill.FISHING), 392, 89);
- g.drawString("Exp / hour: " + experienceTracker.getGainedXPPerHour(Skill.FISHING), 392, 104);
- g.drawString("Levels gained: " + (getSkills().getStatic(Skill.FISHING) - startLevel), 392, 119);
- }
- public void onExit() {
- Utilities.takeScreenshot();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment