Aller au contenu

Photo

Need to Hook into Spell Resistance


  • Veuillez vous connecter pour répondre
45 réponses à ce sujet

#1
_Guile

_Guile
  • Members
  • 685 messages
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 .


#2
WhiZard

WhiZard
  • Members
  • 1 204 messages

_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 .


#3
WhiZard

WhiZard
  • Members
  • 1 204 messages
Double post

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


#4
_Guile

_Guile
  • Members
  • 685 messages
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 .


#5
WhiZard

WhiZard
  • Members
  • 1 204 messages

_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().

#6
_Guile

_Guile
  • Members
  • 685 messages
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 .


#7
WhiZard

WhiZard
  • Members
  • 1 204 messages

_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.

#8
WhiZard

WhiZard
  • Members
  • 1 204 messages
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 .


#9
Shadooow

Shadooow
  • Members
  • 4 465 messages
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*

#10
_Guile

_Guile
  • Members
  • 685 messages
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. :D

#11
Xardex

Xardex
  • Members
  • 217 messages
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.

#12
WhiZard

WhiZard
  • Members
  • 1 204 messages

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.

#13
Shadooow

Shadooow
  • Members
  • 4 465 messages
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.

#14
WhiZard

WhiZard
  • Members
  • 1 204 messages

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.

#15
Shadooow

Shadooow
  • Members
  • 4 465 messages
??? dont understand first part again

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

#16
WhiZard

WhiZard
  • Members
  • 1 204 messages

ShaDoOoW wrote...

??? dont understand first part again

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


I've haven't tested but I have heard it reported otherwise, one instance on NWNwiki under "monk speed".

#17
WhiZard

WhiZard
  • Members
  • 1 204 messages
Actually to get around monk SR (though the SR check will report this wrong) is simply to make the roll manually and then instead of using

if(!ResistSpell())

use

if(!(ResistSpell() > 1))

instead.

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


#18
WhiZard

WhiZard
  • Members
  • 1 204 messages
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 .


#19
Shadooow

Shadooow
  • Members
  • 4 465 messages
Right, this is the PRC solution I just forgot that they return 0 in case that second SR block the spell, still those two feedback which are not multi languaged seemed and still seems to me like a worse downside.

#20
WhiZard

WhiZard
  • Members
  • 1 204 messages

ShaDoOoW wrote...

Right, this is the PRC solution I just forgot that they return 0 in case that second SR block the spell, still those two feedback which are not multi languaged seemed and still seems to me like a worse downside.


You could add it to a TLK file to make it multilingual.

EDIT: found line 8342 in TLK <CUSTOM 0> attempts to resist spell <CUSTOM 1>
<CUSTOM 1> uses 8343, 8344, or 8345 for resist, immunity, or absorption.

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


#21
Shadooow

Shadooow
  • Members
  • 4 465 messages
I cant use new lines in TLK for reasons I already explained. Also you cannot set custom token 0 and 1.

#22
WhiZard

WhiZard
  • Members
  • 1 204 messages

ShaDoOoW wrote...

I cant use new lines in TLK for reasons I already explained. Also you cannot set custom token 0 and 1.


Looked into this and you can "set" both manually simply by replacing that part of the string.  (E.g. "<....0>" can be replaced with a name and "<...1>" can be replaced with the string resrefs above, and this works for any language.

#23
WhiZard

WhiZard
  • Members
  • 1 204 messages
Just if this needs to be referred to later 5353 is the english TLK line for "failure"

Modifié par WhiZard, 27 août 2011 - 12:42 .


#24
_Guile

_Guile
  • Members
  • 685 messages
So what would happen if I did this?

//if(!ResistSpell())
DoCustomSRCheck(oPC, oTarget);

And ran my own custom checks, if passed, "apply" the spell effects, no resistance should be checked at all correct?

#25
WhiZard

WhiZard
  • Members
  • 1 204 messages

_Guile wrote...

So what would happen if I did this?

//if(!ResistSpell())
DoCustomSRCheck(oPC, oTarget);

And ran my own custom checks, if passed, "apply" the spell effects, no resistance should be checked at all correct?

Yes getting rid of ResistSpell() would do that, however, spell level absorption and spell immunity would be problematic to check.