Quantcast

Added absorbbar below the health and incoming healbar. Color dark yellow. The absorb bar will show the health that will be absorbed. The absorb bar has the length of the current health + heal inc + absorb bar, up to the max health.

F. Dekker [03-16-13 - 12:58]
Added absorbbar below the health and incoming healbar. Color dark yellow. The absorb bar will show the health that will be absorbed. The absorb bar has the length of the current health + heal inc + absorb bar, up to the max health.
Filename
PerfectRaid_IncomingHeals.lua
diff --git a/PerfectRaid_IncomingHeals.lua b/PerfectRaid_IncomingHeals.lua
index 2729dde..524c34c 100644
--- a/PerfectRaid_IncomingHeals.lua
+++ b/PerfectRaid_IncomingHeals.lua
@@ -40,17 +40,21 @@ 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_HEAL_PREDICTION", "UpdateIncomingHeals")
+		self:UnregisterEvent("UNIT_ABSORB_AMOUNT_CHANGED", "UpdateIncomingHeals")
 	end
 end


 function IncomingHeals:ConfigureButton( button )

-	local bar = CreateFrame("StatusBar", nil, button)
-	button.incominghealsbar = bar
+	local inchealbar = CreateFrame("StatusBar", nil, button)
+	button.incominghealsbar = inchealbar

+	local absorbbar = CreateFrame("StatusBar", nil, button)
+	button.absorbbar = absorbbar
 end

 function IncomingHeals:UpdateButtonLayout( button )
@@ -63,6 +67,14 @@ function IncomingHeals:UpdateButtonLayout( button )
 	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.83, 0.45, 0.09 )
+	button.absorbbar:Hide()
+
 end

 function IncomingHeals:UpdateIncomingHeals( event, target )
@@ -73,14 +85,17 @@ function IncomingHeals:UpdateIncomingHeals( event, target )
 	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 healthsum = health + healinc
+	local healthincsum = health + healinc
+	local healthabsorbsum = health + healinc + absorbinc

 	-- adjust healthsum to maxhealth
-	if healthsum > maxhealth then healthsum = maxhealth end
+	if healthincsum > maxhealth then healthincsum = maxhealth end
+	if healthabsorbsum > maxhealth then healthabsorbsum = maxhealth end

 	for unit, tbl in pairs(frames) do

@@ -88,13 +103,24 @@ function IncomingHeals:UpdateIncomingHeals( event, target )

 			for frame in pairs(frames[unit]) do

-				if healinc == 0 or health == maxhealth then
+				-- heal inc
+				if healinc == 0 or health == maxhealth then
 					frame.incominghealsbar:Hide()
 				else
 					frame.incominghealsbar:SetMinMaxValues(0, maxhealth)
-					frame.incominghealsbar:SetValue(healthsum)
+					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

 			break