Quantcast
WoWInterface - View Single Post - UNIT_HEALTH vs UNIT_HEALTH_FREQUENT vs combat log parsing
View Single Post
02-09-19, 08:43 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,292
Code:
local frame = CreateFrame("Frame");
frame:RegisterUnitEvent("UNIT_HEALTH", "player");
frame:RegisterUnitEvent("UNIT_MAXHEALTH", "player");
frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", "player");
frame.Count = 0
frame.Health = 0
frame:SetScript("OnEvent", function(self, event, unit)
	if self.Health == 0 then
		self.Health = UnitHealth("player")
	elseif self.Health ~= UnitHealth("player") then
		self:UnregisterAllEvents()
		return
	end
	if event == "UNIT_HEALTH" then
		self.Count = self.Count + 1
		print(event, self.Count, unit, UnitHealth("player"), UnitHealthMax("player"));
	end
end);
Using this, if something attacks me, the printed count is 1. If I /reload, get attacked then the count is 2. /reload again, get attacked the count is 3 etc.
Logout/Login and the count resets.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 02-09-19 at 11:26 PM.
  Reply With Quote