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

Cast a spell at a specific location.

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

Parameters

nSpell

SPELL_*

lTargetLocation

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)

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

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 memorised 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.

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 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,1,PROJECTILE_PATH_TYPE_HIGH_BALLISTIC,1);

}

See Also

functions: ActionCastFakeSpellAtLocation | ActionCounterSpell
categories: Action on Object Functions | Spell Casting Effects Functions | Spells Functions
constants: METAMAGIC_* Constants | PROJECTILE_PATH_TYPE_* Constants | SPELL_* Constants


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