Compare commits

...

1 Commits

Author SHA1 Message Date
emo
57b9280dfe made Quizmaster optional 2025-10-19 18:32:53 -04:00
2 changed files with 51 additions and 2 deletions

View File

@ -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")
}
}

View File

@ -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())
}
}