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