diff --git a/Server/src/main/java/core/game/node/entity/skill/cooking/CookingRewrite.kt b/Server/src/main/java/core/game/node/entity/skill/cooking/CookingRewrite.kt index e9018f88e..34ba566e9 100644 --- a/Server/src/main/java/core/game/node/entity/skill/cooking/CookingRewrite.kt +++ b/Server/src/main/java/core/game/node/entity/skill/cooking/CookingRewrite.kt @@ -1,17 +1,22 @@ package core.game.node.entity.skill.cooking +import api.* import core.game.node.scenery.Scenery import core.game.node.entity.player.Player import core.game.node.item.Item import org.rs09.consts.Items import org.rs09.consts.Items.BREAD_DOUGH_2307 +import org.rs09.consts.Items.RAW_BEAR_MEAT_2136 import org.rs09.consts.Items.RAW_BEEF_2132 import org.rs09.consts.Items.SEAWEED_401 import org.rs09.consts.Items.UNCOOKED_CAKE_1889 import rs09.game.interaction.InteractionListener import rs09.game.node.entity.skill.cooking.CookingDialogue -//author: Ceik +/** + * @author Ceikry + * @author bushtail - added bear meat for sinew making + */ class CookingRewrite : InteractionListener() { val RAW_FOODS: IntArray @@ -20,6 +25,7 @@ class CookingRewrite : InteractionListener() { val list = CookableItems.values().map { it.raw }.toMutableList() list.add(Items.COOKED_MEAT_2142) list.add(RAW_BEEF_2132) + list.add(RAW_BEAR_MEAT_2136) list.add(SEAWEED_401) RAW_FOODS = list.toIntArray() } @@ -31,8 +37,8 @@ class CookingRewrite : InteractionListener() { val obj = with.asScenery() val range = obj.name.toLowerCase().contains("range") when (item.id) { - RAW_BEEF_2132 -> if (range) { - player.dialogueInterpreter.open(CookingDialogue(item.id,9436,true,obj)) + RAW_BEEF_2132, RAW_BEAR_MEAT_2136 -> if (range) { + player.dialogueInterpreter.open(CookingDialogue(item.id,9436,true,obj,item.id)) return@onUseWith true } BREAD_DOUGH_2307, UNCOOKED_CAKE_1889 -> if (!range) { diff --git a/Server/src/main/kotlin/rs09/game/node/entity/skill/cooking/CookingDialogue.kt b/Server/src/main/kotlin/rs09/game/node/entity/skill/cooking/CookingDialogue.kt index 52720e2a8..af2c72866 100644 --- a/Server/src/main/kotlin/rs09/game/node/entity/skill/cooking/CookingDialogue.kt +++ b/Server/src/main/kotlin/rs09/game/node/entity/skill/cooking/CookingDialogue.kt @@ -3,20 +3,28 @@ package rs09.game.node.entity.skill.cooking import api.* import core.cache.def.impl.ItemDefinition import core.game.node.scenery.Scenery -import core.game.node.entity.player.link.RunScript import core.game.node.entity.skill.cooking.CookableItems import core.game.node.entity.skill.cooking.CookingRewrite.Companion.cook +import core.game.node.item.Item import core.net.packet.PacketRepository import core.net.packet.context.ChildPositionContext import core.net.packet.out.RepositionChild +import org.rs09.consts.Items import rs09.game.content.dialogue.DialogueFile +import rs09.game.content.dialogue.SkillDialogueHandler import rs09.tools.START_DIALOGUE +/** + * @author Ceikry + * @author bushtail - fixing it up + */ + class CookingDialogue(vararg val args: Any) : DialogueFile(){ var initial = 0 var product = 0 var `object`: Scenery? = null var sinew = false + var itemid = 0 override fun handle(componentID: Int, buttonID: Int) { when(stage){ START_DIALOGUE -> { @@ -30,14 +38,14 @@ class CookingDialogue(vararg val args: Any) : DialogueFile(){ } `object` = args.get(1) as Scenery } - 4 -> { + 5 -> { initial = args.get(0) as Int product = args.get(1) as Int sinew = args.get(2) as Boolean `object` = args.get(3) as Scenery + itemid = args.get(4) as Int if (sinew) { - player!!.dialogueInterpreter.sendOptions( - "Select one", + options( "Dry the meat into sinew", "Cook the meat" ) @@ -54,9 +62,16 @@ class CookingDialogue(vararg val args: Any) : DialogueFile(){ val amount = getAmount(buttonID) when (amount) { -1 -> { - sendInputDialogue(player!!, true, "Enter the amount:"){value -> - cook(player!!, `object`, initial, product, value as Int) - } + val handler: SkillDialogueHandler = + object : SkillDialogueHandler(player!!, SkillDialogue.ONE_OPTION, Item(product)) { + override fun create(amount: Int, index: Int) { + cook(player, `object`, initial, product, amount) + } + override fun getAll(index: Int) : Int { + return getAmount(amountInInventory(player, initial)) + } + } + handler.open() } else -> { end() @@ -67,10 +82,29 @@ class CookingDialogue(vararg val args: Any) : DialogueFile(){ 100 -> { when (buttonID) { - 1 -> cook(player!!, `object`, initial, product, 1) + 1 -> { + val handler: SkillDialogueHandler = + object : SkillDialogueHandler(player!!, SkillDialogue.ONE_OPTION, Item(Items.SINEW_9436)) { + override fun create(amount: Int, index: Int) { + cook(player, `object`, initial, Items.SINEW_9436, amount) + } + override fun getAll(index: Int) : Int { + return getAmount(amountInInventory(player, initial)) + } + } + handler.open() + } 2 -> { - product = CookableItems.forId(initial).cooked - display() + val handler: SkillDialogueHandler = + object : SkillDialogueHandler(player!!, SkillDialogue.ONE_OPTION, Item(CookableItems.forId(itemid).cooked)) { + override fun create(amount: Int, index: Int) { + cook(player, `object`, initial, CookableItems.forId(itemid).cooked, amount) + } + override fun getAll(index: Int) : Int { + return getAmount(amountInInventory(player, itemid)) + } + } + handler.open() } } }