From NWN Lexicon
Revision as of 13:01, 15 January 2021 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Determines the spell identifier for a spell which a script is currently processing.


Returns the ID (SPELL_*) of the spell that the Spell Script is processing.

Multiple spells share the same script that is used to resolve the effect of the spell for code reuse but the scrip is altered slightly by the specific spell that it is working processing.

For example the Polymorph Self script (script name NW_S0_POLYSELF) is called by different spells determined by what monster they are polymorphing into.


Strictly used in scripts that resolve a spells or spell abilities effects, this function is used to check for what line in spells.2da called the given script. "Feat" spells, as run from feat.2da, also have a spells.2da line and the "spell ID" can help identify these.

On a side note to change the scripting of a spell one could modify the BioWare scripts for a spell or spell ability (eg. NW_S0_FLMSTRIKE for Flame Strike) and save that script within the module (or Hakpak).

This should only be used inside spell scripts. If you want to learn how to use the new spellhooking system, check the advanced scripting tutorials in the Lexicon's Lyceum.

Custom spells and spell-effects can be added; see spells.2da and spells and abilities pages.

Known Bugs

Returns -1 if called inside of AOE script, however it could return a proper ID since a workaround is to use GetEffectSpellId(EffectDazed()).




//:: Polymorph Self
//:: NW_S0_PolySelf.nss
//:: Copyright (c) 2001 Bioware Corp.
    The PC is able to changed their form to one of
    several forms.
//:: Created By: Preston Watamaniuk
//:: Created On: Jan 21, 2002
void main()
    //Declare major variables
    int nSpell = GetSpellId();
    object oTarget = GetSpellTargetObject();
	effect eVis = EffectVisualEffect(VFX_IMP_POLYMORPH);
    effect ePoly;
    int nPoly;
    int nMetaMagic = GetMetaMagicFeat();
    int nDuration = GetCasterLevel(OBJECT_SELF);
    //Enter Metamagic conditions
    if (nMetaMagic == METAMAGIC_EXTEND)
    	nDuration = nDuration *2; //Duration is +100%
    //Determine Polymorph subradial type
    if(nSpell == 387)
    else if (nSpell == 388)
    else if (nSpell == 389)
    else if (nSpell == 390)
    else if (nSpell == 391)
    ePoly = EffectPolymorph(nPoly);
    //Fire cast spell at event for the specified target
    SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_POLYMORPH_SELF, FALSE));
    //Apply the VFX impact and effects
	ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoly, oTarget, TurnsToSeconds(nDuration));

See Also




SPELL_* Constants

 author: Tom Cassiotis, editor: Lilac Soul, additional contributor(s): Martin Sarrazac