From 4f035982aa786fbd8e4c24a070419c05b21b8a9f Mon Sep 17 00:00:00 2001 From: Majesty <32709570+majestyotbr@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:41:34 -0300 Subject: [PATCH] feat: kv: quests --- .../scripts/actions/rookgaard/rapier_quest.lua | 15 +++++++++++++++ data/libs/functions/player.lua | 4 ++++ 2 files changed, 19 insertions(+) create mode 100644 data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua diff --git a/data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua b/data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua new file mode 100644 index 00000000000..553db8e9a73 --- /dev/null +++ b/data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua @@ -0,0 +1,15 @@ +local rapierQuest = Action() + +function rapierQuest.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if player:questKV('rapier'):get('completed') then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The box is empty.") + else + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a rapier.") + player:addItem(3272, 1) + player:kv():scoped('quests'):scoped('rapier'):set('completed', true) + end + return true +end + +rapierQuest:position{x = 32099, y = 32198, z = 9} +rapierQuest:register() diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index 8bb420a5669..f5a2a874124 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -748,3 +748,7 @@ function Player:canFightBoss(bossNameOrId) local cooldown = self:getBossCooldown(bossNameOrId) return cooldown <= os.time() end + +function Player:questKV(questName) + return self:kv():scoped('quests'):scoped(questName) +end