Attributes are keys within a SYNQ object that return values about the object's state, properties, and information. Understanding attributes is fundamental to building effective SYNQ routines.
An attribute is just a key within a SYNQ object that is expected to return some value. Think of them as properties that tell you everything you need to know about a unit, player, or object.
Key Features:
object.enemy works, but so does object.Enemy and object.isEnemyReading attributes is extremely performant. They act as normal key-value pairs, but their value is generated upon reference of the key, and the value is cached until the next "tick". This means:
A few attributes have multiple returns that are only available by selection #, which you can add to the end of the key. Example: player.casting9 == select(9, UnitCastingInfo("player")). You can also use bracket notation to access them variably: player["casting" .. selection].
Returns true if the object exists, nil otherwise.
unit.exists : true | nil
Example:
print("Target exists: " .. tostring(target.exists))
-- true
The class of the object, plus all returns of UnitClass available by multi-selection #.
unit.class : "class" | nil
unit.class2 : "CLASS" | nil
Alternative: classLiteral - 2nd return from UnitClass. Upper case class name which is always the same across different localizations. Equivalent of class2.
Example:
if target.class == "Hunter" then
print("Target is a Hunter!")
elseif target.class2 == "WARLOCK" then
print("Target is a Warlock!")
end
Returns true if the unit is in combat.
unit.combat : isInCombat | nil
Example:
if not enemy.combat then
sap:Cast(enemy)
end
Returns true if the unit is an enemy.
unit.enemy : isEnemy | false
Example:
if target.enemy then
-- Target exists and is an enemy - safe to use enemy-specific logic
end
Returns true if the unit is friendly.
unit.friend : isFriend | false
unit.friendly : isFriend | false
Example:
if target.friendly then
-- Target exists and is friendly - safe to use friendly-specific logic
end
The health of the object in percentage.
unit.hp : hpPercentage | 0
Example:
print("Target health percentage: " .. target.hp .. "%")
-- 69
Other HP attributes:
UnitHealth (instead of percentage)UnitHealthMaxThe name of the object.
unit.name : "name" | nil
Example:
print("Target name: " .. target.name)
-- Synqplayer
The level of the object via UnitLevel.
unit.level : level
Example:
if player.level < 60 then
print("Player level is below 60 - still leveling!")
end
The role of the object, either healer, melee, ranged, tank, or pet.
unit.role : role | nil
Example:
if enemy.role == "healer" then
kidneyShot:Cast(enemy)
end
Limitations: Built primarily for use in arena or on party members. For enemies in BG, World PVP, etc. or for friendly players who are not in your group, it is essentially guessing based on buffs, power resources, etc, and could be wrong sometimes.
You can check power, powerMax, or powerPct for any powerType on the unit - just replace power with your powerType alias.
unit.power -- default UnitPower return w/ no powerType specified
unit.energy -- energy
unit.energyMax -- max energy
unit.mana -- mana
unit.manaPct -- mana percentage (mana / manaMax) * 100
unit.comboPoints -- combo points
unit.comboPointsMax -- max combo points
unit.rage -- current rage
unit.astralPowerMax -- works for all powerTypes
Example:
if player.energy < 30 then
-- Player has low energy - pooling energy for upcoming abilities
end
if player.cp >= 5 then
-- Player has maximum combo points - use finisher ability
kidney:Cast()
end
Returns number of buffs the unit has.
unit.buffCount : numBuffs | 0
Returns an array of all buffs the unit has. Each buff is indexed appropriately, and contains all UnitBuff returns.
unit.buffs : { { buffName, ... }, { buffName, ... }, ... } | {}
Example:
for i, buff in ipairs(player.buffs) do
local name, rank, icon, count = unpack(buff)
-- Process each buff - buffs are cached and performant to iterate
end
Returns number of debuffs the unit has.
unit.debuffCount : numDebuffs | 0
Returns an array of all debuffs the unit has. Each debuff is indexed appropriately, and contains all UnitDebuff returns.
unit.debuffs : { { debuffName, ... }, { debuffName, ... }, ... } | {}
If the object is casting, returns the Casting Info from UnitCastingInfo.
unit.casting : "castName" | nil
Returns: string spellName | nil. Every return of UnitCastingInfo can be queried with selection # e.g, unit.casting9.
Example:
-- Check what spell the target is currently casting
print("Target is casting: " .. target.casting)
-- "Kill Command"
-- Get the spell ID of the cast (casting9 is same as castID)
print("Target cast spell ID: " .. target.casting9)
-- 34026
The spellID of the spell being cast by the object, if they are casting.
unit.castID : castID | nil
If the object is casting, returns the SYNQ Object being targeted by that spellcast.
unit.castTarget : castTargetObject | nil
Example:
if enemy.cast == "Chaos Bolt" and enemy.castTarget.isUnit(player) and enemy.castTimeLeft < synq.buffer then
blazingBarrier:Cast()
end
The time remaining on the object's cast, minus latency.
unit.castRemains : castTimeLeft | 0
Example:
-- Interrupt enemy casts that are dangerous
if target.casting and target.castRemains < 0.5 then
intimidation:Cast(target)
end
If the object is channeling, returns the Channeling Info from UnitChannelInfo.
unit.channel : "channelName" | nil
Example:
-- Check what spell the target is currently channeling
print("Target is channeling: " .. target.channel)
-- "Soothing Mist"
Distance between the player and the object, accounting for combat reach and bounding radius.
unit.distance : distance | 9999
Sister Attribute: distanceTo - checks distance from the object to another object
Similar: distanceLiteral - checks distance without accounting for combat reach or bounding radius
Example:
if target.distance > 15 then
charge:Cast(target)
end
Checks if the object is in line of sight of the player.
unit.los : isLoS | false
Sister Function: losOf(otherObject) - checks this between the object and another object
Similar: losLiteral - checks LoS without accounting for LoS-impairing effects like smoke bomb.
Example:
if enemy.los then
print("Enemy has line of sight to player!")
end
Returns true if the player is in melee range of the object.
unit.meleeRange : true | false
Sister Function: meleeRangeOf(otherObject) - Checks if object is in meleeRange of another object
Example:
if enemy.meleeRange then
warbreaker:Cast()
end
Checks if the unit is moving : (speed > 0).
unit.moving : isMoving | false
Example:
if player.moving then
print("Player is currently moving!")
end
The current speed of the object (in yards per second), plus all other returns of GetUnitSpeed available by selection #.
unit.speed : currentSpeed | 0
unit.speed2 : runSpeed | 0
Example:
if target.speed < player.speed then
print("Player is moving faster than the target!")
end
If the object is in breakable crowd control, returns the spellID of that crowd control debuff.
unit.bcc : ccDebuffID | nil
Example:
if target.bcc then
print("Target is in breakable crowd control - avoiding attack!")
end
If the object is in crowd control, returns the spellID of that crowd control debuff.
unit.cc : ccDebuffID | nil
Example:
if healer.cc then
print("Our healer is in crowd control - need help!")
end
If the object is stunned, returns the spellID of the stun debuff.
unit.stunned : stunID | nil
Example:
if player.stun then
print("Player is stunned!")
end
If the object is rooted, returns the spellID of the root debuff.
unit.rooted : rootID | nil
Example:
if player.rooted then
print("Player is rooted!")
end
If the object is silenced, returns the spellID of the silence debuff.
unit.silenced : silenceID | nil
Example:
if player.silence then
print("Player is silenced!")
end
For the most common applications, you don't need to use these. Spell Objects handle literally all immunity checking you would otherwise need to do when attempting to cast a spell, you just have to set your options when initializing the spell object.
Checks if the unit is currently immune to crowd control effects.
unit.immuneCC : true | false
Example:
if target.immuneCC then
print("Target is immune to crowd control!")
end
Checks if the unit is currently immune to magic damage or effects.
unit.immuneMagic : true | false
Example:
if target.immuneMagic then
print("Target is immune to magic damage and effects!")
end
Checks if the unit is currently immune to physical damage or effects.
unit.immunePhysical : true | false
Example:
if target.immunePhysical then
print("Target is immune to physical damage and effects!")
end
The stun DR of the object. 0.25 is quarter DR, 0.5 is half DR, 1 is full DR.
unit.sdr : stunDR | 1
unit.stunDR : stunDR | 1
Example:
if enemy.stunDR >= 0.25 and enemy.stunRemains < 0.4 then
cheapShot:Cast(enemy)
end
The incapacitate DR of the object. 0.25 is quarter DR, 0.5 is half DR, 1 is full DR.
unit.idr : incapacitateDR | 1
unit.incapDR : incapacitateDR | 1
Example:
-- Cast Intimidation when enemy has full DR (no diminishing returns)
if enemy.incapDR == 1 then
intimidation:Cast(enemy)
end
This comprehensive reference covers the most commonly used object attributes in SYNQ development. Attributes provide a clean, intuitive way to access all the information you need about units, players, and objects in your routines.
Key Takeaways:
Next: Learn about Object Functions for performing operations and calculations.