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.

Problem with making Quest script

Featured Replies

Hello guys, so im fairly new to scripting but think im starting to get a hang of it, So anyways i fucking hate questing so i figured i'd make a script for questing so i don't have to do them manually, aswell as have some fun doing them. Anyways when coding the Witch's potion i ran into some trouble, Here's the problem:

I want my character to talk to Hetty to start the quest - Because you can't get the Rat's tail before the quest is started. So i figured i'd go to the api and use the, Quests.isStarted. But it didn't work, whenever i tryed to call if(getQuests.isStarted(WITCHS_POTION) so i went to the api, and the description says exactly thesame for both IsComplete, and IsStarted.

isComplete
public boolean isComplete(Quests.Quest quest)
Returns:
False if the quest was not complete or there was an issue caching.
isStarted
public boolean isStarted(Quests.Quest quest)
Returns:
False if the quest was not complete or there was an issue caching.

Therefore i don't really know how to check if the quest is marked yellow so i can go for the rat's tail. So any ideas on how to fix this? 

My code: 

import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import static org.osbot.rs07.api.Quests.Quest.WITCHS_POTION;

@ScriptManifest(author = "Slazter", name = "An Example Script", info = "Teamplate", version = 0.1, logo = "")

public final class OsBotFråga extends Script  {

    @Override
    public final int onLoop() throws InterruptedException {

        if(canWitch()){
            questWitchPotion();
        }

        return 150;
    }

    public boolean canWitch(){
        if (!quests.isComplete(WITCHS_POTION)) {
            return true;
        } else return false;
    }
    public void questWitchPotion() throws InterruptedException {
        NPC witch = getNpcs().closest("Hetty");
        Platser plat = new Platser();
        NPC rat = getNpcs().closest("Rat");
        RS2Object range = getObjects().closest("Range");
        RS2Object cauldron = getObjects().closest(2024);
        String[] startitems = {"Onion","Eye of newt"};
        String[] allQItems = {"Onion","Eye of newt","Burnt meat","Rat's tail"};
        GroundItem tail = getGroundItems().closest("Rat's tail");
        Filter<Item> meat = new Filter<Item>() {
            @Override
            public boolean match(Item item) {
                return item.getName().contains("meat");
            }
        };

        if(!inventory.contains(startitems)){
            if(cauldron!=null && plat.witchs_potion.contains(myPosition())){
                if(!dialogues.inDialogue()){
                    cauldron.interact("Drink From");
                    sleep(random(1200,1800));
                } else if(dialogues.inDialogue()){
                    dialogueHandling();
                }
            }
            else if (!getBank().isOpen()) {
                getWalking().webWalk(Banks.DRAYNOR);
                getBank().open();
            } else {
                getBank().depositAll();
                getBank().withdraw("Onion",1);
                getBank().withdraw("Eye of newt", 1);
                getBank().withdraw(meat,1);
            }
        }
        //Start quest
        else if(inventory.contains(startitems)){
            //start quest
            if(!getQuests().isStarted(WITCHS_POTION) && !witch.isVisible()){ // Won't work
                getWalking().webWalk(plat.witchs_potion);
            } else if(witch!=null && !dialogues.inDialogue()){
                witch.interact("Talk-to");
                sleep(random(1200,1800));
            } else if(dialogues.inDialogue()){
                dialogueHandling();
            }
            
            //get Rat's tail
            else if(!inventory.contains("Rat's tail")){
                getWalking().webWalk(new Position(2957,3204,0));
                rat.interact("Attack");
                Sleep.sleepUntil(()-> rat.getHealthPercent()==0 || tail!=null,5000);
                if(tail!=null){
                    tail.interact("Take");
                    Sleep.sleepUntil(()-> !tail.isVisible(),5000);
                }
                // Cook the meat
            } else if(!inventory.contains("Burnt meat")){
                getWalking().webWalk(new Position(2969,3210,0));
                getInventory().getItem(meat).interact("Use");
                sleep(random(1250,1900));
                range.interact("Use");
                Sleep.sleepUntil(()-> !myPlayer().isAnimating(),5000);
                
                //walk back to witch
            } else if(getInventory().contains(allQItems) && !witch.isVisible()){
                getWalking().webWalk(plat.witchs_potion);
                
                //talk to witch
            } else if(witch!=null && getMap().canReach(witch) && !getDialogues().inDialogue()){
                witch.interact("Talk-to");
                Sleep.sleepUntil(()-> getDialogues().inDialogue(),5000);
            } else if(getDialogues().inDialogue()){
                dialogueHandling();
            }
        }
    }

    public void dialogueHandling() throws InterruptedException {
        String[] options = {""};
        if(dialogues.isPendingContinuation()){
            dialogues.clickContinue();
        } else if(dialogues.isPendingOption()){
            dialogues.completeDialogue(options);
        }
    }
}

Also if anyone have any feedback for me on how to improve my coding, i'd be super happy for any input :)

Edited by slazter

Look into Configs

Using Configs you'll be able to determine stages of the quest, meaning you could also figure out when the quest is started.

Edited by Eagle Scripts

  • Author
30 minutes ago, Eagle Scripts said:

Look into Configs

Using Configs you'll be able to determine stages of the quest, meaning you could also figure out when the quest is started.

Worked like a charm! Many thanks to you! :)

1 hour ago, slazter said:

 

Looking good man keep it up:P

Edited by mercylad

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.