EventSpellCastAt(object, int, int)
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. Removes invisibility effects on oCaster. (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 signalled 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.
If bHarmful is TRUE it will also set the last hostile actor, retrieved by GetLastHostileActor, and will break the casters invisibility.
oCaster should be a creature or an Area of Effect object. If an Area of Effect object is passed in as oCaster, it will attempt to get the creator of the AOE and pass that instead (or OBJECT_INVALID if that caster no longer is around) when the event is used on another creature. This is likely to facilitate the Bioware AI which makes assumptions that the caster is always a creature.
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).
Healing Kits automatically get this fired when used, passing SPELL_HEALING_KIT (506) as the nSpell parameter, bHostile is FALSE and the caster as the creature using the kit.
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: | |
| events: |
author: Charles Feduke, editors: Jasperre, Mistress, additional contributors: Jasperre, Lilac Soul, Christopher