Jump to content


Ivy Rems

Recommended Posts

I'm guessing the issue has something to do with your from-boat-to-Void-Knight logic. I say that because you're using both a state-based system and a task node system, which has made your script difficult to follow.

I wrote an ad-hoc alternative that might help:


import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Character;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;

public class PestControl extends Script {
	Position outsideBoat = new Position(2657,2639,0);
	Area insideBoat = new Area(2660,2638,2663,2643);
	Position whereToGo;
    public int onLoop() throws InterruptedException {
		if (myPosition().equals(outsideBoat)) {
		} else if (insideBoat.contains(myPlayer())) {
			whereToGo = null; // reset before the next game
		} else { // assume we're in the minigame
		return 250;
	private void enterTheBoat() {
		RS2Object plank = objects.closest("Gangplank");
		if (plank != null) {
			log("I am crossing the plank");
	private void waitOnTheBoat() throws InterruptedException {
		log("I am waiting on the Boat");
	private void playMinigame() {
		if (whereToGo == null) {
			// generate a dynamic tile where void knight is at
			NPC squire = npcs.closest("Squire");
			if (squire != null) {

				log("I can see the Squire");
				whereToGo = squire.getPosition().translate(0, -15);
		} else if (map.realDistance(whereToGo) > 10) {
			// go to void knight
			log("I am walking to where the Void Knight should be");
		} else {
			// protect void knight
			NPC voidKnight =  npcs.closest("Void Knight");
			if (voidKnight != null) {
				if (!myPlayer().isUnderAttack() && myPlayer().getInteracting() == null) {
					NPC enemy = findEnemy();
					if (enemy != null) {
	private NPC findEnemy() {
		return npcs.getAll().stream()
				// only get Pest Control foes
				// and make sure they're alive
				.filter(npc -> npc.getHealthPercent() > 0)
				// and that they're nearby to where we want to be
				.filter(npc -> npc.getPosition().distance(whereToGo) < 10)
				// then sort our enemies by whether or not they're attacking void knight
				// then get the first enemy in the list
				// or return null
	private static boolean isEnemy(NPC npc) {
		String name = npc.getName();
		return name.equals("Spinner")
				|| name.equals("Shifter")
				|| name.equals("Portal")
				|| name.equals("Defiler")
				|| name.equals("Splatter")
				|| name.equals("Torcher")
				|| name.equals("Brawler");
	private static int prioritiseOnEnemiesAttackingVoidKnight(NPC npc1, NPC npc2) {
		Character<?> c1 = npc1.getInteracting();
		Character<?> c2 = npc2.getInteracting();
		return Boolean.compare(isVoidKnight(c1), isVoidKnight(c2));
	private static boolean isVoidKnight(Character<?> c) {
		return c != null && c instanceof NPC && c.getName().equals("Void Knight");



  • Like 1
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.

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