• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Spell Resistance as Class Ability

direinsomniac

Well-known member
Spell Resistance as Class Ability: UPDATE and new issue

This may be complicated -- but here goes.

I am creating a Prestige Class in which I am trying to have the Spell Resistance ability be equal to my character level + 5 ---> Which I have done by mimicking the Sorc's Alien Resistance.

But, the +5 enhancement is supposed to be able to stack with the SR from other classes (if any), if the total (stacked) SR gained would be higher than the original total provided by the class ability.



This has been confused since I have normally Spell Resistances don't stack, but given that this is a Prestige Class, a player may have standard classes that grant SR (i.e Sorcerer and Monk).
 
Last edited:
Have the base ability apply just the character level as SR, and on the SR pick add 5 to the abImprove field. That is added on top of the total normal value.
 
Pulling the code from the Sorcerer Alien Resistance ability ---
this is the code I have:

Code:
     ~Calculate our value
         field[abValue].value += field[xAllLev].value

         field[abSumm].text = "SR " & field[abValue].value
         field[livename].text = "Spell Resistance " & field
[abvalue].value

      ~if we're not shown, just get out now
      doneif (tagis[Helper.ShowSpec] = 0)

     #applysr[field[abValue].value]

This bit of code should apply SR based off the character level.
I am not sure what you mean by the SR pick and abImprove field.
 
I ran into a few problem trying to code this, resulting from the field[xAllLev] only calculating the PrC's levels. However I did manage to solve this by changing the level pick on the 3rd line of the script to read:

Code:
~Calculate our value
    field[abValue].value += #totallevelcount[]
 
::UPDATE::

I am running into an issue utilizing this script properly, and am not sure what is going on.

My test character is a Human Monk 13/MyPrC 5

This class ability, which grants a SR equal to character level + 5 and is granted upon taking the 7th level of my PrC, is supposed to interact with any pre-existing SR and either add to it, or replace it.

As a 13th level monk, the test character receives a SR value of 23, which remains unchanged as I progress into my PrC --- At least until I add the 6th level.

For some strange reason, the SR value increases by 1 to a value of 24. Then when I add the 7th level, it drops back down to 23.

This alone is weird, however, the other issue at hand, is that the PrC's class ability is not kicking in and replacing this value, since it is less than what is being granted by my PrC's class ability.



This was the code I started with

Post-levels / 10000
Code:
 ~Calculate our value
         field[abValue].value += #totallevelcount[]

         field[abSumm].text = "SR " & field[abValue].value
         field[livename].text = "Spell Resistance " & field[abvalue].value

      ~if we're not shown, just get out now
      doneif (tagis[Helper.ShowSpec] = 0)

      #applysr[field[abValue].value]

      hero.child[xSplRs].field[abImprove].value += 5
 
Last edited:
On a rudimentary level, the above code should have worked but when I actually tested it on a creature that already had SR, it had issues.

Given the wording of the text from the source I am converting this ability from:

At 7th level, the PrC gains spell resistance. The resistance equals his character level + 5. The +5 enhancement stacks with any other spell resistance the character may have from other classes, if doing so would make it higher than the spell resistance gained from this ability. Otherwise, the character uses this ability instead of the other.

I altered the script and came up with this: (but even this script is giving me issues)

