TagEffect(effect, string)

From NWN Lexicon
Revision as of 06:05, 1 July 2019 by WilliamDraco (talk | contribs) (Remarks on use and Example (Including how to callback))
Jump to: navigation, search
Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.
Tags the effect with the provided string.
effect TagEffect(
    effect eEffect,
    string sNewTag


The effect object to tag.
A string to tag the effect object with.


Tags the effect with the provided string. Any other tags in the link will be overwritten.


This function applies in a similar way to other Effect options such as SupernaturalEffect in that it does not tag eEffect passed in, but generates a new effect-with-tag "object" which must be assigned to a variable or applied.

Also similar to the effect options Magical/Supernatural/Extraordinary, only the newest tag will persist for any effect. The resulting tag from applying EffectLinkEffects with two effects which already have tags is unclear.

This is used in conjuction with GetEffectTag to uniquely identify effects, such as to remove effects created by a specific non-spell interaction (see example below).

Note again that if the effect has already been applied, this will not tag that effect. The newly created, tagged effect will need to be applied to the Object/Location (presumably after removing the previous effect).




// Applying a supernatural effect 'permanently' decreasing entering PC's strength by 1.
// Use the tag "TotallyUnique" to make this Strength decrease separate from others in effect.
void main()
    object oPC=GetEnteringObject();
    if(!GetIsPC(oPC)) return;
    effect eBad=EffectAbilityDecrease(ABILITY_STRENGTH, 1);
    eBad=TagEffect(eBad, "TotallyUnique");
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eBad, oPC);
// When the PC leaves we want to remove the above effect, but leave other strength decreases intact.
// Instead of checking for effect type, simply check for the effect tag.
void main()
    object oPC=GetExitingObject();
    if(!GetIsPC(oPC)) return;
    eEffect = GetFirstEffect(oPC);
        if(GetEffectTag(eEffect) == "TotallyUnique")
        eEffect = GetNextEffect(oPC);

See Also

functions: GetEffectTag()