Jump to content

Dialogue Script Help!


imancity

Recommended Posts

So I followed some Java tutorials and explored a bit more and managed to get my script from earlier to run. Now my problem is that when the player talks to the NPC, he keeps on clicking the NPC (after the random sleep i set) and also keeps clicking the first dialogue button. Is there a way to have him complete on BUY before starting over?

 

First time coding and scripting, I appreciate any help!

case BUY:
                state = "Walking To Karim";
                getWalking().walk(kebabstore);
                npcs.closest("Karim").interact("Talk-to");
                sleep(random(300,400));
                if (dialogues.isPendingContinuation()) {
                    dialogues.clickContinue();}
                sleep(random(300,400));
                if (dialogues.isPendingOption()) {
                    dialogues.selectOption("Yes please.");}
                sleep(random(300,400));
                break;
Link to comment
Share on other sites

 

So I followed some Java tutorials and explored a bit more and managed to get my script from earlier to run. Now my problem is that when the player talks to the NPC, he keeps on clicking the NPC (after the random sleep i set) and also keeps clicking the first dialogue button. Is there a way to have him complete on BUY before starting over?

 

First time coding and scripting, I appreciate any help!

case BUY:
                state = "Walking To Karim";
                getWalking().webWalk(kebabstore);
                npcs.closest("Karim").interact("Talk-to");
                sleep(random(300,400));
                if (dialogues.isPendingContinuation()) {
                    dialogues.clickContinue();}
                sleep(random(300,400));
                if (dialogues.isPendingOption()) {
                    dialogues.selectOption("Yes please.");}
                sleep(random(300,400));
                break;
