From 180145336eb8e83898f43274bbbfccf3becd4a14 Mon Sep 17 00:00:00 2001 From: Lila Hioh Date: Thu, 28 Jul 2022 14:08:58 +0000 Subject: [PATCH] Fixed the listener for Shamus Tree (fixes lost city quest) --- .../members/lostcity/ShamusDialogue.java | 3 +- .../members/lostcity/ShamusTreeListener.kt | 70 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 Server/src/main/kotlin/rs09/game/content/quest/members/lostcity/ShamusTreeListener.kt diff --git a/Server/src/main/java/core/game/content/quest/members/lostcity/ShamusDialogue.java b/Server/src/main/java/core/game/content/quest/members/lostcity/ShamusDialogue.java index 1796d8cd8..08daad853 100644 --- a/Server/src/main/java/core/game/content/quest/members/lostcity/ShamusDialogue.java +++ b/Server/src/main/java/core/game/content/quest/members/lostcity/ShamusDialogue.java @@ -3,6 +3,7 @@ package core.game.content.quest.members.lostcity; import core.game.content.dialogue.DialoguePlugin; import core.game.node.entity.player.Player; import core.game.node.entity.player.link.quest.Quest; +import rs09.game.content.quest.members.lostcity.ShamusTreeListener; /** * Handles the shamus npc dialogue. @@ -150,7 +151,7 @@ public final class ShamusDialogue extends DialoguePlugin { * Makes dhamus disappear. */ private void disappear() { - LostCityPlugin.SHAMUS.setInvisible(true); + ShamusTreeListener.Companion.disappearShamus(); interpreter.sendPlainMessage(false, "The leprechaun magically disappears."); stage++; } diff --git a/Server/src/main/kotlin/rs09/game/content/quest/members/lostcity/ShamusTreeListener.kt b/Server/src/main/kotlin/rs09/game/content/quest/members/lostcity/ShamusTreeListener.kt new file mode 100644 index 000000000..51ceea09f --- /dev/null +++ b/Server/src/main/kotlin/rs09/game/content/quest/members/lostcity/ShamusTreeListener.kt @@ -0,0 +1,70 @@ +package rs09.game.content.quest.members.lostcity + +import core.game.content.dialogue.FacialExpression +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.game.node.entity.skill.gather.SkillingTool +import core.game.system.task.Pulse +import core.game.world.map.Location +import core.plugin.Initializable +import org.rs09.consts.NPCs +import org.rs09.consts.Scenery +import rs09.game.interaction.InteractionListener +import rs09.game.world.GameWorld + + +/** + * Shamus tree listener, to handle when a player chops Shamus's home tree, + * and to handle some details about the Shamus NPC + * @author lila + * @author Vexia + */ +@Initializable +class ShamusTreeListener : InteractionListener { + + init { + SHAMUS.init() + SHAMUS.isWalks = true + SHAMUS.isInvisible = true + } + + companion object { + val SHAMUS = NPC(NPCs.SHAMUS_654, Location(3138, 3211, 0)) + fun disappearShamus() { + SHAMUS.isInvisible = true + } + } + + fun handleShamusTree(player: Player): Boolean { + if (SkillingTool.getHatchet(player) == null) { + player.packetDispatch.sendMessage("You do not have an axe which you have the level to use.") + return true + } + showShamus(player) + return true + } + + fun showShamus(player: Player) { + if(SHAMUS.isInvisible) { + SHAMUS.isInvisible = false + SHAMUS.properties.teleportLocation = SHAMUS.properties.spawnLocation + } + player.dialogueInterpreter.sendDialogues(SHAMUS, FacialExpression.FURIOUS, "Hey! Yer big elephant! Don't go choppin' down me", "house, now!") + GameWorld.Pulser.submit(object : Pulse(100) { + override fun pulse(): Boolean { + if (SHAMUS.dialoguePlayer == null) { + SHAMUS.isInvisible = true + return true + } + return false + } + }) + } + + override fun defineListeners() { + on(Scenery.TREE_2409,SCENERY,"chop") { player, _ -> + handleShamusTree(player) + return@on true + } + } +} \ No newline at end of file