Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • How to customise drop order of dropAll()


    Vogelbekdier

    Recommended Posts

    Is there any efficient way to be able to customise the drop order and path of the droppAll() Method?

    I came across the following trying to achieve this but because of the random mouse movements I cannot get this to work.

     

      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};
        Integer[] droppables = {7936};
    
        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 = 568 + 42 * (r % 4);
                int y = 228 + 36 * (r / 4);
                invRects[r] = new Rectangle(x, y, 42, 36);
            }
            
            Instance instance = Client.getInstance();
            Canvas canvas = Instance.getCanvas();
    
            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);
        }

     

    Link to comment
    Share on other sites

    As far as I know, you'd need to implement your own dropAll to do that. I'd suggest iterating over the items in the inventory rather than their rectangles, the code above seems silly for doing that.

    Link to comment
    Share on other sites

    [code]

    Keyboard.pressShift();
    for (int i : dropOrder) {//dropOrder being an array of type int[] of the order you want to drop the items
        Item item = Inventory.getItemInSlot(i);
        if (item != null //any further criteria can be added here) {
            if (item.interact()) {
              //sleep(s)?
        }
    }
    Keyboard.releaseShift();

    [/code]

    Link to comment
    Share on other sites

    On 4/28/2021 at 7:34 PM, Pseudo said:

    [code]

    
    Keyboard.pressShift();
    for (int i : dropOrder) {//dropOrder being an array of type int[] of the order you want to drop the items
        Item item = Inventory.getItemInSlot(i);
        if (item != null //any further criteria can be added here) {
            if (item.interact()) {
              //sleep(s)?
        }
    }
    Keyboard.releaseShift();

    [/code]

    Great reply! Thank you!

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.