case BUY:
    if(!kebabstore.contains(myPosition()){
        getWalking().walk(kebabstore);
    } else if(!getDialogues().inDialogue()){
        npcs.closest("Karim").interact("Talk-to");
        new ConditionalSleep(5000) {
	    @Override
	    public boolean condition() throws InterruptedException {
		return getDialogues().inDialogue();
	    }
        }.sleep();
    } else if (dialogues.isPendingContinuation()) {
        dialogues.clickContinue();
        sleep(random(700, 1000));
    } else if (dialogues.isPendingOption()) {
        dialogues.selectOption("Yes please.");
        sleep(random(700, 1000));
    }
    break;

You only need to perform these actions when certain criteria are satisfied. E.g. you only want to walk to the kebab store if you aren't already there. You only want to talk to Karim if you aren't already in a dialogue etc.

Edited by Explv
  • Like 2
Link to comment
Share on other sites

case BUY:
    if(!kebabstore.contains(myPosition()){
        getWalking().walk(kebabstore);
    } else if(!getDialogues().inDialogue()){
        npcs.closest("Karim").interact("Talk-to");
        new ConditionalSleep(5000) {
	    @Override
	    public boolean condition() throws InterruptedException {
		return getDialogues().inDialogue();
	    }
        }.sleep();
    } else if (dialogues.isPendingContinuation()) {
        dialogues.clickContinue();
        sleep(random(700, 1000));
    } else if (dialogues.isPendingOption()) {
        dialogues.selectOption("Yes please.");
        sleep(random(700, 1000));
    }
    break;

 

Thanks!! I was thinking to do something like that but didn't know how to word it. Appreciate it.

 

For some reason my code is making the contains red, do I need to import something in the beginning in relation to it?

Link to comment
Share on other sites

Thanks!! I was thinking to do something like that but didn't know how to word it. Appreciate it.

 

For some reason my code is making the contains red, do I need to import something in the beginning in relation to it?

 

Sorry I assumed kebabstore was an Area. If you are using a Position, I recommend you change it to this:

private final Area kebabstore = new Area(3271, 3179, 3275, 3183);

Also change

getWalking().walk(kebabstore);

To

getWalking().webWalk(kebabstore);
Edited by Explv
  • Like 1
Link to comment
Share on other sites

 

Sorry I assumed kebabstore was an Area. If you are using a Position, I recommend you change it to this:

private final Area kebabstore = new Area(3271, 3179, 3275, 3183);

Also change

getWalking().walk(kebabstore);

To

getWalking().webWalk(kebabstore);

 

Ohh! I see, that makes sense. So for webWalking do i need Areas? I wanted to use webWalking but couldn't figure it out too well.

 

Link to comment
Share on other sites

Ohh! I see, that makes sense. So for webWalking do i need Areas? I wanted to use webWalking but couldn't figure it out too well.

 

 

No you can use Positions.

 

I only suggested that you use an Area so that you can determine if your player is in the kebab store.

 

That Area consists of all the positions in the kebab store, so by calling the contains method with the player's position, you are effectively saying. "If my player is in the kebab store"

  • Like 3
Link to comment
Share on other sites

No you can use Positions.

 

I only suggested that you use an Area so that you can determine if your player is in the kebab store.

 

That Area consists of all the positions in the kebab store, so by calling the contains method with the player's position, you are effectively saying. "If my player is in the kebab store"

 

The way you explain things really intrigues me, you should teach no joke.

  • Like 4
Link to comment
Share on other sites

  • 2 years later...
On 5/11/2016 at 11:41 AM, Explv said:

 

Thanks boss, I will make some tutorials in the near future

Any plans on making an in-depth dialogue tutorial? ?

 

Or have you already got one...

 

Also, from what you have shown, would that method also work for getting through dialogue which includes going through multiple dialogue choices? For example, I am trying to get from karamja to port sarim and vice versa, so would the following work? I'm asking as it seems like a list like this is very prone to breaking if something was to happen to just one of the options?

   ...else if (dialogues.isPendingOption()) {
        dialogues.selectOption("I have nothing to hide.");
        sleep(random(700, 1000));
    } else if (dialogues.isPendingContinuation()) {
        dialogues.clickContinue();
        sleep(random(700, 1000));
    } else if (dialogues.isPendingOption()) {
        dialogues.selectOption("Second selection in order to board boat.");
        sleep(random(700, 1000));
    } else if (dialogues.isPendingContinuation()) {
        dialogues.clickContinue();
        sleep(random(700, 1000));
    } else if (dialogues.isPendingOption()) {
        dialogues.selectOption("n selection to board boat.");
        sleep(random(700, 1000));
    } else if (dialogues.isPendingContinuation()) {
        dialogues.clickContinue();
        sleep(random(700, 1000));
    }
    break;

For context, I'm trying to avoid webwalk just to learn java a little better. Also, is there a way to conditional sleep in between the dialogue options? If so, what would you return? For the next pending continuation as the condition?

Thanks!

Edited by Glaciation96
Link to comment
Share on other sites

6 hours ago, Glaciation96 said:

Any plans on making an in-depth dialogue tutorial? ?

 

Or have you already got one...

 

Also, from what you have shown, would that method also work for getting through dialogue which includes going through multiple dialogue choices? For example, I am trying to get from karamja to port sarim and vice versa, so would the following work? I'm asking as it seems like a list like this is very prone to breaking if something was to happen to just one of the options?


   ...else if (dialogues.isPendingOption()) {
        dialogues.selectOption("I have nothing to hide.");
        sleep(random(700, 1000));
    } else if (dialogues.isPendingContinuation()) {
        dialogues.clickContinue();
        sleep(random(700, 1000));
    } else if (dialogues.isPendingOption()) {
        dialogues.selectOption("Second selection in order to board boat.");
        sleep(random(700, 1000));
    } else if (dialogues.isPendingContinuation()) {
        dialogues.clickContinue();
        sleep(random(700, 1000));
    } else if (dialogues.isPendingOption()) {
        dialogues.selectOption("n selection to board boat.");
        sleep(random(700, 1000));
    } else if (dialogues.isPendingContinuation()) {
        dialogues.clickContinue();
        sleep(random(700, 1000));
    }
    break;

For context, I'm trying to avoid webwalk just to learn java a little better. Also, is there a way to conditional sleep in between the dialogue options? If so, what would you return? For the next pending continuation as the condition?

Thanks!

You can use the completeDialog() method.

if (!dialogues.inDialog()) {
	// Talk to npc
} else {
	if (dialogues.completeDialog("answer 1", "answer2")) {
		// sleep !dialogues.inDialog()
	}
}

I just wrote this up quickly so there may be some typos but you should get the general idea.

  • Like 2
Link to comment
Share on other sites

17 hours ago, Ragnar Lothbrok said:

You can use the completeDialog() method.


if (!dialogues.inDialog()) {
	// Talk to npc
} else {
	if (dialogues.completeDialog("answer 1", "answer2")) {
		// sleep !dialogues.inDialog()
	}
}

I just wrote this up quickly so there may be some typos but you should get the general idea.

Thanks for the response. I tried to implement this but not sure if it's well off the mark or not. Regardless, any chance of someone giving feedback on how well this would work? I'd really appreciate it!

Spoiler

	public void talkToSeamen() throws InterruptedException {
		Entity sailor = npcs.closest("Seaman Thresnor", "Seaman Lorris", "Captain Tobias");
		if (sailor != null && !dialogues.inDialogue()) {
			if (sailor.interact("Talk to")) {
				new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) {
					@Override
					public boolean condition() throws InterruptedException {
						return getDialogues().inDialogue();
					}
				}.sleep();
			}
		} else {
			if (dialogues.completeDialogue("SeamenOption")) {
				new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) {
					@Override
					public boolean condition() throws InterruptedException {
						return !getDialogues().inDialogue();
					}
				}.sleep();
			}
		}
		new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) {
			@Override
			public boolean condition() throws InterruptedException {
				return boatAtKaramja.contains(myPosition()) && gangplank !=null;
			}
		}.sleep();
		sleep(random(1500,2500)); //Is this needed? Boat anim could play over character who's already at gangplank!
		if(boatAtKaramja.contains(myPosition()) && gangplank !=null) {
			gangplank.interact("Cross");
			new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) {
				@Override
				public boolean condition() throws InterruptedException {
					return !myPlayer().isAnimating() && KaramHarbour.contains(myPosition());
				}
			}.sleep();
		}
	}

 

 

 

Thanks!

Link to comment
Share on other sites

if (dialogues.completeDialogue("SeamenOption")) {
				new ConditionalSleep(9000, (int) (Math.random() * 436 + 247)) {
					@Override
					public boolean condition() throws InterruptedException {
						return !getDialogues().inDialogue();
					}
				}.sleep();
			}

This wont work as I assume the option from the dialog isn't "SeamenOption" - this needs to match the String they offer exactly.

You know WebWalking takes care of this all for you?

Area karamjaDocks = new Area(2943, 3149, 2947, 3145);
if (!karamjaDocks.contains(myPosition)) {
	getWalking.webWalk(karamjaDocks);
} else {
	// We are on Karamja
}
  

 

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