TriggerProjectileTrap(int, object, int, object, object, int)

Causes an origin object to fire a specified spell at a target.

void TriggerProjectileTrap(
    int nSpell,
    object oTarget,
    int nCasterLevel = 20,
    object oOrigin = OBJECT_INVALID,
    object oTrigger = OBJECT_SELF,
    int nProjectilePath = PROJECTILE_PATH_TYPE_DEFAULT
);

Parameters

nSpell

SPELL_*

oTarget

Target to fire a spell at.

nCasterLevel

Caster level with which to cast the spell at. (Default: 20)

oOrigin

Origin object of the spell. (Default: OBJECT_INVALID)

oTrigger

Used when oOrigin is OBJECT_INVALID to find an object closest to oTrigger with the same tag as oTrigger. (Default: OBJECT_SELF)

nProjectilePath

PROJECTILE_PATH_TYPE_* (Default: PROJECTILE_PATH_TYPE_DEFAULT)


Description

Causes oOrigin to fire a spell at oTarget cast at the specified nCasterLevel.

If oOrigin is OBJECT_INVALID, the function will attempt to find the object nearest oTarget that has the same tag as oTrigger. If no such object exists, we assume that the origin of the trap has been destroyed, and don't fire the trap.

Only creatures, placeables, and items can be used as trap origins.



Remarks

Note that a few spells (notably the arrow/bolt/dart/shuriken) require PROJECTILE_PATH_TYPE_HOMING to work correctly.


Known Bugs

The specified level doesn't work. Instead, the reflex save of the origin is used as the caster level and this only works for a few spells currently. Other spells will fire typically at the highest caster level allowed for that spell. Spells which this work with specifically are not known.


Requirements

#include "x0_i0_projtrap"

Version

1.61

See Also

categories: Traps Functions
constants: PROJECTILE_PATH_TYPE_* Constants | SPELL_* Constants


 author: Charles Feduke, editor: Lilac Soul