From NWN Lexicon
Jump to: navigation, search


Create an Immunity effect.

effect EffectImmunity(
    int nImmunityType



One of the IMMUNITY_TYPE_* constants.


Returns a new effect object that when applied to a target will cause them to be Immune to one of the 33 possible types of Hostile actions found in the IMMUNITY_TYPE_* constants group.

Immunities don't stack, but of course a creature can have 2, they just don't do anything extra. They are never total damage immunities, but rather immunities that stop most EffectXXX constructors! Some, such as IMMUNITY_TYPE_MIND_SPELLS will actually stop many effects (in this case, Domination, Stun, Confusion etc.).

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.


You can only define one Immunity per effect but by using EffectLinkEffects(effect1,effect2) you can continuously add them together into one giant effect.

Immunities are general very powerful, and usually only meant for NPC's. They provide immunities to certain effects (but not all of them) most of which are pretty obvious.

Once a person is immune, it doesn't mean they will have current effects removed or even hampered - making someone immune to stunning when they are stunned is obviously only going to stop further uses of EffectStunned() on the target, not remove the effect they are currently under.

Because of this, obviously, you can just loop effects and remove all of them of that subtype - the spell Freedom of Movement does this.

Effect functions are Constructors, which are special methods that help construct effect "objects". You can declare and link effects, and apply them using an ApplyEffectToObject() Command. Once applied, each effect can be got separately via. looping valid effects on the target (GetFirst/NextEffect()). See the Effect Tutorial for more details.




// Sample code for applying immunity to critical hits to a target
void main()
    // This is the Object to apply the effect to.
    object oTarget = OBJECT_SELF;
    // Create the effect to apply
    effect eImmune = EffectImmunity(IMMUNITY_TYPE_CRITICAL_HIT);
    // Create the visual portion of the effect. This is instantly
    // applied and not persistent with whether or not we have the
    // above effect.
    effect eVis = EffectVisualEffect(VFX_IMP_GOOD_HELP);
    // Apply the visual effect to the target
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
    // Apply the effect to the object   
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eImmune, oTarget);

See Also



 author: John Shuell, editor: Jasperre, additional contributor(s): Jasperre