Jump to content

Help with Fishing script


Recommended Posts

Posted

Bot will walk to fishing area and i manually start fishing and get full invent it will bank but wont start fishing itself

Code to start Fishing

 private void StartFishing() throws InterruptedException {
        Entity FISH = objects.closest("Rod Fishing spot");

        if(FISHAREA.contains(myPlayer())){           
          if (FISH != null && !myPlayer().isMoving() && !myPlayer().isAnimating()) {
               FISH.interact("Bait");
                new ConditionalSleep(Script.random(10000, 15000)) {
                    public boolean condition()
                            throws InterruptedException {
                        return !myPlayer().isAnimating();
                    }
                }.sleep();
            }
        }
    }

Posted

I actually made on today too! ^^ Take a look at my code and compare it to yours, see how alike they are. I left out the onstart and onpaint, those won't matter too much.

    @Override
    public int onLoop() throws InterruptedException {

        if (canFish()) {
            Fish();
        } else {
        	drop();
        }
        return 700;
    }

    public boolean canFish() {
        return (getInventory().contains("Fly fishing rod", "Feather") && (!getInventory().isFull()));
    }
    
   

    
    private void drop() throws InterruptedException {
        
    	if  (getInventory().isFull()) {
             getInventory().dropAllExcept("Fly fishing rod", "Feather");
            sleep(random(50, 105));
			new ConditionalSleep(5000, 600) {
			    @Override
			    public boolean condition() {
			        return (getInventory().isEmptyExcept("Fly fishing rod", "Feather"));
			    }
			}.sleep();
        } else {
            stop(false);
        }
    }
    

    
	public void Fish() throws InterruptedException	{
		
        NPC spot = getNpcs().closest("Rod fishing spot");

			if ((!myPlayer().isAnimating()) && spot != null)	{
				spot.interact("Lure");
				sleep(random(100, 200));
				getMouse().moveOutsideScreen();
				sleep(random(4000, 5000));
						}
						new ConditionalSleep(10000, 200) {
						    @Override
						    public boolean condition() {
						        return ((!myPlayer().isAnimating()) && (spot != null));
						    }
						}.sleep();
					  }

  • Like 1
Posted
5 minutes ago, Kushitious said:

Lmao that worked. Thank you! it does spam the action until the animation starts. would i fix this with a sleep?

                new ConditionalSleep(Script.random(10000, 15000)) {
                    public boolean condition()
                            throws InterruptedException {
                        return !myPlayer().isAnimating(); <-- take the exclamation point away
                    }
                }.sleep();

And you should be good!

  • Like 1
Posted
2 minutes ago, Camaro said:

                new ConditionalSleep(Script.random(10000, 15000)) {
                    public boolean condition()
                            throws InterruptedException {
                        return !myPlayer().isAnimating(); <-- take the exclamation point away
                    }
                }.sleep();

And you should be good!

AH i had the ! there still. Thanks loads for the help!

  • Like 1
Posted
15 minutes ago, Kushitious said:

AH i had the ! there still. Thanks loads for the help!

Last thing, you should only sleep if the interact was successful

             if (FISH.interact("Bait")) {
                new ConditionalSleep(Script.random(10000, 15000)) {
                    public boolean condition()
                            throws InterruptedException {
                        return !myPlayer().isAnimating();
                    }
                }.sleep();
             }

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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