Author Topic: Need to Hook into Spell Resistance  (Read 1717 times)

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need to Hook into Spell Resistance
« on: August 26, 2011, 03:42:26 am »


               Some of you are aware of the Custom Spell System I'm working on, and one of the walls I hit was a control which could boost SR based upon the caster's level (epic bonus)...

I would like to give the Builder a control for also setting which would allow them to raise SR overall in the module, which will be especially useful for those with Legendary Level systems (HGLL) in thier modules...

What I need is someone to direct me how to I can alter Spell Resistance...

1.69 Custom Spell System
(I want to finish this this week (in a few days if possible) & your feedback would help A BUNCH, thanks!)
(I finished wiz/sor, am on cleric now, so only have a few more classes and this is done!)

Anyone?
               
               

               


                     Modifié par _Guile, 26 août 2011 - 02:44 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #1 on: August 26, 2011, 04:06:11 am »


               

_Guile wrote...

Some of you are aware of the Custom Spell System I'm working on, and one of the walls I hit was a control which could boost SR based upon the caster's level (epic bonus)...

I would like to give the Builder a control for also setting which would allow them to raise SR overall in the module, which will be especially useful for those with Legendary Level systems (HGLL) in thier modules...

What I need is someone to direct me how to I can alter Spell Resistance...

1.69 Custom Spell System
(I want to finish this this week (in a few days if possible) & your feedback would help A BUNCH, thanks!)
(I finished wiz/sor, am on cleric now, so only have a few more classes and this is done!)

Anyone?


ResistSpell() is hardcoded and performs the spell level absorption, spell immunity, and SR checks.  You can use GetSpellResistance() and EffectSpellResistanceIncrease() to raise the SR to a new value however this will only be accurate if there is not already an EffectSpellResistanceDecrease() on the target.

If you just want to use a high SR, then EffectSpellResistanceIncrease() does support values greater than 32 (the Toolset max).
               
               

               


                     Modifié par WhiZard, 26 août 2011 - 03:12 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #2 on: August 26, 2011, 04:09:23 am »


               Double post
               
               

               


                     Modifié par WhiZard, 26 août 2011 - 03:10 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #3 on: August 26, 2011, 04:44:48 am »


               Could I make a custom function to check the SR of a target vs the caster to get a succeed / fail result?

When I say hook into I mean bypass standard code or even hardcode if possible...

And if so, could you tell me how I should calculate standard SR?

====================
EDITED

I worked something up real fast to give you something to go on, a custom function (multiple are already made)

int SpellResisted(object oCaster, object oTarget, int nSpellID)
{
 int iResist = FALSE;
 //This is another custom function to return the true level of the caster
 //This check returns all qualifying class levels
 int nCL = GetCombinedCasterLevel(oCaster);
 int nTSR = GetSpellResistance(oTarget);
 int nSpellLevel;
 int nSR;

 //Check the level of the spell (Another Custom Function, but will need help with this one!)
 nSpellLevel = GetSpellLevel(nSpellID);
 nSR = nCL + 10 + nSpellLevel;

 if(nTSR > nSR)
 {
  iResist = TRUE;
 }

  return iResist;
}

I need help coming up with a function to check the level of the spell (being cast), if you can help there that would be a huge help!
               
               

               


                     Modifié par _Guile, 26 août 2011 - 03:55 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #4 on: August 26, 2011, 04:56:36 am »


               

_Guile wrote...

Could I make a custom function to check the SR of a target vs the caster to get a succeed / fail result?

When I say hook into I mean bypass standard code or even hardcode if possible...

And if so, could you tell me how I should calculate standard SR?


The default SR roll (which can be performed manually) is

Caster Level + Spell Penetration + 1d20 vs. SR

GetCasterLevel(), GetHasFeat(), d20(), and GetSpellResistance() are all you need.

To perform mantle and spell immunity check is extremely hard to duplicate and may require rewriting the spell scripts and all applications of EffectSpellLevelAbsorption() and EffectSpellImmunity().
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #5 on: August 26, 2011, 05:13:41 am »


               Well instead of EffectSpellImmunity()

I would just do a custom check to see if they had immunity to that spell (based upon item properties & feat checks)

