Jump to content

Randomize Item Interaction in a row


Viston

Recommended Posts

So basically, is it possible to make the script randomly interact with an item in another position in the depositbox? Currently, it interacts with the first item in the row.

E.g The X represents 1 item of multiples.

The Green circle is where the script currently interacts everytime.

The Red circles is what I'm trying to achieve, where the bot interacts with the item in different places.

X7pgxL1.png

 

  • Like 1
Link to comment
Share on other sites

Try to use the depositBox.interact(int slot, String actions) method. The action will probably be Deposit.

To achieve this you can just randomize from 1 to 28 (or from 0 to 27 - please check from where it starts counting).

Just a simple example, just add some decent randomness

 

int[] slots = new int[4] {1. 4, 8, 9};
for (int slot : slots) {
	depositBox.interact(slot, "Deposit");
}

 

Link to comment
Share on other sites

Here's a ghetto method that will work.

Get the coordinates of each inventory slot containing the item. 

x = Math.random();

100/28 ~~ 3

 

if (x <=0.03) { interact with item 1 }


if (x <=0.03) { interact with item 1 }

 

if (x>0.03 && x <=0.06) { interact with item 2 }

 

etc

etc

 

 

I haven't used java in a while so a little rusty but yeah that will work but will be annoying to type out haha. 
Im sure a java expert can show you a better short cut
 

Link to comment
Share on other sites

1 hour ago, Visty said:

So basically, is it possible to make the script randomly interact with an item in another position in the depositbox? Currently, it interacts with the first item in the row.

E.g The X represents 1 item of multiples.

The Green circle is where the script currently interacts everytime.

The Red circles is what I'm trying to achieve, where the bot interacts with the item in different places.

X7pgxL1.png

 

1. Get the length or size of the items in inventory and store it, I don't know if osbot api returns an array or arraylist 

2. Generate a random number using the size of the inventory you found.

3. Deposit using that number

Link to comment
Share on other sites

On 2017-06-13 at 4:44 PM, Visty said:

So basically, is it possible to make the script randomly interact with an item in another position in the depositbox? Currently, it interacts with the first item in the row.

E.g The X represents 1 item of multiples.

The Green circle is where the script currently interacts everytime.

The Red circles is what I'm trying to achieve, where the bot interacts with the item in different places.

X7pgxL1.png

 

Hi, this is an idea of how to accomplish your problem using python. If you need it in java, the syntax should translate fairly easily. I'm going to assume each square is 30x30 pixels and the upper left corner is 0x0.

import win32api
import random
whichitem = list()

##########
for x in range(0,23):                                           #Generate items
          whichitem.append(x)                                #
##########

for x in range(0, 23):
        i = random.randint(0, (len(whichitem) - 1))      #Choose which item
        item = whichitem                                        #
        del whichitem                                             #
        ##########
        if item <= 7:                                                 #Get coordinates of the item
            y = 15                                                      #
            x = 15 + 30*(item)                                    #
        else if 7 < item <= 15:                                   #
            y = 45                                                      #
            x = 15 + 30*(item - 8)                               #
        else:                                                            #
            y = 75                                                      #
            x = 15 + 30*(item - 16)                             #
        ##########
        def click(x,y):                                               #click the middle of the item
            win32api.SetCursorPos((x,y))
            win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
            win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
        click(x, y)
##########


So this will click one of 24 items randomly. After an item has been clicked, it will no longer click that spot. It will click the middle of each spot.
The hashtags are comments, I tried to make it easier to read.


This is just a very general idea of how you can easily use an array or list to do the problem. Of course, there is a great deal more to consider before implementing this in a bot. Some stuff you should also consider would be:

random delay between clicks
random delay on press duration (this would be in between the LEFTDOWN and LEFTUP lines of code. This is where a lot of bots fail instantly)
random x/y location on each item (rather than the middle)
random x/y drift amount between button press and release (most often zero but will be 1 or 2 regularly)
generating a path rather than teleport the cursor

A straight line beats teleporting the cursor, but a curve beats a straight line. Lots of ways you could go about this, off the top of my head a Fourier series would probably beat using splines. You could also divide
the distance into n segments and generate a new curve between each segment, if you really want to cover your ass.

Just thinking out loud now.... SetCursorPos doesn't actually input a mouse event into the command line, so jagex wouldn't see a mouse movement input command (though the mouse would light up their hook, e.g: http://output.jsbin.com/gejuz/1) You'd have to use win32con.MOUSEEVENTF_MOVE to actually send a mouse movement input.

For my codes I manually do the skilling or whatever for a couple hours and record the data. Then you can get your variance, min/max, the type of distribution, etc. It's necessary to factor that into all the above variables to really give the randomness some humanlike qualities. Consider if you were to randomly click a square 30x30 pixel box 10000 times. The locations are random, sure. But then you zoom out and you see a solid black box on a white backdrop. Boundaries is how PRNG gets cracked and I have it on good authority that Jagex uses some sort of Diehard test suite in JS that will analyze data to sniff out poorly hidden RNG.



Anyway man i'm getting rambly so just message me if you want to chat about it! GL :)







 

Edited by Pythons
Link to comment
Share on other sites

Here

	// for item list
	public void interactWithItemsRandomly(List<Item> itemList, Consumer<Item> consumer) {
		
		Collections.shuffle(itemList);
		
		itemList.forEach(consumer);
	}
	
	// for item array
	public void interactWithItemsRandomly(Item[] items, Consumer<Item> consumer) {
		interactWithItemsRandomly(Arrays.asList(items), consumer);
	}

Use like

			Item[] items = depositBox.getItems();
			
			interactWithItemsRandomly(items, item -> item.interact("Deposit"));

Or to filter items

			Item[] items = depositBox.getItems();
			
			List<Item> itemsWeWantToDeposit = Stream.of(items)
					.filter(item -> item.getName().equals("Lobster") || item.getName().equals("Shark"))
					.collect(Collectors.toList());
			
			interactWithItemsRandomly(itemsWeWantToDeposit, item -> item.interact("Deposit"));

Have fun!

Edited by liverare
Link to comment
Share on other sites

25 minutes ago, Alek said:

Use InventorySlotDestination or any of the inventory methods that take slot as an argument (as mentioned above). Good luck with the 0% ban rate, Ill be expecting a competitor client soon. 

Yeah, after learning a little bit from the community, i came to the conclusion that anti-ban is a hoax :doge:

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