-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfetti.lua
76 lines (54 loc) · 1.84 KB
/
Confetti.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
-- Check if the player is a Warrior
local _, _, classIndex = UnitClass("player")
if not (classIndex == 1) then
return;
end
if not ConfettiFrame then
local ConfettiFrame = CreateFrame("Frame", "ConfettiFrame", UIParent);
ConfettiFrame.TimeSinceLastUpdate = 0
end
local UpdateInterval = 1.0
local function FormatNumber(amount)
local formatted = amount
local k
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2');
if (k == 0) then
break
end
end
return formatted
end
local function Unit(amount)
-- TODO improve this
return "k";
end
local function OnShow(self)
self.TimeSinceLastUpdate = 0
PlaySound(15881)
end
local function OnUpdate(self, elapsed)
self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;
if (self.TimeSinceLastUpdate > UpdateInterval) then
self:Hide();
self.TimeSinceLastUpdate = 0;
end
end
local function OnEvent(self, event, ...)
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
local type = select(3, ...)
if type == "SPELL_DAMAGE" then
local timeStamp, type, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool, amount = ...
if (sourceName == UnitName("player") and spellName == "Shield Slam") and amount >= ConfettiVariables.Threshold then
ConfettiFrame:Hide();
amount = FormatNumber(amount);
ConfettiText:SetText("Shield Slam Hit for "..amount..""..Unit(amount).." !");
ConfettiFrame:Show();
end
end
end
end
ConfettiFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
ConfettiFrame:SetScript("OnEvent", OnEvent);
ConfettiFrame:SetScript("OnShow", OnShow);
ConfettiFrame:SetScript("OnUpdate", OnUpdate);