-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPerfectRaid_IncomingHeals.lua
More file actions
130 lines (96 loc) · 3.86 KB
/
PerfectRaid_IncomingHeals.lua
File metadata and controls
130 lines (96 loc) · 3.86 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
--[[-------------------------------------------------------------------------
*
* IncomingHeals module for PerfectRaid addon.
*
* Written by: Panoramix
* Version: 1.0
*
---------------------------------------------------------------------------]]
local IncomingHeals = PerfectRaid:NewModule("PerfectRaid-IncomingHeals")
local L = PerfectRaidLocals
local utils, frames
function IncomingHeals:Initialize()
frames = PerfectRaid.frames
utils = PerfectRaid.utils
self:RegisterMessage("DONGLE_PROFILE_CHANGED")
self:RegisterMessage("PERFECTRAID_CONFIG_CHANGED")
end
function IncomingHeals:DONGLE_PROFILE_CHANGED(event, addon, svname, name)
if svname == "PerfectRaidDB" then
IncomingHeals:EnableIncomingHeals(PerfectRaid.db.profile.showincomingheals)
end
end
function IncomingHeals:PERFECTRAID_CONFIG_CHANGED(event, addon, svname, name)
IncomingHeals:EnableIncomingHeals(PerfectRaid.db.profile.showincomingheals)
end
function IncomingHeals:Enable()
IncomingHeals:EnableIncomingHeals(PerfectRaid.db.profile.showincomingheals)
end
function IncomingHeals:EnableIncomingHeals(value)
if value then
self:RegisterEvent("UNIT_HEAL_PREDICTION", "UpdateIncomingHeals")
self:RegisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", "UpdateIncomingHeals")
else
self:UnregisterEvent("UNIT_HEAL_PREDICTION", "UpdateIncomingHeals")
self:UnregisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", "UpdateIncomingHeals")
end
end
function IncomingHeals:ConfigureButton( button )
local inchealbar = CreateFrame("StatusBar", nil, button)
button.incominghealsbar = inchealbar
local absorbbar = CreateFrame("StatusBar", nil, button)
button.absorbbar = absorbbar
end
function IncomingHeals:UpdateButtonLayout( button )
button.incominghealsbar:ClearAllPoints()
button.incominghealsbar:SetPoint("TOPLEFT", button.leftbox, "TOPRIGHT", 0, -1)
button.incominghealsbar:SetPoint("BOTTOMRIGHT", button.rightbox, "BOTTOMLEFT", 0, 1)
button.incominghealsbar:SetStatusBarTexture("Interface\\AddOns\\PerfectRaid\\images\\smooth")
button.incominghealsbar:SetFrameLevel( button.healthbar:GetFrameLevel()-1 )
button.incominghealsbar:SetStatusBarColor( 0.3, 0.5, 0.3 )
button.incominghealsbar:Hide()
button.absorbbar:ClearAllPoints()
button.absorbbar:SetPoint("TOPLEFT", button.leftbox, "TOPRIGHT", 0, -1)
button.absorbbar:SetPoint("BOTTOMRIGHT", button.rightbox, "BOTTOMLEFT", 0, 1)
button.absorbbar:SetStatusBarTexture("Interface\\AddOns\\PerfectRaid\\images\\smooth")
button.absorbbar:SetFrameLevel( button.healthbar:GetFrameLevel()-2 )
button.absorbbar:SetStatusBarColor( 0, 0.651, 0.871 )
button.absorbbar:Hide()
end
function IncomingHeals:UpdateIncomingHeals( event, target )
-- not the right unit
if target == "target" then return end
local health = UnitHealth(target)
local maxhealth = UnitHealthMax(target)
local healinc = UnitGetIncomingHeals(target)
local absorbinc = UnitGetTotalAbsorbs(target)
-- not correct healinc or health
if health == null or healinc == null then return end
local healthincsum = health + healinc
local healthabsorbsum = health + healinc + absorbinc
-- adjust healthsum to maxhealth
if healthincsum > maxhealth then healthincsum = maxhealth end
if healthabsorbsum > maxhealth then healthabsorbsum = maxhealth end
for unit, tbl in pairs(frames) do
if UnitIsUnit( target, unit ) then
for frame in pairs(frames[unit]) do
-- heal inc
if healinc == 0 or health == maxhealth then
frame.incominghealsbar:Hide()
else
frame.incominghealsbar:SetMinMaxValues(0, maxhealth)
frame.incominghealsbar:SetValue(healthincsum)
frame.incominghealsbar:Show()
end
-- absorb inc
if absorbinc == 0 or health == maxhealth then
frame.absorbbar:Hide()
else
frame.absorbbar:SetMinMaxValues(0, maxhealth)
frame.absorbbar:SetValue(healthabsorbsum)
frame.absorbbar:Show()
end
end
end
end
end