AgentSkillsCN

wow-api-combat

WoW Retail战斗、伤害计量器、威胁判定、失控判定、战斗文本、战斗音效提醒、秘密数值,以及观战者API的完整参考。涵盖12.0.0版本中移除的战斗日志(CLEU不再对插件开放)、C_DamageMeter内置伤害计量器、C_Secrets秘密谓词、C_CurveUtil/C_DurationUtil用于秘密数值的可视化、C_LossOfControl、C_CombatText、C_CombatAudioAlert、ENCOUNTER_STATE_CHANGED事件,以及威胁判定函数与全新的COMBAT_LOG_MESSAGE事件。当您需要处理战斗数据、伤害计量器、威胁判定、失控判定、战斗文本、遭遇事件,或任何与战斗相关的插件功能时,此参考手册将为您提供权威指导。

SKILL.md
--- frontmatter
name: wow-api-combat
description: "Complete reference for WoW Retail Combat, Damage Meter, Threat, Loss of Control, Combat Text, Combat Audio Alert, Secret Values, and Spectator APIs. Covers the 12.0.0 combat log removal (CLEU no longer available to addons), C_DamageMeter built-in damage meter, C_Secrets secret predicates, C_CurveUtil/C_DurationUtil for secret value visualization, C_LossOfControl, C_CombatText, C_CombatAudioAlert, ENCOUNTER_STATE_CHANGED, threat functions, and the new COMBAT_LOG_MESSAGE event. Use when working with combat data, damage meters, threat, loss of control, combat text, encounter events, or any combat-related addon functionality."

Combat API (Retail — Patch 12.0.0)

Comprehensive reference for all combat-related APIs in WoW Retail. Critical: The combat log system was fundamentally changed in 12.0.0. COMBAT_LOG_EVENT_UNFILTERED is no longer available to addons.

Source: https://warcraft.wiki.gg/wiki/World_of_Warcraft_API Current as of: Patch 12.0.0 (Build 65655) — January 28, 2026 Scope: Retail only.

CRITICAL: Combat Log Changes in 12.0.0

COMBAT_LOG_EVENT_UNFILTERED (CLEU) is NO LONGER available to addons.

  • CombatLogGetCurrentEventInfo() is unavailable to tainted (addon) code
  • The old COMBAT_LOG_EVENT event is also unavailable
  • Combat log chat tab messages are now KStrings (unparseable escape sequences)
  • Addons like damage meters must use C_DamageMeter or the built-in system
  • A new COMBAT_LOG_EVENT_INTERNAL_UNFILTERED exists but is restricted to Blizzard code

New Combat Log Events (Addon-Facing)

EventDescription
COMBAT_LOG_MESSAGEFormatted combat log messages (display text only)
COMBAT_LOG_ENTRIES_CLEAREDCombat log entries cleared
COMBAT_LOG_APPLY_FILTER_SETTINGSFilter settings changed
COMBAT_LOG_REFILTER_ENTRIESEntries need refiltering
COMBAT_LOG_MESSAGE_LIMIT_CHANGEDMessage limit changed

Scope

This skill covers:

  • Combat Log — New 12.0.0 combat log system, COMBAT_LOG_MESSAGE
  • C_DamageMeter — Built-in damage/healing meter system
  • Threat — UnitThreatSituation, UnitDetailedThreatSituation
  • C_LossOfControl — Loss of control tracking
  • C_CombatText — Floating combat text
  • C_CombatAudioAlert — Combat audio alert system (accessibility)
  • C_Secrets / C_CurveUtil / C_DurationUtil — Secret value handling for combat data
  • Encounter Events — ENCOUNTER_STATE_CHANGED, ENCOUNTER_WARNING, timeline events
  • Spectator/Commentator — C_Commentator for spectator mode

C_DamageMeter — Built-in Damage Meter

New in 12.0.0. Provides official damage/healing meter data without needing combat log parsing.

Functions

FunctionReturnsDescription
C_DamageMeter.GetCurrentSessionID()sessionIDCurrent combat session
C_DamageMeter.GetSessions()sessionsAll available sessions
C_DamageMeter.GetSessionInfo(sessionID)sessionInfoSession details
C_DamageMeter.GetPlayerData(sessionID, unitGUID)playerDataPlayer's damage/healing
C_DamageMeter.GetPartyData(sessionID)partyDataAll party/raid data
C_DamageMeter.ResetSessions()Clear all sessions

Events

EventDescription
DAMAGE_METER_COMBAT_SESSION_UPDATEDSession data updated
DAMAGE_METER_CURRENT_SESSION_UPDATEDCurrent session changed
DAMAGE_METER_RESETSessions cleared

