Jump to content

How to stop player using knife again until all fish are chunks?


Jueix

Recommended Posts

So I'm making my own aerial fishing bot and when it's time to knife the fish the player continues to use the knife on the fish instead of waiting until none is in inventory. If it clicks to use the knife on the last fish and it dissapear's the knife will be in used and it won't know what to do for fishing.

		if(continuecooking == 1) //used to continue what he's doing, if an interface for level interupts he would go back to fishing.
		{
			if(inventory.contains("Bluegill"))
			{
				if(!myPlayer().isAnimating() || !myPlayer().isMoving()) {
					inventory.getItem("Knife").interact("Use");
					sleep(random(100, 1500));
					inventory.getItem("Bluegill").interact("use");
					continuecooking = 1;
					sleep(random(1000, 6000));
				}
					
				else {
					return 600;
				}
			}
			else if(!inventory.contains("Bluegill")){
				continuecooking = 0;
			}
		}
		if(equipment.isWieldingWeapon("Cormorant's glove") && continuecooking == 0) {
			
			if(!inventory.contains("Fish chunks") && inventory.contains("Bluegill") || !inventory.contains("Fish chunks") && inventory.contains("Common tench")
					|| !inventory.contains("Fish chunks") && inventory.contains("Mottled eel") || !inventory.contains("Fish chunks") && inventory.contains("Greater siren"))
			{
				if(!myPlayer().isAnimating() || !myPlayer().isMoving()) {
					inventory.getItem("Knife").interact("Use");
					sleep(random(1000, 3000));
					inventory.getItem("Bluegill").interact("use");
					continuecooking = 1;
				}
				
				else {
					return 600;
				}
			}
			
			if(!inventory.isFull()) {
				NPC Fishspot = npcs.closest("Fishing spot"); //finds the man for the glove
				Fishspot.interact("Catch");
				sleep(random(1000,4000));
			}
			
			if(inventory.isFull())
			{
				if(!myPlayer().isAnimating() || !myPlayer().isMoving()) {
					inventory.getItem("Knife").interact("Use");
					sleep(random(1000, 3000));
					inventory.getItem("Bluegill").interact("use");
					continuecooking = 1;
				}
			}	
		}
Edited by Jueix
Link to comment
Share on other sites

I'd strongly suggest against using a long sleep (conditional or otherwise). The reason for this is if the script is sleeping, there is nothing else it can be doing and as such is unresponsive.

You're right that this situation poses a particular difficulty which is hard to combat without the use of a long sleep. You could, however, use repeating short sleeps with responsiveness added between calls. One approach to this is to (ideally) use a separate thread and a timer, querying your players animation and resetting the timer if you are still cutting. You know that you are no longer cutting when this timer expires or you have no raw fish left.

Apa

  • Like 1
Link to comment
Share on other sites

There's a function: getDialogues().clickContinue(); that you can and should use as needed.

Also, items can be put into an array String[] fishitems = {"Bluegill", "Common tench", "Mottled eel", "Greater siren"};

and you can do:
if(!inventory.contains("Fish chunks") && inventory.contains(fishitems)

Or you can do something like this:
if(!inventory.contains("Fish chunks") && inventory.contains("Bluegill", "Common tench", "Mottled eel", "Greater siren")

#.contains returns true if you have at least 1 item listed.

Link to comment
Share on other sites

6 hours ago, Malcolm said:

You can just use it if you have a certain amount of the fish or you could use a conditional sleep until the inventory doesn’t contain the fish.

Partially agree. If you calculate how long you would expect to have to wait and you have a conditional sleep look out for things that might distract the fish gutting process, then it can work quite well. However, your point still stands; the thing that I believe gets people banned is an unresponsive player. That period of unresponsiveness might be the tell tale sign of a botter. :)

 

Link to comment
Share on other sites

A conditional sleep that waits until your inventory doesn't contain any fish would be a good start. From there you could begin modifying it to work with cases where you'd get interrupted and wait around unresponsively. @Apaec is right that you should do your best to avoid long sleeps conditional or not, so I'd recommend something like this to start screwing with

new ConditionalSleep(/*Time it would take to gut all fish*/) {
	@Override
	public boolean condition() throws InterruptedException {
		return myPlayer()./*finished gutting condition(s) met*/
			}
	}.sleep();

 

Link to comment
Share on other sites

13 hours ago, quintins said:

Looking forward to the release of this one.. Ive been allover the forum looking for an aerial fishing bot so id be honored to test it out once released sir :boge:

Will do, Testing it for a few hours my self at the moment wish me luck :). Progress report after an hour (Not the best XP but still is having issues at times getting the further away fishing spots or it would be around 17k fishing xp and 25k hunting xp an hour with 8k cooking.) It generates 15 pearls at the moment an hour which isn't too bad. Can be more xp an hour but meh, only really do it for the pearls for the items.

Untitled.jpg

Link to comment
Share on other sites

POGGERS 

Seeing this brings tears to my eyes.. I fucking hate aerial fishing but want the pearls so bad... 

but imo the exp rates aren’t a concern to me.. I am more interested in the pearls and hell its free hunter, fishing, and cooking exp on the way!

I’d be more than willing to test it for you and give any feedback necessary, just let me know :boge:

Link to comment
Share on other sites

50 minutes ago, quintins said:

POGGERS 

Seeing this brings tears to my eyes.. I fucking hate aerial fishing but want the pearls so bad... 

but imo the exp rates aren’t a concern to me.. I am more interested in the pearls and hell its free hunter, fishing, and cooking exp on the way!

I’d be more than willing to test it for you and give any feedback necessary, just let me know :boge:

Add me on discord I'm looking for beta testers for my scripts so will be happy to use you as my first :).

Discord Jueix Rated#6834

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