Difference between revisions of "GetEffectTag"

From NWN Lexicon
Jump to: navigation, search
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{NWNEE}}Returns the string tag set for the provided effect.
+
__NOTOC__{{NWNEE}}Returns the string tag set for the provided effect.
  
 
<nwscript>
 
<nwscript>
Line 8: Line 8:
  
 
===Parameters===
 
===Parameters===
; eEffect
+
 
: The effect object to get the tag from.
+
;eEffect
 +
:The effect object to get the tag from.
 +
 
  
 
===Description===
 
===Description===
 +
 
Returns the string tag set for the provided effect. If no tag has been set, returns an empty string.
 
Returns the string tag set for the provided effect. If no tag has been set, returns an empty string.
 +
  
 
===Remarks===
 
===Remarks===
  
 
The returned string is that which was set using [[TagEffect]] during effect application. Useful in order to check whether an effect is the result of a specific interaction (which is not a spell and therefore [[GetEffectSpellId]] would not work).<br /><br />One such example might be applying a supernatural effect on being hit by a creature, which is normally undispellable, but allow a special potion to clear that effect without clearing all effects of the same type.<br /><br />The example below considers an undispellable effect from entering an area and removing the same effect on exiting.
 
The returned string is that which was set using [[TagEffect]] during effect application. Useful in order to check whether an effect is the result of a specific interaction (which is not a spell and therefore [[GetEffectSpellId]] would not work).<br /><br />One such example might be applying a supernatural effect on being hit by a creature, which is normally undispellable, but allow a special potion to clear that effect without clearing all effects of the same type.<br /><br />The example below considers an undispellable effect from entering an area and removing the same effect on exiting.
 +
  
 
===Version===
 
===Version===
[https://www.beamdog.com/files/nwnee_release_notes.pdf 1.74.8149]
+
 
 +
{{patchnwnee|patch=1.74.8149|link=https://www.beamdog.com/files/nwnee_release_notes.pdf}}
  
 
===Example===
 
===Example===
Line 48: Line 54:
 
     {
 
     {
 
         if(GetEffectTag(eEffect) == "TotallyUnique")
 
         if(GetEffectTag(eEffect) == "TotallyUnique")
             RemoveEffect(eEffect);
+
             RemoveEffect(oPC, eEffect);
 
         eEffect = GetNextEffect(oPC);
 
         eEffect = GetNextEffect(oPC);
 
     }
 
     }
Line 85: Line 91:
 
     {
 
     {
 
         if(GetEffectTag(eEffect) == "AC_BUFF")
 
         if(GetEffectTag(eEffect) == "AC_BUFF")
             RemoveEffect(eEffect);
+
             RemoveEffect(oPC, eEffect);
 
         eEffect = GetNextEffect(oPC);
 
         eEffect = GetNextEffect(oPC);
 
     }
 
     }

Latest revision as of 18:38, 17 October 2021

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.
Returns the string tag set for the provided effect.
string GetEffectTag(
    effect eEffect
);

Parameters

eEffect
The effect object to get the tag from.


Description

Returns the string tag set for the provided effect. If no tag has been set, returns an empty string.


Remarks

The returned string is that which was set using TagEffect during effect application. Useful in order to check whether an effect is the result of a specific interaction (which is not a spell and therefore GetEffectSpellId would not work).

One such example might be applying a supernatural effect on being hit by a creature, which is normally undispellable, but allow a special potion to clear that effect without clearing all effects of the same type.

The example below considers an undispellable effect from entering an area and removing the same effect on exiting.


Version

This function was added in 1.74.8149 of NWN:EE.

Example

// 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=SupernaturalEffect(eBad);
    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;
 
    effect eEffect = GetFirstEffect(oPC);
    while(GetIsEffectValid(eEffect))
    {
        if(GetEffectTag(eEffect) == "TotallyUnique")
            RemoveEffect(oPC, eEffect);
        eEffect = GetNextEffect(oPC);
    }
}
// Applying two linked effects to an entering object, that are removed at once from an exiting object like above.
// This is useful for applying a related visual
void main()
{
    object oPC=GetEnteringObject();
    if(!GetIsPC(oPC)) return;
 
    effect eAC = EffectACIncrease(10);
    effect eDur = EffectVisualEffect(VFX_DUR_GHOSTLY_VISAGE);
    effect eLink = EffectLinkEffects(eAC, eDur);
 
    // Always tag or make supernatural AFTER the linking is done
    eLink = SupernaturalEffect(eLink);
    eLink = TagEffect(eLink, "AC_BUFF");
 
    // Apply the effect
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLink, oPC);
}
 
// When the PC leaves we want to remove the above effect, but leave other effects unaffected.
// You could also just remove one of the two applied and tagged effects, it will automatically remove the other
void main()
{
    object oPC=GetExitingObject();
    if(!GetIsPC(oPC)) return;
 
    effect eEffect = GetFirstEffect(oPC);
    while(GetIsEffectValid(eEffect))
    {
        if(GetEffectTag(eEffect) == "AC_BUFF")
            RemoveEffect(oPC, eEffect);
        eEffect = GetNextEffect(oPC);
    }
}

See Also

functions: TagEffect