Pattern: Reading Damage Meter Data

lua
local frame = CreateFrame("Frame")
frame:RegisterEvent("DAMAGE_METER_COMBAT_SESSION_UPDATED")
frame:SetScript("OnEvent", function(self, event)
    local sessionID = C_DamageMeter.GetCurrentSessionID()
    if sessionID then
        local partyData = C_DamageMeter.GetPartyData(sessionID)
        -- partyData contains per-player damage/healing totals
    end
end)

Threat API

Threat Functions

FunctionReturnsDescription
UnitThreatSituation(unit [, target])statusThreat status (0-3)
UnitDetailedThreatSituation(unit, target)isTanking, status, scaledPercent, rawPercent, threatValueDetailed threat info
UnitThreatPercentageOfLead(unit, target)percentThreat lead percentage

Threat Status Values

ValueMeaning
0Not on threat table
1On threat table, not tanking, not highest
2On threat table, not tanking, highest
3Tanking (highest threat with aggro)
nilUnit doesn't exist or has no threat table

Note: In 12.0.0 instances, threat values for non-player units may be secret values. Pass them directly to UI widgets.


C_LossOfControl

Tracks crowd control effects on the player.

FunctionReturnsDescription
C_LossOfControl.GetActiveLossOfControlData(index)dataActive CC effect data
C_LossOfControl.GetActiveLossOfControlDataByUnit(unit, index)dataCC data for unit
C_LossOfControl.GetActiveLossOfControlDataCount()countNumber of active CC effects
C_LossOfControl.GetActiveLossOfControlDataCountByUnit(unit)countCC count for unit

Loss of Control Data Fields

  • locType — Type of CC (STUN, FEAR, SILENCE, etc.)
  • spellID — Spell causing the CC
  • displayText — Localized display text
  • iconTexture — Spell icon
  • startTime — When CC started
  • timeRemaining — Duration remaining (may be DurationObject in 12.0.0)
  • duration — Total duration
  • lockoutSchool — School lockout (for SCHOOL_INTERRUPT type)
  • priority — Display priority

Events

EventDescription
LOSS_OF_CONTROL_ADDEDNew CC effect applied
LOSS_OF_CONTROL_UPDATECC effect updated

C_CombatText — Floating Combat Text

FunctionReturnsDescription
C_CombatText.IsCombatTextEnabled()enabledFCT enabled?

Combat Text CVars

CVarDescription
enableFloatingCombatTextEnable/disable FCT
floatingCombatTextCombatDamageShow damage
floatingCombatTextCombatHealingShow healing
floatingCombatTextCombatDamageStyleDamage display style

C_CombatAudioAlert — Combat Audio Alerts

New accessibility system providing audio cues for combat events. Replaces some functionality that previously required combat log parsing.

FunctionReturnsDescription
C_CombatAudioAlert.IsEnabled()enabledAudio alerts enabled?
C_CombatAudioAlert.SetEnabled(enabled)Enable/disable

Secret Value Handling for Combat Data

C_Secrets — Secret Predicates

FunctionReturnsDescription
C_Secrets.ShouldUnitHealthBeSecret(unit)isSecretIs health secret for this unit?
C_Secrets.ShouldUnitPowerBeSecret(unit [, powerType])isSecretIs power secret?
C_Secrets.ShouldUnitPowerMaxBeSecret(unit [, powerType])isSecretIs max power secret?
C_Secrets.ShouldUnitSpellCastBeSecret(unit, spellIdentifier)isSpellCastSecretIs spell cast secret?
C_Secrets.ShouldUnitSpellCastingBeSecret(unit)isSpellCastingSecretIs all casting secret?

C_CurveUtil — Curves for Secret Values

Since addons cannot do math on secret values, Curves allow mapping secret numbers to visual output.

FunctionReturnsDescription
C_CurveUtil.CreateCurve()curveObjectCreate a numeric curve
C_CurveUtil.CreateColorCurve()colorCurveObjectCreate a color curve

Pattern: Health-to-Color Without Inspecting Value

lua
-- Create a color curve: green at 100% → red at 0%
local colorCurve = C_CurveUtil.CreateColorCurve()
-- Configure curve points (green → yellow → red)

local healthBar = CreateFrame("StatusBar", nil, parent)
local hp = UnitHealth(unit)         -- SECRET in instances
local maxHp = UnitHealthMax(unit)   -- SECRET in instances
healthBar:SetMinMaxValues(0, maxHp) -- widgets accept secrets
healthBar:SetValue(hp)              -- widgets accept secrets
-- Color is set by curve without addon seeing the actual number

