//:://///////////////////////////////////////////// //:: 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 //::////////////////////////////////////////////// #include "NW_I0_SPELLS" #include "x2_inc_spellhook" void main() { /* 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 = GetMetaMagicFeat(); int nDuration = GetCasterLevel(OBJECT_SELF); int nTargets = nDuration / 4; if(nTargets == 0) { nTargets = 1; } if (nMetaMagic == METAMAGIC_EXTEND) { nDuration = nDuration * 2; //Duration is +100% } 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 = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lLoc, FALSE); while(GetIsObjectValid(oTarget) && nTargets != 0) { if(GetIsFriend(oTarget) && OBJECT_SELF != oTarget) { fDelay = GetRandomDelay(); //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, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget)); DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, TurnsToSeconds(nDuration))); nTargets--; } //Get next target in spell area oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lLoc, FALSE); } DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF)); DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, OBJECT_SELF, TurnsToSeconds(nDuration))); }