LibInstantHealth

LibInstantHealth

918 Downloads

About

Library for instant health updates via combat log. Only group members; other units do not receive instant updates.

Because of technical limitations melee auto attack damage is not instant.

Usage

local InstantHealth = LibStub("LibInstantHealth-1.0")

Use InstantHealth.UnitHealth(unit) where you would use UnitHealth(unit), InstantHealth.UnitHealthMax(unit) where you would use UnitHealthMax(unit), and instead of

frame:SetScript("OnEvent", onEvent)

frame:RegisterEvent(event)

frame:RegisterUnitEvent(event, unit1, unit2)

frame:UnregisterEvent(event)

register the events like this

InstantHealth.RegisterCallback(frame, event, onEvent, frame)

InstantHealth.RegisterCallback(frame, event, function (self, event, unit) if unit == unit1 or unit == unit2 then onEvent(self, event, unit) end end, frame)

InstantHealth.UnregisterCallback(frame, event)

where event is "UNIT_HEALTH", "UNIT_MAXHEALTH", or "UNIT_HEALTH_FREQUENT".

UNIT_HEALTH, UNIT_MAXHEALTH and UNIT_HEALTH_FREQUENT events fire when they normally would; additionally, UNIT_HEALTH_FREQUENT is fired when the health is updated via combat log events.

Because of the potentially large number of UNIT_HEALTH_FREQUENT events, it is recommended to update health bars etc. in OnUpdate if necessary, and not on each UNIT_HEALTH_FREQUENT event.

It is not recommended to use InstantHealth.UnitHealth(unit) and InstantHealth.UnitHealthMax(unit) within event handlers of Blizzard's UNIT_HEALTH, UNIT_MAXHEALTH, UNIT_HEALTH_FREQUENT, and COMBAT_LOG_EVENT/COMBAT_LOG_EVENT_UNFILTERED.