Jump to content

Free || WindPower || BarbVillageFisher || Banking || First Release :) || Source Code


WindPower

Recommended Posts

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:

 

Progress Pics:

Spoiler

image.png.15f326502101cee23d545b71b4c670bf.png

 

 

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 by WindPower
  • Like 4
Link to comment
Share on other sites

  • 1 month later...

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...