As far as the EffectSpell LevelAbsorbtion(), you could just use variables (to decrement it every time they get a spell cast at them, once the variable reached 0, poof goes the mantle...

Still seems like a bit of work, and the checking for feats/properties could slow down spells some.

If it's impossible, I can accept that, if it's more trouble than it's worth I can accept that too, but I would like to dig into the possibilities before I dismiss the notion all together.
               
               

               


                     Modifié par _Guile, 26 août 2011 - 04:15 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #6 on: August 26, 2011, 05:46:59 am »


               

_Guile wrote...

Well instead of EffectSpellImmunity()

I would just do a custom check to see if they had immunity to that spell (based upon item properties & feat checks)

As far as the EffectSpell LevelAbsorbtion(), you could just use variables (to decrement it every time they get a spell cast at them, once the variable reached 0, poof goes the mantle...

Still seems like a bit of work, and the checking for feats/properties could slow down spells some.

If it's impossible, I can accept that, if it's more trouble than it's worth I can accept that too, but I would like to dig into the possibilities before I dismiss the notion all together.


Those two are the killers.  Effects cannot be disected (perhaps a 3rd party tool like NwNx could do this), so you would be replacing effects with variables for both spell immunity (specific spell or spell school and max spell level) and spell level absorption (spell school, max spell level, and spell levels to absorb).  Item properties and feats can work just fine, but you would be going through every item property of every equipped item.

It could work, but it would be a nightmare for both.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #7 on: August 26, 2011, 05:51:32 am »


               Also item properties are not as dynamic as the effect commands.  A spell immunity effect, for example could be used to block just transmutation spells of spell level 5 or less.
               
               

               


                     Modifié par WhiZard, 26 août 2011 - 04:53 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #8 on: August 26, 2011, 11:19:27 am »


               I agree with WhiZard. PRC used solution that computes their custom SR and then call default SR which has two downsides. First it print the feedback twice, second it has two chances to block the spell via SR. However I have an idea, will tell you if it works. *gooing into toolset*
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #9 on: August 26, 2011, 12:05:39 pm »


               OK, I will accept the final verdict then, truly unfeasible to try to "alter" spell resistance...

Thanks, I'll be sure to put that in the documentation of my new spell system.  '<img'>
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #10 on: August 26, 2011, 12:31:47 pm »


               EffectSpellResistanceIncrease() most likely does allow higher then 32 spell resistance. It wouldn't make any sense if it didn't. Try it out, if it does allow, then you can easily accomplish "custom" spell resistance.

This effect does not stack with itself iirc, so you shouldn't need to "get" old spell resistance when increasing it. Only the highest SR applies.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #11 on: August 26, 2011, 01:55:06 pm »


               

WhiZard wrote...

If you just want to use a high SR, then EffectSpellResistanceIncrease() does support values greater than 32 (the Toolset max).


Already mentioned that.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #12 on: August 26, 2011, 03:46:17 pm »


               Ok so one could do this: compute the new SR with all adjustions before.

Now if the result is that the spell passed through the SR apply a decrease SR effect in power of 99 points in order to ensure the spell really passes through the default SR.

If the result will be that spell doesnt passed, then apply a increase SR effect in power of 99 points.

It has just the same downside as my patch's caster level adjustion, the SR decrease effect is not able to decrease monk SR. That could be maybe workaround by removing the diamond soul feat from monk, but I wouldnt be surprised if the monk SR would be hardcoded on the class itself like speed.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #13 on: August 26, 2011, 03:59:23 pm »


               

ShaDoOoW wrote...

Ok so one could do this: compute the new SR with all adjustions before.

Now if the result is that the spell passed through the SR apply a decrease SR effect in power of 99 points in order to ensure the spell really passes through the default SR.

If the result will be that spell doesnt passed, then apply a increase SR effect in power of 99 points.

It has just the same downside as my patch's caster level adjustion, the SR decrease effect is not able to decrease monk SR. That could be maybe workaround by removing the diamond soul feat from monk, but I wouldnt be surprised if the monk SR would be hardcoded on the class itself like speed.


Yes but it does get around SR decrease not stacking.  The diamond soul feat might also not work properly if readded, though I think monk speed can effectively be given to other classes to increase max speed to 3.0.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Need to Hook into Spell Resistance
« Reply #14 on: August 26, 2011, 04:01:59 pm »


               ??? dont understand first part again

for speed, monk speed feat is just a placeholder it has no effect on character