GetCasterLevel

GetCasterLevel(object) Determines the level of caster for a creature or PC casting a spell. int GetCasterLevel(   object oCreature );

Parameters
oCreature
 * Creature or PC casting a spell.

Description
Get the Caster Level of oCreature. If the creature or PC is multiclassed, this function returns the level of the class used to cast the spell.

Return a value of 0 on error.

Remarks
This only works with PC and creature type objects, else it returns 0.

This function only works properly when oCreature is casting a spell. It is certainly the only reliable place. If used outside a spell script, it will return the last caster level of the last spell cast by oCreature - IE, some Area-of-Effect spells do this, to get how much damage dice to use.

Known Bugs
As of version 1.68: As remarked above when used in an area of effect spell it will return the last caster level used. Further more my testing has shown that it even if oCreature has not cast a spell with a different caster level but is de-leveled the AoE will take the new caster level. Furthermore using a special ability such as turn undead will set the last caster level used by oCreature to 0.

Speculation
Considering the above, it is likely though difficult to prove that a spell effect (any spell effect) cast from a scroll will take during a dispel check the caster level at which the last spell was cast by the creator of the effect.

Version
1.68

Based on the original article on the NWN Lexicon by author Brett Lathrope