Jump to content

Stun + Alcher script


DragonAlpha

Recommended Posts

This is a script that gets you 150k mage exp per hour.

 

It casts stun at an enemy, and then really quickly casts high alch afterwards.

 

We wear armour so that we will splash. This process is called Stun-Alching.

Here is a short video about it:

 

This script is very basic. I made it for a user named Anthony who is new here, but actually ended up using this myself.

 

Note: Babysitting advised. The script cannot logout when you are out of runes, because you cannot logout during combat. It also cannot take breaks, because again, you cannot logout during combat.

 

Usage:

Simply change the variable "targetEnemyName" to the name of the npc that you want to splash Stun onto. The current enemy is set to "Skeleton".


package scripts;

import java.awt.Color;
import java.awt.Graphics2D;
import java.text.NumberFormat;
import java.util.Locale;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.ui.Option;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;


@ScriptManifest(name = "Stun Alcher", author = "MegaManAlpha", logo = "", version = 0.0, info = "")
public class StunAlcher extends Script {
    String targetEnemyName = "Skeleton";
    long scriptStartTime = 0;
    int startMagicLevel = 0;
    int startMagicExp = 0;
    int currentMagicExp = 0;
    int soulRunesStartAmount = 0;
    int soulRunesCurrentAmount = 0;
    int soulRunesUsed = 0;
    int natureRunesStartAmount = 0;
    int natureRunesCurrentAmount = 0;
    int natureRunesUsed = 0;
    boolean started = false;

    @Override
    public void onStart() throws InterruptedException {
        antiBan.unregisterAllBehaviors();
        scriptStartTime = System.currentTimeMillis();
        startMagicExp = skills.getExperience(Skill.MAGIC);
        startMagicLevel = skills.getStatic(Skill.MAGIC);
        soulRunesStartAmount = getNumberOfSoulRunes();
        natureRunesStartAmount = getNumberOfNatureRunes();

        log("MegaManAlpha's Stun-Alcher script has now started!");
        log("You will be splashing: " + targetEnemyName);
        started = true;
    }
    
    @Override
    public int onLoop() throws InterruptedException {
        if(started) getState();
        return random(100, 200);
    }
 
    private void getState() throws InterruptedException {
        if(!client.isLoggedIn()) {
            log("Not logged in.");
            log("You need to be logged in for this script to work.");
            return;
        }
        
        if(!tabs.getOpen().equals(Tab.MAGIC)) {
            if(tabs.open(Tab.MAGIC)) {
                sleepUntilMagicTabOpens();
            }
            return;
        }
        
        Entity enemy = npcs.closest(targetEnemyName);
        if(enemy == null) {
            log("Target enemy not found");
            return;
        }
        
        soulRunesCurrentAmount = getNumberOfSoulRunes();
        natureRunesCurrentAmount = getNumberOfNatureRunes();
        soulRunesUsed = soulRunesStartAmount - soulRunesCurrentAmount;
        natureRunesUsed = natureRunesStartAmount - natureRunesCurrentAmount;
        currentMagicExp = skills.getExperience(Skill.MAGIC);

        if(magic.castSpellOnEntity(Spells.NormalSpells.STUN, enemy) && sleepUntilStunIsCast(soulRunesCurrentAmount)) {
            sleep(random(25, 100));
            if(moveMouseToAlchArea()) {
                leftClick();
                if(sleepUntilInventoryTabActive() && isHighAlchOption()) {
                    sleep(random(25, 100));
                    leftClick();
                    sleepUntilMagicTabOpens();
                }
            }
        }
    }
    
    private int getNumberOfSoulRunes() throws InterruptedException {
        for(Item item : inventory.getItems()) {
            if(item != null && item.getDefinition() != null && item.getName() != null) {
                if(item.getName().equals("Soul rune")) {
                    return item.getAmount();
                }
            }
        }
        return 0;
    }
    
    private int getNumberOfNatureRunes() throws InterruptedException {
        for(Item item : inventory.getItems()) {
            if(item != null && item.getDefinition() != null && item.getName() != null) {
                if(item.getName().equals("Nature rune")) {
                    return item.getAmount();
                }
            }
        }
        return 0;
    }
    
    private boolean moveMouseToAlchArea() throws InterruptedException {
        //high alch area rectangle
        //709, 322
        //719, 336
        mouse.move(random(709, 719), random(322, 336));
        return isHighAlchOption();
    }
    
