Jump to content

Help with Fishing script


Kushitious

Recommended Posts

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();
            }
        }
    }

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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