Jump to content

FREE FISHING SCRIPT


Paradox68

Recommended Posts

Yeah I was kinda upset there was nothing on the SDN for free people could use to fish for trout and salmon at edgeville/barb AND bank the fish....So I made a script really quick that does just that figured you guys might like it? I'm too lazy to upload it so if someone wants to do that go ahead. It just catches fish and banks them as opposed to power fishing. No configurable options, just does that one thing. You're welcome to those who wanted this.

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

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.model.RS2Object;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;


@ScriptManifest(author = "Paradox68", info = "Paradox simple Edgeville fishing script.", name = "Paradox Simple Edge Fisher", version = 1.0, logo = "")
public class main extends Script {
	private long timeStart;
	private String state = "Initializing..";
	private int invCount = 0;
	private int caught = 0;
	private int lastMA = 0;
	Area fishArea = new Area( new Position(3111,3437,0), new Position(3100,3422,0));
	Area edgeBank = new Area( new Position(3098,3499,0), new Position(3091,3488,0));
	
	
	@Override
	public void onStart() {
		getExperienceTracker().start(Skill.FISHING);
		timeStart = System.currentTimeMillis();
		
	
	}
	@Override
	public void onPaint(Graphics2D g) {
		long timeElapsed = System.currentTimeMillis() - timeStart;
		long seconds = (timeElapsed / 1000) % 60;
		long minutes = (timeElapsed / (1000 * 60)) % 60;
		long hours = (timeElapsed / (1000 * 60 * 60)) % 24;
		g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
		g.setColor(Color.white);
		
		g.drawString("x", (int)getMouse().getPosition().getX() - 4, (int)getMouse().getPosition().getY() + 5);
		g.drawString(state, 8, 50);
		g.drawString("Time Running: " + (hours >= 10 ? "" + hours : "0" + hours) + ":" + (minutes >= 10 ? "" + minutes : "0" + minutes) + ":" + (seconds >= 10 ? "" + seconds : "0" + seconds), 8, 65);
		g.drawString("XP Gained: " + getExperienceTracker().getGainedXP(Skill.FISHING) + " (" + getExperienceTracker().getGainedLevels(Skill.FISHING) + ")", 8, 80);
		g.drawString("Fish caught: " + caught, 8, 95);
	}
	
	private void randomizeMouse() {
		lastMA++;
		if (lastMA > 4) {
			int i = random(5);
			switch (i) {
			case 0:
			case 1:
				getMouse().moveOutsideScreen();
				break;
			case 2:
				getMouse().moveRandomly();
				break;
			case 3:
				getMouse().moveSlightly();
				lastMA = 3;
				break;
			case 4:
				getMouse().moveVerySlightly();
				break;
			case 5:
				getTabs().open(randomTab());
				if (getTabs().getOpen() == Tab.SKILLS) {
					getMouse().move(704, 283);
				}
			}
			
			lastMA = 0;	
		}
	}
	
