Jump to content

Is there a more efficient way to handle dialogue whilst incorporating random sleep intervals?


Recommended Posts

Posted

Just started on a Romeo and Juliet script and I was wondering if there was a more efficient way to write a dialogue handler?

When interacting with NPCs, I'm adding each specific dialogue option manually when required and then calling another Method to get through the regular ("Click to continue") dialogue. This is how my script looks so far:

    @Override
    public int onLoop() throws InterruptedException {
    	Position julietHouse = new Position(3159, 3425, 1);
    	WebWalkEvent walkToJuliet = new WebWalkEvent(julietHouse);
    	walkToJuliet.setMinDistanceThreshold(1);
    	Area romeo = new Area (3209, 3422, 3215, 3425);
    	if (!romeo.contains(myPlayer())) {
    	log("Walking to Romeo");
    	getWalking().webWalk(romeo.getRandomPosition());
    	}
    	log("Starting quest...");
    	npcs.closest("Romeo").interact("Talk-to"); 
    	new ConditionalSleep(5000) {
            @Override
            public boolean condition() throws InterruptedException {
                return getDialogues().inDialogue();
            }
            }.sleep();
    	randSleep();
    	getThroughDialogue();
    	getDialogues().selectOption(1);
    	randSleep();
    	getThroughDialogue();
    	getDialogues().selectOption(1);
    	randSleep();

My getThroughDialogue method:

	public void getThroughDialogue() throws InterruptedException {
		for (getDialogues().isPendingContinuation(); getDialogues().clickContinue() ; randSleep());
		}

Is there a better/cleaner way to navigate dialogue while implementing sleeps? I'm really enjoying writing this quest script and I figured I should learn now as I'm planning to make several more. 

I saw in the API there is a completeDialogue method but I wasn't confident on how to use it, and wanted to add my own random interval sleeps during the dialogue to simulate a player reading the text.

Note: my getThroughDialogue method works fine when I run it but it's my first time using a for loop so it may be incorrect

Posted

I recommend going to the api, and googling that api with"site:osbot.org" attached at the end. there is an api that if you have an array of dialogues you want the bot to read through, it will. issues with this is if you have more complex dialogues to go through that each question has to be answered which iirc, RandJ does not have. i dont have the code on hand for what you want but the api will be something of:

getDialogues().completeDialogues(String ... ArrayOfDiags)
  • Like 1
Posted
2 hours ago, popshopadop said:

I recommend going to the api, and googling that api with"site:osbot.org" attached at the end. there is an api that if you have an array of dialogues you want the bot to read through, it will. issues with this is if you have more complex dialogues to go through that each question has to be answered which iirc, RandJ does not have. i dont have the code on hand for what you want but the api will be something of:

getDialogues().completeDialogues(String ... ArrayOfDiags)

Great tip thank you, I'll look into this and search the api + site:osbot.org in future ❤️

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