Invisibility purge - need scripting help

Hey guys,

Need some help with editing the script for Invisibility purge. I’m trying to edit the spell to remove only the invisibility effect from the targets (without the concealment effect from improved insivility and spellabilities as improved invisibility), plus I don’t want it to work on the caster. I might want to edit it further so it doesn’t work on those spellabilities, but for now the first part is giving me trouble, no idea why.

Here’s a part of my onEnter NW_S0_InvPurgeA script:

void main()
    //Declare major variables

    object oTarget = GetEnteringObject();

    effect eInvis = GetFirstEffect(oTarget);
    int bRemove;
    while (GetIsEffectValid(eInvis))
        switch (GetEffectSpellId(eInvis))
            case SPELL_INVISIBILITY:
            bRemove = TRUE;
            bRemove = GetEffectType(eInvis) == EFFECT_TYPE_INVISIBILITY || GetEffectType(eInvis) == EFFECT_TYPE_IMPROVEDINVISIBILITY;
        if (bRemove)
            if (spellsIsTarget(oTarget,SPELL_TARGET_STANDARDHOSTILE, aoe.Creator))
                //Fire cast spell at event for the specified target
                SignalEvent(oTarget, EventSpellCastAt(aoe.AOE, spell.Id));
                //Fire cast spell at event for the specified target
                SignalEvent(oTarget, EventSpellCastAt(aoe.AOE, spell.Id, FALSE));
            if (oTarget != spell.Caster)
                //Remove invisibility
                RemoveSpecificEffect(EFFECT_TYPE_INVISIBILITY, oTarget);
        //Get Next Effect
        eInvis = GetNextEffect(oTarget);

It removes only the invisibility effect, as intended, but causes an error:

Script: NW_S0_InvPurgeA
OID: 80000834
Too many commands

What am I doing wrong? Any tips?

One possibility: Since you are cycling through all the effects, use “RemoveEffect(oTarget, eInvis);” instead of RemoveSpecificEffect, which strangely will remove all instances of the effect on oTarget and therefore has an extra search function. I think you already check if eInvis is an Invisibility effect, but you can put a check of that right before the Remove Effect call.

Yeah… RemoveSpecificEffect uses a GetFirst/NextEffect() loop too so your iterator is getting messed up. But as Mannast says, you already have the effect you need to remove so just remove it.

Using the example of improved invisibility, perhaps the invisibility effect is linked with the concealment effect, preventing one from being removed without the other?

In that case you’d need to edit the improved invisibility spell as well, I think.

Please correct me if I’m wrong.

Mannast and meaglyn, thanks for your input, but going for RemoveEffect(oTarget, eInvis) removes both effects of improved invisibility (invisibility and concealment). What I’m trying to achieve is removing only the invisibility effect.

Charles, improved invisibility applies two effects: EffectInvisibility and EffectConcealment. Those effects are not linked (at least that’s what it looks like).

…then remove the second half of this line. It’s telling the later code to remove IMPROVEDINVIS effect. And use RemoveEffect().

Edit: you may want to remove the case statement for SPELL_IMPROVED… as well.

But you are also hitting an otherwise infinite loop which only ends at TMI. That’s what I was helping you fix.

1 Like

Gosh, it was way less complicated than I thought it would be. You were right, I had to make one loop through effects and remove only EFFECT_TYPE_INVISIBILITY and that’s it.

Thanks guys!

1 Like