Initial upload.
Adding base PRC 4.19a files to repository.
This commit is contained in:
70
trunk/spells/nw_s0_sanctuary.nss
Normal file
70
trunk/spells/nw_s0_sanctuary.nss
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
nw_s0_sanctuary
|
||||
|
||||
Makes the target creature invisible to hostile
|
||||
creatures unless they make a Will Save to ignore
|
||||
the Sanctuary Effect
|
||||
|
||||
By: Preston Watamaniuk
|
||||
Created: Jan 7, 2002
|
||||
Modified: Jun 29, 2006
|
||||
|
||||
Flaming_Sword: added greater sanctuary
|
||||
cleaned up
|
||||
*/
|
||||
|
||||
#include "prc_sp_func"
|
||||
#include "prc_inc_teleport"
|
||||
#include "prc_add_spell_dc"
|
||||
|
||||
//Implements the spell impact, put code here
|
||||
// if called in many places, return TRUE if
|
||||
// stored charges should be decreased
|
||||
// eg. touch attack hits
|
||||
//
|
||||
// Variables passed may be changed if necessary
|
||||
int DoSpell(object oCaster, object oTarget, int nCasterLevel, int nEvent)
|
||||
{
|
||||
int nSpellID = PRCGetSpellId();
|
||||
int bSanc = (nSpellID == SPELL_SANCTUARY);
|
||||
effect eSanc = bSanc ? EffectSanctuary((PRCGetSaveDC(oTarget,oCaster))) : EffectEthereal();
|
||||
effect eLink = EffectLinkEffects(EffectVisualEffect(VFX_DUR_SANCTUARY), eSanc);
|
||||
eLink = EffectLinkEffects(eLink, EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE));
|
||||
float fDuration = bSanc ? RoundsToSeconds(nCasterLevel) : TurnsToSeconds(nCasterLevel);
|
||||
int nMetaMagic = PRCGetMetaMagicFeat();
|
||||
if (CheckMetaMagic(nMetaMagic, METAMAGIC_EXTEND))
|
||||
fDuration *= 2; //Duration is +100%
|
||||
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellID, FALSE));
|
||||
if(bSanc || GetCanTeleport(oTarget, GetLocation(oTarget), FALSE, TRUE))
|
||||
SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, fDuration,TRUE,-1,nCasterLevel);
|
||||
|
||||
return TRUE; //return TRUE if spell charges should be decremented
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
object oCaster = OBJECT_SELF;
|
||||
int nCasterLevel = PRCGetCasterLevel(oCaster);
|
||||
PRCSetSchool(GetSpellSchool(PRCGetSpellId()));
|
||||
if (!X2PreSpellCastCode()) return;
|
||||
object oTarget = PRCGetSpellTargetObject();
|
||||
int nEvent = GetLocalInt(oCaster, PRC_SPELL_EVENT); //use bitwise & to extract flags
|
||||
if(!nEvent) //normal cast
|
||||
{
|
||||
if(GetLocalInt(oCaster, PRC_SPELL_HOLD) && oCaster == oTarget)
|
||||
{ //holding the charge, casting spell on self
|
||||
SetLocalSpellVariables(oCaster, 1); //change 1 to number of charges
|
||||
return;
|
||||
}
|
||||
DoSpell(oCaster, oTarget, nCasterLevel, nEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(nEvent & PRC_SPELL_EVENT_ATTACK)
|
||||
{
|
||||
if(DoSpell(oCaster, oTarget, nCasterLevel, nEvent))
|
||||
DecrementSpellCharges(oCaster);
|
||||
}
|
||||
}
|
||||
PRCSetSchool();
|
||||
}
|
Reference in New Issue
Block a user