Gaming
 

GetCasterLevel

From NWNWiki

GetCasterLevel(object) determines the level of caster for a creature or PC casting a spell.

int GetCasterLevel(
   object oCreature
);

Contents

[edit] Parameters

object oCreature

Creature or PC casting a spell.

[edit] Description

Gets 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.

Returns a value of 0 on error.

[edit] 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 — e.g., some persistent spells (particularly those that make use of EffectAreaOfEffect) do this to get how many damage dice to use.

[edit] Known bugs

As of version 1.68: As remarked above, when used outside a spell script, this function will return the last caster level used. Further testing has shown that even if oCreature is deleveled, but has not cast a spell with a different caster level, the area of effect 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.

[edit] Speculation

It is likely, but not known at this time, that a spell cast from a scroll or other item will take the caster level of the last spell cast by the item's user during a dispel check. Further testing will also be needed to establish this for spells cast normally (i.e. not from a scroll or other item).

[edit] Version

1.68

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