EffectSpellFailure

From NWN Lexicon
Jump to: navigation, search

EffectSpellFailure(int, int)

Creates an effect that inhibits spells.

effect EffectSpellFailure(
    int nPercent = 100,
    SPELL_SCHOOL_GENERAL
);

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.

It is likely these do not stack, and only the highest appropriate penalty applies. If this is incorrect, send a bug report in.

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.

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).

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.

Version

1.62

Example

// Apply 100% spell failure to anyone who enters this area, after all magical effects are removed!
// 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:

ItemPropertyArcaneSpellFailure

constants: 

SPELL_SCHOOL_* Constants


 author: Charles Feduke, editors: Jasperre, Mistress, additional contributors: Jasperre