EffectImmunity(int)

Create an Immunity effect.

effect EffectImmunity(
    int nImmunityType
);

Parameters

nImmunityType

One of the IMMUNITY_TYPE_* constants.


Description

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 cannot be applied instantly, only temporarily or permanently.



Remarks

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 cirtain 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 stuning when they are stunned is obvioulsy only going to stop futher uses of EffectStun 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 seperately via. looping valid effects on the target (GetFirst/NextEffect()). See the Effect Tutorial for more details.


Version

1.62

Example

// Sample code for applying immunity to criticals 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 persistant with wether 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

categories: Effects Functions
constants: IMMUNITY_TYPE_* Constants


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