Jump to content

Trying to make a splasher


Recommended Posts

Posted

I'm trying to make a splasher for spells like curse etc which can't be autocasted. But how do i only attack the npc that is currently attacking me? Because in the script i'm making that doesn't work correctly.

 

Spoiler

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.ui.MagicSpell;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.utility.ConditionalSleep;

public class Attacker {

	public Attacker(MethodProvider mp, MagicSpell spellToCast) throws InterruptedException {

		NPC npc = mp.getNpcs().closest(n -> n.getName().equals("Rat") && n.getInteracting() == null && !n.isUnderAttack());
		
		if(mp.myPlayer().isUnderAttack()) {
			NPC rat = mp.getNpcs().closest("Rat");
			if(rat != null) {
				if(rat.isInteracting(mp.myPlayer())) {
					if(!mp.getMagic().isSpellSelected()) {
						if(mp.getMagic().castSpell(spellToCast)) new ConditionalSleep(1000) {
							
							@Override
							public boolean condition() throws InterruptedException {
								return mp.getMagic().isSpellSelected();
							}
						}.sleep();
					} else {
						if(!mp.myPlayer().isAnimating()) {
							if(rat.interact("Cast")) new ConditionalSleep(2000) {
								
								@Override
								public boolean condition() throws InterruptedException {
									return !mp.getMagic().isSpellSelected();
								}
							}.sleep();
						}
					}
				}
			}
			
		} else {
			if(npc != null) {
				if(!mp.myPlayer().isMoving() && !mp.myPlayer().isAnimating()) {
				if(!mp.getMagic().isSpellSelected()) {
					if(mp.getMagic().castSpell(spellToCast)) new ConditionalSleep(1000) {
						
						@Override
						public boolean condition() throws InterruptedException {
							return mp.getMagic().isSpellSelected();
						}
					}.sleep();
				} else {
					if(npc.interact("Cast")) new ConditionalSleep(2000) {
						
						@Override
						public boolean condition() throws InterruptedException {
							return !mp.getMagic().isSpellSelected();
						}
					}.sleep();
				}
				}
			}
		}
		
		
	}
	
}

 

 

And also what is a good way to make it stop spamming the spells?

 

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