OnSpellCastAt

From NWN Lexicon
Revision as of 22:52, 14 January 2021 by Jasperre (talk | contribs)
Jump to: navigation, search

The script attached to this event fires when the object becomes the target of a spell. This can include responses such as casting a spell of the object's own, dying, disappearing, getting stronger (absorbing the magical effect), etc.

Trigger

A spell has been cast at the creature, door, or placeable object. It only fires when EventSpellCastAt is fired on the object using SignalEvent.


Function(s)

To perform combat usually DetermineCombatRound(object, int) is called by the default AI.

These functions are functional in the event:

Note there is no reliable way to link this to damage received, although a later check of effects can reveal temporary or permanent effects from this particular casting. You might be able to link the spell to particular damage by tracking the OnDamaged event at the same time (usually this is called beforehand in most spell scripts).


Remarks

This event by itself does nothing to faction reputation or the change of invisible to not invisible - that is handled entirely by the engine during the SignalEvent/EventSpellCastAt routine.

Some Bioware spells are miscoded as friendly when they should be hostile, which is why sometimes you can cast a hostile spell (not a damaging one) and remain undetected or not be attacked.


Known Bugs

GetLastSpellCaster cannot return any area of effects which fire the event, and so may return OBJECT_INVALID (eg; if the object that created it is now logged off or destroyed).

Not sure if this is intended, although Bioware's own Area of Effect reaction code in the event does take it into account and dispels the creatures own location.

See Also

functions:  GetLastSpellHarmful

GetLastSpellCaster

GetLastSpell