From 647a0eb0be28ba6d950ea45435ed5e8f719352d2 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Sat, 20 Mar 2021 23:54:23 -0500 Subject: [PATCH] Eastor eggz --- .../content/global/action/EquipHandler.kt | 3 + .../game/interaction/InteractionListener.kt | 6 ++ .../game/interaction/InteractionListeners.kt | 30 ++++++++++ .../interaction/item/withnpc/HatEasterEgg.kt | 51 +++++++++++++++++ .../item/withnpc/MistagEasterEgg.kt | 56 +++++++++++++++++++ 5 files changed, 146 insertions(+) create mode 100644 Server/src/main/kotlin/rs09/game/interaction/item/withnpc/HatEasterEgg.kt create mode 100644 Server/src/main/kotlin/rs09/game/interaction/item/withnpc/MistagEasterEgg.kt diff --git a/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt b/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt index 9bf089404..a6083ab63 100644 --- a/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt +++ b/Server/src/main/kotlin/rs09/game/content/global/action/EquipHandler.kt @@ -11,6 +11,7 @@ import core.game.world.map.zone.ZoneBorders import core.plugin.Plugin import org.rs09.consts.Items import rs09.game.interaction.InteractionListener +import rs09.game.interaction.InteractionListeners import rs09.game.system.config.ItemConfigParser import rs09.game.world.GameWorld @@ -51,6 +52,7 @@ class EquipHandler : InteractionListener() { return } } + InteractionListeners.run(node.id,player,node,true) val lock = player.locks.equipmentLock if (lock != null && lock.isLocked) { @@ -116,6 +118,7 @@ class EquipHandler : InteractionListener() { return } } + InteractionListeners.run(itemId,player,item,false) if (player.equipment.remove(item)) { player.audioManager.send(Audio(2238, 10, 1)) player.dialogueInterpreter.close() diff --git a/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt b/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt index 9494648c9..b3524c673 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/InteractionListener.kt @@ -28,6 +28,12 @@ abstract class InteractionListener : Listener{ fun onUseWith(type: Int, used: IntArray, vararg with: Int, handler: (player: Player, used: Node, with: Node) -> Boolean){ InteractionListeners.add(type,used,with,handler) } + fun onEquip(id: Int, handler: (player: Player, node: Node) -> Unit){ + InteractionListeners.addEquip(id,handler) + } + fun onUnequip(id:Int, handler: (player: Player, node: Node) -> Unit){ + InteractionListeners.addUnequip(id,handler) + } open fun defineDestinationOverrides(){} diff --git a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt index f9c4dd4cf..7ad902126 100644 --- a/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt +++ b/Server/src/main/kotlin/rs09/game/interaction/InteractionListeners.kt @@ -10,6 +10,7 @@ object InteractionListeners { private val listeners = HashMap Boolean>(1000) private val useWithListeners = HashMap Boolean>(1000) private val destinationOverrides = HashMap Location>(100) + private val equipListeners = HashMap Unit>(10) @JvmStatic fun add(id: Int, type: Int, option: Array, method: (Player,Node) -> Boolean){ @@ -51,6 +52,26 @@ object InteractionListeners { } } + @JvmStatic + fun addEquip(id: Int,method: (Player, Node) -> Unit){ + equipListeners["equip:$id"] = method + } + + @JvmStatic + fun addUnequip(id: Int, method: (Player,Node) -> Unit){ + equipListeners["unequip:$id"] = method + } + + @JvmStatic + fun getEquip(id: Int): ((Player,Node) -> Unit)? { + return equipListeners["equip:$id"] + } + + @JvmStatic + fun getUnequip(id: Int): ((Player,Node) -> Unit)? { + return equipListeners["unequip:$id"] + } + @JvmStatic fun get(used: Int, with: Int, type: Int): ((Player,Node,Node) -> Boolean)?{ return useWithListeners["$used:$with:$type"] @@ -102,6 +123,15 @@ object InteractionListeners { return destinationOverrides["$type:$option"] } + @JvmStatic + fun run(id: Int, player: Player, node: Node, isEquip: Boolean){ + if(isEquip){ + equipListeners["equip:$id"]?.invoke(player,node) + } else { + equipListeners["unequip:$id"]?.invoke(player,node) + } + } + @JvmStatic fun run(used: Node, with: Node, type: Int,player: Player): Boolean{ val flag = when(type){ diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/HatEasterEgg.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/HatEasterEgg.kt new file mode 100644 index 000000000..6da48c400 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/HatEasterEgg.kt @@ -0,0 +1,51 @@ +package rs09.game.interaction.item.withnpc + +import core.game.content.dialogue.FacialExpression +import core.game.node.entity.npc.NPC +import core.game.node.item.Item +import core.game.world.update.flag.context.Graphics +import org.rs09.consts.Items +import rs09.game.content.dialogue.DialogueFile +import rs09.game.interaction.InteractionListener + +val graphics = 482 +class HatEasterEgg : InteractionListener(){ + + val MACHINE = 20040 + val WIZ_HAT = Items.WIZARD_HAT_579 + val NEW_HAT = 14650 + + override fun defineListeners() { + onUseWith(OBJECT,WIZ_HAT,MACHINE){player, used, with -> + player.dialogueInterpreter.open(HatDialogue(), NPC(872)) + return@onUseWith true + } + } + +} + +class HatDialogue : DialogueFile(){ + override fun handle(componentID: Int, buttonID: Int) { + when(stage++){ + 0 -> { + npc("WHAT HAVE YOU DONE?") + player!!.graphics(Graphics(graphics)) + } + 1 -> player(FacialExpression.AFRAID,"What do you mean?!") + 2 -> npc("You've disjointed the fabric assimilation matrix!") + 3 -> player(FacialExpression.THINKING,"W-what...?") + 4 -> npc("You've put us at risk of ripping Gielinor apart!") + 5 -> player(FacialExpression.HALF_GUILTY,"I.. I just wanted a hat...") + 6 -> npc("Damn you and damn your hat! You could kill us all!") + 7 -> player("I... I'm sorry....") + 8 -> npc("*sigh* I've managed to stabilize the flux material inductors.") + 9 -> npc("You may just be safe, yet.") + 10 -> npc("Here, take your damn hat and get out of here.") + 11 -> { + end() + player!!.inventory.remove(Item(Items.WIZARD_HAT_579)) + player!!.inventory.add(Item(14650)) + } + } + } +} \ No newline at end of file diff --git a/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/MistagEasterEgg.kt b/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/MistagEasterEgg.kt new file mode 100644 index 000000000..c5abf1209 --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/interaction/item/withnpc/MistagEasterEgg.kt @@ -0,0 +1,56 @@ +package rs09.game.interaction.item.withnpc + +import core.game.component.Component +import core.game.content.dialogue.FacialExpression +import core.game.node.item.Item +import org.rs09.consts.Items +import org.rs09.consts.NPCs +import rs09.game.content.dialogue.DialogueFile +import rs09.game.interaction.InteractionListener +import rs09.tools.END_DIALOGUE + +class MistagEasterEgg : InteractionListener() { + val DIAMOND = Items.DIAMOND_1601 + val MISTAG = NPCs.MISTAG_2084 + val ZANIK_RING = 14649 + + override fun defineListeners() { + onUseWith(NPC,DIAMOND,MISTAG){player, _, with -> + val alreadyHasRing = player.inventory.contains(ZANIK_RING,1) || player.bank.contains(ZANIK_RING,1) || player.equipment.contains(ZANIK_RING,1) + player.dialogueInterpreter.open(MistagEasterEggDialogue(alreadyHasRing),with.asNpc()) + return@onUseWith true + } + + onEquip(ZANIK_RING){player,_ -> + player.appearance.transformNPC(NPCs.ZANIK_3712) + } + + onUnequip(ZANIK_RING){player, _ -> + player.appearance.transformNPC(-1) + } + } +} + +class MistagEasterEggDialogue(val hasRing: Boolean): DialogueFile(){ + override fun handle(componentID: Int, buttonID: Int) { + + if(hasRing){ + npc("Lovely gem, adventurer, but I have nothing for you.").also { stage = END_DIALOGUE } + return + } + + when(stage++){ + 0 -> npc("Well thank you adventurer! Here, take this.") + 1 -> { + end() + if(player!!.inventory.remove(Item(Items.DIAMOND_1601))){ + player!!.inventory.add(Item(14649)) + } + } + } + } + + override fun npc(vararg messages: String?): Component? { + return super.npc(FacialExpression.OLD_HAPPY,*messages) + } +} \ No newline at end of file