1 local UnitIsConnected = UnitIsConnected;
2 local UnitIsDeadOrGhost = UnitIsDeadOrGhost;
3 local UnitHealthMax = UnitHealthMax;
4 local UnitHealth = UnitHealth;
6 hooksecurefunc("CompactUnitFrame_UpdateStatusText", function(frame)
7 if frame and not frame:IsForbidden() then
8 local frameName = frame:GetName();
9 if frameName and frameName:match("^CompactRaidFrame%d") and frame.unit then
10 -- conditions taken from CompactUnitFrame.lua
11 if not UnitIsConnected(frame.unit) or UnitIsDeadOrGhost(frame.displayedUnit) then
13 elseif (frame.optionTable.healthText == "losthealth") then
14 -- only losthealth option is condensed
15 local healthLost = UnitHealthMax(frame.displayedUnit) - UnitHealth(frame.displayedUnit);
16 if healthLost <= 0 then return end
19 if healthLost > 1200000000 then -- 1.2B
20 local h1b = healthLost / 1000000000;
21 local h100m = (healthLost % 1000000000) / 100000000;
22 prettyHealth = string.format("-%d.%dB", h1b, h100m);
23 elseif healthLost > 1200000 then -- 1.2M
24 prettyHealth = string.format("-%dM", healthLost / 1000000);
25 elseif healthLost > 1000 then -- 1K
26 prettyHealth = string.format("-%dK", healthLost / 1000);
28 prettyHealth = string.format("-%d", healthLost)
31 frame.statusText:SetText(prettyHealth);