From 708d5bb507bb256fcef7f855ae086950b9ba856d Mon Sep 17 00:00:00 2001 From: downthecrop Date: Wed, 4 Oct 2023 23:35:24 +0000 Subject: [PATCH] Rewrote Captain Barnaby and Shilo Cart interactions --- .../dialogue/CaptainBarnabyDialogue.java | 102 ------------ .../dialogue/CaptainBarnabyListener.kt | 55 ++++++ .../dialogue/CaptainShanksDialogue.java | 4 +- .../karamja/shilo/handlers/ShiloCart.kt | 120 +++++++++++++ .../shilo/handlers/ShiloVillagePlugin.java | 157 ------------------ 5 files changed, 177 insertions(+), 261 deletions(-) delete mode 100644 Server/src/main/content/region/kandarin/ardougne/dialogue/CaptainBarnabyDialogue.java create mode 100644 Server/src/main/content/region/kandarin/ardougne/dialogue/CaptainBarnabyListener.kt create mode 100644 Server/src/main/content/region/karamja/shilo/handlers/ShiloCart.kt delete mode 100644 Server/src/main/content/region/karamja/shilo/handlers/ShiloVillagePlugin.java diff --git a/Server/src/main/content/region/kandarin/ardougne/dialogue/CaptainBarnabyDialogue.java b/Server/src/main/content/region/kandarin/ardougne/dialogue/CaptainBarnabyDialogue.java deleted file mode 100644 index 8539a1ea3..000000000 --- a/Server/src/main/content/region/kandarin/ardougne/dialogue/CaptainBarnabyDialogue.java +++ /dev/null @@ -1,102 +0,0 @@ -package content.region.kandarin.ardougne.dialogue; - -import content.global.travel.ship.Ships; -import core.game.dialogue.DialoguePlugin; -import core.game.dialogue.FacialExpression; -import core.game.node.entity.npc.NPC; -import core.game.node.entity.player.Player; -import core.plugin.Initializable; -import core.game.node.item.Item; - -import static core.api.ContentAPIKt.*; - -/** - * Represents the captain barnaby dialogue plugin. - * @author 'Vexia - * @version 1.0 - */ -@Initializable -public final class CaptainBarnabyDialogue extends DialoguePlugin { - - /** - * Represents the coins item. - */ - private static final Item COINS = new Item(995, 30); - - /** - * Constructs a new {@code CaptainBarnabyDialogue} {@code Object}. - */ - public CaptainBarnabyDialogue() { - /** - * empty. - */ - } - - /** - * Constructs a new {@code CaptainBarnabyDialogue} {@code Object}. - * @param player the player. - */ - public CaptainBarnabyDialogue(Player player) { - super(player); - } - - @Override - public DialoguePlugin newInstance(Player player) { - return new CaptainBarnabyDialogue(player); - } - - @Override - public boolean open(Object... args) { - npc = (NPC) args[0]; - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Do you want to go on a trip to Brimhaven?"); - stage = 0; - return true; - } - - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (stage) { - case 0: - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "The trip will cost you 30 coins."); - stage = 1; - break; - case 1: - interpreter.sendOptions("Select an Option", "Yes please.", "No, thank you."); - stage = 2; - break; - case 2: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Yes please."); - stage = 10; - break; - case 2: - end(); - break; - } - break; - case 10: - if (!player.getInventory().containsItem(COINS)) { - interpreter.sendDialogues(player, null, "Sorry, I don't seem to have enough coins."); - stage = 220; - return true; - } - if (player.getInventory().remove(COINS)) { - end(); - player.getPacketDispatch().sendMessage("You pay 30 coins and board the ship."); - playJingle(player, 171); - Ships.ARDOUGNE_TO_BRIMHAVEN.sail(player); - } - break; - case 220: - end(); - break; - } - return true; - } - - @Override - public int[] getIds() { - return new int[] { 381 }; - } -} diff --git a/Server/src/main/content/region/kandarin/ardougne/dialogue/CaptainBarnabyListener.kt b/Server/src/main/content/region/kandarin/ardougne/dialogue/CaptainBarnabyListener.kt new file mode 100644 index 000000000..066aeba0f --- /dev/null +++ b/Server/src/main/content/region/kandarin/ardougne/dialogue/CaptainBarnabyListener.kt @@ -0,0 +1,55 @@ +package content.region.kandarin.ardougne.dialogue + +import content.global.travel.ship.Ships +import core.api.* +import core.game.dialogue.DialogueFile +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.item.Item +import core.tools.END_DIALOGUE +import org.rs09.consts.Items +import org.rs09.consts.NPCs + + +class CaptainBarnabyListener : InteractionListener { + override fun defineListeners() { + on(NPCs.CAPTAIN_BARNABY_4974, IntType.NPC, "talk-to") { player, npc -> + openDialogue(player,CaptainBarnabyDialogue(), npc) + return@on true + } + on(NPCs.CAPTAIN_BARNABY_4974, IntType.NPC, "pay-fare") { player, _ -> + if (removeItem(player,Item(Items.COINS_995,30))) { + sendMessage(player,"You pay 30 coins and board the ship.") + playJingle(player, 171) + Ships.ARDOUGNE_TO_BRIMHAVEN.sail(player) + } else { + sendMessage(player,"You don't have enough coins.") + } + return@on true + } + } +} + +class CaptainBarnabyDialogue : DialogueFile(){ + override fun handle(componentID: Int, buttonID: Int) { + when (stage) { + 0 -> npcl("Do you want to go on a trip to Brimhaven?").also { stage += 1 } + 1 -> npcl( "The trip will cost you 30 coins.").also { stage += 1 } + 2 -> options("Yes please.", "No, thank you.").also { stage += 1 } + 3 -> when (buttonID) { + 1 -> playerl("Yes please.").also { stage = 10 } + 2 -> playerl("No, thank you.").also { stage = END_DIALOGUE } + } + 10 -> { + if (removeItem(player!!,Item(Items.COINS_995,30))) { + sendMessage(player!!,"You pay 30 coins and board the ship.") + playJingle(player!!, 171) + Ships.ARDOUGNE_TO_BRIMHAVEN.sail(player) + stage = END_DIALOGUE + } else{ + playerl("Sorry, I don't seem to have enough coins.").also{ stage = END_DIALOGUE } + } + } + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/region/karamja/dialogue/CaptainShanksDialogue.java b/Server/src/main/content/region/karamja/dialogue/CaptainShanksDialogue.java index 3bcabdfc7..ddf3f18e5 100644 --- a/Server/src/main/content/region/karamja/dialogue/CaptainShanksDialogue.java +++ b/Server/src/main/content/region/karamja/dialogue/CaptainShanksDialogue.java @@ -21,7 +21,7 @@ public final class CaptainShanksDialogue extends DialoguePlugin { private static final Item TICKET = new Item(Items.SHIP_TICKET_621); /** - * Constructs a new {@code CaptainBarnabyDialogue} {@code Object}. + * Constructs a new {@code CaptainShanksDialogue} {@code Object}. */ public CaptainShanksDialogue() { /** @@ -30,7 +30,7 @@ public final class CaptainShanksDialogue extends DialoguePlugin { } /** - * Constructs a new {@code CaptainBarnabyDialogue} {@code Object}. + * Constructs a new {@code CaptainShanksDialogue} {@code Object}. * @param player the player. */ public CaptainShanksDialogue(Player player) { diff --git a/Server/src/main/content/region/karamja/shilo/handlers/ShiloCart.kt b/Server/src/main/content/region/karamja/shilo/handlers/ShiloCart.kt new file mode 100644 index 000000000..b432a0cf9 --- /dev/null +++ b/Server/src/main/content/region/karamja/shilo/handlers/ShiloCart.kt @@ -0,0 +1,120 @@ +package content.region.karamja.shilo.handlers + +import core.api.* +import core.game.component.Component +import core.game.dialogue.DialogueFile +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.interaction.QueueStrength +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.link.diary.DiaryType +import core.game.node.item.Item +import core.game.world.map.Location +import core.tools.END_DIALOGUE +import org.rs09.consts.Components +import org.rs09.consts.Items +import org.rs09.consts.NPCs + +class ShiloCart : InteractionListener { + + override fun defineListeners() { + + val BRIMHAVEN_CART = 2230 + val SHILO_CART = 2265 + + // Cart IN Brimhaven + on(BRIMHAVEN_CART, IntType.SCENERY, "board") { player, _ -> + openDialogue(player, CartTravelDialogue(), NPC(NPCs.HAJEDY_510)) + return@on true + } + on(BRIMHAVEN_CART, IntType.SCENERY, "pay-fare") { player, _ -> + openDialogue(player, CartQuickPay(), NPC(NPCs.HAJEDY_510)) + return@on true + } + + // Hajedy + on(NPCs.HAJEDY_510, IntType.NPC, "talk-to") { player, _ -> + openDialogue(player, CartTravelDialogue(), NPC(NPCs.HAJEDY_510)) + return@on true + } + on(NPCs.HAJEDY_510, IntType.NPC, "pay-fare") { player, _ -> + openDialogue(player, CartQuickPay(), NPC(NPCs.HAJEDY_510)) + return@on true + } + + + // Cart IN Shilo + on(SHILO_CART, IntType.SCENERY, "board") { player, _ -> + openDialogue(player, CartTravelDialogue(), NPC(NPCs.VIGROY_511)) + return@on true + } + on(SHILO_CART, IntType.SCENERY, "pay-fare") { player, _ -> + openDialogue(player, CartQuickPay(), NPC(NPCs.VIGROY_511)) + return@on true + } + + // Vigroy + on(NPCs.VIGROY_511, IntType.NPC, "talk-to") { player, npc -> + openDialogue(player, CartTravelDialogue(), npc) + return@on true + } + on(NPCs.VIGROY_511, IntType.NPC, "pay-fare") { player, npc -> + openDialogue(player, CartQuickPay(), npc) + return@on true + } + } +} + +class CartQuickPay : DialogueFile(){ + override fun handle(interfaceId: Int, buttonId: Int) { + if (!hasRequirement(player!!, "Shilo Village")) return; + val shilo = npc?.id == 510; + when (stage) { + 0 -> if(inInventory(player!!,Items.COINS_995,10)){ + sendDialogue(player!!,"You pay the fare and hand 10 gold coins to "+ (npc?.name ?: "") +".").also { stage++ } + } else { + sendMessage(player!!,"You don't have enough coins.").also { stage = END_DIALOGUE } + } + 1 -> { + if(removeItem(player!!,Item(Items.COINS_995,10))){ + queueScript(player!!, 1, QueueStrength.SOFT) { Qstage: Int -> + when(Qstage){ + 0 -> { + player!!.interfaceManager.closeOverlay() + player!!.interfaceManager.openOverlay(Component(Components.FADE_TO_BLACK_120)) + return@queueScript keepRunning(player!!) + } + 1 -> { + teleport(player!!, if (shilo) Location.create(2834, 2951, 0) else Location.create(2780, 3212, 0)) + player!!.interfaceManager.closeOverlay() + player!!.interfaceManager.openOverlay(Component(Components.FADE_FROM_BLACK_170)) + player!!.achievementDiaryManager.finishTask(player, DiaryType.KARAMJA, 1, 3) + sendDialogue(player!!,"You feel tired from the journey, but at least you didn't have to walk all that distance.").also { stage = END_DIALOGUE } + } + } + return@queueScript stopExecuting(player!!) + } + } + stage = END_DIALOGUE; + } + } + } +} + +class CartTravelDialogue : DialogueFile(){ + override fun handle(componentID: Int, buttonID: Int) { + if (!hasRequirement(player!!, "Shilo Village")) return; + val shilo = npc?.id == 510; + when (stage) { + 0 -> npcl("I am offering a cart ride to " + (if (shilo) "Shilo Village" else "Brimhaven") + " if you're interested? It will cost 10 gold coins. Is that Ok?").also { stage++ } + 1 -> if (inInventory(player!!,Items.COINS_995,10)) { + playerl("Yes please, I'd like to go to " + (if (shilo) "Shilo Village" else "Brimhaven") + ".").also { stage++ } + } else{ + playerl("Sorry, I don't seem to have enough coins.").also{ stage = END_DIALOGUE } + } + 2 -> npcl("Great! Just hop into the cart then and we'll go!").also { stage++ } + 3 -> sendDialogue(player!!,"You hop into the cart and the driver urges the horses on. You take a taxing journey through the jungle to " + (if (shilo) "Shilo Village" else "Brimhaven") + ".").also { stage++ } + 4 -> openDialogue(player!!,CartQuickPay(),npc!!) + } + } +} \ No newline at end of file diff --git a/Server/src/main/content/region/karamja/shilo/handlers/ShiloVillagePlugin.java b/Server/src/main/content/region/karamja/shilo/handlers/ShiloVillagePlugin.java deleted file mode 100644 index 6dc4d101e..000000000 --- a/Server/src/main/content/region/karamja/shilo/handlers/ShiloVillagePlugin.java +++ /dev/null @@ -1,157 +0,0 @@ -package content.region.karamja.shilo.handlers; - -import core.cache.def.impl.NPCDefinition; -import core.cache.def.impl.SceneryDefinition; -import core.plugin.Initializable; -import core.game.dialogue.DialoguePlugin; -import core.game.interaction.OptionHandler; -import core.game.node.Node; -import core.game.node.entity.npc.NPC; -import core.game.node.entity.player.Player; -import core.game.node.entity.player.link.diary.DiaryType; -import core.game.node.item.Item; -import core.game.world.map.Location; -import core.game.world.map.RegionManager; -import core.plugin.Plugin; -import core.plugin.ClassScanner; - -import static core.api.ContentAPIKt.hasRequirement; - -/** - * Handles shilo village interactions. - * @author Vexia - */ -@Initializable -public final class ShiloVillagePlugin extends OptionHandler { - - @Override - public Plugin newInstance(Object arg) throws Throwable { - NPCDefinition.forId(511).getHandlers().put("option:pay-fare", this); - NPCDefinition.forId(510).getHandlers().put("option:pay-fare", this); - SceneryDefinition.forId(2230).getHandlers().put("option:board", this);// cart - // travel. - SceneryDefinition.forId(2230).getHandlers().put("option:pay-fare", this);// cart - // travel. - SceneryDefinition.forId(2265).getHandlers().put("option:board", this);// cart - // travel. - SceneryDefinition.forId(2265).getHandlers().put("option:pay-fare", this);// cart - // travel. - ClassScanner.definePlugin(new VillageCartDialogue()); - return this; - } - - @Override - public boolean handle(Player player, Node node, String option) { - if (!hasRequirement(player, "Shilo Village")) - return true; - switch (node.getId()) { - case 511: - case 510: - player.getDialogueInterpreter().open(510, node); - break; - case 2230: - case 2265: - player.getDialogueInterpreter().open(510, RegionManager.getNpc(player, node.getId() == 2230 ? 510 : 511)); - break; - } - return true; - } - - /** - * Handles the vigroy dialogue. - * @author Vexia - */ - public static final class VillageCartDialogue extends DialoguePlugin { - - /** - * If the ride is to shilo. - */ - private boolean shilo; - - /** - * Constructs a new {@Code VigroyDialogue} {@Code Object} - * @param player the player. - */ - public VillageCartDialogue(Player player) { - super(player); - } - - /** - * Constructs a new {@Code VigroyDialogue} {@Code Object} - */ - public VillageCartDialogue() { - /** - * empty. - */ - } - - @Override - public DialoguePlugin newInstance(Player player) { - return new VillageCartDialogue(player); - } - - @Override - public boolean open(Object... args) { - npc = (NPC) args[0]; - shilo = npc.getId() == 510; - npc("Hello Bwana!"); - if (!hasRequirement(player, "Shilo Village")) { - end(); - return true; - } - return true; - } - - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (stage) { - case 0: - npc("I am offering a cart ride to " + (shilo ? "Shilo Village" : "Brimhaven") + " if you're", "interested? It will cost 10 gold coins. Is that Ok?"); - stage++; - break; - case 1: - player("Yes please, I'd like to go to " + (shilo ? "Shilo Village" : "Brimhaven") + "."); - stage++; - break; - case 2: - npc("Great! Just hop into the cart then and we'll go!"); - stage++; - break; - case 3: - if (!player.getInventory().contains(995, 10)) { - player.sendMessage("Not enough coins."); - end(); - break; - } - interpreter.sendDialogue("You hop into the cart and the driver urges the horses on. You take", "a taxing journey through the jungle to " + (shilo ? "Shilo Village" : "Brimhaven") + "."); - stage++; - break; - case 4: - interpreter.sendDialogue("You pay the fare and hand 10 gold coins to " + npc.getName() + "."); - stage++; - break; - case 5: - if (player.getInventory().remove(new Item(995, 10))) { - interpreter.sendDialogue("You feel tired from the journey, but at least you didn't have to walk", "all that distance."); - stage++; - } else { - end(); - } - break; - case 6: - end(); - player.getProperties().setTeleportLocation(shilo ? Location.create(2834, 2951, 0) : Location.create(2780, 3212, 0)); - // Use Vigroy and Hajedy's cart service - player.getAchievementDiaryManager().finishTask(player, DiaryType.KARAMJA, 1, 3); - break; - } - return true; - } - - @Override - public int[] getIds() { - return new int[] { 511, 510 }; - } - - } -}