Jump to content

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


DirtyDick

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 ❤️

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