Skip to content

Unit and spell state

Thin wrappers over the client's own unit and spell API, with the sharp edges filed off. Every one tolerates being called before the player is in the world.

35 entry points, 35 documented.

Nyx.RefreshClass

lua
Nyx.RefreshClass()

Caches the player class token ("ROGUE") once the world exists. Returns it.

State.lua

Nyx.Spec

lua
Nyx.Spec()

Talent tabs are ordered by the client's spec order (Rogue: 1 Assassination, 2 Combat, 3 Subtlety). The tab with the most points spent is the spec; the name comes from the client so it is already localized.

State.lua

Nyx.Exists

lua
Nyx.Exists(unit)

True when the unit token resolves to something. UnitExists returns 1 or nil, not a boolean.

State.lua

Nyx.TargetValid

lua
Nyx.TargetValid(unit)

True when the unit exists and the player may attack it. Does not check whether it is alive.

State.lua

Nyx.Attackable

lua
Nyx.Attackable(unit)

True when the unit is attackable AND alive. This is the one a rotation wants.

State.lua

Nyx.Health

lua
Nyx.Health(unit)

Current and maximum health of a unit, as two values.

State.lua

Nyx.HealthPercent

lua
Nyx.HealthPercent(unit)

Health as 0-100. Returns 0 rather than nil when the unit is unknown, so callers can compare safely.

State.lua

Nyx.InCombat

lua
Nyx.InCombat()

True while the player is in combat.

State.lua

Nyx.IsBusy

lua
Nyx.IsBusy()

True while the player is casting or channelling. The engine skips a tick rather than clipping a cast.

State.lua

Nyx.Power

lua
Nyx.Power(unit)

Current power of the unit's active type: energy for a rogue, rage for a warrior.

State.lua

Nyx.PowerMax

lua
Nyx.PowerMax(unit)

Maximum power of the active type.

State.lua

Nyx.PowerPercent

lua
Nyx.PowerPercent(unit)

Power as 0-100.

State.lua

Nyx.ComboPoints

lua
Nyx.ComboPoints(unit)

Combo points the player has on the unit (default target). 0 when there are none.

State.lua

Nyx.Position

lua
Nyx.Position(unit)

Position is deliberately absent: 3.3.5a has no UnitPosition, so world-space drawing needs the object manager (Nyx.Engine.*), not the Lua API. Nyx.Position stays defined so callers can branch on nil instead of erroring.

State.lua

Nyx.Distance

lua
Nyx.Distance(first, second)

Straight-line distance between two unit tokens, or nil. Needs UnitPosition, which 3.3.5a lacks - use Nyx.Objects.Distance instead.

State.lua

Nyx.Casting

lua
Nyx.Casting(unit)

Returns spell name, seconds remaining, and whether the cast is immune to interrupts. UnitChannelInfo has one return fewer than UnitCastingInfo (no castID), so the two are unpacked separately.

State.lua

Nyx.TargetCasting

lua
Nyx.TargetCasting(unit)

True when the unit is casting or channelling anything, interruptible or not. Prefer Nyx.Interruptible.

State.lua

Nyx.Interruptible

lua
Nyx.Interruptible(unit)

True only for a cast this client is allowed to interrupt. A rotation that fires Kick at an immune cast just wastes the cooldown.

State.lua

Nyx.Aura

lua
Nyx.Aura(unit, name, filter)

Seconds remaining (0 for an aura with no duration) and stack count, or nil when the aura is absent. filter follows the client's convention: "HELPFUL", "HARMFUL", and "|PLAYER" to restrict to our own casts.

State.lua

Nyx.HasAura

lua
Nyx.HasAura(unit, filter, name)

Legacy argument order (unit, filter, name). New code should use Nyx.Buff / Nyx.Debuff, which also return the time remaining.

State.lua

Nyx.Buff

lua
Nyx.Buff(name, unit)

Seconds remaining and stacks of a helpful aura from anyone, or nil when absent.

State.lua

Nyx.MyBuff

lua
Nyx.MyBuff(name, unit)

As Nyx.Buff, but only auras the player cast.

State.lua

Nyx.Debuff

lua
Nyx.Debuff(name, unit)

Seconds remaining and stacks of a harmful aura from anyone, or nil. Use Nyx.MyDebuff for upkeep.

State.lua

Nyx.MyDebuff

lua
Nyx.MyDebuff(name, unit)

The one that matters for DoT upkeep: somebody else's Rupture on the target must not stop us refreshing our own.

State.lua

Nyx.RefreshSpellbook

lua
Nyx.RefreshSpellbook()

Rescans the spellbook. Called automatically; only needed after learning a spell mid-tick.

State.lua

Nyx.InvalidateSpellbook

lua
Nyx.InvalidateSpellbook()

Marks the spellbook cache stale so the next Nyx.Known rescans.

State.lua

Nyx.Known

lua
Nyx.Known(spell)

True when the spell is in the player's spellbook. GetSpellInfo cannot answer this - it resolves any name the client knows, learned or not.

State.lua

Nyx.CooldownReady

lua
Nyx.CooldownReady(spell)

True when the spell is off cooldown. The global cooldown counts, so this covers the GCD too.

State.lua

Nyx.CooldownRemaining

lua
Nyx.CooldownRemaining(spell)

Seconds until the spell is ready, 0 when it already is.

State.lua

Nyx.InRange

lua
Nyx.InRange(spell, unit)

IsSpellInRange returns 1/0 for spells the client has range data for and nil for most melee abilities. Falling through to nil made every melee entry fail its range check and the rotation never fired; the duel-distance check is the closest stand-in the 3.3.5a API offers (9.9 yd, so slightly generous for a 5 yd ability - the cast simply fails with "out of range" in that window).

State.lua

Nyx.Usable

lua
Nyx.Usable(spell)

True when the client says the spell is usable right now (resources, form, stance).

State.lua

Nyx.CanCast

lua
Nyx.CanCast(spell, onSelf, unit)

Known AND usable AND off cooldown AND in range. What the engine checks before casting. onSelf skips the range test.

State.lua

Nyx.CanCastSelf

lua
Nyx.CanCastSelf(spell)

Nyx.CanCast with the range check skipped, for self-buffs.

State.lua

Nyx.Cast

lua
Nyx.Cast(spell, onSelf)

CastSpellByName's second argument is read as a self-cast flag by some 3.3.5a builds and as a unit token by others. Passing "player" self-casts under both readings, and passing nothing casts at the current target under both, so the bot never uses any other form.

State.lua

Nyx.Facing

lua
Nyx.Facing(unit)

Facing angle of a unit in radians, or nil - 3.3.5a has no UnitFacing, so this is nil in practice. Use Nyx.Objects for facing.

State.lua

API reference generated from source.