	private Tab randomTab() {
		int i = random(6);
		switch(i) {
		case 0:
		case 1:
			return Tab.INVENTORY;
		case 2:
			return Tab.EQUIPMENT;
		case 3:
			return Tab.ATTACK;
		case 4:
			return Tab.SKILLS;
		case 5:
			return Tab.FRIENDS;
		case 6:
			return Tab.QUEST;
		}
		return Tab.SKILLS;
	}
	
	
	@Override
	public int onLoop() throws InterruptedException {
		if (getInventory().isFull() && !edgeBank.contains(myPlayer()) && !getBank().isOpen()) {
			state = "Walking to bank";
			getWalking().webWalk(new Position(Banks.EDGEVILLE.getRandomPosition()));
		}
		
		if (getInventory().isFull() && edgeBank.contains(myPlayer()) && !getBank().isOpen()) {
			RS2Object bank = getObjects().closest("Bank booth");
			state = "Opening bank";
			if (bank != null) {
				if (bank.interact("Bank")) {
					state = "Depositing items";
					sleep(1000);
				}
			}
		}
		
		if (getInventory().isFull() && edgeBank.contains(myPlayer()) && getBank().isOpen()) {
			getBank().depositAllExcept("Fly fishing rod", "Feather");
			while (getInventory().contains("Trout") || getInventory().contains("Salmon")) {
				sleep(100);
			}
			state = "Closing bank";
			getBank().close();
		}
		
		if (!getInventory().isFull() && !fishArea.contains(myPlayer()) && !getBank().isOpen() ) {
			state = "Walking to fishing spots.";
			getWalking().webWalk(new Position(3102 + random(3), 3433 + random(3), 0));
		}
		
		if (!getInventory().isFull() && fishArea.contains(myPlayer())) {
			NPC spot = getNpcs().closest("Fishing spot");
			state = "Finding spot.";
			if (spot != null && spot.hasAction("Lure")) {
				spot.interact("Lure");
				sleep(2000);
				invCount = getInventory().getEmptySlots();
			}
			while (myPlayer().isAnimating()) {
				state = "Catching fish.";
				randomizeMouse();
				if (getInventory().getEmptySlots() != invCount && fishArea.contains(myPlayer())) {
					invCount = getInventory().getEmptySlots();
					caught += 1;
				}
				sleep(1000);
			}	
		}
		
		
		
		
		
		return random(500, 800);
	}
	
}

Not gonna wait two hours for a good proggy but here's one. Theoretically if it lasts through one full iteration, it can last through a billion....I did two iterations for posterity and cause i'm such a saint.

7166448e41a1ba3fa89c08a90bd48ff6.png

Edited by Paradox68
Link to comment
Share on other sites

while (getInventory().contains("Trout") || getInventory().contains("Salmon")) {
                sleep(100);
}

u might get stuck here m8

 

 

Nah it won't get stuck because the onLoop calls depositAllExcept("Fly fishing rod", "Feather"); in the event before the while event is handled. So logically unless the computer somehow skips a line of code for the first time since the computer was invented, then the event should execute just fine. I ran the script for 8 hours yesterday no errors. If you feel more comfortable removing it, you're welcome to do so. I just used it so  depositAllExcept("Fly fishing rod", "Feather"); wasn't being called every 500-800ms while the bank was open. I'm sure there are better ways but as you can see this is not a full-measure script release.

Edited by Paradox68
Link to comment
Share on other sites

Since the script got a bit of love, here's an updated version of the original script with some mouse moving anti-ban methods, and switched to webwalking.

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

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.model.RS2Object;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;


@ScriptManifest(author = "Paradox68", info = "Paradox simple Edgeville fishing script.", name = "Paradox Simple Edge Fisher", version = 1.0, logo = "")
public class main extends Script {
	private long timeStart;
	private String state = "Initializing..";
	private int invCount = 0;
	private int caught = 0;
	private int lastMA = 0;
	Area fishArea = new Area( new Position(3111,3437,0), new Position(3100,3422,0));
	Area edgeBank = new Area( new Position(3098,3499,0), new Position(3091,3488,0));
	
	
	@Override
	public void onStart() {
		getExperienceTracker().start(Skill.FISHING);
		timeStart = System.currentTimeMillis();
		
	
	}
	@Override
	public void onPaint(Graphics2D g) {
		long timeElapsed = System.currentTimeMillis() - timeStart;
		long seconds = (timeElapsed / 1000) % 60;
		long minutes = (timeElapsed / (1000 * 60)) % 60;
		long hours = (timeElapsed / (1000 * 60 * 60)) % 24;
		g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
		g.setColor(Color.white);
		
		g.drawString("x", (int)getMouse().getPosition().getX() - 4, (int)getMouse().getPosition().getY() + 5);
		g.drawString(state, 8, 50);
		g.drawString("Time Running: " + (hours >= 10 ? "" + hours : "0" + hours) + ":" + (minutes >= 10 ? "" + minutes : "0" + minutes) + ":" + (seconds >= 10 ? "" + seconds : "0" + seconds), 8, 65);
		g.drawString("XP Gained: " + getExperienceTracker().getGainedXP(Skill.FISHING) + " (" + getExperienceTracker().getGainedLevels(Skill.FISHING) + ")", 8, 80);
		g.drawString("Fish caught: " + caught, 8, 95);
	}
	
