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

  • 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 key event handling issue


      Fix other event handling issue


      Fix RSServer hook


      Update world hopper to have it use OCR, thanks to Todd


      Use proper disposal of old Graphics objects


      Reformat code


      Rearrange code


      Organize code imports


      Apply around 8000 automated code refactorings


      Make preparations for Java 9


      Fix 11 various bugs


      Add more reliable debugging support


      Fix mouseEntered/Exited event dispatching bug


      Fix minimap walking bug where it opens the map


      Fix broken hooks for today's game update
        • Thanks
        • Like
      • 55 replies
    • This update will:

      Fix GE inventory item positioning bug


      Fix broken object hooks
        • Like
      • 27 replies
    • This release will:

      Fix some ClosedChannelException bug


      Fix bug in RSObject#getAllTiles


      Add game tab support for "Kourend Favour"
        • Like
      • 15 replies
    • This release will:

      Fix Settings UI placement bug


      Fix game object location bug


      Fix small layout bug making the client shift up and down


      Fix client crashing bug where loading the client with a small display area will cause the client to crash


      Fix annoying Linux bug relating to painting events and peers


      Fix settings saving bug where settings are saved to disk more often than they should


      Fix RSInterface#isBeingDrawn bug affecting a limited amount of people


      Drop Java 1.7 bytecode version for 1.8


      Important: Since the downloadable RS client uses Java 7, it will no longer be compatible with Looking Glass. To make up for this, we will add support for using other clients such as RuneLite (at a later date).


      This change was necessary to allow us to use Java 8 syntax. It also paves the way for Java 9/10/11 support.
        • Like
      • 40 replies
    • This update will:

      Fix the RSMenuNode bug which also fixes the bug with bank opening


      Fix the incorrect object positions bug


      Fix and re-enable the LG Objects API Accelerator


      Fix the RSObject#getAllTiles bug
        • Like
      • 22 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×