Spell Class
Several checks are automatically performed in the cast()
and smartaoe()
functions, making manual checks redundant. These include:
ready()
- No need to check if spell is ready before castingcastable(unit)
- No need to check if spell is castable before castingisusable()
- No need to check if spell is usable before castinginrange(unit)
- No need to check range before castingunit.distance
- No need to check distance before castingunit.los
- No need to check line of sight before castingunit.facing
- No need to check facing before casting
Incorrect Usage:
if spell:ready() and spell:castable("target") and target.los and target.distanceto(player) < 40 then
spell:cast("target") -- Redundant checks!
end
Correct Usage:
spell:cast("target") -- All necessary checks are performed internally
The Spell class provides a comprehensive interface for handling spells in World of Warcraft. It includes functionality for checking spell availability, casting spells, managing cooldowns, and handling various spell-specific behaviors.
Installation
local spell = Aurora.SpellHandler.NewSpell(spellID, payload)
Parameters
Parameter | Type | Description |
---|---|---|
spellID | number | number[] | Single spell ID or array of spell IDs for different ranks |
payload | table | Optional configuration settings |
Payload Options
Option | Type | Default | Description |
---|---|---|---|
ignoreCasting | boolean | false | Ignore if player is casting |
ignoreChanneling | boolean | false | Ignore if player is channeling |
ignoreCost | boolean | false | Ignore resource costs |
ignoreFacing | boolean | false | Ignore facing requirements |
ignoreMoving | boolean | false | Ignore movement restrictions |
isSkillshot | boolean | false | Treat as skillshot spell |
maxOffset | number | 0 | Maximum targeting offset |
minOffset | number | 0 | Minimum targeting offset |
nextMelee | boolean | false | Queue for next melee |
radius | number | 0 | Spell effect radius |
queued | boolean | false | Allow spell queueing |
timeToHit | number | 0 | Time until spell impact |
petspell | boolean | false | Check if said spell is a pet spell |
castbyID | boolean | false | Cast spell by ID instead of name (useful for spells like mangle(cat) & mangle(feral) on classic WoW) |
Core Methods
cast(unit)
Attempts to cast the spell on the specified unit.
local success = spell:cast(target) -- Returns boolean indicating success
castable(unit)
Checks if spell can be cast on the specified unit.
local canCast = spell:castable(target) -- Returns boolean
ready()
Checks if spell is ready to be cast (off cooldown and usable).
local isReady = spell:ready() -- Returns boolean
Cooldown Methods
getcd()
Gets remaining cooldown time in seconds.
local cooldown = spell:getcd() -- Returns number (seconds)
charges()
Gets current number of charges.
local currentCharges = spell:charges() -- Returns number
maxcharges()
Gets maximum number of charges.
local maxCharges = spell:maxcharges() -- Returns number
chargesleft()
Gets fractional charges remaining (includes partial charge regeneration).
local fractionalCharges = spell:chargesleft() -- Returns number
timetofull()
Gets time until all charges are regenerated.
local timeToFull = spell:timetofull() -- Returns number (seconds)
timetonextcharge()
Gets time until next charge is available.
local timeToNext = spell:timetonextcharge() -- Returns number (seconds)
Cast History Methods
waslastcast(timeWindow)
Checks if this spell was the last one cast within the specified time window.
local wasLast = spell:waslastcast(1.5) -- Returns boolean
wasSecondLastCast()
Checks if this spell was the second-to-last spell cast.
local wasSecondLast = spell:wasSecondLastCast() -- Returns boolean
timeSinceLastCast()
Gets time elapsed since this spell was last cast.
local timeSince = spell:timeSinceLastCast() -- Returns number (seconds)
AOE Methods
smartaoe(target, options)
Intelligently casts AOE spell considering multiple targets.
spell:smartaoe(target, {
offsetMin = 0, -- Minimum offset distance
offsetMax = 8, -- Maximum offset distance
distanceSteps = 24, -- Number of distance checks
circleSteps = 48, -- Number of circular positions to check
filter = function(unit, distance, position) -- Optional filter function
return true -- Return true to count this unit
end,
ignoreEnemies = false, -- Ignore enemy units
ignoreFriends = false -- Ignore friendly units
})
smartaoeposition(target, options)
Gets the optimal position for an AOE spell cast.
local position = spell:smartaoeposition(target, {
-- Same options as smartaoe()
})
-- Returns {x, y, z, hitCount} or nil
Utility Methods
inrange(unit)
Checks if target is within spell range.
local inRange = spell:inrange(target) -- Returns boolean
rank()
Gets the current rank of a talent spell.
local rank = spell:rank() -- Returns number
overlayed()
Checks if the spell is currently overlayed (glowing).
local isOverlayed = spell:overlayed() -- Returns boolean
getcasttime()
Gets the cast time of the spell in seconds.
local castTime = spell:getcasttime() -- Returns number (seconds)
isusable()
Checks if spell is currently usable (has resources, etc).
local isusable, notEnoughResources = spell:isusable() -- Returns two booleans
Example Usage
-- Create a new spell object for Fireball
local fireball = Aurora.SpellHandler.NewSpell(133, {
})
-- Check if we can cast Fireball on our target
if fireball:castable("target") then
-- Cast Fireball
fireball:cast("target")
end
-- Create an AOE spell like Blizzard
local blizzard = Aurora.SpellHandler.NewSpell(190356, {
isSkillshot = true,
radius = 8
})
-- Cast Blizzard optimally on groups of enemies
blizzard:smartaoe("target", {
offsetMax = 30,
filter = function(unit, distance, position)
return unit.enemy and not unit.dead
end
})