Difference between revisions of "GetSpellId"

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

Revision as of 01:32, 26 August 2012



GetSpellId()

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

Description

Returns the ID (SPELL_*) of the spell that the 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 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.

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; check out the Custom Content Guide entry at http://ccg.dladventures.com/index.php/Spells.


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