osrssom 25 Posted October 8, 2021 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! 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 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); } }
SDN Bot 217 Posted October 11, 2021 SomStunAlcher has been approved and is now live on the SDN!Thanks!
msemtex 6 Posted October 19, 2021 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!
osrssom 25 Author Posted October 19, 2021 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
msemtex 6 Posted October 19, 2021 1 hour ago, osrssom said: Glad you got it working! Let me know how it goes Proggy from over 2 hours in, pretty good
osrssom 25 Author Posted October 19, 2021 1 hour ago, msemtex said: Proggy from over 2 hours in, pretty good Love it! Keep sending them in!
msemtex 6 Posted October 20, 2021 Have ran further tests involving 2 - 3 hour blocks and the script has been decent - nearing 85 magic up from 66 yesterday.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.