landsandboat/scripts/items/megalixir.lua
claywar 6e4fa2af25
[type] Add type annotations to Item scripts
rename to reflect type definition

Annotate xi.itemUtils.foodOnItemCheck

Make TItemFood functions optional, since the definition does not include types
2024-08-24 18:25:26 -04:00

29 lines
751 B
Lua

-----------------------------------
-- ID: 4254
-- Item: Megalixir
-- Item Effect: Instantly restores 100% of HP and MP
-----------------------------------
---@type TItem
local itemObject = {}
itemObject.onItemCheck = function(target, item, param, caster)
local result = 0
local mHP = target:getMaxHP()
local cHP = target:getHP()
local mMP = target:getMaxMP()
local cMP = target:getMP()
if mHP == cHP and mMP == cMP then
result = 56 -- Does not let player use item if their hp and mp are full
end
return result
end
itemObject.onItemUse = function(target)
target:addHP(target:getMaxHP())
target:addMP(target:getMaxMP())
target:messageBasic(xi.msg.basic.RECOVERS_HP_AND_MP)
end
return itemObject