//:://///////////////////////////////////////////// //:: Protection from Spells //:: NW_S0_PrChaos.nss //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* Grants the caster and up to 1 target per 4 levels a +8 saving throw bonus versus spells */ //::////////////////////////////////////////////// //:: Created By: Preston Watamaniuk //:: Created On: June 27, 2001 //::////////////////////////////////////////////// //:: modified by mr_bumpkin Dec 4, 2003 for PRC stuff #include "prc_inc_spells" void main() { DeleteLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR"); SetLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR", SPELL_SCHOOL_ENCHANTMENT); /* Spellcast Hook Code Added 2003-06-23 by GeorgZ If you want to make changes to all spells, check x2_inc_spellhook.nss to find out more */ if (!X2PreSpellCastCode()) { // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell return; } // End of Spell Cast Hook //Declare major variables int nMetaMagic = PRCGetMetaMagicFeat(); int CasterLvl = PRCGetCasterLevel(OBJECT_SELF); int nDuration = CasterLvl; if (nMetaMagic & METAMAGIC_EXTEND) { nDuration = nDuration *2; //Duration is +100% } int nTargets = nDuration / 4; if(nTargets == 0) { nTargets = 1; } object oTarget; effect eVis = EffectVisualEffect(VFX_IMP_MAGIC_PROTECTION); effect eSave = EffectSavingThrowIncrease(SAVING_THROW_ALL, 8, SAVING_THROW_TYPE_SPELL); effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE); effect eDur2 = EffectVisualEffect(VFX_DUR_MAGIC_RESISTANCE); effect eLink = EffectLinkEffects(eSave, eDur); eLink = EffectLinkEffects(eLink, eDur2); float fDelay; //Get first target in spell area location lLoc = GetLocation(OBJECT_SELF); oTarget = MyFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lLoc, FALSE); while(GetIsObjectValid(oTarget) && nTargets != 0) { if(GetIsFriend(oTarget) && OBJECT_SELF != oTarget) { fDelay = PRCGetRandomDelay(); //Fire cast spell at event for the specified target SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_PROTECTION_FROM_SPELLS, FALSE)); //Apply the VFX impact and effects DelayCommand(fDelay, SPApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget)); DelayCommand(fDelay, SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, TurnsToSeconds(nDuration),TRUE,-1,CasterLvl)); nTargets--; } //Get next target in spell area oTarget = MyNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lLoc, FALSE); } DelayCommand(fDelay, SPApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF)); DelayCommand(fDelay, SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, OBJECT_SELF, TurnsToSeconds(nDuration),TRUE,-1,CasterLvl)); DeleteLocalInt(OBJECT_SELF, "X2_L_LAST_SPELLSCHOOL_VAR"); // Getting rid of the integer used to hold the spells spell school }