Core Concepts

Creating 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. Each spell object provides a powerful, customized set of tools for casting, tracking, and managing that specific spell throughout your routine.

Create spell objects by providing a spell ID and optional traits that describe how the spell behaves. Once created, all methods and attributes for that spell object follow the traits you've defined.

Basic Creation

synq.Spell(spellID, traits) -> Spell Object

Example

local killCommand = synq.Spell(34026, {damage = "physical", targeted = true})

Now killCommand contains all attributes, methods, and functions of a spell object. You can use it to check cooldowns, cast the spell, set up callbacks, and gather information about Kill Command.

SYNQ automatically gathers spell information from WoW's API and presents it as attributes. By telling it damage = "physical", the spell object knows to avoid casting into physical damage immunities automatically.

Spell Traits

Spell traits tell SYNQ how each spell behaves. Many traits exist to prevent casting into immunities, while others define special casting rules (like casting while moving or while crowd controlled).

Control Immunity Example

By default, :Cast won't attempt to cast while you're crowd controlled. Some abilities can be cast during CC, like Feign Death:

-- Feign Death can be cast while in CC, and we want it to cancel any channeling spells
-- ignoreControl allows casting while crowd controlled
-- ignoreChanneling allows it to cancel current channel to cast
feignDeath = synq.Spell(5384, {ignoreControl = true, ignoreChanneling = true})

Movement Example

Some spells can be cast while moving, like Cobra Shot or Steady Shot:

cobraShot = synq.Spell(193455, {damage = "physical", ranged = true, ignoreMoving = true})

The ignoreMoving trait tells SYNQ this spell can be cast while moving, so it won't wait for you to stop before attempting to cast.

Benefits of Spell Objects

Spell objects handle complex casting logic automatically. Even a simple example like Kill Command benefits—the :Cast method automatically checks:

  • The spell is off cooldown
  • You have enough Focus
  • You're in range of the target and facing them (if required)
  • The target isn't immune to physical damage
  • Line of sight is clear
  • And much more before attempting to cast

All of this happens automatically when you call killCommand:Cast(target), so you can focus on rotation logic instead of casting conditions.

Organization & Performance Benefits

Spell objects allow you to modularize code related to the spell into neat little packages within itself. This provides:

  • Fantastic organization - Code related to each spell is within its own spell object
  • Easy to digest actors - Your actor becomes an easy to digest spell-related stack of priorities, as routines should be
  • Major performance benefit - Code related to spells only runs when the underlying spell is ready to be cast

Advanced Features

  • Spells with cast times already know to start :Cast perfectly timed as an immunity to it will fall
  • Complex AoE positioning around corners and out of range is all handled automatically by CastEdge
  • And so much more

Populating the Actor

Use synq.Populate to make spell objects available to your routine actor and the current file's scope. This lets you reference spells directly by name without creating local variables or storing them in tables.

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

local spells = {
    exhilaration = synq.Spell(109304, {heal = true}),
    intimidation = synq.Spell(19577, {effect = "physical", stun = true}),
    killCommand = synq.Spell(34026, {damage = "physical", targeted = true}),
}

synq.Populate(spells, bm, getfenv(1))

After populating, you can call killCommand() or exhilaration() directly in your actor without needing local references. This keeps your code clean and organized.

Complete Spellbook Example

Here's a comprehensive Beast Mastery Hunter spellbook showing how to organize spells with proper traits:

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

synq.Populate({
    -- SYNQ objects (always available)
    target = synq.target,
    focus = synq.focus,
    player = synq.player,
    healer = synq.healer,
    pet = synq.pet,
    enemyHealer = synq.enemyHealer,

    -- Core rotation abilities
    killCommand = Spell(34026, { damage = "physical", targeted = true }),
    barbedShot = Spell(217200, { damage = "physical", ranged = true, targeted = true }),
    cobraShot = Spell(193455, { damage = "physical", ranged = true, targeted = true }),
    serpentSting = Spell(271788, { damage = "physical", ranged = true, targeted = true, bleed = true }),

    -- Cooldowns
    bestialWrath = Spell(19574, { damage = "physical" }),
    aspectOfTheWild = Spell(193530, { damage = "physical" }),
    bloodshed = Spell(321530, { damage = "physical", targeted = true }),

    -- Utility
    disengage = Spell(781, { ignoreFacing = true }),
    harpoon = Spell(190925, { damage = "physical", targeted = true }),
    feignDeath = Spell(5384),
    exhilaration = Spell(109304, { heal = true }),
    mendPet = Spell(136, { heal = true }),

    -- Crowd control
    intimidation = Spell(19577, { effect = "physical", stun = true }),
    concussiveShot = Spell(5116, { effect = "physical", ranged = true, targeted = true, slow = true }),

}, bm, getfenv(1))

This example shows how to organize a complete spellbook with proper traits. Each trait helps SYNQ make intelligent casting decisions—avoiding immunities, checking range, and handling special cases automatically.


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