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..726279dd274 --- /dev/null +++ b/data-otservbr-global/scripts/actions/rookgaard/rapier_quest.lua @@ -0,0 +1,20 @@ +local rapierQuest = Action() +local reward = 3272 +function rapierQuest.onUse(player, item, fromPosition, target, toPosition, isHotkey) + local itemType = ItemType(reward) + local itemWeight = itemType:getWeight() + if player:getFreeCapacity() >= itemType:getWeight() then + if not player:questKV("rapier"):get("completed") then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have found a rapier.") + player:addItem(reward, 1) + player:questKV("rapier"):set("completed", true) + else + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The box is empty.") + end + else + player:sendTextMessage(MESSAGE_LOOK, "You have found a " .. itemType:getName() .. " weighing " .. (itemWeight/ 100) .. " oz, but it's too heavy.") + end + return true +end +rapierQuest:uid(14042) +rapierQuest:register() diff --git a/data-otservbr-global/startup/tables/chest.lua b/data-otservbr-global/startup/tables/chest.lua index f5049f93f61..228e9ba2976 100644 --- a/data-otservbr-global/startup/tables/chest.lua +++ b/data-otservbr-global/startup/tables/chest.lua @@ -1186,4 +1186,8 @@ ChestUnique = { itemId = 11810, itemPos = { x = 33195, y = 31765, z = 1 }, }, + [14042] = { + itemId = 2473, + itemPos = { x = 32099, y = 32198, z = 9 }, + }, } diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index 8bb420a5669..965e8def297 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