Post-levels / 10000
Code:
~If we aren't 7th level in this class, get out now
doneif (#levelcount[thisPrC] = 7)

  ~Our SR is equal to character level + 5, unless another source 
provides a greater value

    ~Calculate our value
    var protection as number
    protection = #totallevelcount[] + 5

    if (hero.child[xSplRs].field[abValue].value > protection) then

      ~we only increase the existing SR by 5
      hero.child[xSplRs].field[abImprove].value += 5

      else
      ~we calculate the SR for this abilty as normal

        field[abValue].value += #totallevelcount[] + 5

        #applysr[field[abValue].value]
    endif
  
  field[abSumm].text = "SR " & field[abValue].value
  field[livename].text = "Spell Resistance " & field[abValue].value
 
If I understand what you're attempting, I think this might work

Code:
    ~ If we're not shown, just get out now
    doneif (tagis[Helper.ShowSpec] = 0)

    ~ If we've been Disabled, get out now
    doneif (tagis[Helper.SpcDisable] <> 0)

    ~Calculate our value
    field[abValue].value = #totallevelcount[]
    
    ~Our SR is equal to character level or another source, whichever is higher
    #applysr[field[abValue].value]

    ~Then increase that value by 5, as long as it is non-zero.
    hero.child[xSplRs].field[abImprove].value += 5

    ~Set our texts
    field[abSumm].text = "SR " & field[abValue].value
    field[livename].text = "Spell Resistance " & field[abValue].value

Edit: Modified the doneif to use ShadowChemosh's suggestions below.
 
Last edited:
Code:
~If we aren't 7th level in this class, get out now
doneif (#levelcount[thisPrC] = 7)
Note that this line of code says you must be "7th" level in the PrC to run this script. So if the character is level 6 or level 8 this script no longer runs. I am going to "assume" that is not the intended idea as that is not normal for a class ability.

My advice is use the standard class stop script instead:
Code:
~ If we're not shown, just get out now
doneif (tagis[Helper.ShowSpec] <> 1)
~ If we've been Disabled, get out now
doneif (tagis[Helper.SpcDisable] <> 0)

The above script no longer cares about level as it gets that now from the bootstrap. So when you attached to the class and set it to level 7 that's the level the script will work at. If the later you change the bootstrap to be level 6 the script don't care and will then work at level 6. This is really nice if re-using the same class ability on a different class that gets it a different level.

The above script also looks to see if something from a feat to an archetype has disabled the class special.

The last useful info about the above is that will only work if the script runs in the Post-Level timing. As before that the Helper.? tags are not set so the script will never execute.

Just my advice...
 
There is an issue with the above code. In using the abImprove field, the SR would be increased regardless, assuming the value non-zero.

However the way I am understanding the source text, the +5 should ONLY apply to the existing SR value IF that value and the +5 would be higher than what the PrC would grant.

In other words, using my test character above (Monk 13/MyPrc 7)

if the monk's existing SR of 23 (which is calculated solely off of the Monk class level) added to the +5 enhancement (a value of 28) would be higher than the total value granted by the PrC's ability (which in this example would be 25 [total character level +5]), which it is -- then the higher of the two values is taken.

It was this logic, that made me try to write a script that would compare the values as explained.
 
There is an issue with the above code. In using the abImprove field, the SR would be increased regardless, assuming the value non-zero.

However the way I am understanding the source text, the +5 should ONLY apply to the existing SR value IF that value and the +5 would be higher than what the PrC would grant.

In other words, using my test character above (Monk 13/MyPrc 7)

if the monk's existing SR of 23 (which is calculated solely off of the Monk class level) added to the +5 enhancement (a value of 28) would be higher than the total value granted by the PrC's ability (which in this example would be 25 [total character level +5]), which it is -- then the higher of the two values is taken.

It was this logic, that made me try to write a script that would compare the values as explained.

I wrote the code above with that understanding.

Spell resistance already maximizes it's value from all sources, and since the +5 applies to this abilities granted SR and ANY OTHER granted SR, to give you the highest value possible there is no need to compare anything. #applysr will grant the highest base value, and then abImprove will increase it by 5.
 
direinsomniac, I recommend you post the exact wording of the ability.

I did post the source text, but here it is again.

At 7th level, the PrC gains spell resistance. The resistance equals his character level + 5. The +5 enhancement stacks with any other spell resistance the character may have from other classes, if doing so would make it higher than the spell resistance gained from this ability. Otherwise, the character uses this ability instead of the other.
 
So it seems I did understand your intent correctly.

Have you tried the code I posted above? What about it is not working (I.E. when using it, what are you expecting to see and how is that different from what you're seeing). I usually don't test things I post for folks, relying on them to try it out and adjust it as necessary. This A. saves me time, and B. helps folks learn by doing.
 
I did test the code, but it is only applying the PrC's version of the SR, (25) instead of the monk's version with the + 5, which would equal 28.
 
Here's some things to consider/check out using debug.

When is the PrC class ability's eval script running? Is the total character level being calculated properly? What is the value of xSplRs's abValue field before you add the 7th level of the PrC? What is it after? How about the abImprove field for that pick in the same before/after? How does diamond soul apply its spell resistance, could there be something special about its eval script?
 
If after attempting to figure out how to fix this yourself, you're still stumped, you can send me a copy of your .user file. But please attempt it yourself first.
 
Back
Top