EffectSpellFailure(int, int)
Creates an effect that inhibits spells.
Parameters
- nPercent
- Percent chance of spell failing (1 to 100). (Default: 100)
- nSpellSchool
- Spell school that is affected (SPELL_SCHOOL_*). (Default: SPELL_SCHOOL_GENERAL )
Description
Returns an effect that has a chance of causing a spell to fail. Spells that are cast and fail are lost. Specific schools of spells may be affected (SPELL_SCHOOL_*) or all schools may be affected (SPELL_SCHOOL_GENERAL). To guarantee that no spell can be successfully cast in an area with this effect, apply the effect with its default parameters.
This is a buggy effect - see Effect Breakdown and Known Bugs - when more than one effect of this type is used it simply overrides the last one, and removal of one removes the entire effect.
The target this effect is applied to must be a creature for it to work. This effect should not be applied instantly, only temporarily or permanently.
EffectSpellFailure only affects spells cast with the UserType column set to 1. It is not arcane spell failure, it applies to any spell cast.
Remarks
This effect has nothing to do with arcane spell failure you can put on items (or is naturally there via. armor). It is a separate check, and affects the caster whenever they cast a spell in addition to normal armor checks, concentration checks and so forth. For information on arcane spell failure item property see ItemPropertyArcaneSpellFailure.
It affects spells.2da lines which are UserType "1". It only affects ActionCastSpell (normal spellbook or spells added as monster abilities in the toolset), not using items such as scrolls, potions or wands with that spell. You get the simple message "Spell failed!" with no further feedback (on the roll, or type of failure) when it causes a spell to fail. The casting attempted is lost.
Putting it to 100 will stop any spell being cast. Even 1% can be deadly to a caster. This can be used to create a "magic dead-zone" as per the Time of Troubles (TSR modules FR1 through FR3) although the Spell Hook would needed to stop any items being used.
Effect Breakdown
It seems, especially since Bioware barely uses this effect, to be a very buggy effect. What appears to happen is any time a new effect occurs of this type, the old ones are all overriden entirely. When any one is removed, it reverts back to 0 spell failure. Example:
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSpellFailure(1), OBJECT_SELF); // Now spell failure is 1%
Removing effects also clears any previously set value even if more than one effect remains:
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSpellFailure(100), OBJECT_SELF);
RemoveEffect(OBJECT_SELF, GetFirstEffect(OBJECT_SELF));
// Still has 1 effect but the spell failure is reset to 0. Note this also removes the effect icon (erroneously)
The percentage value can also go over 100. It seems to loop back at 256 (100% failure at 255, and no apparent failure roll on 256) therefore the maximum value is 255. However realistically anything over 100 always fails the d100 check roll.
As noted above the roll is only done on spell castings, not item usage, and only affects spells with a UserType value of 1 (so a dragons breath, or a gaze, is unaffected, but Ray of Frost is, whether in a monsters abilities list or a proper spell book).
As noted in Known Bugs the subtype is not set so it isn't removed by resting. It can be correctly removed if the subtype is set, or you manually remove it with RemoveEffect.
nIndex | Parameter Value | Description and Notes |
---|---|---|
GetEffectInteger | ||
0 | nPercent | The percentage of spell failure, although see effect breakdown for bugs and limits. |
1 | nSpellSchool | The default value - SPELL_SCHOOL_GENERAL - is 0 so may not be apparent. |
Known Bugs
Unlike other effects, the subtype of this effect is not magical by default but "none". This can be a problem as such effect will not be removed after resting. To workaround this issue, use MagicalEffect(EffectSpellFailure()); if you want to create a spell failure effect of the magical subtype.
As noted above applying this just sets the spell failure to the given %, instead of summing up the values. Removing any one effect also sets it back to 0. These are major bugs making this effect very difficult to use properly.
Version
1.62
Example
// NB: In NWN:EE using a tagged effect for this would be recommended
void main()
{
// Declare effects
effect eVis = EffectVisualEffect(VFX_IMP_BREACH);
effect eDur = EffectVisualEffect(VFX_DUR_GLOW_LIGHT_BLUE);
effect eAntiMag = EffectSpellFailure(100);
eAntiMag = EffectLinkEffects(eDur, eAntiMag);
eAntiMag = SupernaturalEffect(eAntiMag);
// Get who to effect
object oTarget = GetEnteringObject();
// Must NOT be a DM or plot-flagged creature
if(GetIsDM(oTarget) || GetPlotFlag(oTarget)) return;
// Remove effects which are magical
effect eCheck = GetFirstEffect(oTarget);
while(GetIsEffectValid(eCheck))
{
if (GetEffectSubType(eCheck) == SUBTYPE_MAGICAL)
{
if (GetEffectType(eCheck) != EFFECT_TYPE_DISAPPEARAPPEAR
&& GetEffectType(eCheck) != EFFECT_TYPE_SPELL_FAILURE)
{
RemoveEffect(oTarget, eCheck);
}
}
eCheck = GetNextEffect(oTarget);
}
// Apply effects
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eAntiMag, oTarget);
}
// Remove any spell failure when they exit the area
// NB: In NWN:EE using a tagged effect for this would be recommended
void main()
{
// Remove from exiter.
object oTarget = GetExitingObject();
// Remove effects which are spell failure
effect eCheck = GetFirstEffect(oTarget);
while(GetIsEffectValid(eCheck))
{
if(GetEffectSubType(eCheck) == SUBTYPE_SUPERNATURAL)
{
if(GetEffectType(eCheck) == EFFECT_TYPE_SPELL_FAILURE)
{
RemoveEffect(oTarget, eCheck);
}
}
eCheck = GetNextEffect(oTarget);
}
}
See Also
functions: | |
constants: |
author: Charles Feduke, editors: Jasperre, Mistress, additional contributors: Jasperre