Skip to content

Commit cc7f17c

Browse files
committed
Added monk stagger status (added to misc category)
1 parent b511ca7 commit cc7f17c

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

Grid2.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,5 @@ modules\StatusShields.lua
104104
modules\StatusHealAbsorbs.lua
105105
modules\StatusSummon.lua
106106
modules\StatusPhased.lua
107+
modules\StatusStagger.lua
107108
#@end-retail@

Options/modules/statuses/StatusMisc.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ Grid2Options:RegisterStatusOptions("summon", "misc", nil, {
6060
titleIcon = "2470702",
6161
titleIconCoords = {0.5890625, 0.7390625, 0.115625, 0.415625},
6262
})
63+
64+
Grid2Options:RegisterStatusOptions("monk-stagger", "misc", nil, {
65+
color1 = L["High stagger"],
66+
color2 = L["Medium stagger"],
67+
color3 = L["Low stagger"],
68+
width = "full",
69+
titleIcon = "463281",
70+
})

modules/StatusStagger.lua

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
if Grid2.isClassic then return end
2+
3+
-- Stagger monk status, created by Michael
4+
local Stagger = Grid2.statusPrototype:new("monk-stagger")
5+
6+
local Grid2 = Grid2
7+
local fmt = string.format
8+
local UnitClass = UnitClass
9+
local UnitStagger = UnitStagger
10+
local UnitHealthMax = UnitHealthMax
11+
12+
function Stagger:OnEnable()
13+
self:RegisterEvent("UNIT_POWER_UPDATE")
14+
end
15+
16+
function Stagger:OnDisable()
17+
self:UnregisterEvent("UNIT_POWER_UPDATE")
18+
end
19+
20+
function Stagger:UNIT_POWER_UPDATE(_,unit)
21+
local _,class = UnitClass(unit)
22+
if class == 'MONK' then
23+
self:UpdateIndicators(unit)
24+
end
25+
end
26+
27+
function Stagger:GetColor(unit)
28+
local dbx, c = self.dbx
29+
local percent = self:GetPercent(unit)
30+
if percent >= 0.6 then
31+
c = dbx.color1
32+
elseif percent >= 0.3 then
33+
c = dbx.color2
34+
else
35+
c = dbx.color3
36+
end
37+
return c.r, c.g, c.b, c.a
38+
end
39+
40+
function Stagger:GetText(unit)
41+
return fmt("%.1fk", (UnitStagger(unit) or 0) / 1000 )
42+
end
43+
44+
function Stagger:GetPercent(unit)
45+
local m = UnitHealthMax(unit)
46+
return m>0 and (UnitStagger(unit) or 0) / m or 0
47+
end
48+
49+
function Stagger:IsActive(unit)
50+
return (UnitStagger(unit) or 0)>0
51+
end
52+
53+
local function Create(baseKey, dbx)
54+
Grid2:RegisterStatus(Stagger, { "color", "percent", "text" }, baseKey, dbx)
55+
return Stagger
56+
end
57+
58+
Grid2.setupFunc["monk-stagger"] = Create
59+
60+
Grid2:DbSetStatusDefaultValue( "monk-stagger", { type = "monk-stagger", colorCount = 3,
61+
color1 = { r = 1, g = 0, b = 0, a=1 },
62+
color2 = { r = 1, g = 1, b = 0, a=1 },
63+
color3 = { r = 0, g = 1, b = 0, a=1 },
64+
} )
65+

0 commit comments

Comments
 (0)