From NWN Lexicon
Revision as of 12:04, 9 November 2020 by Jasperre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Returns the class that the spellcaster cast the spell as.


Returns the class that the spellcaster (OBJECT_SELF in a called spell script) cast the spell as.

It will return CLASS_TYPE_INVALID for:

  • Creature spells and special abilities
  • Any ActionCastSpellXXX() with the bCheat parameter TRUE (which will always be the case for placeables), even if they have the spell already.
  • Any "spell" script fired by a feat (Epic spells, barbarian rage ETC).
  • Items cast from spells the first time they are used. See Known Bugs.


Very useful new function as there didn't use to be any reliable way of telling which class an object used to cast a spell.

It is only to be used in a spell script for spells which are castable by PC's, or at least, that is the only useful place. Also, by definition, the class level will be adequate to cast this spell.

Known bugs

The result of this function doesn't change (remain previous value of last spell cast) in case the spell is cast from an item. It is recommended to use GetSpellCastItem to check for this before assuming this works.




// If the last class to cast this spell is a cleric, speak the clerics Deity.
// As OBJECT_SELF is the caster, the caster will speak it.
void main()
    // Get caster class
    if(GetLastSpellCastClass() == CLASS_TYPE_CLERIC)
        // Speak the string
        SpeakString("I do this for " + GetDeity(OBJECT_SELF) + "!");

See Also


CLASS_TYPE_* Constants


Spell Script

 author: Lilac Soul, editor: Jasperre, additional contributor(s): arQon