Jump to content
drunksigma

Can't get the bot to take the right item

Recommended Posts

I'm trying to get the bot to click the nearest cowhide ground item. If i don't open it with right click using dynamicclick or any other clicking method which can be used to right left click then it just clicks on the grounditem stack and does not left click and then click the right take item option from the menunode.

When i do it like i have done in this code snippet it only picks the first take option which is not the correct one. How can i solve this?

 

RSGroundItem items[] = GroundItems.find("Cowhide");
			GroundItems.sortByDistanceA(Player.getPosition(), items);;
			
			if(!items.equals(null)) {
				println("here2");
				
				for(RSGroundItem index: items) {
					println("here3");
					println(index);
					if(!index.isClickable()) {
						
						
						
						
						Camera.turnToTile(index.getPosition());
						if(DynamicClicking.clickRSGroundItem(index,3)) {
							ChooseOption.select("Take");
							
						}
						
					
					
					}else {
						
						if(DynamicClicking.clickRSGroundItem(index,3)) {
							ChooseOption.select("Take");
							
						}	
					}
					sleep(1000);
					break;
				}
				
				//DynamicClicking.clickRSGroundItem(items[0],"Take")
				
				
			}

 

Share this post


Link to post
Share on other sites
6 minutes ago, drunksigma said:

RSGroundItem items[] = GroundItems.find("Cowhide");

I'm not sure, but I think that this method already sorts the found items by distance, relative to the player.

 

7 minutes ago, drunksigma said:

if(!index.isClickable())

Would make more sense to call RSGroudItem.isOnScreen().

 

7 minutes ago, drunksigma said:

Camera.turnToTile(index.getPosition());

This method accepts any objects that implement Positionable. Instead of calling getPosition,()  you could pass the RSItem itself as an argument.

Camera.turnToTile(index); 

 

10 minutes ago, drunksigma said:

if(DynamicClicking.clickRSGroundItem(index,3))

Since this client update, the Clicking class will use dynamic clicking by default.

 

 

12 minutes ago, drunksigma said:

When i do it like i have done in this code snippet it only picks the first take option which is not the correct one. How can i solve this?

 

Try this:

RSGroundItem[] cowHides = GroundItems.find("Cowhide");
if (cowHides.length > 0) {
	if (!cowHides[0].isOnScreen()) {
		Camera.turnToTile(cowHides[0]);
		Walking.blindWalkTo(cowHides[0]);
	} else if (cowHides[0].click("Take Cowhide")) {
		int i = Inventory.getCount("Cowhide");
		Timing.waitCondition(new Condition() {
			@Override
			public boolean active() {
				General.sleep(300);
				return Inventory.getCount("Cowhide") > i;
			}
		}, General.random(5000, 8000));
	}
}

 

Share this post


Link to post
Share on other sites

dojmA0T.png

I can't edit the comment above.

 

5 minutes ago, Einstein said:

I'm not sure, but I think that this method already sorts the found items by distance, relative to the player.

 

@drunksigma The method does not automatically sort by distance. However, you can achieve this on a single line:

RSGroundItem cowHides[] = GroundItems.sortByDistance(Player.getPosition(), GroundItems.find("Cowhide"));

 

Share this post


Link to post
Share on other sites
Just now, Einstein said:

dojmA0T.png

I can't edit the comment above.

 

 

@drunksigma The method does not automatically sort by distance. However, you can achieve this on a single line:

RSGroundItem cowHides[] = GroundItems.sortByDistance(Player.getPosition(), GroundItems.find("Cowhide"));

 

Thanks for the help, I just tested it and i know it does not sort by distance automaticaly. But there is a method in GroundItems which does it automaticaly.

Share this post


Link to post
Share on other sites
2 minutes ago, drunksigma said:

Thanks for the help, I just tested it and i know it does not sort by distance automaticaly. But there is a method in GroundItems which does it automaticaly.

 

That's correct, but since you didn't use it in your code, I thought that you have a specific reason for avoiding it:

37 minutes ago, drunksigma said:

RSGroundItem items[] = GroundItems.find("Cowhide");

            GroundItems.sortByDistanceA(Player.getPosition(), items);;

 

Share this post


Link to post
Share on other sites

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.

×