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.