UW2_PRC8/_haks/poa_exp_spells/sp_lowersr.nss
Jaysyn904 2bb2c470e0 Updated to PRC8
Updated to PRC8.  Further function integration.  Fixed NPC onDeath script.   Full compile.  Updated release archive.
2024-02-20 22:24:11 -05:00

42 lines
1.7 KiB
Plaintext

#include "prc_inc_spells"
#include "prc_add_spell_dc"
void main()
{
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
if (!X2PreSpellCastCode()) return;
PRCSetSchool(SPELL_SCHOOL_TRANSMUTATION);
object oTarget = PRCGetSpellTargetObject();
int nCasterLvl = PRCGetCasterLevel(OBJECT_SELF);
if(spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
{
// Fire cast spell at event for the specified target
PRCSignalSpellEvent(oTarget);
if(PRCGetIsAliveCreature(oTarget))
{
// Let the target attempte to make a fort save. (good luck since there is a penalty equal to the
// caster's level on the save).
if(!PRCMySavingThrow(SAVING_THROW_FORT, oTarget, PRCGetSaveDC(oTarget,OBJECT_SELF) + nCasterLvl, SAVING_THROW_TYPE_SPELL))
{
// Calculate the duration of the spell.
float fDuration = PRCGetMetaMagicDuration(MinutesToSeconds(nCasterLvl));
// Generate a SR decrease for the caster level, up to a max of 15.
int nSRReduction = nCasterLvl;
if (nSRReduction > 40) nSRReduction = 40;
effect eSR = EffectLinkEffects(EffectSpellResistanceDecrease(nSRReduction), EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE));
//Apply the VFX impact and effects
SPApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSR, oTarget, fDuration,TRUE,-1,nCasterLvl);
SPApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_REDUCE_ABILITY_SCORE), oTarget);
}
}
}
PRCSetSchool();
}