Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.


Dark Dreams of Furiae - a new module for NWN:EE! Buy now
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

TagEffect() and RemoveEffect()


We have a subrace system, which relies on Removing and re-adding passive abilities every login.
We tag the linked effects with one tag upon adding the passive abilities, and remove them prior to adding them:

    eLink = TagEffect(eLink, SUBRACE_EFFECTS_TAG);
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, SupernaturalEffect(eLink), oPC);

//Remove Subrace passive effects.
void RemoveSubracePassives(object oPC) {
    effect eEffect = GetFirstEffect(oPC);

    while(GetIsEffectValid(eEffect)) {
        if(GetEffectTag(eEffect) == SUBRACE_EFFECTS_TAG) {
            SendBasicDebuggingMessage("RemoveSubracePassives(): Found effect with SUBRACE_EFFECTS_TAG!", "inc_subraces");
            RemoveEffect(oPC, eEffect);

        eEffect = GetNextEffect(oPC);

For some reason however the effects dont get removed and keep stacking, despite the fact we do find the effect with the proper tag.

Would appreciate help in understanding the behavior of TagEffect() and RemoveEffect() especially when dealing with Linked effects. Should they still work and remove the entire link? Any recommendations on how to tackle this?

Thanks in advance!


  • NeverwinterWightsNeverwinterWights Member Posts: 259
    As per NWN Lexicon:

    "The resulting tag from applying EffectLinkEffects with two effects which already have tags is unclear."

    If you are having trouble specifically with linked effects I would try and separate them, give them the same tags still, then try and remove them and see if that works.

  • WilliamDracoWilliamDraco Member Posts: 156
    TagEffect() will tag the entire, linked effect - and RemoveEffect() will remove the entire, linked. The concern raised by the lexicon is what happens if you link an effect tagged "Tag1" and an effect tagged "Tag2" - What is the tag of the result?

    Given the script posted, I don't think that's the issue. Everything is already pre-linked before the tag is applied.

    I'd recommend a little more debugging to be sure everything is calling correctly. For example, in your removal script, within the while but before the IF, have it print a debug string saying what the EffectTag is.

    Maybe the removal script isn't being called (from wherever that's meant to happen) properly. The removal function ends after the first time it finds one such effect, maybe it is working, but you apply two separate effects with SUBRACE_EFFECTS_TAG and so there are some leftovers?

  • Strife_and_DiscordStrife_and_Discord Member Posts: 17
    Thanks alot to the both of you :)

    It was actually the case WiliamDraco described. For some reason the Effect Tag was found 3 times, even though its only applied once. I am inclined to believe that the linked effects might eventually be added to the object separately with the same tag.

    Since the original creator of the code placed that break point - We never removed the other instances.

Sign In or Register to comment.