Jump to content

casting magic help


moops22

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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