package plugin.quests.cooksassistant import com.rs2.event.EventContext import com.rs2.event.EventSubscriber import com.rs2.event.SubscribesTo import com.rs2.event.impl.ButtonActionEvent import com.rs2.game.content.quests.QuestAssistant import com.rs2.game.players.Player import com.rs2.game.content.StaticItemList.BUCKET_OF_MILK import com.rs2.game.content.StaticItemList.EGG import com.rs2.game.content.StaticItemList.POT_OF_FLOUR import plugin.quests.cooksassistant.CooksAssistantConstants.GAVE_EGG_KEY import plugin.quests.cooksassistant.CooksAssistantConstants.GAVE_FLOUR_KEY import plugin.quests.cooksassistant.CooksAssistantConstants.GAVE_MILK_KEY import plugin.quests.cooksassistant.CooksAssistantConstants.ITEMS_GIVEN_KEY import plugin.quests.cooksassistant.CooksAssistantConstants.JOURNAL_BUTTON_ID import plugin.quests.cooksassistant.CooksAssistantConstants.PLUGIN_ID import plugin.quests.cooksassistant.CooksAssistantConstants.STAGE_COMPLETE import plugin.quests.cooksassistant.CooksAssistantConstants.STAGE_IN_PROGRESS import plugin.quests.cooksassistant.CooksAssistantConstants.STAGE_NOT_STARTED @SubscribesTo(ButtonActionEvent::class) class CooksAssistantJournalPlugin : EventSubscriber { override fun test(event: ButtonActionEvent) = event.button == JOURNAL_BUTTON_ID override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) { for (id in 8144 until 8196) player.packetSender.sendString("", id) for (id in 12174 until 12224) player.packetSender.sendString("", id) for (id in 14945 until 15045) player.packetSender.sendString("", id) player.packetSender.sendString("@dre@Cook's Assistant", 8144) player.packetSender.sendString("", 8145) val stage = player.pluginData.getInt(PLUGIN_ID, QuestAssistant.STAGE_KEY, STAGE_NOT_STARTED) val itemsGiven = player.pluginData.getInt(PLUGIN_ID, ITEMS_GIVEN_KEY, 0) == 1 when (stage) { STAGE_NOT_STARTED -> { player.packetSender.sendString("I can start this quest by speaking to the Cook in the", 8147) player.packetSender.sendString("Lumbridge Castle kitchen.", 8148) player.packetSender.sendString("", 8149) player.packetSender.sendString("There are no minimum requirements.", 8150) } STAGE_IN_PROGRESS -> { if (itemsGiven) { player.packetSender.sendString("@str@I talked to the cook.", 8147) player.packetSender.sendString("@str@I gave the cook his items.", 8148) player.packetSender.sendString("I should go speak to the cook.", 8149) } else { player.packetSender.sendString("@str@I've talked to the cook.", 8147) player.packetSender.sendString("He wants me to gather the following materials:", 8148) val hasEgg = player.pluginData.getInt(PLUGIN_ID, GAVE_EGG_KEY, 0) == 1 || player.itemAssistant.playerHasItem(EGG, 1) val hasMilk = player.pluginData.getInt(PLUGIN_ID, GAVE_MILK_KEY, 0) == 1 || player.itemAssistant.playerHasItem(BUCKET_OF_MILK, 1) val hasFlour = player.pluginData.getInt(PLUGIN_ID, GAVE_FLOUR_KEY, 0) == 1 || player.itemAssistant.playerHasItem(POT_OF_FLOUR, 1) player.packetSender.sendString(if (hasEgg) "@str@1 egg" else "@red@1 egg", 8149) player.packetSender.sendString(if (hasMilk) "@str@1 bucket of milk" else "@red@1 bucket of milk", 8150) player.packetSender.sendString(if (hasFlour) "@str@1 pot of flour" else "@red@1 pot of flour", 8151) } } STAGE_COMPLETE -> { player.packetSender.sendString("@str@It was the Duke of Lumbridge's birthday, and I helped", 8147) player.packetSender.sendString("@str@the cook by finding him an egg, some milk, and flour.", 8148) player.packetSender.sendString("@red@ QUEST COMPLETE", 8150) player.packetSender.sendString("As a reward, I gained 1 Quest Point, 300 Cooking", 8151) player.packetSender.sendString("Experience, 500 coins, and access to the cook's range.", 8152) } } player.packetSender.showInterface(8134) } }