GetLastSpellCastClass

From NWN Lexicon

Contents

[edit] GetLastSpellCastClass()

Returns the class that the spellcaster cast the spell as

[edit] Description

Returns the class that the spellcaster cast the spell as.
- Returns CLASS_TYPE_INVALID if the caster has no valid class (placeables, etc...)

It will return CLASS_TYPE_INVALID for:

- Creature spells and special abilties
- Any ActionCastSpellXXX() with the bCheat parameter TRUE, even if they have the spell already.
- Any "spell" script fired by a feat (Epic spells, barbarian rage ETC).

[edit] Remarks

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.

[edit] 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.

[edit] Version

1.62

[edit] Example

// If the last class to cast this spell is a cleric, speak the clerics Diety.
// 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) + "!");
    }
}

[edit] See Also

constants: 

CLASS_TYPE_* Constants


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

Personal tools
Categories