Difference between revisions of "OnSpellCastAt"

From NWN Lexicon
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
 
====Trigger====
 
====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]].
+
A spell has been cast at the creature, door, or placeable object. It only fires when [[EventSpellCastAt]] is fired on the object using [[SignalEvent]]. This event calling can actually happen outside of a spell being cast (and does when an Area of Effect applies an effect usually), and the AI could respond to special numbers used and passed to [[GetLastSpell]] for instance.
  
 
<br />
 
<br />
Line 26: Line 26:
 
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.
 
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.
  
 +
There is one special line - line 509 - of spells.2da labelled "HealingKit" used for when SKILL_HEAL is applied to a target. Not sure why this wasn't used for the other active skills, which typically fire [[OnPhysicalAttacked]].
  
 
====Known Bugs====
 
====Known Bugs====

Latest revision as of 13:39, 21 January 2021

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. This event calling can actually happen outside of a spell being cast (and does when an Area of Effect applies an effect usually), and the AI could respond to special numbers used and passed to GetLastSpell for instance.


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.

There is one special line - line 509 - of spells.2da labelled "HealingKit" used for when SKILL_HEAL is applied to a target. Not sure why this wasn't used for the other active skills, which typically fire OnPhysicalAttacked.

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