ActionCastSpellAtLocation(int, location, int, int, int, int)

From NWN Lexicon
Jump to: navigation, search
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 a specific location.

void ActionCastSpellAtLocation(
    int nSpell,
    location lTargetLocation,
    nMetaMagic = METAMAGIC_ANY,
    int bCheat = FALSE,
    int nProjectilePathType = PROJECTILE_PATH_TYPE_DEFAULT,
    int bInstantSpell = FALSE
);

Parameters

nSpell
The SPELL_* constant matching the spell to cast
lTargetLocation
The location at which to cast 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)
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)

Description

Use this function to cast a spell at a specific location. You must at least give this function a Spell (nSpell) and a Location (lTargetLocation) for it to work properly.

The location can be a Waypoint or anything else you can set in the GetLocation function.

Set bCheat to true if you wish the executor of the script to be able to cast the spell whether or not they have the ability to cast.

Remarks

Use this function when you wish to cast a spell at a particular location. The object calling this function will become the origin of the casting. For example a fireball trap that triggers over a chest. Note that spells cast with this function will actually apply their damage and/or effects; for visuals only, see ActionCastFakeSpellAtLocation.

Known Bugs

For some reason, any memorized spells which are prepared metamagically (A Empowered Fireball for example) cause this to not work correctly. Cheat-cast, or non-metamagically prepared spells work correctly, however, as do if they are passed into ActionCastSpellAtObject.

Like ActionCastSpellAtObject, 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.

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 Fireball spell at the target. In this case
// the target is a Waypoint with the tag "TARGET_WP1".
void main()
{
    location lTarget = GetLocation(GetWaypointByTag("TARGET_WP1"));
    ActionCastSpellAtLocation(SPELL_FIREBALL, lTarget, METAMAGIC_NONE, TRUE, PROJECTILE_PATH_TYPE_HIGH_BALLISTIC, TRUE);
}

See Also

functions:  ActionCastSpellAtObject, ActionCastFakeSpellAtLocation
constants:  SPELL_* Constants


author: Dan Spezzano, editor: Jasperre, additional contributor(s): Jasperre