C_DurationUtil — Duration Objects

FunctionReturnsDescription
C_DurationUtil.CreateDuration()durationObjectCreate a duration object
lua
-- Use DurationObject for cooldown display
local cooldown = CreateFrame("Cooldown", nil, parent, "CooldownFrameTemplate")
local duration = C_DurationUtil.CreateDuration()
cooldown:SetCooldownFromDurationObject(duration)

Encounter Events

New in 12.0.0, these replace addon combat log parsing for encounter state tracking.

EventDescription
ENCOUNTER_STATE_CHANGEDEncounter state changed (pull, wipe, kill)
ENCOUNTER_WARNINGBuilt-in encounter warning system
ENCOUNTER_TIMELINE_EVENT_STARTTimeline event started
ENCOUNTER_TIMELINE_EVENT_UPDATETimeline event updated
ENCOUNTER_TIMELINE_EVENT_ENDTimeline event ended

Other Combat Events

EventDescription
PLAYER_REGEN_DISABLEDEntering combat
PLAYER_REGEN_ENABLEDLeaving combat
PLAYER_ENTER_COMBATPlayer starts auto-attack
PLAYER_LEAVE_COMBATPlayer stops auto-attack
UNIT_COMBATUnit took/dealt damage or healing
UNIT_THREAT_SITUATION_UPDATEThreat status changed
UNIT_THREAT_LIST_UPDATEThreat table updated
PLAYER_DEADPlayer died
PLAYER_ALIVEPlayer released spirit
PLAYER_UNGHOSTPlayer resurrected

Commentator / Spectator API

C_Commentator provides spectator mode functionality for esports viewing.

Key Functions

FunctionReturnsDescription
C_Commentator.IsSpectating()isSpectatingIn spectator mode?
C_Commentator.GetAllPlayerData(teamIndex)playerDataAll player data for team
C_Commentator.GetPlayerData(teamIndex, playerIndex)dataSpecific player data
C_Commentator.GetTeamColorAndName(teamIndex)color, nameTeam info
C_Commentator.GetMatchDuration()durationMatch elapsed time
C_Commentator.StartWargame(...)Start a wargame
C_Commentator.UpdatePlayerInfo()Refresh player data

Common Patterns

Check Combat State

lua
local function IsInCombat()
    return UnitAffectingCombat("player")
end

-- Or use the lockdown check for secure frame operations
if InCombatLockdown() then
    print("In combat lockdown — restricted operations blocked")
end

Threat-Based Nameplate Coloring

lua
-- Note: In 12.0.0 instances, threat values may be secret
local status = UnitThreatSituation("player", "target")
if not issecretvalue(status) then
    if status == 3 then
        -- Tanking — show red
    elseif status == 2 then
        -- Pulling aggro — show orange
    else
        -- Safe — show green
    end
end

Loss of Control Display

lua
local frame = CreateFrame("Frame")
frame:RegisterEvent("LOSS_OF_CONTROL_ADDED")
frame:RegisterEvent("LOSS_OF_CONTROL_UPDATE")
frame:SetScript("OnEvent", function()
    local count = C_LossOfControl.GetActiveLossOfControlDataCount()
    for i = 1, count do
        local data = C_LossOfControl.GetActiveLossOfControlData(i)
        if data then
            print(data.displayText, data.timeRemaining)
        end
    end
end)

Gotchas & Restrictions

  1. CLEU is GONE — Do NOT register for COMBAT_LOG_EVENT_UNFILTERED. It will not fire for addon code in 12.0.0.
  2. No combat log parsingCombatLogGetCurrentEventInfo() is unavailable to tainted code.
  3. KString chat messages — Combat log chat tab output is now KStrings that cannot be parsed.
  4. Health is secretUnitHealth() returns secret values in instances. Pass directly to StatusBar:SetValue().
  5. Use DurationObjects — Don't do manual cooldown math. Use C_DurationUtil.CreateDuration() and Cooldown:SetCooldownFromDurationObject().
  6. Built-in damage meter — Use C_DamageMeter for damage/healing data instead of parsing combat events.
  7. SendAddonMessage blocked — Cannot send addon messages in instances. Boss mod addons must use new encounter event patterns.
  8. Unit identity restrictedUnitName(), UnitClass() may return secrets for enemy units in instances during combat.
  9. Threat in instances — Threat values may be secret. Pass to widgets directly; don't branch on them.
  10. Design philosophy — Addons should NOT provide competitive advantage in combat. Blizzard provides built-in replacements for most restricted functionality.