Quantcast

Fix HPS Meter

Joe Vaughan [10-19-16 - 23:07]
Fix HPS Meter

Fix for #1 where the HPS meter was overcounting (massively)
Filename
.gitignore
SVUI_!Core/system/_reports/dps.lua
SVUI_!Core/system/_reports/hps.lua
SVUI_NamePlates/assets/UNIT-AGGRO.blp
diff --git a/.gitignore b/.gitignore
index 72aaefc..93e3fac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 Thumbs.db
 [Dd]ev*/
+*.txt
diff --git a/SVUI_!Core/system/_reports/dps.lua b/SVUI_!Core/system/_reports/dps.lua
index 233dcb2..c1d6aa8 100644
--- a/SVUI_!Core/system/_reports/dps.lua
+++ b/SVUI_!Core/system/_reports/dps.lua
@@ -26,6 +26,14 @@ GET ADDON DATA
 local SV = select(2, ...)
 local L = SV.L
 local Reports = SV.Reports;
+--[[
+##########################################################
+UTILS
+##########################################################
+]]--
+local function round(num, idp)
+  return string.format("%." .. (idp or 0) .. "f", num)
+end
 --[[
 ##########################################################
 DPS STATS
@@ -108,7 +116,7 @@ Report.OnEvent = function(self, event, ...)
 		local DPS = (data.totalamount) / (data.totaltime)
 		self.text:SetFormattedText(TEXT_PATTERN1, HEX_COLOR, DPS)
 		self.TText = "DPS:"
-		self.TText2 = DPS
+		self.TText2 = round(DPS,4)
 	end
 end

@@ -126,7 +134,7 @@ Report.OnClick = function(self, button)
 		local DPS = (data.totalamount) / (data.totaltime)
 		self.text:SetFormattedText(TEXT_PATTERN1, HEX_COLOR, DPS)
 		self.TText = "DPS:"
-		self.TText2 = DPS
+		self.TText2 = round(DPS,4)
 	end
 end

diff --git a/SVUI_!Core/system/_reports/hps.lua b/SVUI_!Core/system/_reports/hps.lua
index 4458613..1e6b5f4 100644
--- a/SVUI_!Core/system/_reports/hps.lua
+++ b/SVUI_!Core/system/_reports/hps.lua
@@ -29,6 +29,14 @@ local L = SV.L
 local Reports = SV.Reports;
 --[[
 ##########################################################
+UTILS
+##########################################################
+]]--
+local function round(num, idp)
+  return string.format("%." .. (idp or 0) .. "f", num)
+end
+--[[
+##########################################################
 HPS STATS
 ##########################################################
 ]]--
@@ -84,7 +92,8 @@ Report.OnEvent = function(self, event, ...)
 			if data.thistime == 0 then data.thistime = newTime end
 			data.lasttime = data.thistime
 			data.totaltime = newTime - data.thistime
-			data.lastamount = data.lastamount + (lastHealAmount - overHeal)
+			-- JV 20161019: For some reason this was lastamount + (...) which meant that it was over counting since lastamount wasn't necessarily 0
+			data.lastamount =  (lastHealAmount - overHeal)
 			data.totalamount = data.totalamount + data.lastamount
 			data.overamount = data.overamount + overHeal
 		end
@@ -100,7 +109,7 @@ Report.OnEvent = function(self, event, ...)
 		local HPS = (data.totalamount) / (data.totaltime)
 		self.text:SetFormattedText(TEXT_PATTERN1, HEX_COLOR, HPS)
 		self.TText = "HPS:"
-		self.TText2 = HPS
+		self.TText2 = round(HPS,4)
 	end
 end

@@ -118,7 +127,7 @@ Report.OnClick = function(self, button)
 		local HPS = (data.totalamount) / (data.totaltime)
 		self.text:SetFormattedText(TEXT_PATTERN1, HEX_COLOR, HPS)
 		self.TText = "HPS:"
-		self.TText2 = HPS
+		self.TText2 = round(HPS,4)
 	end
 end

diff --git a/SVUI_NamePlates/assets/UNIT-AGGRO.blp b/SVUI_NamePlates/assets/UNIT-AGGRO.blp
new file mode 100644
index 0000000..35ad289
Binary files /dev/null and b/SVUI_NamePlates/assets/UNIT-AGGRO.blp differ