landsandboat/scripts/items/magic_slacks.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

28 lines
658 B
Lua

-----------------------------------
-- ID: 15372
-- Item: Magic Slacks
-- Item Effect: Restores 30-39 MP
-----------------------------------
---@type TItem
local itemObject = {}
itemObject.onItemCheck = function(target, item, param, caster)
if target:getMP() == target:getMaxMP() then
return xi.msg.basic.ITEM_UNABLE_TO_USE
end
return 0
end
itemObject.onItemUse = function(target)
local mpHeal = math.random(30, 40)
local dif = target:getMaxMP() - target:getMP()
if mpHeal > dif then
mpHeal = dif
end
target:addMP(mpHeal)
target:messageBasic(xi.msg.basic.RECOVERS_MP, 0, mpHeal)
end
return itemObject