moops22 Posted March 13 Share Posted March 13 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 Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted March 14 Share Posted March 14 (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 March 14 by Khaleesi Quote Link to comment Share on other sites More sharing options...