Jump to content

Working with Autocasting


Recommended Posts

Posted (edited)

Autocast config is getConfigs().get(108)

Not sure if the 108 is related to what staff you are carrying or it's just static, I've done this with a staff of air

 

Value 0 is no spell selected

Value 3 is air strike

5 is water strike and so on

 

smile.png

Here is a snippet that does a spell change based on levels

private int getSpellChange()
{
    int currentSpell = self.getConfigs().get(108);
    int currentLevel = self.getSkills().getStatic(Skill.MAGIC);
    if (currentLevel >= 13) {
        if (currentSpell != 9) {
            return 4;
        } else{ 
            return 0;
        }
    } else if (currentLevel >= 9) {
        if (currentSpell != 7) {
            return 3;
        } else{ 
            return 0;
        }
    } else if (currentLevel >= 5) {
        if (currentSpell != 5) {
            return 2;
        } else{ 
            return 0;
        }
    } else if (currentLevel >= 1) {
        if (currentSpell != 3) {
            return 1;
        } else{ 
            return 0;
        }
    } 
    return 0;
}


private void changeSpell()
{
    if (self.getTabs().open(Tab.ATTACK)) {
        RS2Widget castWidget = self.getWidgets().get(593, 25);
        if (castWidget != null && castWidget.isVisible()) {
            if (castWidget.interact()) {
                new ConditionalSleep(MethodProvider.random(2000,5000), MethodProvider.random(100,200)) {
                    @[member=Override]
                    public boolean condition() throws InterruptedException {
                        return !castWidget.isVisible();
                    }
                }.sleep();
            }
        } else {
            RS2Widget spellWidget = self.getWidgets().get(201, 0 , getSpellChange());
            if (spellWidget != null && spellWidget.isVisible() && spellWidget.interact()) {
                new ConditionalSleep(MethodProvider.random(2000,5000), MethodProvider.random(100,200)) {
                    @[member=Override]
                    public boolean condition() throws InterruptedException {
                        return getSpellChange() == 0;
                    }
                }.sleep();
                if (MethodProvider.random(0, 1) == 0) {
                    self.getTabs().open(Tab.INVENTORY);
                }
            }
        }
    }
}   


Edited by Abuse
  • Like 1
  • 2 weeks later...
Posted

 

Autocast config is getConfigs().get(108)

Not sure if the 108 is related to what staff you are carrying or it's just static, I've done this with a staff of air

 

Value 0 is no spell selected

Value 3 is air strike

5 is water strike and so on

 

smile.png

Here is a snippet that does a spell change based on levels

private int getSpellChange()
{
    int currentSpell = self.getConfigs().get(108);
    int currentLevel = self.getSkills().getStatic(Skill.MAGIC);
    if (currentLevel >= 13) {
        if (currentSpell != 9) {
            return 4;
        } else{ 
            return 0;
        }
    } else if (currentLevel >= 9) {
        if (currentSpell != 7) {
            return 3;
        } else{ 
            return 0;
        }
    } else if (currentLevel >= 5) {
        if (currentSpell != 5) {
            return 2;
        } else{ 
            return 0;
        }
    } else if (currentLevel >= 1) {
        if (currentSpell != 3) {
            return 1;
        } else{ 
            return 0;
        }
    } 
    return 0;
}


private void changeSpell()
{
    if (self.getTabs().open(Tab.ATTACK)) {
        RS2Widget castWidget = self.getWidgets().get(593, 25);
        if (castWidget != null && castWidget.isVisible()) {
            if (castWidget.interact()) {
                new ConditionalSleep(MethodProvider.random(2000,5000), MethodProvider.random(100,200)) {
                    @[member='Override']
                    public boolean condition() throws InterruptedException {
                        return !castWidget.isVisible();
                    }
                }.sleep();
            }
        } else {
            RS2Widget spellWidget = self.getWidgets().get(201, 0 , getSpellChange());
            if (spellWidget != null && spellWidget.isVisible() && spellWidget.interact()) {
                new ConditionalSleep(MethodProvider.random(2000,5000), MethodProvider.random(100,200)) {
                    @[member='Override']
                    public boolean condition() throws InterruptedException {
                        return getSpellChange() == 0;
                    }
                }.sleep();
                if (MethodProvider.random(0, 1) == 0) {
                    self.getTabs().open(Tab.INVENTORY);
                }
            }
        }
    }
}   


sorry for the late reply but thanks so much! this will definitely come in handy. 

Try autocast api made by botre in the snippets section

i saw that but i dont really know how to add like a function like that into my script :(

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
  • Recently Browsing   0 members

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