diff --git a/Windfury/Windfury.lua b/Windfury/Windfury.lua index 5a4c386..1e6f486 100644 --- a/Windfury/Windfury.lua +++ b/Windfury/Windfury.lua @@ -215,6 +215,47 @@ events:SetScript("OnEvent", function(self, event, arg1) play() end) +-- Debug log (temporary) ----------------------------------------------------- +-- COMBAT_TEXT_UPDATE never saw a proc in game. Log the player's own casts and +-- buffs gained, by readable name, to find another event that carries it. +-- A cast named "Windfury Attack" fires the show right away. + +local function count(t, key) t[key] = (t[key] or 0) + 1 end +local function readable(v) return v ~= nil and not secret(v) end + +local debug = CreateFrame("Frame") +debug:RegisterEvent("PLAYER_LOGIN") +debug:SetScript("OnEvent", function(self, event, unit, a2, a3) + if event == "PLAYER_LOGIN" then + db.debug = { fct = C_CVar.GetCVarBool("enableFloatingCombatText"), casts = {}, auras = {} } + self:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", "player") + self:RegisterUnitEvent("UNIT_AURA", "player") + return + end + if event == "UNIT_SPELLCAST_SUCCEEDED" then + local id = a3 + if not readable(id) then count(db.debug.casts, "secret"); return end + local name = C_Spell.GetSpellName(id) + if not readable(name) then name = "?" end + count(db.debug.casts, id .. " " .. name) + if db.enabled and name == "Windfury Attack" then + db.procs = db.procs + 1 + play() + end + elseif event == "UNIT_AURA" then + local info = a2 + if not readable(info) or not info.addedAuras then return end + for _, aura in ipairs(info.addedAuras) do + local id, name = aura.spellId, aura.name + if readable(id) and readable(name) then + count(db.debug.auras, id .. " " .. name) + else + count(db.debug.auras, "secret") + end + end + end +end) + -- Slash command ------------------------------------------------------------- local function say(msg) print("|cff66ccffWindfury!|r " .. msg) end diff --git a/tests/test_wf.lua b/tests/test_wf.lua index 0912327..228774a 100644 --- a/tests/test_wf.lua +++ b/tests/test_wf.lua @@ -39,6 +39,7 @@ function CreateFrame(_, name) fr.scripts, fr.events = {}, {} function fr:SetScript(k, fn) self.scripts[k] = fn end function fr:RegisterEvent(e) self.events[e] = true end + function fr:RegisterUnitEvent(e) self.events[e] = true end function fr:UnregisterEvent(e) self.events[e] = nil end function fr:CreateTexture() return region() end function fr:CreateMaskTexture() return region() end @@ -135,5 +136,22 @@ SlashCmdList.WINDFURY("sound on") SlashCmdList.WINDFURY("") assert(not printed[#printed]:find("Scrolling Combat Text")) +-- Debug log: casts and auras by name; a "Windfury Attack" cast fires the show. +C_Spell = { GetSpellName = function(id) return ({ [8517] = "Windfury Attack", [133] = "Fireball" })[id] end } +local dbg +for _, fr in ipairs(frames) do if fr.events.PLAYER_LOGIN then dbg = fr end end +dbg.scripts.OnEvent(dbg, "PLAYER_LOGIN") +assert(WindfuryDB.debug.fct == true) +run(5) +local procs = WindfuryDB.procs +dbg.scripts.OnEvent(dbg, "UNIT_SPELLCAST_SUCCEEDED", "player", "guid", 133) +assert(not overlay.shown and WindfuryDB.debug.casts["133 Fireball"] == 1) +dbg.scripts.OnEvent(dbg, "UNIT_SPELLCAST_SUCCEEDED", "player", "guid", 8517) +assert(overlay.shown and WindfuryDB.procs == procs + 1) +dbg.scripts.OnEvent(dbg, "UNIT_SPELLCAST_SUCCEEDED", "player", "guid", st) +assert(WindfuryDB.debug.casts.secret == 1) +dbg.scripts.OnEvent(dbg, "UNIT_AURA", "player", { addedAuras = { { spellId = 1, name = "Flurry" }, { spellId = st, name = "x" } } }) +assert(WindfuryDB.debug.auras["1 Flurry"] == 1 and WindfuryDB.debug.auras.secret == 1) + print = _G.print io.write("ok\n")