century 26 Share Posted September 1, 2017 Firstly, a word of thanks for distraction, slasso, and Xephy for the amazing support and help along the way. Thank you. I am where I am because of you. While working on a human-like system for dropping an inventory of items, I ended up writing this helper method. The idea is that you give the helper method the ID's of the items to be dropped and the order in which they'll be dropped. By supplying just the IDs, you won't accidentally drop any valuables; there is no unintended or unwanted behavior. By having the flexibility of providing your own pattern, you'll be able to implement some advanced patterns. Personally, I'll be using the "Drunken Walk" Algorithm for generating the drop paths. There are many maze algorithms for you to choose from. Alternatively, it would certainly be acceptable to have a few hard coded drop paths. Here is an example of a drop path that you could use: int dropOrder[] = {0,1,2,3,7,6,5,4,8,9,10,11,15,14,13,12,16,17,18,19,23,22,21,20,24,25,26,27}; Here's the method: public void dropOnlyThese (Integer[] droppables, int[] dropOrder) { // the grid construction should be in your constructor. // this is for the sake of example Rectangle[] invRects = new Rectangle[28]; for (int r = 0; r < invRects.length; r++) { int x = 563 + 42 * (r % 4); int y = 213 + 36 * (r / 4); invRects[r] = new Rectangle(x, y, 42, 36); } Mouse mouse = getMouse(); Instance instance = getClient().getInstance(); Canvas canvas = instance.getCanvas(); Inventory inventory = getInventory(); instance.setKeyboardInputEnabled(true); mouse.getMouseSettings(); MouseSettings.setSpeed(Calculations.random(7, 11)); canvas.dispatchEvent(new KeyEvent(canvas, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, KeyEvent.VK_SHIFT, KeyEvent.CHAR_UNDEFINED)); for (int r = 0; r < dropOrder.length; r++) { if (inventory.getItemInSlot(dropOrder[r]) != null && Arrays.asList(droppables).contains(inventory.getItemInSlot(dropOrder[r]).getID())) { mouse.click(invRects[dropOrder[r]]); } try { Thread.sleep(250); // randomize & speed this up } catch (InterruptedException e) { e.printStackTrace(); } } canvas.dispatchEvent(new KeyEvent(canvas, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), 0, KeyEvent.VK_SHIFT, KeyEvent.CHAR_UNDEFINED)); mouse.getMouseSettings().resetSpeed(); instance.setKeyboardInputEnabled(false); } And example usage: Integer[] droppables = {11328, 11330, 11332}; // Leaping trout, salmon, sturgeon int dropOrder[] = {0,1,2,3,7,6,5,4,8,9,10,11,15,14,13,12,16,17,18,19,23,22,21,20,24,25,26,27}; dropOnlyThese(droppables, dropOrder); I hope many of you can make good use of this. How would you generate the drop pattern? Link to comment Share on other sites More sharing options...
Koschei 147 Share Posted September 1, 2017 This is really over complicated... But I guess if it works for you Link to comment Share on other sites More sharing options...
century 26 Author Share Posted September 1, 2017 This is really over complicated... But I guess if it works for you I think the users will thank me at the end of the day when this feature reduces their ban rates. Link to comment Share on other sites More sharing options...
Studentcoder 0 Share Posted September 7, 2018 Really useful! Thanks. I think the regular getInventory().dropAll is kinda shitty so this is very nice Link to comment Share on other sites More sharing options...
ScripterSteve 5 Share Posted November 4, 2018 so changing this to click instead of drops - would it just be a case of removing the shift key out of the method? Link to comment Share on other sites More sharing options...
Thinker Bot 0 Share Posted October 12, 2019 I know this Post is dead, but i wanted to say thank you. I REALLY dont like getInventory().dropAll(x); Link to comment Share on other sites More sharing options...
lihany 1 Share Posted November 26, 2019 On 9/1/2017 at 8:44 PM, century said: I think the users will thank me at the end of the day when this feature reduces their ban rates. I know this post is dead, but this day has come! Thank you sir. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.