Jump to content

Trying to make a splasher


MarWo22

Recommended Posts

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?

 

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