Windfury!: huge on-screen show on Windfury procs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
38e942ac1d
commit
ee02d3dd94
3 changed files with 385 additions and 0 deletions
239
Windfury/Windfury.lua
Normal file
239
Windfury/Windfury.lua
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
-- 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
|
||||
7
Windfury/Windfury.toc
Normal file
7
Windfury/Windfury.toc
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
## Interface: 16001
|
||||
## Title: Windfury!
|
||||
## Notes: Every Windfury proc puts on a show.
|
||||
## Version: 1.0
|
||||
## SavedVariables: WindfuryDB
|
||||
|
||||
Windfury.lua
|
||||
139
tests/test_wf.lua
Normal file
139
tests/test_wf.lua
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
-- Runs Windfury.lua against a mock of the WoW API.
|
||||
-- arg[1] = addon file
|
||||
|
||||
local clock = 100
|
||||
function GetTime() return clock end
|
||||
STANDARD_TEXT_FONT = "Fonts\\FRIZQT__.TTF"
|
||||
SOUNDKIT = { RAID_WARNING = 8959, UI_RAID_BOSS_WHISPER_WARNING = 37666 }
|
||||
local sounds = {}
|
||||
function PlaySound(id, channel) sounds[#sounds + 1] = id; assert(channel == "Master") end
|
||||
local fctOn = false
|
||||
C_CVar = { GetCVarBool = function(n) assert(n == "enableFloatingCombatText"); return fctOn end }
|
||||
local secrets = {}
|
||||
function issecretvalue(v) return secrets[v] == true end
|
||||
local spell
|
||||
C_CombatText = { GetCurrentEventInfo = function() return spell end }
|
||||
local printed = {}
|
||||
function print(s) printed[#printed + 1] = s end
|
||||
SlashCmdList = {}
|
||||
|
||||
local frames = {}
|
||||
local function region()
|
||||
local r = { shown = true, alpha = 1, scale = 1 }
|
||||
function r:SetAlpha(a) assert(a >= -1e-9 and a <= 1 + 1e-9, "alpha " .. a); self.alpha = a end
|
||||
function r:SetScale(s) assert(s > 0); self.scale = s end
|
||||
function r:Show() self.shown = true end
|
||||
function r:Hide() self.shown = false end
|
||||
function r:IsShown() return self.shown end
|
||||
function r:SetText(t) self.text = t end
|
||||
local noop = function() end
|
||||
for _, k in ipairs({ "SetPoint", "ClearAllPoints", "SetAllPoints", "SetSize", "SetTexture", "SetColorTexture",
|
||||
"SetBlendMode", "SetVertexColor", "SetRotation", "AddMaskTexture", "SetFont", "SetTextColor",
|
||||
"SetShadowOffset", "SetShadowColor", "SetFrameStrata", "EnableMouse" }) do
|
||||
r[k] = r[k] or noop
|
||||
end
|
||||
return r
|
||||
end
|
||||
function CreateFrame(_, name)
|
||||
local fr = region()
|
||||
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:UnregisterEvent(e) self.events[e] = nil end
|
||||
function fr:CreateTexture() return region() end
|
||||
function fr:CreateMaskTexture() return region() end
|
||||
function fr:CreateFontString() return region() end
|
||||
frames[#frames + 1] = fr
|
||||
if name then _G[name] = fr end
|
||||
return fr
|
||||
end
|
||||
UIParent = region()
|
||||
|
||||
dofile(arg[1])
|
||||
|
||||
local overlay = WindfuryOverlay
|
||||
local events
|
||||
for _, fr in ipairs(frames) do if fr.events.ADDON_LOADED then events = fr end end
|
||||
assert(overlay and events)
|
||||
local function fire(...) events.scripts.OnEvent(events, ...) end
|
||||
local function run(sec)
|
||||
local steps = math.floor(sec / 0.016)
|
||||
for _ = 1, steps do
|
||||
clock = clock + 0.016
|
||||
if overlay.shown then overlay.scripts.OnUpdate(overlay, 0.016) end
|
||||
end
|
||||
end
|
||||
|
||||
fire("ADDON_LOADED", "Other")
|
||||
assert(WindfuryDB == nil)
|
||||
fire("ADDON_LOADED", "Windfury")
|
||||
assert(events.events.COMBAT_TEXT_UPDATE and not events.events.ADDON_LOADED)
|
||||
assert(not overlay.shown)
|
||||
|
||||
-- Other combat text is ignored but logged.
|
||||
fire("COMBAT_TEXT_UPDATE", "DAMAGE")
|
||||
assert(not overlay.shown and WindfuryDB.types.DAMAGE == 1)
|
||||
|
||||
-- A readable Windfury proc fires the show, which hides itself again.
|
||||
spell = "Windfury Weapon"
|
||||
fire("COMBAT_TEXT_UPDATE", "EXTRA_ATTACKS")
|
||||
assert(overlay.shown and WindfuryDB.procs == 1 and #sounds == 1)
|
||||
assert(WindfuryDB.names["Windfury Weapon"] == 1)
|
||||
run(0.5)
|
||||
assert(overlay.shown)
|
||||
run(1)
|
||||
assert(not overlay.shown, "show should end")
|
||||
|
||||
-- A readable non-Windfury extra attack is skipped.
|
||||
spell = "Hand of Justice"
|
||||
fire("COMBAT_TEXT_UPDATE", "EXTRA_ATTACKS")
|
||||
assert(not overlay.shown and WindfuryDB.procs == 1)
|
||||
|
||||
-- A secret name counts (combat hides it).
|
||||
spell = {}
|
||||
secrets[spell] = true
|
||||
fire("COMBAT_TEXT_UPDATE", "EXTRA_ATTACKS")
|
||||
assert(overlay.shown and WindfuryDB.procs == 2)
|
||||
-- A secret event type is ignored without touching it.
|
||||
local st = {}
|
||||
secrets[st] = true
|
||||
fire("COMBAT_TEXT_UPDATE", st)
|
||||
|
||||
-- Procs within the window build a combo; the third adds the second horn.
|
||||
spell = "Windfury Totem"
|
||||
run(0.3)
|
||||
fire("COMBAT_TEXT_UPDATE", "EXTRA_ATTACKS")
|
||||
run(2)
|
||||
assert(not overlay.shown)
|
||||
fire("COMBAT_TEXT_UPDATE", "EXTRA_ATTACKS")
|
||||
assert(#sounds == 6, "sounds " .. #sounds)
|
||||
run(3)
|
||||
-- After a long gap the combo resets: one horn only.
|
||||
run(10)
|
||||
local before = #sounds
|
||||
fire("COMBAT_TEXT_UPDATE", "EXTRA_ATTACKS")
|
||||
assert(#sounds == before + 1)
|
||||
run(2)
|
||||
|
||||
-- Big combos stay in range.
|
||||
for _ = 1, 12 do fire("COMBAT_TEXT_UPDATE", "EXTRA_ATTACKS"); run(0.2) end
|
||||
run(3)
|
||||
assert(not overlay.shown)
|
||||
|
||||
-- Slash command.
|
||||
SlashCmdList.WINDFURY("off")
|
||||
fire("COMBAT_TEXT_UPDATE", "EXTRA_ATTACKS")
|
||||
assert(not overlay.shown)
|
||||
SlashCmdList.WINDFURY(" ON ")
|
||||
SlashCmdList.WINDFURY("sound off")
|
||||
before = #sounds
|
||||
SlashCmdList.WINDFURY("")
|
||||
assert(overlay.shown and #sounds == before, "test show, silent")
|
||||
assert(printed[#printed]:find("Scrolling Combat Text"))
|
||||
fctOn = true
|
||||
SlashCmdList.WINDFURY("sound on")
|
||||
SlashCmdList.WINDFURY("")
|
||||
assert(not printed[#printed]:find("Scrolling Combat Text"))
|
||||
|
||||
print = _G.print
|
||||
io.write("ok\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue