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

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.


  • 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 prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 61 replies
    • This release will:

      Add new internal framework for capturing exceptions


      Fix issue with not selecting the last column in world hopper (Thanks @Todd)


      Add a message about pin usage in Banking#openBank (Thanks @Todd)


      Disable the firewall by default (Thanks @Todd)


      Fix handling of the welcome screen after login (Thanks @Encoded)


      Fix wrong amount bank withdrawal (Thanks @Encoded)


      Fix Screen#isInViewport


      Fix Game#isInViewport (Thanks @Encoded)


      Call onBreakEnd for ListenerManager Breaking Listeners (Thanks @Encoded)


      Fix Prayer#getPrayerPoints NumberFormatException (Thanks @JoeDezzy1)



      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Thanks
        • Like
      • 28 replies
    • 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
      • 64 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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...