This might be a helpful function to use for custom SR checks. The spell resistance part comes before the spell level absorption.
int DoResistSpell(object oCaster, object oTarget, int nCaster = -100)
{
if(nCaster == -100) nCaster = GetCasterLevel(oCaster); //Allows preset caster level
int nRoll = nCaster + d20();
int nSR = GetSpellResistance(oTarget);
if(GetHasFeat(FEAT_EPIC_SPELL_PENETRATION, oCaster)) nRoll += 6;
else if(GetHasFeat(FEAT_GREATER_SPELL_PENETRATION, oCaster)) nRoll += 4;
else if(GetHasFeat(FEAT_SPELL_PENETRATION, oCaster)) nRoll +=2;
if(nRoll >= nSR || !nSR) //0 SR opponents get hit
{
FloatingTextStringOnCreature("Spell resistance: spell resisted", oCaster, FALSE);
FloatingTextStringOnCreature("Spell resistance: spell resisted", oTarget, FALSE);
return 1;
}
int nResist = ResistSpell(oCaster, oTarget);
if(nResist == 1)
{
FloatingTextStringOnCreature("Spell bypassed resistance", oCaster, FALSE);
FloatingTextStringOnCreature("Spell bypassed resistance", oTarget, FALSE);
nResist = 0;
}
return nResist;
}
Modifié par WhiZard, 26 août 2011 - 04:18 .