Core Concepts

Spell Objects

Learn how to create spell objects with traits and organize them in your rotation

Spell Objects are SYNQ's object-oriented system for working with abilities. Create them by providing a spell ID and optional traits that describe how the spell behaves.

Creating Spell Objects

lua
synq.Spell(spellID, traits) -> Spell Object
lua
local killCommand = synq.Spell(34026, {damage = "physical", targeted = true})

The spell object contains all attributes, methods, and functions for that spell. SYNQ automatically gathers spell information from WoW's API and uses traits to make intelligent casting decisions.

Spell Traits

Traits tell SYNQ how each spell behaves - preventing casts into immunities, defining special casting rules, and handling edge cases automatically.

Common traits:

  • damage = "physical" or "magic" - Avoids damage immunities
  • effect = "physical" or "magic" - Avoids effect immunities
  • targeted = true - Requires a target
  • ranged = true - Ranged spell
  • heal = true - Healing spell
  • ignoreMoving = true - Can cast while moving
  • ignoreControl = true - Can cast while crowd controlled
  • ignoreChanneling = true - Cancels current channel to cast
  • ignoreFacing = true - Doesn't require facing target
  • stun = true - Stun effect
  • bleed = true - Bleed effect
  • slow = true - Slow effect
  • override = true - Spell may be replaced by another spell at runtime (talent, buff, or empower swap). Pairs with the spell.overridden attribute.
  • alwaysFaceHack = true - Apply FaceHack automatically on every :Cast. Equivalent to passing { faceHack = true } each time. Aliases: autoFaceHack, faceHack.

Override Detection

When a spell is flagged with override = true, SYNQ keeps tracking the original spell object even after the game swaps it for a replacement (e.g. Wake of Ashes → Hammer of Light). The spell.overridden attribute lets your callback branch based on which spell is actually live.

lua
spell.overridden : true | nil
lua
local wakeofashes = synq.Spell(255937, { override = true })

wakeofashes:Callback(function(spell)
    -- Hammer of Light requires a target; Wake of Ashes does not.
    if spell.overridden then return spell:Cast(target) end
    return spell:Cast()
end)

The callback fires on the original spell object, so the same handler covers both forms — branch on spell.overridden only when the override changes targeting or behaviour.

Spell Cost

Access the resource cost of a spell. Use spell.cost to check a specific power type, or spell.costs to auto-detect the power type and amount.

spell.cost.{powerType} - Cost for a specific power type

lua
spell.cost.focus   : number | 0
spell.cost.energy  : number | 0
spell.cost.mana    : number | 0
spell.cost.rage    : number | 0

spell.costs - Auto-detects the power type and how much the spell costs

lua
spell.costs : number | 0
lua
-- Check specific power type cost
if player.focus >= killCommand.cost.focus then
    killCommand()
end

-- Auto-detect cost (will return the cost regardless of power type)
if player.power >= cobraShot.costs then
    cobraShot()
end

Cast Options

spell:Cast accepts an optional table as its second argument to tweak how the cast executes for that single call.

lua
spell:Cast(unit, options)

faceHack

Force the player to face the target for the cast, then restore the previous facing. Mouselook is preserved.

lua
spell:Cast(unit, { faceHack = true })       -- face + restore
spell:Cast(unit, { faceHack = "oneWay" })   -- face only, no restore
spell:Cast(unit, { faceHack = "force" })    -- same as true

faceOffset

Apply an angular offset (in radians) on top of FaceHack. Useful for spells that need to fire slightly off-axis.

lua
spell:Cast(unit, { faceHack = true, faceOffset = math.rad(20) })

Setting FaceHack as a default

To apply FaceHack on every cast of a spell without repeating the option, set the trait when constructing it:

lua
local kick = synq.Spell(118, { alwaysFaceHack = true })
-- Aliases: autoFaceHack = true, faceHack = true

The same option is also accepted by item:Use — see Item Objects › Use. The underlying primitives (synq.FaceHack, synq.FaceSmooth, etc.) are documented in General Tools › Face Manipulation.

Examples

lua
cobraShot = synq.Spell(193455, {damage = "physical", ranged = true, ignoreMoving = true})
feignDeath = synq.Spell(5384, {ignoreControl = true, ignoreChanneling = true})
exhilaration = synq.Spell(109304, {heal = true})
intimidation = synq.Spell(19577, {effect = "physical", stun = true})

Populating the Actor

Use synq.Populate to make spell objects available to your routine actor and file scope.

lua
local Unlocker, synq, example = ...
local bm = example.hunter.bm

local Spell = synq.Spell
synq.Populate({
    killCommand = Spell(34026, {damage = "physical", targeted = true}),
    barbedShot = Spell(217200, {damage = "physical", ranged = true, targeted = true}),
    cobraShot = Spell(193455, {damage = "physical", ranged = true, ignoreMoving = true}),
}, bm, getfenv(1))

After populating, call spells directly: killCommand() or barbedShot().

Full Example

For a complete spellbook example with traits, callbacks, and rotation logic, see the Getting Started tutorial.


Next: Learn how to work with Item Objects for consumables, trinkets, and equipment.