void SpellResApply(object oPlayer, int iMax )
{
int iHD = GetHitDice(oPlayer);
int iHcalc = (iHD *2);
if (iHcalc < iMax)
  {
   ApplyEffectToObject(DURATION_TYPE_PERMANENT,
   SupernaturalEffect(EffectSpellResistanceIncrease(iHcalc)), oPlayer);

  }
  else
  {
   iHcalc = iMax;
   ApplyEffectToObject(DURATION_TYPE_PERMANENT,
   SupernaturalEffect(EffectSpellResistanceIncrease(iHcalc)), oPlayer);
   }
}
//void main (){}