More dialogue work

This commit is contained in:
Ceikry 2021-03-10 11:00:01 -06:00
parent 9df72a579a
commit a0b2ae5fb8
5 changed files with 23 additions and 17 deletions

View file

@ -10,7 +10,7 @@ abstract class DialogueFile {
var player: Player? = null
var npc: NPC? = null
var interpreter: DialogueInterpreter? = null
var stage = START_DIALOGUE
open var stage = START_DIALOGUE
abstract fun handle(componentID: Int, buttonID: Int)
fun load(player: Player, npc: NPC, interpreter: DialogueInterpreter): DialogueFile{
this.player = player
@ -80,4 +80,8 @@ abstract class DialogueFile {
player("Huh. Nevermind.")
}
open fun getCurrentStage(): Int{
return stage
}
}

View file

@ -174,8 +174,10 @@ public final class DialogueInterpreter {
return;
}
player.setAttribute("chatbox-buttonid",buttonId);
if(player.getDialogueInterpreter().getDialogue().stage == END_DIALOGUE){
dialogue.close();
if((player.getDialogueInterpreter().getDialogue().file != null && player.getDialogueInterpreter().getDialogue().file.getCurrentStage() == END_DIALOGUE) || player.getDialogueInterpreter().getDialogue().stage == END_DIALOGUE){
player.getInterfaceManager().closeChatbox();
player.getInterfaceManager().openChatbox(137);
player.getDialogueInterpreter().dialogue.finished = true;
close();
return;
}

View file

@ -26,6 +26,18 @@ public class SigmundDialogue extends DialoguePlugin {
return new int[] { 2082, 2083, 2090, 3713, 3716, 3717, 3718, 3719, 3720, 4328, 4331, 4332, 4333, 4334, 4335 };
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Can I help you?");
if(player.getQuestRepository().getQuest("Lost Tribe").getStage(player) > 0 && player.getQuestRepository().getQuest("Lost Tribe").getStage(player) < 100){
npc("Have you found out what it was?");
stage = 34;
}
stage = 0;
return true;
}
@Override
public boolean handle(int interfaceId, int buttonId) {
switch (stage) {
@ -108,16 +120,4 @@ public class SigmundDialogue extends DialoguePlugin {
return new SigmundDialogue(player);
}
@Override
public boolean open(Object... args) {
npc = (NPC) args[0];
interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Can I help you?");
if(player.getQuestRepository().getQuest("Lost Tribe").getStage(player) > 0 && player.getQuestRepository().getQuest("Lost Tribe").getStage(player) < 100){
npc("Have you found out what it was?");
stage = 34;
}
stage = 0;
return true;
}
}

View file

@ -13,7 +13,7 @@ class DukeHoracioDSDialogue(val questStage: Int) : DialogueFile() {
if(questStage >= 20 && !hasShield(player!!)){
when(stage){
START_DIALOGUE -> player("I seek a shield that will protect me from dragonbreath.")
START_DIALOGUE -> player("I seek a shield that will protect me from dragonbreath.").also { stage++ }
1 -> npc("A knight going on a dragon quest, hmm? What", "dragon do you intend to slay?").also{ stage++ }
2 -> player("Elvarg, the dragon of Crandor island!").also { stage++ }
3 -> npc("Elvarg? Are you sure?").also { stage++ }

View file

@ -46,7 +46,7 @@ class DukeHoracioRMDialogue(val questStage: Int) : DialogueFile() {
when(stage){
START_DIALOGUE -> npc("The only task remotely approaching a quest is the", "delivery of the talisman I gave you to the head wizard", "of the Wizards' Tower,").also { stage++ }
2 -> npc("south-west of here. I suggest you deliver it to him as", "soon as possible. I have the oddest feeling that is", "important...").also { stage = END_DIALOGUE }
1 -> npc("south-west of here. I suggest you deliver it to him as", "soon as possible. I have the oddest feeling that is", "important...").also { stage = END_DIALOGUE }
}
}