MSFD Managing and testing spell effects
GetEffect, Effect_ID (returns short)
If ( GetEffect, sEffectRestoreHealth == 1 )
This function returns TRUE if the calling Actor is being affected by the effect. Important: Effects are not spells, but the elements spells are made of. In the Appendix you can find a list of all spell effects.
Don't count on GetEffect being triggered immediately when a spell is added/cast: it will return 1 when the spell has begun to affect the actor, not when the spell is cast on or added to the actor (i.e. there's a short delay - might only be 1 frame but I didn't check).
Note: sEffectRestoreFatigue can't be detected using GetEffect. -(Phaedrus). This may also be true of other fatigue-related effects -(CaveRat).
sEffectWaterBreathing can’t be detected from scripts, although it works in the console. Luckly there is a workarround in the form of the GetWaterBreathing function.
RemoveEffects, Effect_ID#_enum
Player->RemoveEffects, 75
Removes all spells on the Actor that include the Effect. For this function you need the number of the effect-ID unlike the GetEffect function where you need the effect ID itself (Bravo, Bethesda!). Both can be found in the appendix.
Important: Effects are not spells, but the elements spells are made of. In the Appendix you can find a list of all spell effects and their number.
Sample script: This is a demonstration script that lets you check if a spell is in inventory, if it's active on the player, if the effect it causes is on the player and then removes the effect. Start it in the console using "StartScript Magictest" to try it out.
Begin Magictest
short var_1
short var_2
short var_3
if ( Player->GetSpell, "hearth heal" )
set var_1 to 1
else
set var_1 to 0
endif
if ( Player->GetSpellEffects, "hearth heal" )
set var_2 to 1
else
set var_2 to 0
endif
if ( Player->GetEffect, sEffectRestoreHealth )
Player->RemoveEffects, 75 ;delete this line to see what happens normally
set var_3 to 1
else
set var_3 to 0
endif
MessageBox "GetSpell: %.0f GetSpellEffects, %.0f GetEffect: %.0f ", var_1, var_2, var_3
End