landsandboat/scripts/items/sacred_sword.lua

36 lines
1.2 KiB
Lua

-----------------------------------
-- ID: 17682
-- Item: Sacred Sword
-- Enchantment: Enlight
-- Duration: 3 minutes
-----------------------------------
---@type TItem
local itemObject = {}
itemObject.onItemCheck = function(target, item, caster)
if target:getStatusEffectBySource(xi.effect.ENLIGHT, xi.effectSourceType.EQUIPPED_ITEM, xi.item.SACRED_SWORD) ~= nil then
target:delStatusEffect(xi.effect.ENLIGHT, nil, xi.effectSourceType.EQUIPPED_ITEM, xi.item.SACRED_SWORD)
end
return 0
end
itemObject.onItemUse = function(target, user)
if target:hasEquipped(xi.item.SACRED_SWORD) 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_SWORD })
end
end
return itemObject