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
  • Try asking for help in the chatbox
  • [Free] SomStunAlcher - 170k+ Magic xp/hr


    osrssom
     Share

    Recommended Posts

    r9zFqSu.png

    Splashes stun spells while casting high level alchemy for great xp/hour

    Welcome to my first script on DreamBot! I recently came back to OSRS but I don't have time for the long grinds required to reach the content I want to play, so I'll be scripting these tasks for myself and figured I might as well give back by releasing them as I create them. I've played for ~14 years off and on, used to script for another botting site, and have computer science and data science degrees - so hopefully I can create some useful bots for y'all! This first one is pretty simple.

    Requirements

    • Start next to the NPC you want to splash on
      • Works best at locations similar to the Monk of Zamorak in Varrock Palace
    • Start with the item you want to alch, as well as runes/staves/etc required for casting
      • Nats, fires, waters, earths, souls
      • Cheapest way is Mud battlestaff + Tome of fire with nats and souls in your inventory
        • If you're using a Tome of fire start the script with 5 fire runes in your inventory
      • Having the item to alch in inventory slot 12 or 16 makes the script look more human-like
        • Don't have valuable/important items next to the alchables as the script occasionally misclicks
    • Have 66+ magic

    Features

    • Progressive spell selection
      • Casts the best stun spell you can (Vulnerability at 66, Enfeeble at 73, and Stun at 80)
    • GUI to enter names of the item to alch and monster to attack
      • Case sensitive
    • Human-like idling
      • Randomly idles anywhere from 2 seconds to 2.5 minutes without too much impact to xp/hour
    • Feel free to request any features! 
      • Things like world hopping from crashers could be added, but I only bot to the side while I work from home so I'm always babysitting.

    Proggies

    If you use this script drop any progress screenshots in the comments!

    0bf930cac3496668e1fb9bc1a7e64ae2.png 913c75b9135851c36924f8b2e4f80d2b.png 1458ab50e76bfa060688fd0f7cb09ac5.png image.png.30601c1f2b77d05d385f2955f5fab25f.png

    Quick GIF of script in action 

     

    Now available on the SDN

    Code: Feel free to add the script locally. Also looking for any constructive criticism as I haven't used Java since sophomore year of undergrad and haven't scripted bots since around the same time :D

    Spoiler
    import org.dreambot.api.Client;
    import org.dreambot.api.input.Mouse;
    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.container.impl.Inventory;
    import org.dreambot.api.methods.interactive.NPCs;
    import org.dreambot.api.methods.magic.Magic;
    import org.dreambot.api.methods.magic.Normal;
    import org.dreambot.api.methods.magic.Spell;
    import org.dreambot.api.methods.skills.Skill;
    import org.dreambot.api.methods.skills.SkillTracker;
    import org.dreambot.api.methods.skills.Skills;
    import org.dreambot.api.methods.tabs.Tab;
    import org.dreambot.api.methods.tabs.Tabs;
    import org.dreambot.api.methods.world.World;
    import org.dreambot.api.methods.world.Worlds;
    import org.dreambot.api.methods.worldhopper.WorldHopper;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.Timer;
    import org.dreambot.api.wrappers.interactive.NPC;
    import org.dreambot.api.wrappers.interactive.Player;
    
    import javax.swing.*;
    import java.awt.*;
    import java.lang.reflect.InvocationTargetException;
    
    @ScriptManifest(name = "SomStunAlcher", description = "Stun alchs the Varrock choas druid", author = "osrssom",
                    version = 1.0, category = Category.MAGIC, image = "")
    
    public class SomStunAlcher extends AbstractScript {
    
        private static long START_TIME;
        private static String ALCH_ITEM, TARGET;
        public boolean isRunning = false;
    
        @Override
        public void onStart() {
            START_TIME = System.currentTimeMillis();
            SkillTracker.start(Skill.MAGIC);
            SwingUtilities.invokeLater(() -> createGUI());
        }
    
        public static void setAlchItem(String s) {
            log("Item to alch: " + s);
            ALCH_ITEM = s;
        }
    
        public static void setTarget(String s) {
            log("NPC to attack: " + s);
            TARGET = s;
        }
    
        private enum State {
            STUN_ALCH, WAIT
        };
    
        private State getState() {
            if (canStunAlch())
                return State.STUN_ALCH;
            else {
                log("Stopping Script");
                Tabs.logout();
                stop();
            }
            return State.WAIT;
        }
    
        @Override
        public int onLoop() {
            if (!isRunning) {
                return 500;
            }
            switch (getState()) {
                case STUN_ALCH:
                    stunAlch(bestSpell());
                    break;
                case WAIT:
                    idle(-1);
                    break;
            }
            return Calculations.random(1100, 1500);
        }
    
        private Spell bestSpell() {
            int currentLevel = Skills.getRealLevel(Skill.MAGIC);
            if (currentLevel > 79)
                return Normal.STUN;
            if (currentLevel > 72)
                return Normal.ENFEEBLE;
            return Normal.VULNERABILITY;
        }
    
        private boolean canStunAlch() {
            NPC target = NPCs.closest(TARGET);
            boolean canAttack = target != null && target.canAttack();
            boolean canStun = Magic.canCast(bestSpell()); //1 soul, 12 earth, 12 water, 80 mage
            boolean canAlch = Inventory.contains(ALCH_ITEM) && Magic.canCast(Normal.HIGH_LEVEL_ALCHEMY);
            return canAttack && canStun && canAlch;
        }
    
        private void stunAlch(Spell spell) {
            openMagic();
            NPC target = NPCs.closest(TARGET);
            Magic.castSpellOn(spell, target);
            idle(0);
            Magic.castSpell(Normal.HIGH_LEVEL_ALCHEMY);
            idle(1);
            Inventory.get(ALCH_ITEM).interact();
        }
    
        private void idle(int step) {
            int time = Calculations.random(100, 300);
            if (step == 1) {
                time = Calculations.random(100, 300);
            } else if (Calculations.random(0, 10000) < 10) {
                time = Calculations.random(2000, 10000);
                log("Sleeping 2 to 10 seconds");
            } else if (Calculations.random(1, 10000) < 4) {
                time = Calculations.random(10000, 150000);
                log("Sleeping 10 seconds to 2.5 minutes");
            }
            try {
                Thread.sleep(time);
            } catch (InterruptedException e) {
                log(e.getMessage());
            }
        }
    
        // This method opens the magic menu
        private boolean openMagic() {
            if (Tabs.getOpen() != Tab.MAGIC) {
                // Sometimes use hot keys, sometimes use mouse
                if (Calculations.random(1, 3) == 2)
                    Tabs.open(Tab.MAGIC);
                else {
                    int x = Tab.MAGIC.getWidgetChild().getX() + Calculations.random(0, 10);
                    int y = Tab.MAGIC.getWidgetChild().getY() + Calculations.random(0, 10);
                    Mouse.move(new Point(x, y));
                    Mouse.click();
                }
    
                sleep(50, 250);
            }
    
            return Tabs.getOpen() == Tab.MAGIC;
        }
    
        @Override
        public void onPaint(Graphics graphics) {
            graphics.setFont(new Font("Century Gothic", Font.BOLD, 12));
            graphics.setColor(Color.BLACK);
            graphics.drawString("SomStunAlcher - " + Timer.formatTime(System.currentTimeMillis() - START_TIME), 20, 40 );
            graphics.drawString("Xp Gained: " + SkillTracker.getGainedExperience(Skill.MAGIC) + " (+" + SkillTracker.getGainedLevels(Skill.MAGIC) + ")", 20, 55);
            graphics.drawString("Xp/hour: " + SkillTracker.getGainedExperiencePerHour(Skill.MAGIC), 20, 70);
        }
    
        private void createGUI() {
            JFrame frame = new JFrame();
            frame.setTitle("SomStunAlcher");
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.setLocationRelativeTo(Client.getInstance().getCanvas());
            frame.setPreferredSize(new Dimension(300, 170));
            frame.getContentPane().setLayout(new BorderLayout());
    
            JPanel settingPanel = new JPanel();
            settingPanel.setLayout(new GridLayout(0, 2));
    
            JLabel alchLabel = new JLabel();
            alchLabel.setText("Item to alch: ");
            settingPanel.add(alchLabel);
    
            JTextField alchTextField = new JTextField();
            settingPanel.add(alchTextField);
    
            JLabel targetLabel = new JLabel();
            targetLabel.setText("Monster Name: ");
            settingPanel.add(targetLabel);
    
            JTextField npcTextField = new JTextField();
            settingPanel.add(npcTextField);
    
            frame.getContentPane().add(settingPanel, BorderLayout.CENTER);
    
            JPanel buttonPanel = new JPanel();
            buttonPanel.setLayout(new FlowLayout());
    
            JButton button = new JButton();
            button.setText("Start Script");
    
            button.addActionListener(l -> {
                setAlchItem(alchTextField.getText());
                setTarget(npcTextField.getText());
                isRunning = true;
                frame.dispose();
            });
            buttonPanel.add(button);
    
            frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    
            frame.pack();
            frame.setVisible(true);
        }
    
    }

     

     

    Edited by osrssom
    requirements update
    Link to comment
    Share on other sites

    Followed the steps to stun at Varrock Palace and despite specifying the Monk and item to alch, the script logs out as soon as it starts up? Item and monster are using the correct case formatting.

    EDIT: Ah - I think the script detected that my mage attack bonus was not low enough (1 def pure) - using runes with no staff or tomb of fire did the trick! Just testing now!

    Edited by msemtex
    Link to comment
    Share on other sites

    1 hour ago, msemtex said:

    Followed the steps to stun at Varrock Palace and despite specifying the Monk and item to alch, the script logs out as soon as it starts up? Item and monster are using the correct case formatting.

    EDIT: Ah - I think the script detected that my mage attack bonus was not low enough (1 def pure) - using runes with no staff or tomb of fire did the trick! Just testing now!

    Glad you got it working! Let me know how it goes

    Link to comment
    Share on other sites

    • 4 weeks later...

    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
     Share

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