forked from Jaysyn/PRC8
84 lines
2.7 KiB
Plaintext
84 lines
2.7 KiB
Plaintext
|
/*
|
||
|
nw_s0_splresis
|
||
|
|
||
|
The target creature gains 12 + Caster Level SR.
|
||
|
|
||
|
By: Preston Watamaniuk
|
||
|
Created: Mar 19, 2001
|
||
|
Modified: Jun 28, 2006
|
||
|
|
||
|
Cleaned up slightly
|
||
|
*/
|
||
|
|
||
|
#include "prc_sp_func"
|
||
|
|
||
|
//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 nMetaMagic = PRCGetMetaMagicFeat();
|
||
|
|
||
|
int nLevel = nCasterLevel;
|
||
|
int nCounter = nCasterLevel;
|
||
|
float fRange = FeetToMeters(15.0);
|
||
|
effect eSR = EffectSpellResistanceIncrease(12 + nLevel);
|
||
|
effect eVis = EffectVisualEffect(VFX_IMP_MAGIC_PROTECTION);
|
||
|
effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
|
||
|
effect eDur2 = EffectVisualEffect(249);
|
||
|
effect eLink = EffectLinkEffects(eSR, eDur);
|
||
|
eLink = EffectLinkEffects(eLink, eDur2);
|
||
|
|
||
|
if (CheckMetaMagic(nMetaMagic, METAMAGIC_EXTEND))
|
||
|
{
|
||
|
nLevel *= 2; //Duration is +100%
|
||
|
}
|
||
|
|
||
|
location lTarget = PRCGetSpellTargetLocation();
|
||
|
object oTarget = MyFirstObjectInShape(SHAPE_SPHERE, fRange, lTarget, TRUE, OBJECT_TYPE_CREATURE);
|
||
|
|
||
|
while (GetIsObjectValid(oTarget) && nCounter > 0)
|
||
|
{
|
||
|
if (spellsIsTarget(oTarget, SPELL_TARGET_ALLALLIES, oCaster))
|
||
|
{
|
||
|
nCounter --;
|
||
|
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_SPELL_RESISTANCE, FALSE));
|
||
|
SPApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
|
||
|
SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(nLevel),TRUE,-1,nCasterLevel);
|
||
|
}
|
||
|
oTarget = MyNextObjectInShape(SHAPE_SPHERE, fRange, lTarget, TRUE, OBJECT_TYPE_CREATURE);
|
||
|
}
|
||
|
|
||
|
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();
|
||
|
}
|