    private boolean isHighAlchOption() {
        for(Option option : menu.getMenu()) {
            if(option != null) {
                if(option.action.equals("Cast")) {
                    if(option.name.contains("High Level Alchemy")) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
    
    private void leftClick() {
        mouse.click(false);
    }
    
    private void rightClick() {
        mouse.click(true);
    }
    
    private void sleepUntilMagicTabOpens() throws InterruptedException {
        long startTime = System.currentTimeMillis();
        long timeout = 4000;
        
        while(!tabs.getOpen().equals(Tab.MAGIC)) {
            long timeNow = System.currentTimeMillis();
            if(timeNow > startTime + timeout) {
                break;
            }
            sleep(100);
        }
    }
    
    private boolean sleepUntilStunIsCast(int startNumOfSoulRunes) throws InterruptedException {
        long startTime = System.currentTimeMillis();
        long timeout = 4000;
        
        while(getNumberOfSoulRunes() == startNumOfSoulRunes) {
            long timeNow = System.currentTimeMillis();
            if(timeNow > startTime + timeout) {
                return false;
            }
            sleep(100);
        }
        
        return true;
    }
    
    private boolean sleepUntilInventoryTabActive() throws InterruptedException {
        long startTime = System.currentTimeMillis();
        long timeout = 4000;
        
        while(!tabs.getOpen().equals(Tab.INVENTORY)) {
            long timeNow = System.currentTimeMillis();
            if(timeNow > startTime + timeout) {
                return false;
            }
            sleep(100);
        }
        
        return true;
    }
    
    @Override
    public void onPaint(Graphics2D g) {
        int baseY = 10;
        int baseX = 275;
        int gapYAfterHeading = 20;
        g.setColor(Color.LIGHT_GRAY);
        g.fillRect(baseX, baseY, 290, 151);
        g.setColor(Color.BLACK);
        g.drawString("---: STUN-ALCHER :---", baseX+30, baseY+20);
        
        long totalRunTime = System.currentTimeMillis() - scriptStartTime;
        long secondsRunTime = totalRunTime / 1000;
        long minutesRunTime = 0;
        if(secondsRunTime >= 60) {
            minutesRunTime = secondsRunTime / 60;
            secondsRunTime = secondsRunTime - (minutesRunTime * 60);
        }
        String strRunTime = "";
        if(minutesRunTime > 0)
            strRunTime += minutesRunTime + "min ";
        strRunTime += secondsRunTime + "s";
        g.drawString("Run Time: " + strRunTime, baseX+10, baseY+gapYAfterHeading+35);
        
        g.drawString("Total Stuns: " + soulRunesUsed, baseX+10, baseY+gapYAfterHeading+50);

        g.drawString("Total High Alchs: " + natureRunesUsed, baseX+10, baseY+gapYAfterHeading+65);
        
        g.drawString("Exp to next level: " + NumberFormat.getNumberInstance(Locale.ENGLISH).format(skills.experienceToLevel(Skill.MAGIC)), baseX+10, baseY+gapYAfterHeading+80);
        
        int totalMagicExp = currentMagicExp - startMagicExp;
        String strMagicExp = NumberFormat.getNumberInstance(Locale.ENGLISH).format(totalMagicExp);
        g.drawString("Total Exp gained: " + strMagicExp, baseX+10, baseY+gapYAfterHeading+95);
        
        int magicLevel = skills.getStatic(Skill.MAGIC);
        g.drawString("Current level: " + magicLevel, baseX+10, baseY+gapYAfterHeading+110);
        
        g.drawString("Levels gained: " + (magicLevel - startMagicLevel), baseX+10, baseY+gapYAfterHeading+125);
    }
}

Edited by MegaManAlpha
  • Like 1
Link to comment
Share on other sites

Looks really good, is this a very expensive method? Tempted to go for 90 magic or so.

 

I only just started doing it today. So I don't know if it's expensive.

 

So far I've paid about 500k for a mud staff (mud gives me infinite earth and water runes).

 

So it means I can cast the Stun spell easily, Stun requires: 12 water, 12 earth and 1 soul rune.

 

The downside is you need to use fire runes for the high alching, since you will be wielding a mud staff.

 

I have only trialed this script with 2k soul runes, 2k natures, and 2k maple longbows (and 10k fire runes), i have been very impressed with the mega exp rates.

Link to comment
Share on other sites

  • 4 weeks later...
  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...