ActionCastSpellAtObject(int, object, int, int, int, int, int)

From NWN Lexicon
Red bug icon.png Warning: This function has a known bug and may not work as expected in some situations. See Known Bugs for details.

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
);

Contents

[edit] Parameters

nSpell
The SPELL_* constant matching the spell to cast
oTarget
The target for the spell
nMetaMagic
A METAMAGIC_* constant signaling what metamagic should be applied to the spell (Default: METAMAGIC_ANY)
bCheat
If this is TRUE, 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
A PROJECTILE_PATH_TYPE_* constant (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)

[edit] 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.

[edit] Remarks

Object oTarget should be a valid target such as a creature or PC. Some object types may not work with this function (barrels work now, but they didn't at the time this article was first written). More experimentation is needed.

Note that spells cast with this function will actually apply their damage and/or effects; for visuals only, see ActionCastFakeSpellAtObject.

[edit] 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 ActionCastSpellAtLocation, Ranger and Paladin spells do not work properly. 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.

[edit] Version

1.64

[edit] 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);
}

[edit] See Also

functions:  ActionCastSpellAtLocation, ActionCastFakeSpellAtObject
constants:  SPELL_* Constants


author: Dan Spezzano, editor: Jasperre, additional contributor(s): Daniel LeDuke, Slow Slosh, Chris Heywood, Jasperre

Personal tools
Categories