	private void randomizeMouse() {
		lastMA++;
		if (lastMA > 4) {
			int i = random(5);
			switch (i) {
			case 0:
			case 1:
				getMouse().moveOutsideScreen();
				break;
			case 2:
				getMouse().moveRandomly();
				break;
			case 3:
				getMouse().moveSlightly();
				lastMA = 3;
				break;
			case 4:
				getMouse().moveVerySlightly();
				break;
			case 5:
				getTabs().open(randomTab());
				if (getTabs().getOpen() == Tab.SKILLS) {
					getMouse().move(704, 283);
				}
			}
			
			lastMA = 0;	
		}
	}
	
	private Tab randomTab() {
		int i = random(6);
		switch(i) {
		case 0:
		case 1:
			return Tab.INVENTORY;
		case 2:
			return Tab.EQUIPMENT;
		case 3:
			return Tab.ATTACK;
		case 4:
			return Tab.SKILLS;
		case 5:
			return Tab.FRIENDS;
		case 6:
			return Tab.QUEST;
		}
		return Tab.SKILLS;
	}
	
	
	@Override
	public int onLoop() throws InterruptedException {
		if (getInventory().isFull() && !edgeBank.contains(myPlayer()) && !getBank().isOpen()) {
			state = "Walking to bank";
			getWalking().webWalk(new Position(Banks.EDGEVILLE.getRandomPosition()));
		}
		
		if (getInventory().isFull() && edgeBank.contains(myPlayer()) && !getBank().isOpen()) {
			RS2Object bank = getObjects().closest("Bank booth");
			state = "Opening bank";
			if (bank != null) {
				if (bank.interact("Bank")) {
					state = "Depositing items";
					sleep(1000);
				}
			}
		}
		
		if (getInventory().isFull() && edgeBank.contains(myPlayer()) && getBank().isOpen()) {
			getBank().depositAllExcept("Fly fishing rod", "Feather");
			while (getInventory().contains("Trout") || getInventory().contains("Salmon")) {
				sleep(100);
			}
			state = "Closing bank";
			getBank().close();
		}
		
		if (!getInventory().isFull() && !fishArea.contains(myPlayer()) && !getBank().isOpen() ) {
			state = "Walking to fishing spots.";
			getWalking().webWalk(new Position(3102 + random(3), 3433 + random(3), 0));
		}
		
		if (!getInventory().isFull() && fishArea.contains(myPlayer())) {
			NPC spot = getNpcs().closest("Fishing spot");
			state = "Finding spot.";
			if (spot != null && spot.hasAction("Lure")) {
				spot.interact("Lure");
				sleep(2000);
				invCount = getInventory().getEmptySlots();
			}
			while (myPlayer().isAnimating()) {
				state = "Catching fish.";
				randomizeMouse();
				if (getInventory().getEmptySlots() != invCount && fishArea.contains(myPlayer())) {
					invCount = getInventory().getEmptySlots();
					caught += 1;
				}
				sleep(1000);
			}	
		}
		
		
		
		
		
		return random(500, 800);
	}
	
}
Link to comment
Share on other sites

  • 2 weeks later...
			while (myPlayer().isAnimating()) {

Don't use while loops in your scripts. The only while loop you should be using is the onLoop method that you're forced to override after extending script. Since your script is already looping, you could easily use an if statement to check if you're animating.

 

 

Good point, I'll keep this in mind too.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...