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

37 lines
1 KiB
Lua

-----------------------------------
-- ID: 11675
-- Fervor Ring
-- Pet mod via latent effect
-----------------------------------
---@type TItem
local itemObject = {}
local listenerPrefix = 'PET_MOD_LATENT'
local latentPetId = xi.petId.IFRIT
local latentMods =
{
{ xi.mod.MATT, 2 },
}
itemObject.onItemCheck = function(target, item, param, caster)
return 0
end
itemObject.onItemEquip = function(user, item)
local listenerName = fmt('{}_{}', listenerPrefix, item:getID())
xi.itemUtils.handlePetLatentMods(user, latentPetId, latentMods, true)
user:addListener('MAGIC_STATE_EXIT', listenerName, function(player, spell)
if spell:getSpellGroup() == xi.magic.spellGroup.SUMMONING then
xi.itemUtils.handlePetLatentMods(user, latentPetId, latentMods, true)
end
end)
end
itemObject.onItemUnequip = function(user, item)
local listenerName = fmt('{}_{}', listenerPrefix, item:getID())
xi.itemUtils.handlePetLatentMods(user, latentPetId, latentMods, false)
user:removeListener(listenerName)
end
return itemObject