Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
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

  • Similar Content

    • By fleq6
      So, I'm wondering if there's a way to make DynamicClicking a bit more accurate.
      I have the Mouse Speed set to 200, and even with that speed, when trying to loot an item in the ground while the player is running is quite hard. DynamicClicking keeps trying to reach the item while the player runs, but most of the times it can't and eventually the player runs past it and it's not on the screen anymore. Even when walking, although less often, this happens as well.
      Is there any way to decrease the fail-rate and increase the accuracy of DynamicClicking?
      Thank you.
    • By srsqtee
      Hey everyone.  As with the Banking class, I was looking to see if there was a method in the GrandExchange api to even open the GE window.  I can't seem to find one.  Does that mean I'll have to use the interface and simulate mouse/keyboard strokes in order to open the GE window?
  • Our picks

    • This release will:

      Fix LG for both OSBuddy and RuneLite


      Fix issue where the resizable client isn't able to be made smaller (Thanks @JoeDezzy1)


      Fix detection of the logout game tab when resizable mode and side panels are enabled (Thanks @JoeDezzy1)


      Add initial support for Sentry to allow us to identify and easily debug exceptions happening with all TRiBot users


      Add methods to determine if the bank is actually loaded, and not just the overarching interface (Thanks @wastedbro)



      Upcoming updates:

      Improved CLI support


      Full Sentry support


      Much more
        • Like
      • 51 replies
    • This release will:

      Fix NPE in Camera API (Thanks @wastedbro)


      Update deposit box interface ids (Thanks @Encoded)


      Add various bank methods (Thanks @wastedbro)


      Banking#getWithdrawXQuantity


      Banking#getDefaultWithdrawQuantity


      Banking#arePlaceholdersOn




      Fix resizeable minimap bug (Thanks @wastedbro)


      Remove Java 8 requirement


      Please note: TRiBot is not yet fully compatible with Java 10+




      Fix the break handler issues by ensuring the break handler thread never gets paused


      Fix broken settings hooks



      Upcoming updates:

      Improved CLI support


      Much more



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 68 replies
    • This release will:

      Add support for using custom F key bindings to switch between game tabs (Thanks @erickho123)


      Fix tab opening for "Skills" and "Kourend Tasks" (Thanks @erickho123)



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 34 replies
    • This release will:

      Fix an issue where breaks would stop firing


      Fix Combat#getWildernessLevel, use dynamic search for text and cache ID for later calls


      Fix an NPE in the Combat API


      Fix Mouse#leaveGame bug where the mouse wouldn't actually leave the game screen
        • Like
      • 21 replies
    • This release will:

      Add LG support for Runelite


      Fix NPCChat issues


      Fix a bug where the camera angle setter would just hold down a key for 5 seconds (the timeout)


      Slightly adjust the rotation via keys to be more accurate


      Add the ability for asynchronous camera movement via keys


      Make Camera rotation via mouse more fluid, with more antiban, and work much better in resizable mode


      Add a "Camera#setCamera" method, allowing the rotation and angle to be set in parallel


      Increase the likelihood of using the mouse for camera movements


      Add support for adjusting the camera to positionable entities (Positionable#adjustCameraTo)



      Upcoming updates:

      Improved CLI support


      Much more



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Thanks
        • Like
      • 59 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×