Author Topic: Funny behavior from GetCasterLevel()?  (Read 325 times)

Legacy_BCH

  • Full Member
  • ***
  • Posts: 160
  • Karma: +0/-0
Funny behavior from GetCasterLevel()?
« on: April 02, 2011, 03:42:39 am »


               When I create a PC with five levels of Harper Scout, their Invisibility feat appears to work properly.

When I created an NPC with five levels of Harper Scout and the Invisibility feat, activating it and targeting the NPC (NPC possessed by the DM) seemed to produce no results.  It appeared that in this case, a caster level of zero was being returned by GetCasterLevel().

I changed the  
NW_S0_Invisib script
, and put in a line to separately look for Harper level and add that to the overall caster level, and then the same NPC could cast the spell successfully (again possessed by the DM).

At first I assumed that GetCasterLevel() was not looking for Harper levels, but a Harper PC was able to cast that spell successfully, so that theory seems unlikely to me.

Any ideas?
               
               

               
            

Legacy_Werehound

  • Newbie
  • *
  • Posts: 22
  • Karma: +0/-0
Funny behavior from GetCasterLevel()?
« Reply #1 on: May 04, 2011, 06:37:36 pm »


               Force additional caster levels based on any conditions you want. Do a GetIsDMPossessed(oNPC) check and add 5 levels. =P
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Funny behavior from GetCasterLevel()?
« Reply #2 on: May 05, 2011, 11:56:23 am »


               default AI can't cast this spell due to 2da settings, I dont know if its related to issue that you can cast it via DM possession but it has no effect but try to download the community patch I fixed that 2da there
               
               

               


                     Modifié par ShaDoOoW, 05 mai 2011 - 10:57 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Funny behavior from GetCasterLevel()?
« Reply #3 on: May 05, 2011, 01:52:38 pm »


               Maybe because you are invisible already?   << Possible...

Look for why it's failing & read the script to see if there is a check or something preventing it from working..

My 2 cents..
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
Funny behavior from GetCasterLevel()?
« Reply #4 on: May 07, 2011, 02:50:50 pm »


               Hello.

You pick an interesting subject.
This might save you a few hours of frustration:

GetCasterLevel() is fully reliable for spells cast from a spellbook (both by PC and NPC) and from spell-like abilities activated by PC.

GetCasterLevel() is also fully reliable when quried for spells cast from items.

DM who are currently not possessing anybody get a fixed CasterLevel of 10.
Same goes even if they possess someone but still cast spells from their DM radial menus.

NPC are the most unreliable of the lot. CasterLevel from their Special Abilities is always in range [1 - 15], as defined within the very Toolset (Creature Properties window, Special Abilities tab) regardless of the NPC class levels assigned.
Also, for Special Abilities used by NPC, not even a GetLastSpellCastclass() call shall return you a valid class.
Furthermore, albeit occasionally, if an NPC casts a Special Ability as the module has just loaded and a PC has just joined it, the queried CasterLevel for said Special Ability may read 0.
But should you have TWO identical NPCs casting the same thing at the same time, and very close to module load time, you may get a CasterLevel of 0 from one NPC, yet a valid CasterLevel (but always in range [1 - 15]) for the other NPC.

GetCasterLevel() is rather flawed, or, better said, flawed is whatever engine code feeds values to it.
I did thus code my own workaround for it, so I could at least get coherent and constant values that would not change by the moon phases.
If you are interested, seek it in my [fox spells].
The function is named fox_SD_GetCasterLevel(), within fox_inc_spelldat.nss.


Does it help?


-fox