Module cast
These functions help in casting spells and retrieving information about casts.
Cast functions are the profile API table `cast` (br.api.profile.cast); profiles use it by name.
`spell` in the function represent the name in the actions list (Spec, Shared Class, Shared Global Lists) defined in Expansions/
Functions
| cast.able.id (spellID, thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies) | Checks if a spell can be cast by its ID based on various parameters. |
| cast.able.name (spellName, thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies) | Checks if a spell can be cast by its Name based on various parameters. |
| able. (thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies) | Checks if a spell can be cast based on various parameters. |
| active. (thisUnit) | Checks if the spell is the one currently being cast. |
| auto. () | Checks if the spell is set to auto-repeat or if it's the current spell being cast. |
| cancel. () | Cancels the current spell being cast if it matches the specified spell, or stops it repeating (Auto Shot, Shoot). |
| cost. (altPower) | Gets the cost of the spell. |
| cast.current.id () | Gets the spell id of the current (or previously) cast spell by the API. |
| current. (thisUnit) | Gets the currently cast spell for the target (Alternate to cast.active.spell()). |
| dispel. (thisUnit) | Checks if the spell is capable of dispelling the target. |
| empowered. () | Gets current empowered rank of the spell or 0 if not empowered. |
| form (formIndex) | Casts the form corresponding to the provided formIndex number. |
| id (spellID, thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies) | Cast a spell by its ID based on various parameters. |
| inFlight. (thisUnit) | Checks if the spell is currently in flight to the target. |
| inFlightRemain. (thisUnit) | Gets time remaining on a spell in flight to the target. |
| last. (index) | Checks if the spell was the last one cast or not. |
| cast.last.time. () | Gets the GetTime() value the last cast of this spell occurred, or 0 if it hasn't been cast. |
| macro (macroText[, associatedSpellID[, lockDuration=0.5]]) | Runs the macro text passed to it. |
| maxRank. () | Get the highest known rank number for this spell (1 on clients without spell ranks). |
| name (spellName, thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies) | Cast a spell by its Name based on various parameters. |
| noControl. () | Checks if the spell can free you of a "no control" effect. |
| opener. () | Casts a spell as one step of an opener: same arguments and result as cast.spell (true when the cast is sent). |
| cast.opener.done () | True once the opener has run all its steps (until it resets). |
| cast.opener.active () | True while an opener is under way: started and not finished. |
| pool. (altPower, specificAmt, multiplier) | Checks if specified power requirements are not met. |
| range. () | Gets the spell's range, if it has one. |
| regen. () | Gets the amount of power spell will generate when cast. |
| safe. (thisUnit, aoeType, minUnits, effectRng, shape) | Checks if safe to cast specified aoe spell on unit given the aoe dimensions. |
| cast. (thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies) | Cast a spell based on various parameters. |
| time. () | Gets the cast time of player's spell. |
| timeRemain (thisUnit) | Gets the cast time remaining on player's cast or supplied target. |
| timeSinceLast. () | Gets the time since the last cast of this spell occurred (very large if it hasn't been cast). |
| wait (condition) | Checks if the provided condition is true else it waits for 0.1sec. |
| withAnimationCancel (castFn) | Casts with the movement animation cancelled: steps back with a jump while castFn runs (Havoc's Fel Rush). |
Functions
- cast.able.id (spellID, thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies)
-
Checks if a spell can be cast by its ID based on various parameters.
Parameters:
- spellID number The ID of the spell to check.
- thisUnit string The target unit for the spell. Can be standard WoW units, dynamic units, or special parameters.
- castType string Defines the type of AoE or special cast conditions.
- minUnits number Minimum number of units needed to be hit by AoE spell.
- effectRng number The AoE's reach: the radius for aoe/ground/targetAOE, the length for cone/rect.
- predict boolean or number ground: true to predict enemy movement. cone: its angle in degrees; rect: its full width in yards (from spell data; the cast is refused without it).
- predictPad boolean Pads the prediction cast time. 'predict' must be true.
- enemies table A table of enemy units that the spell should be cast on.
Returns:
-
boolean
- cast.able.name (spellName, thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies)
-
Checks if a spell can be cast by its Name based on various parameters.
Parameters:
- spellName string The Name of the spell to check.
- thisUnit string The target unit for the spell. Can be standard WoW units, dynamic units, or special parameters.
- castType string Defines the type of AoE or special cast conditions.
- minUnits number Minimum number of units needed to be hit by AoE spell.
- effectRng number The AoE's reach: the radius for aoe/ground/targetAOE, the length for cone/rect.
- predict boolean or number ground: true to predict enemy movement. cone: its angle in degrees; rect: its full width in yards (from spell data; the cast is refused without it).
- predictPad boolean Pads the prediction cast time. 'predict' must be true.
- enemies table A table of enemy units that the spell should be cast on.
Returns:
-
boolean
- able. (thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies)
-
Checks if a spell can be cast based on various parameters.
The function name is dynamically generated based on the spell name.
Parameters:
- thisUnit string The target unit for the spell. Can be standard WoW units, dynamic units, or special parameters.
- castType string Defines the type of AoE or special cast conditions.
- minUnits number Minimum number of units needed to be hit by AoE spell.
- effectRng number The AoE's reach: the radius for aoe/ground/targetAOE, the length for cone/rect.
- predict boolean or number ground: true to predict enemy movement. cone: its angle in degrees; rect: its full width in yards (from spell data; the cast is refused without it).
- predictPad boolean Pads the prediction cast time. 'predict' must be true.
- enemies table A table of enemy units that the spell should be cast on.
Returns:
-
boolean
Also cast.able.spell.aoe(range, minUnits, unit), .rank(n) and the other forms (see the top of this file).
- active. (thisUnit)
-
Checks if the spell is the one currently being cast.
Parameters:
- thisUnit string The unit to check if it's casting the spell. Can be standard WoW units or dynamic units.
Returns:
-
boolean
- auto. ()
-
Checks if the spell is set to auto-repeat or if it's the current spell being cast.
Returns:
-
boolean
- cancel. ()
-
Cancels the current spell being cast if it matches the specified spell, or stops it repeating
(Auto Shot, Shoot).
Returns:
-
boolean
- cost. (altPower)
-
Gets the cost of the spell.
Parameters:
- altPower boolean Set to "true" to return alternate power cost.
Returns:
-
number
- cast.current.id ()
-
Gets the spell id of the current (or previously) cast spell by the API.
Returns:
-
number
- current. (thisUnit)
-
Gets the currently cast spell for the target (Alternate to cast.active.spell()).
Parameters:
- thisUnit string Acceptable parameters: nil (defaults to "player"), standard WoW units, or dynamic units.
Returns:
-
boolean
- dispel. (thisUnit)
-
Checks if the spell is capable of dispelling the target.
Parameters:
- thisUnit string Acceptable parameters: nil (defaults to "target"), standard WoW units, or dynamic units.
Returns:
-
boolean
- empowered. ()
-
Gets current empowered rank of the spell or 0 if not empowered.
Returns:
-
number
- form (formIndex)
-
Casts the form corresponding to the provided formIndex number.
Parameters:
- formIndex number Index of the form to be casted. If not provided, defaults to 0.
- id (spellID, thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies)
-
Cast a spell by its ID based on various parameters.
Parameters:
- spellID number The ID of the spell to cast.
- thisUnit string The target unit for the spell. Can be standard WoW units, dynamic units, or special parameters.
- castType string Defines the type of AoE or special cast conditions.
- minUnits number Minimum number of units needed to be hit by AoE spell.
- effectRng number The AoE's reach: the radius for aoe/ground/targetAOE, the length for cone/rect.
- predict boolean or number ground: true to predict enemy movement. cone: its angle in degrees; rect: its full width in yards (from spell data; the cast is refused without it).
- predictPad boolean Pads the prediction cast time. 'predict' must be true.
- enemies table A table of enemy units that the spell should be cast on.
Returns:
-
boolean
- inFlight. (thisUnit)
-
Checks if the spell is currently in flight to the target.
Parameters:
- thisUnit string Acceptable parameters: nil (defaults to "target"), standard WoW units, or dynamic units.
Returns:
-
boolean
- inFlightRemain. (thisUnit)
-
Gets time remaining on a spell in flight to the target.
Parameters:
- thisUnit string The target unit to check for the spell in flight.
Returns:
-
number
- last. (index)
-
Checks if the spell was the last one cast or not.
Parameters:
- index number Number of last cast spell up to 10 previous spells, default value is 1 if not provided.
Returns:
-
boolean
- cast.last.time. ()
-
Gets the GetTime() value the last cast of this spell occurred, or 0 if it hasn't been cast.
Returns:
-
number
- macro (macroText[, associatedSpellID[, lockDuration=0.5]])
-
Runs the macro text passed to it. Optionally integrates with the cast gate's
throttle infrastructure when an associated spell ID is supplied.
Parameters:
- macroText string The macro text to be run.
- associatedSpellID integer Spell ID representing the intent of this macro. When passed, the cast gate writes castTimers + castIntentLocks for this spell ID so the next tick's gateDoubleCast / gateCooldownTimer blocks immediate re-fires through the same mechanism createCastFunction uses. Callers that don't pass this argument retain the original unprotected behavior (backward-compatible). (optional)
- lockDuration number Throttle window in seconds. Defaults to 0.5s (matches the createCastFunction success-path convention). (default 0.5)
Returns:
-
boolean
Always true.
- maxRank. ()
-
Get the highest known rank number for this spell (1 on clients without spell ranks).
Returns:
-
number
The highest rank number the player knows (1-based), or 0 if none
Usage:
local knownRank = cast.maxRank.healingTouch() if knownRank >= 5 then -- Player knows at least Rank 5 end
- name (spellName, thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies)
-
Cast a spell by its Name based on various parameters.
Parameters:
- spellName string The name of the spell to cast.
- thisUnit string The target unit for the spell. Can be standard WoW units, dynamic units, or special parameters.
- castType string Defines the type of AoE or special cast conditions.
- minUnits number Minimum number of units needed to be hit by AoE spell.
- effectRng number The AoE's reach: the radius for aoe/ground/targetAOE, the length for cone/rect.
- predict boolean or number ground: true to predict enemy movement. cone: its angle in degrees; rect: its full width in yards (from spell data; the cast is refused without it).
- predictPad boolean Pads the prediction cast time. 'predict' must be true.
- enemies table A table of enemy units that the spell should be cast on.
Returns:
-
boolean
- noControl. ()
-
Checks if the spell can free you of a "no control" effect.
Returns:
-
boolean
- opener. ()
-
Casts a spell as one step of an opener: same arguments and result as cast.spell (true when
the cast is sent). Write the opener as ordinary priority lines; the steps go in the order
they're called in. A step that's done or skipped lets the next line run; the current step
casts when it can, and while it waits every cast after it in the rotation is refused, so
nothing jumps in (lines above the opener still run); later steps wait their turn. A step is
done when the game confirms the cast, and skipped when the spell isn't known, its cooldown
won't be up in time, or it can't be cast for about two GCDs. A step whose condition is false
is passed over. The opener resets out of combat without a target, or on a new target.
Returns:
-
boolean
Usage:
if not debuff.rake.exists("target") then if cast.opener.rake() then ui.debug("Casting Rake [Opener]") return true end end
- cast.opener.done ()
-
True once the opener has run all its steps (until it resets).
Returns:
-
boolean
- cast.opener.active ()
-
True while an opener is under way: started and not finished.
Returns:
-
boolean
- pool. (altPower, specificAmt, multiplier)
-
Checks if specified power requirements are not met.
Parameters:
- altPower boolean Set to "true" to return alternate power cost. Defaults to false if not provided.
- specificAmt number Set to specified power amount. Defaults to 0 if not provided.
- multiplier number Set to specified power multiplier. Defaults to 1 if not provided.
Returns:
-
boolean
- range. ()
-
Gets the spell's range, if it has one.
Returns:
-
number
- regen. ()
-
Gets the amount of power spell will generate when cast.
Returns:
-
number
- safe. (thisUnit, aoeType, minUnits, effectRng, shape)
-
Checks if safe to cast specified aoe spell on unit given the aoe dimensions.
Parameters:
- thisUnit string The target unit to check for safety. Defaults to "target" if not provided.
- aoeType string The type of AoE to check for safety. Can be "rect", "cone", "ground", or "aoe".
- minUnits number Specify minimal number of units needed to be hit by AoE spell before it will use.
- effectRng number The AoE's reach: the radius, or the length of a cone or rect.
- shape number A cone's angle in degrees or a rect's full width in yards.
Returns:
-
boolean
- cast. (thisUnit, castType, minUnits, effectRng, predict, predictPad, enemies)
-
Cast a spell based on various parameters.
The function name is dynamically generated based on the spell name.
For example, for a spell named "thisSpell", the function would be `cast.thisSpell()`.
Parameters:
- thisUnit string The target unit for the spell. Can be standard WoW units, dynamic units, or special parameters like "best", "playerGround", etc.
- castType string Defines the type of AoE or special cast conditions.
- minUnits number Minimum number of units needed to be hit by AoE spell.
- effectRng number The AoE's reach: the radius for aoe/ground/targetAOE, the length for cone/rect.
- predict boolean or number ground: true to predict enemy movement. cone: its angle in degrees; rect: its full width in yards (from spell data; the cast is refused without it).
- predictPad boolean Pads the prediction cast time. 'predict' must be true.
- enemies table A table of enemy units that the spell should be cast on.
Returns:
-
boolean
Usage:
cast.wrath() -- best target, best rank cast.demoralizingRoar.aoe(10) -- around you, 10 yards (aoe/cone/rect/ground/targetAOE: cast.swipe.aoe(8, 3) -- range, minUnits = 1, unit), pet(unit), dead(unit) cast.blizzard.ground(8, 3) -- on the ground where it covers 3+ enemies cast.healingTouch.rank(3)("player") -- rank 3, or the highest known below it cast.healingWave.forAmount(missing)("player") -- the lowest known rank that heals that much cast.consecration.rank(1).aoe(8, 3) -- the forms work at a rank, and on cast.able / cast.opener
- time. ()
-
Gets the cast time of player's spell. If the spell has no cast time, it returns the global cooldown.
Returns:
-
number
- timeRemain (thisUnit)
-
Gets the cast time remaining on player's cast or supplied target.
Parameters:
- thisUnit string The unit to check cast time remaining. Defaults to "player" if not provided.
Returns:
-
number
- timeSinceLast. ()
-
Gets the time since the last cast of this spell occurred (very large if it hasn't been cast).
Returns:
-
number
- wait (condition)
-
Checks if the provided condition is true else it waits for 0.1sec.
Parameters:
- condition The condition to check.
Returns:
-
boolean
- withAnimationCancel (castFn)
-
Casts with the movement animation cancelled: steps back with a jump while castFn runs (Havoc's
Fel Rush). This moves the character, so only use it behind a mode the player turns on.
Parameters:
- castFn function Casts the spell, e.g. function() return cast.felRush() end
Returns:
-
boolean
What castFn returned