From 57b9280dfe2e04a82df6edf7b5d51909402e62ed Mon Sep 17 00:00:00 2001 From: emo Date: Sun, 19 Oct 2025 18:32:53 -0400 Subject: [PATCH] made Quizmaster optional --- .../quizmaster/QuizMasterChoiceDialogue.kt | 42 +++++++++++++++++++ .../ame/events/quizmaster/QuizMasterNPC.kt | 11 ++++- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 Server/src/main/content/global/ame/events/quizmaster/QuizMasterChoiceDialogue.kt diff --git a/Server/src/main/content/global/ame/events/quizmaster/QuizMasterChoiceDialogue.kt b/Server/src/main/content/global/ame/events/quizmaster/QuizMasterChoiceDialogue.kt new file mode 100644 index 0000000..0d737ce --- /dev/null +++ b/Server/src/main/content/global/ame/events/quizmaster/QuizMasterChoiceDialogue.kt @@ -0,0 +1,42 @@ +package content.global.ame.events.quizmaster + +import core.game.dialogue.DialogueFile +import core.game.dialogue.FacialExpression +import core.game.system.timer.impl.AntiMacro + +class QuizMasterChoiceDialogue : DialogueFile() { + + val CHOICE_STAGE = 50000 + + override fun handle(componentID: Int, buttonID: Int) { + if (stage < CHOICE_STAGE) { + npc(FacialExpression.FRIENDLY, "Hey ${player?.username}! It's your lucky day!", "Would you like to take part in my quiz show?") + stage = CHOICE_STAGE + } else if (stage >= CHOICE_STAGE) { + when (stage) { + CHOICE_STAGE -> options("Yes, I'd love to!", "No, thanks.").also { stage++ } + CHOICE_STAGE + 1 -> when (buttonID) { + 1 -> { + end() + // Start the quiz by calling the original kidnapping logic + startQuiz(player!!) + } + 2 -> { + end() + // Player declined, terminate the random event + AntiMacro.terminateEventNpc(player!!) + } + } + } + } + } + + private fun startQuiz(player: core.game.node.entity.player.Player) { + // This will trigger the original kidnapping and quiz logic + // We need to call the QuizMasterNPC's kidnapping method + val quizMaster = player.getAttribute("current-random-event-npc", null) as? QuizMasterNPC + quizMaster?.startQuiz() + // Clean up the attribute + player.removeAttribute("current-random-event-npc") + } +} diff --git a/Server/src/main/content/global/ame/events/quizmaster/QuizMasterNPC.kt b/Server/src/main/content/global/ame/events/quizmaster/QuizMasterNPC.kt index 26407a1..2fb3f93 100644 --- a/Server/src/main/content/global/ame/events/quizmaster/QuizMasterNPC.kt +++ b/Server/src/main/content/global/ame/events/quizmaster/QuizMasterNPC.kt @@ -26,7 +26,14 @@ import org.rs09.consts.Sounds class QuizMasterNPC(var type: String = "", override var loot: WeightBasedTable? = null) : RandomEventNPC(NPCs.QUIZ_MASTER_2477) { override fun init() { super.init() - sendChat("Hey ${player.username}! It's your lucky day!") + // Store reference to this NPC for the dialogue to access + setAttribute(player, "current-random-event-npc", this) + // Open the choice dialogue instead of immediately kidnapping + openDialogue(player, QuizMasterChoiceDialogue(), this.asNpc()) + } + + fun startQuiz() { + sendChat("Excellent! Let's begin!") queueScript(player, 4, QueueStrength.SOFT) { stage: Int -> when (stage) { 0 -> { @@ -60,6 +67,6 @@ class QuizMasterNPC(var type: String = "", override var loot: WeightBasedTable? } override fun talkTo(npc: NPC) { - openDialogue(player, QuizMasterDialogueFile(), this.asNpc()) + openDialogue(player, QuizMasterChoiceDialogue(), this.asNpc()) } } \ No newline at end of file