Author Topic: Guru, guide thou me. MyResistSpell(), GetCasterLevel() and dispel magic  (Read 472 times)

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0


                 I want to implement a different system to handle dispel magic, SR, and calculating caster level for our mod.  I see existing systems such as Fox spells or mr bumkin's prc caster level stuff (or Shadow/Zoeller's core function override tutorials), but I can't quite get my mind around how to integrate any of them into our mod with many existing spell/feat modifications.  This post is to ask for some step-by-step help, and for me to think ouloud so I can be corrected.
  
  Overriding core functions seems like it should be easy, but I've only managed to create fodder-modules by messing with it thus far.  Considering that, I'm attempting to use mr bumpkin's work here:
http://nwvault.ign.c....Detail&id=1980
 
int nCasterLvl = (GetCasterLevel(oCaster) + GetChangesToCasterLevel(oCaster));
  Mr B uses GetChangesToCasterLevel() to account for pale master levels and to check if it's a divine or arcane class to decide if the pale master levels should be added.  I can edit it to add levels how I want from different prestige classes, no problems there.
  1 - To make use of this in our mod, I'll have to manually add this function to every call of GetCasterLevel() for every spell/feat/ability and add his file as an include right?
  2 - Is there an easy way to do this?
  3 - Is there a list of every script I'd need to update?  If not, I can just look at the .erf included with his download.

  The second part is the same as the first... I think.  He's rewritten MyResistSpell() and it contains the same arguments as the original, so I'd have to replace every instance of MyResistSpell() with his function.

  4 - If I got this much done, it would allow me to account for prestige class levels for things like duration, damage, and beating SR, yes?

  That leaves handling the dispel magic checks - which I know the least about.  I see Mr B has written his own method for handling this, but I'm not sure which parts of it I need to make it all work.  I'm so confused about this part, I'm having trouble asking a specific question.
  5 - What functions/scripts does stock NWN use to handle dispel magic?  i.e. what needs to be substituted so I can include pale master levels for the purposes of dispel magic checks?
  What I'm after is, a 10wizard/30PM to be considered a level20 or 25 caster so that a lowbie NPC cannot strip half or your buffs with a regular dispel.

Thanks
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Guru, guide thou me. MyResistSpell(), GetCasterLevel() and dispel magic
« Reply #1 on: April 16, 2011, 12:03:27 pm »


               

Terrorble wrote...
5 - What functions/scripts does stock NWN use to handle dispel magic?  i.e. what needs to be substituted so I can include pale master levels for the purposes of dispel magic checks?


No point asking.

For two good reason:

1) it is all hardcoded in the engine, with no chance for you to intervene.

2) Its stock implementation is unintuitive, to begin. To investigate it would steer you in the wrong direction.



If you want to learn about dispel magic, simply read it up in the core rulebook of D&D 3rd edition.

That shall give you all the knowledge you require to make many a clever guess.



Terrorble wrote...
What I'm after is, a 10wizard/30PM to be considered a level20 or 25 caster so that a lowbie NPC cannot strip half or your buffs with a regular dispel.

Then you wish to intervene at GetCasterLevel() level -- pun is not intended.
The Caster level dictates the power *given* to dispel magic.
Limit the Caster Level (or boost it) and you make dispel magic less effective (or more).


-fox
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Guru, guide thou me. MyResistSpell(), GetCasterLevel() and dispel magic
« Reply #2 on: April 16, 2011, 01:16:47 pm »


               I can second fox with dispell.

anyway:

2) use core hooking instead, then you just need to add include into all these scripts, to do this you can use this: http://nwvault.ign.c...d=51805&id=1354
3) http://nwvault.ign.c....Detail&id=1337
               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Guru, guide thou me. MyResistSpell(), GetCasterLevel() and dispel magic
« Reply #3 on: April 17, 2011, 12:53:44 am »


               

the.gray.fox wrote...

...

Terrorble wrote...
What I'm after is, a 10wizard/30PM to be considered a level20 or 25 caster so that a lowbie NPC cannot strip half or your buffs with a regular dispel.

Then you wish to intervene at GetCasterLevel() level -- pun is not intended.
The Caster level dictates the power *given* to dispel magic.
Limit the Caster Level (or boost it) and you make dispel magic less effective (or more).


-fox


Just to be clear, let's say I have a level 10wizard/10palemaster who casts discplacement on himself.  Using Mr B's method, the caster level is decided this way: 

nCasterLvl = GetCasterLevel(OBJECT_SELF) + GetChangesToCasterLevel(OBJECT_SELF)**;
**GetChangesToCasterLevel() returns 5 in this case, since we add +1/ 2pm levels.  Therefore, nCasterLvl = 15

If a level10 cleric casts dispel magic on my wizard-pm, will the discplacement buff be treated as if a level 15 caster cast it?  (i.e. the dispel check looks like:  1d20 + 10 vs 15 + 11)

Or do I need to do something additional?

Thanks again
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Guru, guide thou me. MyResistSpell(), GetCasterLevel() and dispel magic
« Reply #4 on: April 17, 2011, 02:07:24 am »


               No it wont, the dispell magic uses hardcoded values of the effect so it will still be lvl 10 for dispells purposes.

You would have to rewrite dispell magics and thats quite problematic, I don't think its even possible to workaround it correctlyy without newest NWNX plugins
               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Guru, guide thou me. MyResistSpell(), GetCasterLevel() and dispel magic
« Reply #5 on: April 18, 2011, 05:34:05 am »


               Ahh, that's too bad.  It is the one part that would allow a prestige class to operate legitimately as a casting class.

So Shadow, I ended up using your instructions to override GetCasterLevel(), and everything is working nicely.  Though, I encountered a couple problems on the way.

When I openned nwscript, changed the function name and saved it, I got this error:
Error. 'nwscript' did not compile.
nwscript.nss(11): ERROR: INVALID DECLARATION TYPE
This is line 11:  #define ENGINE_NUM_STRUCTURES   5

Now when I build the module scripts, I get a compile error from nwscript, but the module and changes run just fine.  Should I ignore the error message, or did I break something?

 Also, if you run your include file adder program in your modules/temp0 folder, it adds the include file to your custom include and to nwscript as well, which causes circular include errors.  Even after removing the include line from nwscript and the include file itself, I couldn't get rid of the problem and had many compile errors.
 I ended up adding the include manually.  I thought it'd take forever, but realized if you add your include to nw_i0_spells, x0_i0_spells that most scripts compile right away (since those includes are already setup inside most of the spells).  
 Anyway, I'm probably boring you with stuff y'all already know.  I appreciate the help guys.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Guru, guide thou me. MyResistSpell(), GetCasterLevel() and dispel magic
« Reply #6 on: April 18, 2011, 01:08:56 pm »


               Its fine, just ignore it. nwscript.nss is include file and those cannot be compiled.

Sorry for my includer program, seems it has few flaws I forget about.