EventSpellCastAt(object, int, int)

From NWN Lexicon
Jump to: navigation, search

Creates an event which triggers a "spell cast at" reaction.

event EventSpellCastAt(
    object oCaster,
    int nSpell,
    int bHarmful = TRUE
);

Parameters

oCaster
Caster of the spell.
nSpell
Spell being cast, spells.2da line - usually SPELL_* constant
bHarmful
Determines if the spell is harmful to its target. (Default: TRUE)

Description

Returns an event which triggers the OnSpellCastAt event script.

This event must then be signaled using SignalEvent.

In the event the oCaster parameter is returned by GetLastSpellCaster, nSpell parameter is returned by GetLastSpell, and the parameter bHarmful is returned by GetLastSpellHarmful.

Remarks

This doesn't actually cast the spell, it just makes the object that the event is signaled to behave as if it were. The main additional effect of the event is if oCaster is invisible, and bHarmful is TRUE, then invisibility effects will be removed.

oCaster doesn't have to be the original spellcaster or even a creature. It is sometimes useful to have the "caster" be, say, the Area of Effect object, so the creature knows that an Area of Effect is present and which one has affected them.

If a spell script doesn't fire any event, then the AI will not even notice a spell was cast (and would only react to damage in the OnDamaged event out of all the effects that could be applied).

Version

1.64

Example

// Makes us think that Magic Missile (a hostile spell) was cast
// on ourselves, by ourselves. Not a very good example, but it is
// one none the less.
 
void main()
{
    // Note: Ususally, this is all used on one line, because it is easier.
    SignalEvent(OBJECT_SELF, EventSpellCastAt(OBJECT_SELF, SPELL_MAGIC_MISSILE, TRUE));
}

See Also

constants: 

SPELL_* Constants

events: 

OnSpellCastAt Event SignalEvent



 author: Charles Feduke, editors: Jasperre, Mistress, additional contributors: Jasperre, Lilac Soul, Christopher