From 209e1ae8cf422a864a5c737acf6c661e5f771bc5 Mon Sep 17 00:00:00 2001 From: GregF Date: Sat, 10 Aug 2024 11:13:56 +0000 Subject: [PATCH] Implemented taxidermist --- Server/data/configs/item_configs.json | 75 ++++++------- .../canifis/dialogue/TaxidermistDialogue.java | 76 ------------- .../canifis/dialogue/TaxidermistDialogue.kt | 43 ++++++++ .../handlers/TaxidermistInteraction.kt | 100 ++++++++++++++++++ 4 files changed, 182 insertions(+), 112 deletions(-) delete mode 100644 Server/src/main/content/region/morytania/canifis/dialogue/TaxidermistDialogue.java create mode 100644 Server/src/main/content/region/morytania/canifis/dialogue/TaxidermistDialogue.kt create mode 100644 Server/src/main/content/region/morytania/canifis/handlers/TaxidermistInteraction.kt diff --git a/Server/data/configs/item_configs.json b/Server/data/configs/item_configs.json index 667cb0a3d..f3cf0c2da 100644 --- a/Server/data/configs/item_configs.json +++ b/Server/data/configs/item_configs.json @@ -4243,8 +4243,8 @@ "tradeable": "false", "destroy": "true", "archery_ticket_price": "0", - "id": "456", - "weight": "0.15" + "weight": "0.15", + "id": "456" }, { "destroy_message": "You will need to speak to Thormac to get another cage.", @@ -4254,8 +4254,8 @@ "tradeable": "false", "destroy": "true", "archery_ticket_price": "0", - "id": "457", - "weight": "0.175" + "weight": "0.175", + "id": "457" }, { "destroy_message": "You will need to speak to Thormac to get another cage.", @@ -4265,8 +4265,8 @@ "tradeable": "false", "destroy": "true", "archery_ticket_price": "0", - "id": "458", - "weight": "0.2" + "weight": "0.2", + "id": "458" }, { "destroy_message": "You will need to speak to Thormac to get another cage.", @@ -4276,8 +4276,8 @@ "tradeable": "false", "destroy": "true", "archery_ticket_price": "0", - "id": "459", - "weight": "0.175" + "weight": "0.175", + "id": "459" }, { "destroy_message": "You will need to speak to Thormac to get another cage.", @@ -4287,8 +4287,8 @@ "tradeable": "false", "destroy": "true", "archery_ticket_price": "0", - "id": "460", - "weight": "0.2" + "weight": "0.2", + "id": "460" }, { "destroy_message": "You will need to speak to Thormac to get another cage.", @@ -4298,8 +4298,8 @@ "tradeable": "false", "destroy": "true", "archery_ticket_price": "0", - "id": "461", - "weight": "0.175" + "weight": "0.175", + "id": "461" }, { "destroy_message": "You will need to speak to Thormac to get another cage.", @@ -4309,8 +4309,8 @@ "tradeable": "false", "destroy": "true", "archery_ticket_price": "0", - "id": "462", - "weight": "0.2" + "weight": "0.2", + "id": "462" }, { "destroy_message": "You will need to speak to Thormac to get another cage.", @@ -4320,8 +4320,8 @@ "tradeable": "false", "destroy": "true", "archery_ticket_price": "0", - "id": "463", - "weight": "0.225" + "weight": "0.225", + "id": "463" }, { "ge_buy_limit": "10000", @@ -72394,6 +72394,7 @@ "id": "7973" }, { + "examine": "I should get it stuffed!", "durability": null, "name": "Crawling hand", "archery_ticket_price": "0", @@ -72458,6 +72459,7 @@ "id": "7981" }, { + "examine": "I could mount this on my wall!", "durability": null, "name": "Crawling hand", "archery_ticket_price": "0", @@ -72465,7 +72467,7 @@ "id": "7982" }, { - "examine": "I should get it stuffed!", + "examine": "I could mount this on my wall!", "durability": null, "name": "Cockatrice head", "tradeable": "false", @@ -72475,7 +72477,7 @@ "id": "7983" }, { - "examine": "I should get it stuffed!", + "examine": "I could mount this on my wall!", "durability": null, "name": "Basilisk head", "tradeable": "false", @@ -72485,7 +72487,7 @@ "id": "7984" }, { - "examine": "I should get it stuffed!", + "examine": "I could mount this on my wall!", "durability": null, "name": "Kurask head", "tradeable": "false", @@ -72495,7 +72497,7 @@ "id": "7985" }, { - "examine": "I should get it stuffed!", + "examine": "I could mount this on my wall!", "durability": null, "name": "Abyssal head", "tradeable": "false", @@ -72505,7 +72507,7 @@ "id": "7986" }, { - "examine": "I should get it stuffed!", + "examine": "I could mount these on my wall!", "durability": null, "name": "Kbd heads", "tradeable": "false", @@ -72515,7 +72517,7 @@ "id": "7987" }, { - "examine": "I should get it stuffed!", + "examine": "I could mount this on my wall!", "durability": null, "name": "Kq head", "archery_ticket_price": "0", @@ -72530,7 +72532,7 @@ "id": "7989" }, { - "examine": "Whopper! I should get this stuffed!", + "examine": "I should mount this on my wall!", "durability": null, "name": "Big bass", "weight": "6", @@ -72545,14 +72547,14 @@ "id": "7991" }, { - "examine": "Whopper! I should get this stuffed!", + "examine": "I should mount this on my wall!", "durability": null, "name": "Big swordfish", "archery_ticket_price": "0", "id": "7992" }, { - "examine": "Its a monster! I should get this stuffed!", + "examine": "It's a monster! I should get this stuffed!", "durability": null, "name": "Big shark", "weight": "0.7", @@ -72560,7 +72562,7 @@ "id": "7993" }, { - "examine": "Its a monster! I should get this stuffed!", + "examine": "I should mount this on my wall!", "durability": null, "name": "Big shark", "weight": "0.7", @@ -73289,6 +73291,7 @@ "id": "8248" }, { + "examine": "A trophy of a mighty slayer!", "durability": null, "name": "Crawling hand", "archery_ticket_price": "0", @@ -73296,7 +73299,7 @@ "id": "8260" }, { - "examine": "I should get it stuffed!", + "examine": "A trophy of a mighty slayer!", "durability": null, "name": "Cockatrice head", "tradeable": "false", @@ -73306,7 +73309,7 @@ "id": "8261" }, { - "examine": "I should get it stuffed!", + "examine": "A trophy of a mighty slayer!", "durability": null, "name": "Basilisk head", "tradeable": "false", @@ -73316,7 +73319,7 @@ "id": "8262" }, { - "examine": "I should get it stuffed!", + "examine": "A trophy of a mighty slayer!", "durability": null, "name": "Kurask head", "tradeable": "false", @@ -73326,7 +73329,7 @@ "id": "8263" }, { - "examine": "I should get it stuffed!", + "examine": "A trophy of a mighty slayer!!", "durability": null, "name": "Abyssal head", "tradeable": "false", @@ -73336,7 +73339,7 @@ "id": "8264" }, { - "examine": "I should get it stuffed!", + "examine": "A trophy of a mighty dragon-slayer!", "durability": null, "name": "Kbd heads", "tradeable": "false", @@ -73346,7 +73349,7 @@ "id": "8265" }, { - "examine": "I should get it stuffed!", + "examine": "A trophy of a mighty kalphite slayer!", "durability": null, "name": "Kq head", "archery_ticket_price": "0", @@ -77088,16 +77091,16 @@ "requirements": "{1,20}-{2,10}", "ge_buy_limit": "10", "examine": "A magic cave horror mask.", - "grand_exchange_price": "989400", "durability": null, "rare_item": "true", + "weight": "10", + "equipment_slot": "0", + "grand_exchange_price": "989400", "name": "Black mask (10)", "tradeable": "true", - "weight": "10", "archery_ticket_price": "0", "id": "8901", - "bonuses": "0,0,0,-3,-1,9,10,8,-1,9,0,0,0,0,0", - "equipment_slot": "0" + "bonuses": "0,0,0,-3,-1,9,10,8,-1,9,0,0,0,0,0" }, { "ge_buy_limit": "10", diff --git a/Server/src/main/content/region/morytania/canifis/dialogue/TaxidermistDialogue.java b/Server/src/main/content/region/morytania/canifis/dialogue/TaxidermistDialogue.java deleted file mode 100644 index eedae1210..000000000 --- a/Server/src/main/content/region/morytania/canifis/dialogue/TaxidermistDialogue.java +++ /dev/null @@ -1,76 +0,0 @@ -package content.region.morytania.canifis.dialogue; - -import core.game.dialogue.DialoguePlugin; -import core.game.dialogue.FacialExpression; -import core.game.node.entity.npc.NPC; -import core.plugin.Initializable; -import core.game.node.entity.player.Player; - -/** - * Handles the TaxidermistDialogue dialogue. - * @author 'Vexia - */ -@Initializable -public class TaxidermistDialogue extends DialoguePlugin { - - public TaxidermistDialogue() { - - } - - public TaxidermistDialogue(Player player) { - super(player); - } - - @Override - public DialoguePlugin newInstance(Player player) { - - return new TaxidermistDialogue(player); - } - - @Override - public boolean open(Object... args) { - npc = (NPC) args[0]; - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Oh, hello. Have you got something you want", "preserving?"); - stage = 0; - return true; - } - - @Override - public boolean handle(int interfaceId, int buttonId) { - switch (stage) { - case 0: - interpreter.sendOptions("Select an Option", "Yes please", "Not right now"); - stage = 1; - break; - case 1: - switch (buttonId) { - case 1: - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Yes please."); - stage = 10; - break; - case 2: - interpreter.sendDialogues(player, FacialExpression.HALF_GUILTY, "Not right now."); - stage = 20; - break; - - } - break; - case 10: - interpreter.sendDialogues(npc, FacialExpression.HALF_GUILTY, "Give it to me to look at then."); - stage = 11; - break; - case 11: - end(); - break; - case 20: - end(); - break; - } - return true; - } - - @Override - public int[] getIds() { - return new int[] { 4246 }; - } -} diff --git a/Server/src/main/content/region/morytania/canifis/dialogue/TaxidermistDialogue.kt b/Server/src/main/content/region/morytania/canifis/dialogue/TaxidermistDialogue.kt new file mode 100644 index 000000000..abaefb1d0 --- /dev/null +++ b/Server/src/main/content/region/morytania/canifis/dialogue/TaxidermistDialogue.kt @@ -0,0 +1,43 @@ +package content.region.morytania.canifis.dialogue + +import core.game.dialogue.DialoguePlugin +import core.game.dialogue.FacialExpression +import core.game.dialogue.Topic +import core.game.node.entity.player.Player +import core.plugin.Initializable +import core.tools.END_DIALOGUE +import core.tools.START_DIALOGUE +import org.rs09.consts.NPCs + +@Initializable +open class TaxidermistDialogue(player: Player? = null) : DialoguePlugin(player) { + companion object{ + const val YES = 10 + const val NO = 20 + const val WHAT = 30 + } + + override fun open(vararg args: Any?): Boolean { + npcl(FacialExpression.HAPPY, "Oh, hello. Have you got something you want preserving?").also { stage++ } + return true + } + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when(stage){ + START_DIALOGUE + 1 -> showTopics( + Topic("Yes please.", YES), + Topic("Not right now.", NO), + Topic("What?", WHAT) + ) + + YES -> npcl(FacialExpression.HAPPY, "Give it to me to look at then.").also { stage = END_DIALOGUE } + NO -> npcl(FacialExpression.ANNOYED, "Well, you go kill things so I can stuff them, eh?").also { stage = END_DIALOGUE } + WHAT -> npcl(FacialExpression.NEUTRAL, " If you bring me a monster head or a very big fish, I can preserve it for you so you can mount it in your house.").also { stage++ } + WHAT + 1 -> npcl(FacialExpression.HAPPY, "I hear there are all sorts of exotic creatures in the Slayer Tower -- I'd like a chance to stuff one of them!").also { stage = END_DIALOGUE } + } + return true + } + + override fun getIds(): IntArray { + return intArrayOf(NPCs.TAXIDERMIST_4246) + } +} diff --git a/Server/src/main/content/region/morytania/canifis/handlers/TaxidermistInteraction.kt b/Server/src/main/content/region/morytania/canifis/handlers/TaxidermistInteraction.kt new file mode 100644 index 000000000..d7ead3a88 --- /dev/null +++ b/Server/src/main/content/region/morytania/canifis/handlers/TaxidermistInteraction.kt @@ -0,0 +1,100 @@ +package content.region.morytania.canifis.handlers + +import content.region.morytania.canifis.dialogue.TaxidermistDialogue +import core.api.* +import core.game.dialogue.DialogueFile +import core.game.dialogue.FacialExpression +import core.game.dialogue.Topic +import core.game.interaction.IntType +import core.game.interaction.InteractionListener +import core.game.node.entity.npc.NPC +import core.game.node.entity.player.Player +import core.game.node.item.Item +import core.tools.END_DIALOGUE +import core.tools.START_DIALOGUE +import org.rs09.consts.Items +import org.rs09.consts.NPCs + +class TaxidermistInteraction : InteractionListener { + + enum class StuffableItem(val toStuff : Int, val product : Int, val message : String, val cost : Int){ + BASS(Items.BIG_BASS_7989, Items.BIG_BASS_7990, "That's a mighty fine sea bass you've caught there.", 1000), + SWORDFISH(Items.BIG_SWORDFISH_7991, Items.BIG_SWORDFISH_7992, "Don't point that thing at me!", 2500), + SHARK(Items.BIG_SHARK_7993,Items.BIG_SHARK_7994, "That's quite a fearsome shark! You've done everyone a service by removing it from the sea!", 5000), + CRAWLING_HAND(Items.CRAWLING_HAND_7975,Items.CRAWLING_HAND_7982, "That's a very fine crawling hand.", 1000), + COCKATRICE(Items.COCKATRICE_HEAD_7976, Items.COCKATRICE_HEAD_7983, "A cockatrice! Beautiful, isn't it? Look at the plumage!", 2000), + BASILISK( Items.BASILISK_HEAD_7977, Items.BASILISK_HEAD_7984, "My, he's a scary-looking fellow, isn't he? He'll look good on your wall!",4000), + KURASK(Items.KURASK_HEAD_7978, Items.KURASK_HEAD_7985, "A kurask? Splendid! Look at those horns!", 6000), + ABYSSAL(Items.ABYSSAL_HEAD_7979, Items.ABYSSAL_HEAD_7986, "Goodness, an abyssal demon!", 12000), + KBD(Items.KBD_HEADS_7980, Items.KBD_HEADS_7987, " This must be a King Black Dragon!", 50000), + KQ(Items.KQ_HEAD_7981, Items.KQ_HEAD_7988, " That must be the biggest kalphite I've ever seen!", 50000) + } + class TaxidermistTradeDialogue : DialogueFile() { + companion object{ + const val TRADE = 10 + const val YES = 20 + const val NO = 30 + const val POOR = 40 + } + + lateinit var stuffableItem : StuffableItem + override fun handle(componentID: Int, buttonID: Int) { + when (stage) { + START_DIALOGUE -> npcl(FacialExpression.HAPPY, stuffableItem.message).also { + stage = when(stuffableItem){ + StuffableItem.ABYSSAL -> stage + 1 + StuffableItem.KBD -> stage + 2 + StuffableItem.KQ -> stage + 3 + else -> TRADE + } + } + START_DIALOGUE + 1 -> npcl(FacialExpression.HAPPY, "See how it's still glowing? I'll have to use some magic to preserve that.").also { stage = TRADE } + START_DIALOGUE + 2 -> npcl(FacialExpression.HAPPY, "I'll have to get out my heavy duty tools -- this skin's as tough as iron!").also { stage = TRADE } + START_DIALOGUE + 3 -> npcl(FacialExpression.HAPPY, "Preserving insects is always tricky. I'll have to be careful...").also { stage = TRADE } + + TRADE -> npcl(FacialExpression.HAPPY, "I can preserve that for you for ${stuffableItem.cost} coins.").also { stage++ } + TRADE + 1 -> showTopics( + Topic("Yes please.", YES), + Topic("No thanks.", NO) + ) + YES -> { + if (inInventory(player!!, Items.COINS_995, stuffableItem.cost)){ + if (removeItem(player!!, stuffableItem.toStuff) && removeItem(player!!, Item(Items.COINS_995, stuffableItem.cost))){ + addItem(player!!, stuffableItem.product) + npcl(FacialExpression.HAPPY, "There you go!").also { stage = END_DIALOGUE } + } + } + else { + playerl(FacialExpression.SAD, "But I don't have enough money on me.").also { stage = POOR } + } + } + + POOR -> npcl(FacialExpression.ANNOYED, "Don't waste my time, then!").also { stage = END_DIALOGUE } + + NO -> npcl(FacialExpression.NEUTRAL, "All right, come back if you change your mind, eh?").also { stage = END_DIALOGUE } + } + } + + } + + override fun defineListeners() { + + onUseAnyWith(IntType.NPC, NPCs.TAXIDERMIST_4246) { player, used, with -> + val item = used.id + StuffableItem.values().map { if(it.toStuff == item){ + val dialogueFile = TaxidermistTradeDialogue() + dialogueFile.stuffableItem = it + openDialogue(player, dialogueFile, with as NPC) + return@onUseAnyWith true + } + } + + when (item) { + // all fish + Items.RAW_CHICKEN_2138 -> sendNPCDialogue(player, with.id, "Killing a chicken is hardly worth boasting about!") + else -> sendNPCDialogue(player, with.id, "Don't be silly, I can't preserve that!") + } + return@onUseAnyWith true + } + } +} \ No newline at end of file