magicEffectAdded⚓︎
This event triggers when a magic source stores the first active instance for one of its effects.
For a magic source with multiple effects, this event triggers once for each effect that is added. For example, a spell with fire damage and frost damage effects triggers once when the fire damage effect is added and once when the frost damage effect is added. If additional references are affected, magicEffectAdded, magicEffectActivated, magicEffectDeactivated, and magicEffectRemoved can each trigger once for each affected reference.
--- @param e magicEffectAddedEventData
local function magicEffectAddedCallback(e)
end
event.register(tes3.event.magicEffectAdded, magicEffectAddedCallback)
Tip
This event can be filtered based on the effectId event data.
Tip
An event can be claimed by setting e.claim to true, or by returning false from the callback. Claiming the event prevents any lower priority callbacks from being called.
Event Data⚓︎
caster(tes3reference): Read-only. The caster of the magic source. Can benil.effect(tes3effect): Read-only. The specific effect that triggered the event. This is equal toe.source.effects[e.effectIndex]. Can benil.effectId(tes3.effect, integer): Read-only. The magic effect ID ate.source.effects[e.effectIndex]. Maps to values intes3.effectnamespace.effectIndex(integer): Read-only. The index of the effect in the magic source's effects list.effectInstance(tes3magicEffectInstance): Read-only. The unique instance of the magic effect that caused the source effect to be added.source(tes3alchemy, tes3enchantment, tes3spell): Read-only. The magic source that contains the effect.sourceInstance(tes3magicSourceInstance): Read-only. The unique instance of the magic source that contains the effect.state(tes3.spellState): Read-only. The state of the magic effect instance when the event fired.target(tes3reference): Read-only. The target of the magic effect instance that caused the source effect to be added.
Examples⚓︎
Example: Show Added Effect
Show the magic effect and source names when a source effect is added on the player.
local function onMagicEffectAdded(e)
if e.target ~= tes3.player then return end
local effectName = tes3.getMagicEffect(e.effect.id).name
local sourceName = e.source.name
tes3.messageBox("Effect '%s' from '%s' was added.", effectName, sourceName)
end
event.register(tes3.event.magicEffectAdded, onMagicEffectAdded)
Related events⚓︎
magicEffectActivatedmagicEffectDeactivatedmagicEffectRemovedspellTick