ActionCastSpellAtObject(int, object, int, int, int, int, int)
Cast a spell at an object.
void ActionCastSpellAtObject( int nSpell, object oTarget, int nMetaMagic = METAMAGIC_ANY, int bCheat = FALSE, int nDomainLevel = 0, int nProjectilePathType = PROJECTILE_PATH_TYPE_DEFAULT, int bInstantSpell = FALSE );
Parameters
nSpell
oTarget
Target for the spell
nMetaMagic
METAMAGIC_* (Default: METAMAGIC_ANY)
bCheat
If this is TRUE, then the executor of the action doesn't have to be able to cast the spell. (Default: FALSE)
nDomainLevel
Should define the caster level (see Known Bugs). (Default: 0)
nProjectilePathType
PROJECTILE_PATH_TYPE_* (Default: PROJECTILE_PATH_TYPE_DEFAULT)
bInstantSpell
If this is TRUE, the spell is cast immediately. This allows the end-user to simulate a high-level magic-user having lots of advance warning of impending trouble (Default: FALSE)
Description
Casts nSpell at oTarget with regards to the values of the other parameters. At minimum nSpell and oTarget must be specified for this function to work.
Remarks
Object oTarget should be a valid target such as a creature or PC. Experiment with different target types as some targets do not work with this function (verified that this function does not work with barrels).
Known Bugs
The variable nDomainLevel should define the caster level of the spell, but this variable is ignored.
When a henchman casts any one of the following three spells listed below on itself, the henchman loses all spell casting ability.
SPELL_EAGLE_SPLENDOR
SPELL_FOXS_CUNNING
SPELL_OWLS_WISDOM
As with all ActionCastSpellXXX, Ranger and Paladin spells do not work properley. nMetaMagic is ignored in the spell script (GetMetaMagicFeat() returns -1 in the spell script).
1.64 does fix the problem with sub-dial spells. These can now be cast correctly using these functions. It doesn't mention any fixes for the above issues however.
Version
1.64
Example
// The script below is placed on the OnUse Event handler for a placeable, in our // example a lever. When used it casts a Magic Missile spell at the target. In this case // the target is a nearby commoner called "TARGET2". Try this script for kicks. void main() { object oTarget = GetObjectByTag("TARGET2"); ActionCastSpellAtObject(SPELL_MAGIC_MISSILE,oTarget,1); }
See Also
author: Dan Spezzano, editor: Jasperre, additional contributor(s): Daniel LeDuke, Slow Slosh, Chris Heywood, Jasperre