wow-addons/Windfury/Windfury.lua
rope ee02d3dd94 Windfury!: huge on-screen show on Windfury procs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 20:17:42 +00:00

239 lines
8 KiB
Lua

-- Windfury!: every Windfury proc slams a huge "WINDFURY!" onto the screen with
-- a lightning flash, a storm glow at the edges, a spinning Windfury icon, a
-- burst of icons and a raid warning horn. Procs close together build a combo
-- that makes it bigger, longer and shakier.
--
-- Forever's combat log is secure-only, so addons can't read it. Extra attacks
-- still reach addons as COMBAT_TEXT_UPDATE("EXTRA_ATTACKS"). Its spell name is
-- a secret value in combat: when it can be read and isn't Windfury (Hand of
-- Justice, Sword Specialization) the proc is skipped, otherwise it counts.
local COMBO_WINDOW = 8 -- seconds between procs that keep a combo going
local SHOW_TIME = 1.3 -- base length of the show, +0.1s per combo step
local PARTICLES = 14
local ICON = "Interface\\Icons\\Spell_Nature_Cyclone"
local SOUND_PROC = (SOUNDKIT and SOUNDKIT.RAID_WARNING) or 8959
local SOUND_COMBO = (SOUNDKIT and SOUNDKIT.UI_RAID_BOSS_WHISPER_WARNING) or 37666
local COMBO_TEXT = {
[2] = "DOUBLE WINDFURY",
[3] = "TRIPLE WINDFURY",
[4] = "QUADRA WINDFURY",
[5] = "WINDFURY RAMPAGE",
[6] = "UNSTOPPABLE",
}
local COMBO_MAX_TEXT = "GODLIKE"
local function secret(v)
return issecretvalue ~= nil and issecretvalue(v)
end
local db
local combo, lastProc = 0, -math.huge
-- Frames --------------------------------------------------------------------
local f = CreateFrame("Frame", "WindfuryOverlay", UIParent)
f:SetFrameStrata("FULLSCREEN_DIALOG")
f:SetAllPoints(UIParent)
f:EnableMouse(false)
f:Hide()
local flash = f:CreateTexture(nil, "BACKGROUND")
flash:SetAllPoints()
flash:SetColorTexture(1, 1, 1, 1)
flash:SetBlendMode("ADD")
flash:SetVertexColor(0.55, 0.85, 1)
local edge = f:CreateTexture(nil, "BORDER")
edge:SetAllPoints()
edge:SetTexture("Interface\\FullScreenTextures\\LowHealth")
edge:SetBlendMode("ADD")
edge:SetVertexColor(0.2, 0.7, 1)
local function roundIcon(parent, layer, size)
local t = parent:CreateTexture(nil, layer)
t:SetTexture(ICON)
t:SetSize(size, size)
t:SetBlendMode("ADD")
local m = parent:CreateMaskTexture()
m:SetTexture("Interface\\CharacterFrame\\TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE")
m:SetAllPoints(t)
t:AddMaskTexture(m)
return t
end
local vortex = roundIcon(f, "ARTWORK", 256)
vortex:SetPoint("CENTER", 0, 120)
local particles = {}
for i = 1, PARTICLES do
local p = roundIcon(f, "ARTWORK", 40)
p.angle = (i / PARTICLES) * 2 * math.pi
particles[i] = p
end
-- The title sits in its own frame so it can be scaled as a whole. Two tinted
-- copies jitter behind it for a glitchy, chromatic look.
local title = CreateFrame("Frame", nil, f)
title:SetSize(1, 1)
local function titleText(r, g, b, a, layer)
local s = title:CreateFontString(nil, layer)
s:SetFont(STANDARD_TEXT_FONT, 72, "THICKOUTLINE")
s:SetText("WINDFURY!")
s:SetTextColor(r, g, b, a)
return s
end
local ghostRed = titleText(1, 0.15, 0.3, 0.7, "ARTWORK")
local ghostCyan = titleText(0.1, 1, 1, 0.7, "ARTWORK")
local main = titleText(0.85, 0.97, 1, 1, "OVERLAY")
main:SetPoint("CENTER")
main:SetShadowOffset(4, -4)
main:SetShadowColor(0, 0.2, 0.6, 1)
local comboText = f:CreateFontString(nil, "OVERLAY")
comboText:SetFont(STANDARD_TEXT_FONT, 32, "THICKOUTLINE")
comboText:SetTextColor(1, 0.85, 0.1)
-- Animation -----------------------------------------------------------------
local t, duration = 0, SHOW_TIME
local function clamp(x) return x < 0 and 0 or (x > 1 and 1 or x) end
local function easeOut(x) x = clamp(x); return 1 - (1 - x) * (1 - x) end
local function jitter(n) return (math.random() * 2 - 1) * n end
local function render()
local shake = (6 + 4 * combo) * (1 - clamp(t / duration))
flash:SetAlpha(0.5 * (1 - clamp(t / 0.25)) + ((t > 0.1 and t < 0.18) and 0.35 or 0))
edge:SetAlpha(0.9 * (1 - clamp(t / duration)))
local v = clamp(t / 0.7)
vortex:SetRotation(-t * 8)
local vs = 128 + 640 * easeOut(v)
vortex:SetSize(vs, vs)
vortex:SetAlpha(0.6 * (1 - v))
local pt = clamp(t / 0.8)
local dist = (350 + 40 * combo) * easeOut(pt)
for _, p in ipairs(particles) do
p:ClearAllPoints()
p:SetPoint("CENTER", f, "CENTER", math.cos(p.angle) * dist, 120 + math.sin(p.angle) * dist)
p:SetRotation(t * 10)
p:SetAlpha(1 - pt)
end
-- Slam in, hold with a throb and shake, then blow out.
local scale, alpha
local outStart = duration - 0.3
if t < 0.12 then
local x = 1 - t / 0.12
scale, alpha = 1 + 3 * x * x, 1 - x
elseif t < outStart then
scale, alpha = 1 + 0.06 * math.sin(t * 30), 1
else
local x = clamp((t - outStart) / 0.3)
scale, alpha = 1 + 0.8 * x, 1 - x
end
scale = scale * (1 + 0.08 * math.min(combo - 1, 5))
title:SetScale(scale)
title:SetAlpha(alpha)
title:ClearAllPoints()
title:SetPoint("CENTER", f, "CENTER", jitter(shake) / scale, (120 + jitter(shake)) / scale)
local g = 3 + combo
ghostRed:ClearAllPoints()
ghostRed:SetPoint("CENTER", jitter(g), jitter(g))
ghostCyan:ClearAllPoints()
ghostCyan:SetPoint("CENTER", jitter(g), jitter(g))
comboText:SetAlpha(alpha)
comboText:ClearAllPoints()
comboText:SetPoint("CENTER", f, "CENTER", jitter(shake / 2), 40 + jitter(shake / 2))
end
f:SetScript("OnUpdate", function(self, elapsed)
t = t + elapsed
if t >= duration then
self:Hide()
return
end
render()
end)
local function play()
local now = GetTime()
combo = (now - lastProc <= COMBO_WINDOW) and combo + 1 or 1
lastProc = now
t = 0
duration = SHOW_TIME + 0.1 * math.min(combo - 1, 5)
if combo >= 2 then
comboText:SetText(string.format("%s x%d", COMBO_TEXT[combo] or COMBO_MAX_TEXT, combo))
comboText:Show()
else
comboText:Hide()
end
render()
f:Show()
if db.sound then
PlaySound(SOUND_PROC, "Master")
if combo >= 3 then PlaySound(SOUND_COMBO, "Master") end
end
end
-- Events --------------------------------------------------------------------
local function isWindfury(name)
if name == nil or secret(name) then return true end
db.names[name] = (db.names[name] or 0) + 1
return name:find("Windfury") ~= nil
end
local events = CreateFrame("Frame")
events:RegisterEvent("ADDON_LOADED")
events:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" then
if arg1 ~= "Windfury" then return end
WindfuryDB = WindfuryDB or {}
db = WindfuryDB
if db.enabled == nil then db.enabled = true end
if db.sound == nil then db.sound = true end
db.procs = db.procs or 0
-- Every combat text type seen, and readable extra attack names, so a
-- silent addon can be diagnosed from SavedVariables.
db.types = db.types or {}
db.names = db.names or {}
self:UnregisterEvent("ADDON_LOADED")
self:RegisterEvent("COMBAT_TEXT_UPDATE")
return
end
if arg1 == nil or secret(arg1) then return end
db.types[arg1] = (db.types[arg1] or 0) + 1
if arg1 ~= "EXTRA_ATTACKS" or not db.enabled then return end
if not isWindfury((C_CombatText.GetCurrentEventInfo())) then return end
db.procs = db.procs + 1
play()
end)
-- Slash command -------------------------------------------------------------
local function say(msg) print("|cff66ccffWindfury!|r " .. msg) end
SLASH_WINDFURY1 = "/wf"
SlashCmdList.WINDFURY = function(msg)
msg = (msg or ""):lower():gsub("^%s+", ""):gsub("%s+$", "")
if msg == "on" or msg == "off" then
db.enabled = msg == "on"
say(db.enabled and "on." or "off.")
elseif msg == "sound on" or msg == "sound off" then
db.sound = msg == "sound on"
say(db.sound and "sound on." or "sound off.")
else
play()
say(string.format("%s, sound %s, %d procs so far. /wf on|off, /wf sound on|off",
db.enabled and "on" or "off", db.sound and "on" or "off", db.procs))
if not C_CVar.GetCVarBool("enableFloatingCombatText") then
say("If procs never show, turn on Options > Combat > Scrolling Combat Text.")
end
end
end