Files
pfUI/modules/innervatecall.lua
Brues bd2dc15c05 Read Innervate's combat log values from the event's arguments
pfUI.events forwards every COMBAT_LOG_EVENT_UNFILTERED value to its
callbacks, so the handler takes them as parameters instead of calling
CombatLogGetCurrentEventInfo.
2026-11-14 23:38:05 -06:00

71 lines
2.2 KiB
Lua

-- Innervate Callout Module
-- Announces Innervate casts via raid/party/battleground chat
-- Listens to COMBAT_LOG_EVENT_UNFILTERED - zero polling, pure event-driven
pfUI:RegisterModule("innervatecall", function ()
-- Only load for druids
if UnitClassBase("player") ~= "DRUID" then return end
local INNERVATE_SPELLID = 29166
local GCD_DURATION = 1.5
-- Determine chat channel based on group context
local function GetAnnounceChannel()
local _, instanceType = IsInInstance()
if instanceType == "pvp" then
return "BATTLEGROUND"
end
if IsInRaid() then
return "RAID"
end
if IsInGroup() then
return "PARTY"
end
return nil
end
-- Set on our cast, cleared once the "ready" timer is scheduled
local pending = false
-- Schedule the "ready" announcement once Innervate's own cooldown is in
-- the spell history. Until then GetSpellCooldown reports only the GCD,
-- which has no isOnGCD flag here, so tell them apart by duration.
local function ScheduleReady()
local cd = C_Spell.GetSpellCooldown(INNERVATE_SPELLID)
if not cd or cd.duration <= GCD_DURATION then return end
pending = false
C_Timer.After(cd.startTime + cd.duration - GetTime(), function()
local ch = GetAnnounceChannel()
if ch then
SendChatMessage(T[">> Innervate is ready <<"], ch)
end
end)
end
pfUI.events:RegisterFrameEventAndCallback("SPELL_UPDATE_COOLDOWN", function()
if pending then ScheduleReady() end
end)
-- the callback takes the owner, then the event's values
pfUI.events:RegisterFrameEventAndCallback("COMBAT_LOG_EVENT_UNFILTERED", function(_, _, subevent, _, sourceGUID, _, _, _, _, destName, _, _, spellId)
-- Innervate is instant, so it logs SPELL_CAST_SUCCESS with its target
if subevent ~= "SPELL_CAST_SUCCESS" or spellId ~= INNERVATE_SPELLID then return end
-- Only announce our own casts
if not IsPlayerGuid(sourceGUID) then return end
-- Determine channel
local channel = GetAnnounceChannel()
if not channel then return end -- solo, no announcement
SendChatMessage(format(T[">> Innervate cast on %s <<"], destName or UNKNOWN), channel)
pending = true
ScheduleReady()
end)
end)