landsandboat/scripts/items/sacred_mace.lua
2026-02-20 18:42:33 -07:00

34 lines
1.2 KiB
Lua

-----------------------------------
-- ID: 18391
-- Item: Sacred Mace
-- Enchantment: Enlight
-- Duration: 3 minutes
-----------------------------------
local itemObject = {}
itemObject.onItemCheck = function(target, user)
if target:getStatusEffectBySource(xi.effect.ENLIGHT, xi.effectSourceType.EQUIPPED_ITEM, xi.item.SACRED_MACE) ~= nil then
target:delStatusEffect(xi.effect.ENLIGHT, nil, xi.effectSourceType.EQUIPPED_ITEM, xi.item.SACRED_MACE)
end
return 0
end
itemObject.onItemUse = function(target, user)
if target:hasEquipped(xi.item.SACRED_MACE) then
local effect = xi.effect.ENLIGHT
local magicskill = target:getSkillLevel(xi.skill.ENHANCING_MAGIC)
local potency = 0
if magicskill <= 200 then
potency = 3 + math.floor(6 * magicskill / 100)
elseif magicskill > 200 then
potency = 5 + math.floor(5 * magicskill / 100)
end
potency = utils.clamp(potency, 3, 25)
target:addStatusEffect(effect, { power = potency, duration = 180, origin = user, sourceType = xi.effectSourceType.EQUIPPED_ITEM, sourceTypeParam = xi.item.SACRED_MACE })
end
end
return itemObject