Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Why is my script not stopping?

Featured Replies

Once it finishes the dialog with the wizard, it loops back to the bank and tries to get beads again. What am I doing wrong here? I've tried different variations and can't get it to stop once it sees the "Congratulations" message! :(

package quests;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.*;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.utility.ConditionalSleep;

public class ImpCatcher extends QuestObject {
	private Area wizardsTower;

	private Area[] area = { new Area(3103, 3162, 3105, 3164).setPlane(2), // wizards tower
	};

	private String[] items = new String[] { "Red bead", "Black bead", "Yellow bead", "White bead" };

	public ImpCatcher() {
		wizardsTower = area[0];
	}

	@Override
	public int run() throws InterruptedException {
		if (!checkInventory()) {
			return 1;
		}
		switch (configs.get(808)) {
		case 0:
			startQuest();
			break;
		case 1:
            if (completeQuest()) {
                log("Quest Complete!");
                return 2;
            }
		case 2:
			log("Quest has already been completed!");
		default:
			return 2;
		}
		return 1;
	}

	private boolean checkInventory() throws InterruptedException {
		boolean inventoryReady = getInventory().contains(items);
		if (!inventoryReady && !Banks.DRAYNOR.contains(myPosition())) {
			getWalking().webWalk(Banks.DRAYNOR);
			return false;
		} else if (!inventoryReady && Banks.DRAYNOR.contains(myPosition())) {
			openBank();
			bankItems();
			takeBankItems();
			return true;
		} else {
			log("Inventory does not need to be banked!");
			return true;
		}
	}

	private void openBank() throws InterruptedException {
		if (!getBank().isOpen()) {
			getBank().open();
			log("Opening Bank...");
			new ConditionalSleep(5000) {
				@Override
				public boolean condition() throws InterruptedException {
					return getBank().isOpen();
				}
			}.sleep();
		} else {
			log("Bank is already open!");
		}
	}

	private void takeBankItems() {
		for (String item : items) {
			if (getBank().contains(item)) {
				log("Found item for quest: " + item);
				getBank().withdraw(item, 1);
			}
		}
	}

	private void bankItems() {
		if (getBank().depositAll()) {
			log("Deposited all items!");
		} else {
			log("There was an issue depositing all items!");
		}
	}

	private void walkToArea(Area area, String location) {
		log("Walking to: " + location);
		if (!area.contains(myPosition())) {
			getWalking().webWalk(area);
			new ConditionalSleep(5000) {
				@Override
				public boolean condition() throws InterruptedException {
					return area.contains(myPosition());
				}
			}.sleep();
		} else {
			log("Already in Area: " + location);
		}
	}

	private void startQuest() throws InterruptedException {
		RS2Widget widget = getWidgets().get(277, 1);
		// walk to the tower
		walkToArea(wizardsTower, "Wizard's tower");
		talkToWizard();
		new ConditionalSleep(5000) {
			@Override
			public boolean condition() throws InterruptedException {
				return widget != null && widget.isVisible();
			}
		}.sleep();
	}

	public boolean completeQuest() {
		RS2Widget widget = getWidgets().get(277, 1);
		return (widget != null && widget.isVisible());
	}

	private void talkToWizard() throws InterruptedException {
		Entity wizard = npcs.closest("Wizard Mizgog");
		if (wizard != null) {
			if (!getDialogues().inDialogue()) {
				log("Not talking to Mizgog. Starting conversation.");
				wizard.interact("Talk-to");
				log("Sleeping until conversation starts!");
				new ConditionalSleep(5000) {
					@Override
					public boolean condition() throws InterruptedException {
						return getDialogues().inDialogue();
					}
				}.sleep();
			}
			String[] options = new String[] { "Click here to continue", "Give me a quest please." };
			if (getDialogues().completeDialogue(options)) {
				log("Dialogue complete successfully!");
			} else {
				log("Dialogue failed!");
			}
			log("Just spoke with Mizgog!");
		}
	}
}

 

What are you doing with the returned int value in the run()?

Also are you sure that 2 is the correct child id of 808 when the quest is complete?

Edited by BravoTaco

  • Author
7 hours ago, BravoTaco said:

What are you doing with the returned int value in the run()?

Also are you sure that 2 is the correct child id of 808 when the quest is complete?

Oops. The ID was 3, not 2. Thanks. ^^

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.