Jump to content

casting magic help


Recommended Posts

Posted

I am making a script for 1-99 magic and so far I have wind strike, fire strike, and fire bolt. it buys runes and staves but my one problem is the attacking. this is the first thing I made in my script so I am confused on how to fix it because I have no previous java experience but I have some experience in c++ can anyone help me make a better attack script for the Lesser demon on top of the wizards tower because right now it just clicks constantly and selects the spell sometimes.
 

private void firestrikedemon() throws InterruptedException {
    if (getTabs().open(Tab.MAGIC)) {
        if (getMouse().click(true))
            sleep(random(1000, 2000));
        NPC enemy = getNpcs().closest("Lesser demon");
        if (enemy != null) {
            magic.castSpell(Spells.NormalSpells.FIRE_STRIKE);
            if (enemy != null && !enemy.interact("Attack"))
            if (enemy.interact()) {
                sleep(random(964,1960));
            }
        }
    }
}

demon_splash.java

Posted (edited)
8 hours ago, moops22 said:

I am making a script for 1-99 magic and so far I have wind strike, fire strike, and fire bolt. it buys runes and staves but my one problem is the attacking. this is the first thing I made in my script so I am confused on how to fix it because I have no previous java experience but I have some experience in c++ can anyone help me make a better attack script for the Lesser demon on top of the wizards tower because right now it just clicks constantly and selects the spell sometimes.
 

private void firestrikedemon() throws InterruptedException {
    if (getTabs().open(Tab.MAGIC)) {
        if (getMouse().click(true))
            sleep(random(1000, 2000));
        NPC enemy = getNpcs().closest("Lesser demon");
        if (enemy != null) {
            magic.castSpell(Spells.NormalSpells.FIRE_STRIKE);
            if (enemy != null && !enemy.interact("Attack"))
            if (enemy.interact()) {
                sleep(random(964,1960));
            }
        }
    }
}

demon_splash.java 17.86 kB · 0 downloads

So why not buy a staff and auto cast? or why do you wanna cast every spell by clicking it?

Above code could be changed to something like this:

        if(getMagic().isSpellSelected()){
            NPC enemy = getNpcs().closest("Lesser demon");
            if(enemy != null){
                if(enemy.interact("Attack")){
                    ConditionalSleep2.sleep(2500, () -> !getMagic().isSpellSelected());
                }
            }
        }else{
            if(getMagic().castSpell(Spells.NormalSpells.FIRE_STRIKE)){
                ConditionalSleep2.sleep(2500, () -> getMagic().isSpellSelected());
            }
        }
Edited by Khaleesi

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