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
  • Custom Item Dropper


    Roused

    Recommended Posts

    Posted

    If you're like me, you may have noticed that the dropping patterns of Inventory.dropAll do not mimic what you actually do when you drop all holding shift. In my case, (when playing legitimately) I tend to drop the first item, then the one below it, then the seond, then below, etc. I created a class to mimic this instead of the built-in one (which also drops more quickly). You can use this code to implement it in your projects, if you'd like.

     

    ItemDropper.dropAll() - drops all items in your inventory.

    ItemDropper.dropAllExceptTopRow() - drops all items except the top row.

     

    Feedback/suggestions welcome. Happy scripting!

     

    import org.dreambot.api.input.Mouse;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.input.Keyboard;
    import org.dreambot.api.methods.tabs.Tab;
    import org.dreambot.api.methods.tabs.Tabs;
    import org.dreambot.api.methods.widget.Widgets;
    import org.dreambot.api.utilities.Sleep;
    
    import java.awt.*;
    import java.util.HashMap;
    import java.util.Map;
    
    public class ItemDropper {
    
        private final static Map<Integer, Rectangle> itemClickboxes = new HashMap<Integer, Rectangle>() {{
            put(0, Widgets.getWidget(149).getChild(0).getChild(0).getRectangle());
            put(1, Widgets.getWidget(149).getChild(0).getChild(1).getRectangle());
            put(2, Widgets.getWidget(149).getChild(0).getChild(2).getRectangle());
            put(3, Widgets.getWidget(149).getChild(0).getChild(3).getRectangle());
            put(4, Widgets.getWidget(149).getChild(0).getChild(4).getRectangle());
            put(5, Widgets.getWidget(149).getChild(0).getChild(5).getRectangle());
            put(6, Widgets.getWidget(149).getChild(0).getChild(6).getRectangle());
            put(7, Widgets.getWidget(149).getChild(0).getChild(7).getRectangle());
            put(8, Widgets.getWidget(149).getChild(0).getChild(8).getRectangle());
            put(9, Widgets.getWidget(149).getChild(0).getChild(9).getRectangle());
            put(10, Widgets.getWidget(149).getChild(0).getChild(10).getRectangle());
            put(11, Widgets.getWidget(149).getChild(0).getChild(11).getRectangle());
            put(12, Widgets.getWidget(149).getChild(0).getChild(12).getRectangle());
            put(13, Widgets.getWidget(149).getChild(0).getChild(13).getRectangle());
            put(14, Widgets.getWidget(149).getChild(0).getChild(14).getRectangle());
            put(15, Widgets.getWidget(149).getChild(0).getChild(15).getRectangle());
            put(16, Widgets.getWidget(149).getChild(0).getChild(16).getRectangle());
            put(17, Widgets.getWidget(149).getChild(0).getChild(17).getRectangle());
            put(18, Widgets.getWidget(149).getChild(0).getChild(18).getRectangle());
            put(19, Widgets.getWidget(149).getChild(0).getChild(19).getRectangle());
            put(20, Widgets.getWidget(149).getChild(0).getChild(20).getRectangle());
            put(21, Widgets.getWidget(149).getChild(0).getChild(21).getRectangle());
            put(22, Widgets.getWidget(149).getChild(0).getChild(22).getRectangle());
            put(23, Widgets.getWidget(149).getChild(0).getChild(23).getRectangle());
            put(24, Widgets.getWidget(149).getChild(0).getChild(24).getRectangle());
            put(25, Widgets.getWidget(149).getChild(0).getChild(25).getRectangle());
            put(26, Widgets.getWidget(149).getChild(0).getChild(26).getRectangle());
            put(27, Widgets.getWidget(149).getChild(0).getChild(27).getRectangle());
        }};
    
        public static void dropAll(){
    
            if (!Tabs.isOpen(Tab.INVENTORY)){
                Tabs.open(Tab.INVENTORY);
                Sleep.sleepUntil(() -> Tabs.isOpen(Tab.INVENTORY), 1200, 20);
            }
    
            Keyboard.pressShift();
    
            //First two rows
            for (int i = 0; i <= 3; i ++){
                mouseClick(i);
                Sleep.sleep(Calculations.random(5, 15));
                mouseClick(i + 4);
            }
    
            //Second two rows
            for (int i = 8; i <= 11; i ++){
                mouseClick(i);
                Sleep.sleep(Calculations.random(5, 15));
                mouseClick(i + 4);
            }
            //Third two rows
            for (int i = 16; i <= 19; i ++){
                mouseClick(i);
                Sleep.sleep(Calculations.random(5, 15));
                mouseClick(i + 4);
            }
            //Fourth two rows
            for (int i = 24; i <= 27; i ++){
                mouseClick(i);
                Sleep.sleep(Calculations.random(5, 15));
                mouseClick(i + 4);
            }
    
            Keyboard.releaseShift();
        }
        public static void dropAllExceptTopRow(){
            if (!Tabs.isOpen(Tab.INVENTORY)){
                Tabs.open(Tab.INVENTORY);
                Sleep.sleepUntil(() -> Tabs.isOpen(Tab.INVENTORY), 1200, 20);
            }
    
            Keyboard.pressShift();
    
            //Second two rows
            for (int i = 4; i <= 7; i ++){
                mouseClick(i);
                Sleep.sleep(Calculations.random(5, 15));
                mouseClick(i + 4);
            }
    
            //Third two rows
            for (int i = 12; i <= 15; i ++){
                mouseClick(i);
                Sleep.sleep(Calculations.random(5, 15));
                mouseClick(i + 4);
            }
            //Fourth two rows
            for (int i = 20; i <= 23; i ++){
                mouseClick(i);
                Sleep.sleep(Calculations.random(5, 15));
                mouseClick(i + 4);
            }
    
            Keyboard.releaseShift();
    
        }
        private static void mouseClick(int index){
            Mouse.move(itemClickboxes.get(index));
            Mouse.click();
        }
    }

     

    • 2 weeks later...
    Posted

    Nice work, but you could just use DropPattern from the DreamBot API ;)

     

    StandardDropPattern dp = new StandardDropPattern(new int[] {0, 4, 8, 12, 16, 20, 24, 25, 21, 17, 13, 9, 5, 1, 2, 6, 10, 14, 18, 22, 26, 27, 23, 19, 15, 11, 7, 3});
    Inventory.setDropPattern(dp);
    

     

     

    Posted
    7 hours ago, hashbang said:

    Nice work, but you could just use DropPattern from the DreamBot API ;)

     

    StandardDropPattern dp = new StandardDropPattern(new int[] {0, 4, 8, 12, 16, 20, 24, 25, 21, 17, 13, 9, 5, 1, 2, 6, 10, 14, 18, 22, 26, 27, 23, 19, 15, 11, 7, 3});
    Inventory.setDropPattern(dp);
    

     

     

    omg haha amazing! thank you! much easier

    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.