From b8a887b3194e53af63ec210ae8d9345e11220ef9 Mon Sep 17 00:00:00 2001 From: Bonesy Date: Sun, 17 Mar 2024 08:59:11 +0000 Subject: [PATCH] Fixed crafting guild tanning interface Rewrote master crafter dialogue Added missing master crafter dialogues Fixed issue preventing crafting guild entry with trimmed crafting cape --- .../dialogue/CapelessMasterCrafterDialogue.kt | 29 +++++ .../dialogue/MasterCrafterDialogue.kt | 109 +++++++++++++----- .../asgarnia/dialogue/TannerDialogue.kt | 8 +- .../asgarnia/dialogue/TheDoorDialogues.kt | 5 +- .../dialogue/YoungMasterCrafterDialogue.kt | 60 ++++++++++ .../handlers/CraftingGuildListeners.kt | 18 +-- 6 files changed, 185 insertions(+), 44 deletions(-) create mode 100644 Server/src/main/content/region/asgarnia/dialogue/CapelessMasterCrafterDialogue.kt create mode 100644 Server/src/main/content/region/asgarnia/dialogue/YoungMasterCrafterDialogue.kt diff --git a/Server/src/main/content/region/asgarnia/dialogue/CapelessMasterCrafterDialogue.kt b/Server/src/main/content/region/asgarnia/dialogue/CapelessMasterCrafterDialogue.kt new file mode 100644 index 000000000..135dc1cb4 --- /dev/null +++ b/Server/src/main/content/region/asgarnia/dialogue/CapelessMasterCrafterDialogue.kt @@ -0,0 +1,29 @@ +package content.region.asgarnia.dialogue + +import core.game.dialogue.DialoguePlugin +import core.game.dialogue.FacialExpression +import core.game.node.entity.player.Player +import core.plugin.Initializable +import core.tools.END_DIALOGUE +import org.rs09.consts.NPCs + +@Initializable +class CapelessMasterCrafterDialogue(player: Player? = null) : DialoguePlugin(player) { + + override fun newInstance(player: Player): DialoguePlugin { + return CapelessMasterCrafterDialogue(player) + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + npcl( + FacialExpression.FRIENDLY, + "Hello, and welcome to the Crafting Guild. Accomplished crafters from all " + + "over the land come here to use our top notch workshops." + ).also { stage = END_DIALOGUE } + return true + } + + override fun getIds(): IntArray { + return intArrayOf(NPCs.MASTER_CRAFTER_2732) + } +} \ No newline at end of file diff --git a/Server/src/main/content/region/asgarnia/dialogue/MasterCrafterDialogue.kt b/Server/src/main/content/region/asgarnia/dialogue/MasterCrafterDialogue.kt index d603a573d..d059afb09 100644 --- a/Server/src/main/content/region/asgarnia/dialogue/MasterCrafterDialogue.kt +++ b/Server/src/main/content/region/asgarnia/dialogue/MasterCrafterDialogue.kt @@ -3,10 +3,9 @@ package content.region.asgarnia.dialogue import core.api.* import core.game.dialogue.DialoguePlugin import core.game.dialogue.FacialExpression -import core.game.node.entity.npc.NPC +import core.game.global.Skillcape import core.game.node.entity.player.Player import core.game.node.entity.skill.Skills -import core.game.node.item.Item import core.plugin.Initializable import org.rs09.consts.Items import org.rs09.consts.NPCs @@ -19,44 +18,94 @@ import core.tools.END_DIALOGUE @Initializable class MasterCrafterDialogue(player: Player? = null) : DialoguePlugin(player) { - var CAPE = Items.CRAFTING_CAPE_9780 - var COIN = Items.COINS_995 - - override fun newInstance(player: Player) : DialoguePlugin { + override fun newInstance(player: Player): DialoguePlugin { return MasterCrafterDialogue(player) } - override fun handle(interfaceId: Int, buttonId: Int) : Boolean { - when(stage) { - 0 -> if(hasLevelStat(player, Skills.CRAFTING, 99)) { - player(FacialExpression.ASKING, "Hey, could I buy a Skillcape of Crafting?").also{ stage = 10 } - } else { - player(FacialExpression.ASKING,"Hey, what is that cape you're wearing? I don't recognize it.").also { stage++ } + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when (stage) { + 0 -> npcl( + FacialExpression.FRIENDLY, + "Hello, and welcome to the Crafting Guild. Accomplished crafters from all " + + "over the land come here to use our top notch workshops." + ).also { stage++ } + + 1 -> { + if (Skillcape.isMaster(player, Skills.CRAFTING)) { + playerl( + FacialExpression.ASKING, + "Are you the person I need to talk to about buying a Skillcape of Crafting?" + ).also { stage = 100 } + } else { + end() + } } - 1 -> npcl(FacialExpression.FRIENDLY, "This? This is a Skillcape of Crafting. It is a symbol of my ability " + - "and standing here in the Crafting Guild. If you should ever achieve level 99 Crafting come and talk to me " + - "and we'll see if we can sort you out with one.").also{ stage = END_DIALOGUE } - 10 -> npcl(FacialExpression.HAPPY, "Certainly! Right after you pay me 99000 coins.").also{ stage++ } - 11 -> options("Okay, here you go.", "No thanks.").also{ stage++ } - 12 -> when(buttonId) { - 1 -> player(FacialExpression.FRIENDLY, "Okay, here you go.").also{ stage++ } - 2 -> player(FacialExpression.HALF_THINKING, "No, thanks.").also{ stage = END_DIALOGUE } + + 100 -> npcl( + FacialExpression.FRIENDLY, + "I certainly am, and I can see that you are definitely talented enough to own one! " + + "Unfortunately, being such a prestigious item, they are appropriately expensive. " + + "I'm afraid I must ask you for 99000 gold." + ).also { stage++ } + + 101 -> options( + "99000 gold! Are you mad?", "That's fine." + ).also { stage++ } + + 102 -> { + when (buttonId) { + 1 -> playerl( + FacialExpression.ASKING, + "99000 gold! Are you mad?" + ).also { stage++ } + + 2 -> { + when { + !inInventory(player, Items.COINS_995, 99000) -> playerl( + FacialExpression.NEUTRAL, + "But, unfortunately, I don't have enough money with me." + ).also { stage = 111 } + + freeSlots(player) < 2 -> npcl( + FacialExpression.FRIENDLY, + "Unfortunately all Skillcapes are only available with a free hood, it's part " + + "of a skill promotion deal; buy one get one free, you know. So you'll need " + + "to free up some inventory space before I can sell you one." + ).also { stage = END_DIALOGUE } + + else -> playerl( + FacialExpression.FRIENDLY, + "That's fine." + ).also { stage = 112 } + } + } + } } - 13 -> if(inInventory(player, COIN, 99000)) { - removeItem(player, Item(COIN, 99000), Container.INVENTORY) - addItem(player, CAPE, 1) - npcl(FacialExpression.HAPPY, "There you go! Enjoy.").also{ stage = END_DIALOGUE } - } else { - npcl(FacialExpression.NEUTRAL, "You don't have enough coins for a cape.").also{ stage = END_DIALOGUE } + + 103 -> npcl( + FacialExpression.FRIENDLY, + "Not at all; there are many other adventurers who would love the opportunity to purchase " + + "such a prestigious item! You can find me here if you change your mind." + ).also { stage = END_DIALOGUE } + + + 111 -> npcl( + FacialExpression.FRIENDLY, + "Well, come back and see me when you do." + ).also { stage = END_DIALOGUE } + + 112 -> { + Skillcape.purchase(player, Skills.CRAFTING) + npcl( + FacialExpression.FRIENDLY, + "Excellent! Wear that cape with pride my friend." + ).also { stage = END_DIALOGUE } } - 20 -> npcl(FacialExpression.NEUTRAL, "Where's your brown apron? You can't come in here unless you're wearing one.").also{ stage++ } - 21 -> player(FacialExpression.HALF_GUILTY, "Err... I haven't got one.").also{ stage = END_DIALOGUE } } return true } - override fun getIds() : IntArray { + override fun getIds(): IntArray { return intArrayOf(NPCs.MASTER_CRAFTER_805) } - } \ No newline at end of file diff --git a/Server/src/main/content/region/asgarnia/dialogue/TannerDialogue.kt b/Server/src/main/content/region/asgarnia/dialogue/TannerDialogue.kt index 5782e6af9..fe7c09060 100644 --- a/Server/src/main/content/region/asgarnia/dialogue/TannerDialogue.kt +++ b/Server/src/main/content/region/asgarnia/dialogue/TannerDialogue.kt @@ -1,5 +1,6 @@ package content.region.asgarnia.dialogue +import content.global.skill.crafting.TanningProduct import core.game.dialogue.DialoguePlugin import core.game.dialogue.FacialExpression import core.game.node.entity.npc.NPC @@ -34,8 +35,7 @@ class TannerDialogue(player: Player? = null) : DialoguePlugin(player) { 2 -> player(FacialExpression.SUSPICIOUS, "Leather is rather weak stuff.").also { stage = 20 } } - 10 -> npcl(FacialExpression.FRIENDLY, "Certainly!").also { stage = END_DIALOGUE }.also{ npc.openShop(player) } - + 10 -> npcl(FacialExpression.FRIENDLY, "Certainly!").also { stage = 30 } 20 -> npcl(FacialExpression.NOD_YES, "Normal leather may be quite weak, but it's very cheap - I " + "make it from cowhides for only 1 gp per hide - and it's so easy to craft that anyone can work with it.").also{ stage++ } 21 -> npcl(FacialExpression.HALF_THINKING, "Alternatively you could try hard leather. It's not so easy " + @@ -43,6 +43,10 @@ class TannerDialogue(player: Player? = null) : DialoguePlugin(player) { 22 -> npcl(FacialExpression.FRIENDLY, "I can also tan snake hides and dragonhides, suitable for crafting" + "into the highest quality armour for rangers.").also{ stage++ } 23 -> player(FacialExpression.NEUTRAL, "Thanks, I'll bear it in mind.").also { stage = END_DIALOGUE } + 30 -> { + end() + TanningProduct.open(player, npc.id) + } } return true } diff --git a/Server/src/main/content/region/asgarnia/dialogue/TheDoorDialogues.kt b/Server/src/main/content/region/asgarnia/dialogue/TheDoorDialogues.kt index 11559fb3a..fd7f6bae0 100644 --- a/Server/src/main/content/region/asgarnia/dialogue/TheDoorDialogues.kt +++ b/Server/src/main/content/region/asgarnia/dialogue/TheDoorDialogues.kt @@ -15,7 +15,7 @@ class TheDoorDialogues(val it: Int) : DialogueFile() { npc = NPC(NPCs.MASTER_CRAFTER_805) when(it) { 0 -> when(stage) { - 0 -> npcl(FacialExpression.FRIENDLY, "Welcome to the Guild of Master craftsmen.").also{ stage = END_DIALOGUE } + 0 -> npcl(FacialExpression.FRIENDLY, "Welcome to the Guild of Master Craftsmen.").also{ stage = END_DIALOGUE } } 1 -> when(stage) { 0 -> npcl(FacialExpression.ASKING, "Where's your brown apron? You can't come in here unless you're wearing one.").also{ stage++ } @@ -25,8 +25,5 @@ class TheDoorDialogues(val it: Int) : DialogueFile() { 0 -> npcl(FacialExpression.NEUTRAL, "Sorry, only experienced crafters are allowed in here. You must be level 40 or above to enter.").also{ stage = END_DIALOGUE } } } - } - - } \ No newline at end of file diff --git a/Server/src/main/content/region/asgarnia/dialogue/YoungMasterCrafterDialogue.kt b/Server/src/main/content/region/asgarnia/dialogue/YoungMasterCrafterDialogue.kt new file mode 100644 index 000000000..84ae78c11 --- /dev/null +++ b/Server/src/main/content/region/asgarnia/dialogue/YoungMasterCrafterDialogue.kt @@ -0,0 +1,60 @@ +package content.region.asgarnia.dialogue + +import core.game.dialogue.DialoguePlugin +import core.game.dialogue.FacialExpression +import core.game.node.entity.player.Player +import core.plugin.Initializable +import core.tools.END_DIALOGUE +import org.rs09.consts.NPCs + +@Initializable +class YoungMasterCrafterDialogue(player: Player? = null) : DialoguePlugin(player) { + + override fun newInstance(player: Player): DialoguePlugin { + return YoungMasterCrafterDialogue(player) + } + + override fun handle(interfaceId: Int, buttonId: Int): Boolean { + when (stage) { + 0 -> npcl( + FacialExpression.HALF_ASKING, + "Yeah?" + ).also { stage++ } + + 1 -> playerl( + FacialExpression.FRIENDLY, + "Hello." + ).also { stage++ } + + 2 -> npcl( + FacialExpression.HALF_ASKING, + "Whassup?" + ).also { stage++ } + + 3 -> playerl( + FacialExpression.NEUTRAL, + "So... are you here to give crafting tips?" + ).also { stage++ } + + 4 -> npcl( + FacialExpression.ANNOYED, + "Dude, do I look like I wanna talk to you?" + ).also { stage++ } + + 5 -> playerl( + FacialExpression.NEUTRAL, + "I suppose not." + ).also { stage++ } + + 6 -> npcl( + FacialExpression.NEUTRAL, + "Right on!" + ).also { stage = END_DIALOGUE } + } + return true + } + + override fun getIds(): IntArray { + return intArrayOf(NPCs.MASTER_CRAFTER_2733) + } +} \ No newline at end of file diff --git a/Server/src/main/content/region/asgarnia/handlers/CraftingGuildListeners.kt b/Server/src/main/content/region/asgarnia/handlers/CraftingGuildListeners.kt index 6cad8f839..9ca8b163a 100644 --- a/Server/src/main/content/region/asgarnia/handlers/CraftingGuildListeners.kt +++ b/Server/src/main/content/region/asgarnia/handlers/CraftingGuildListeners.kt @@ -1,5 +1,6 @@ package content.region.asgarnia.handlers +import content.global.skill.crafting.TanningProduct import core.api.* import core.game.node.entity.skill.Skills import core.game.world.map.Location @@ -8,6 +9,7 @@ import org.rs09.consts.Scenery import content.region.asgarnia.dialogue.TheDoorDialogues import core.game.interaction.InteractionListener import core.game.interaction.IntType +import org.rs09.consts.NPCs /** * @author bushtail @@ -15,18 +17,13 @@ import core.game.interaction.IntType class CraftingGuildListeners : InteractionListener { private val GUILD_DOOR = Scenery.GUILD_DOOR_2647 - private val APRON = Items.BROWN_APRON_1757 - private val CAPE = Items.CRAFTING_CAPE_9780 + private val REQUIRED_ITEMS = intArrayOf(Items.BROWN_APRON_1757, Items.CRAFTING_CAPE_9780, Items.CRAFTING_CAPET_9781) override fun defineListeners() { on(GUILD_DOOR, IntType.SCENERY, "open") { player, door -> if (player.location == Location.create(2933, 3289, 0)) { if (hasLevelStat(player, Skills.CRAFTING, 40)) { - if (inEquipment(player, APRON)) { - openDialogue(player, TheDoorDialogues(0)) - core.game.global.action.DoorActionHandler.handleAutowalkDoor(player, door.asScenery()) - return@on true - } else if (inEquipment(player, CAPE)) { + if (anyInEquipment(player, *REQUIRED_ITEMS)) { openDialogue(player, TheDoorDialogues(0)) core.game.global.action.DoorActionHandler.handleAutowalkDoor(player, door.asScenery()) return@on true @@ -43,5 +40,10 @@ class CraftingGuildListeners : InteractionListener { return@on true } } + + on(NPCs.TANNER_804, IntType.NPC, "trade") { player, node -> + TanningProduct.open(player, node.id) + return@on true + } } -} +} \ No newline at end of file