Difference between revisions of "GetSpellId"

From NWN Lexicon
Jump to: navigation, search
(Remarks)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{DISPLAYTITLE:GetSpellId()}}__NOTOC__
 +
Determines the spell identifier for a spell which a script is currently processing.
 +
<nwscript>
 +
int GetSpellId();
 +
</nwscript>
  
 +
====Description====
  
 +
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.
  
=GetSpellId()=
+
For example the Polymorph Self script (script name NW_S0_POLYSELF) is called by different spells determined by what monster they are polymorphing into.
  
Determines the spell identifier for a spell which a script is currently processing.
 
  
<nwscript>
+
====Remarks====
int GetSpellId();
+
 
</nwscript>
+
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.
  
====Description====
+
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).
  
Returns the ID (SPELL_*) of the spell that the script is processing. <br /><br /> 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. <br /><br /> For example the Polymorph Self script (script name NW_S0_POLYSELF) is called by different spells determined by what monster they are polymorphing into.
+
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.
  
<br /><br />
+
Custom spells and spell-effects can be added; see [https://nwn.wiki/display/NWN1/spells.2da spells.2da] and [https://nwn.wiki/display/NWN1/Spells+and+Abilities spells and abilities] pages.
  
====Remarks====
 
  
Strictly used in scripts that resolve a spells or spell abilities effects, this function should not be used unless you are modifying how existing spells or spell abilities (scripted by BioWare and the scripts are found in scripts.bif) are implemented. <br /><br /> 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). <br /><br /> 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. <br /><br /> Custom spells and spell-effects can be added; check out the Custom Content Guide entry at http://ccg.dladventures.com/index.php/Spells. <br /><br />
+
====Known Bugs====
  
Returns -1 if called inside of AOE scriptGetEffectSpellId(EffectDaze()) will workaround this.
+
Returns -1 if called inside of AOE script, however it could return a proper ID since a workaround is to use [[GetEffectSpellId]]([[EffectDazed]]()).
  
<br />
 
  
 
====Version====
 
====Version====
Line 100: Line 105:
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
|
 
|
[[GetLastSpell | GetLastSpell ]]
+
[[ GetLastSpell | GetLastSpell ]]
 
|-
 
|-
 
|-
 
|-
 
| width="1px" align="right" valign="top" | <font color="gray">constants: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">constants: </font>
 
|
 
|
[[ spell | SPELL_* Constants  ]]
+
[[ Spell_(constant_group) | SPELL_* Constants  ]]
 
|}
 
|}
  

Latest revision as of 13:01, 15 January 2021

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

Description

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.


Remarks

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()).


Version

1.61

Example

//::///////////////////////////////////////////////
//:: 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)
    {
        nPoly = POLYMORPH_TYPE_GIANT_SPIDER;
    }
    else if (nSpell == 388)
    {
        nPoly = POLYMORPH_TYPE_TROLL;
    }
    else if (nSpell == 389)
    {
        nPoly = POLYMORPH_TYPE_UMBER_HULK;
    }
    else if (nSpell == 390)
    {
        nPoly = POLYMORPH_TYPE_PIXIE;
    }
    else if (nSpell == 391)
    {
        nPoly = POLYMORPH_TYPE_ZOMBIE;
    }
    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

functions: 

GetLastSpell

constants: 

SPELL_* Constants



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