GetCasterLevel INFO

I’m not sure how much this occurs, but I have recently discovered that the GetCasterLevel function can sometimes fail to return the caster level of a non-PC creature. I have particularly noticed this in a customised version of nw_s0_summon script I have.

I debugged the AI surrounding the calling of this script, and the results were inconsistent. My only guess, at this stage, is that in the test I had, 3 NPCs were casting the Summon Monster spell at the same time, and … maybe … the function return for the caster level became confused (as it is known to reset to zero between casts). Every other aspect of the summon spell script worked fine, and debug showed (for example) the caster name no problem. The spell even cast the correct creature, but (the problem being), the creature immediately disappeared because the duration was based on a caster return result of 0 (zero). i.e. Last for zero rounds!

I have put in a minimum value return check now, and all works as it should. I was just concerned that the function had this result if multiple calls were made at the same time for NPCs.

Any other feedback welcome.

GetCasterLevel can return the level only if a spell have been casted by the creature.

I needed it to work all the time for something and I have to rewrite it. (Reading 2Da caster progression files and summing them accross the 4 possibles creature classes).

In this case, three clerics were all summoning monsters at the same time. Normal spell casting via their AI. It was the first spell they cast. For some reason, the function only worked sometimes for some of them. Results varied from the function working two out of three times to not at all.

I have a working solution for the current situation, but am concerned this can come back as an issue in another AI cast spell at another time. I am looking into both delays and potential variable backup.