Well, then, it's fairly straightfoward. Edit an include name of your choosing into all the spell scripts. Do a Find/Replace on all the MyResistSpell instances, replacing them with your custom spell resistance function, named whatever you like. Then, write your custom function in the custom include you've made, keeping the same inputs as the original function:
// * Used to route the resist magic checks into this function to check for spell countering by SR, Globes or Mantles.
// Return value if oCaster or oTarget is an invalid object: FALSE
// Return value if spell cast is not a player spell: - 1
// Return value if spell resisted: 1
// Return value if spell resisted via magic immunity: 2
// Return value if spell resisted via spell absorption: 3
int MyResistSpell(object oCaster, object oTarget, float fDelay = 0.0)
There you'll need to calculate the sr and sp of the target and caster, convert them to percentiles in whatever way you like, compare the results, and kick out the appropriate return as indicated in the original function, which you can find in NW_I0_SPELLS. Lastly, you'd probably want to edit the tlk so that item properties on your server show the proper percentile values instead of dc values.
Here's a sample replacement function, though it's still dc-based (no way to convert it without knowing what metric you intend to use). Note that it has an EXTRA input at the end, with a pre-specified default. You can add as many of those as you need to the end of your custom function, as the original functions will just get the default values applied, with you adding different values as needed. It also changed the inputs, however, something I'm not suggesting you do - we did a FAR more extensive rewrite of our spells.
int GetSpellResisted (struct SpellInfo si, object oTarget=OBJECT_INVALID, float fDelay=0.0, int bSROnly=FALSE) {
int nSR = 0, nResisted = 0, nRoll = 0;
if (!GetIsObjectValid(oTarget))
oTarget = si.target;
if (!GetIsObjectValid(oTarget))
return 0;
if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
nSR = GetSpellResistance(oTarget);
else
nSR = GetLocalInt(oTarget, "SR");
if (nSR > 0 && GetHasSpellImmunity(SPELL_SPELL_RESISTANCE, oTarget)) {
nSR -= GetLocalInt(oTarget, "TauntResult");
if (nSR < 1)
nSR = 1;
}
if (nSR > 0 && si.sp >= 0 && !GetFactionEqual(si.caster, oTarget)) {
nRoll = d20(1);
if (si.sp + nRoll < nSR)
nResisted = 1;
}
if (nResisted == 0) {
if (bSROnly) {
if (bSROnly == 2 && GetHasSpellImmunity(si.id, oTarget))
nResisted = 2;
} else {
switch (ResistSpell(si.caster, oTarget)) {
case 2: /* globe or spell immunity */
nResisted = 2;
break;
case 3: /* spell mantle */
if (si.sp >= 0)
nResisted = 3;
break;
}
}
}
if (!nResisted) {
if (nRoll > 0)
SendSpellResistanceMessage(si.caster, oTarget, nRoll, si.sp, nSR, fDelay);
return 0;
}
if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE) {
effect eVis;
switch (nResisted) {
case 2:
nSR = -2;
eVis = EffectVisualEffect(VFX_IMP_GLOBE_USE);
break;
case 3:
nSR = -3;
eVis = EffectVisualEffect(VFX_IMP_SPELL_MANTLE_USE);
break;
default:
eVis = EffectVisualEffect(VFX_IMP_MAGIC_RESISTANCE_USE);
break;
}
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
}
if (nRoll > 0 || nSR < -1)
SendSpellResistanceMessage(si.caster, oTarget, nRoll, si.sp, nSR, fDelay);
return nResisted;
}
Funky
Modifié par FunkySwerve, 05 décembre 2010 - 03:10 .