- if healthLost > 0 then
- frame.statusText:SetText(prettyHealth);
- frame.statusText:Show();
- else
- frame.statusText:Hide();
- end
+hooksecurefunc("CompactUnitFrame_UpdateStatusText", function(frame)
+ if frame and not frame:IsForbidden() then
+ local frameName = frame:GetName();
+ if frameName and frameName:match("^CompactRaidFrame%d") and frame.unit then
+ -- conditions taken from CompactUnitFrame.lua
+ if not UnitIsConnected(frame.unit) or UnitIsDeadOrGhost(frame.displayedUnit) then
+ return;
+ elseif (frame.optionTable.healthText == "losthealth") then
+ -- only losthealth option is condensed
+ local healthLost = UnitHealthMax(frame.displayedUnit) - UnitHealth(frame.displayedUnit);
+ if healthLost <= 0 then return end
+
+ local prettyHealth;
+ if healthLost > 1200000000 then -- 1.2B
+ local h1b = healthLost / 1000000000;
+ local h100m = (healthLost % 1000000000) / 100000000;
+ prettyHealth = string.format("-%d.%dB", h1b, h100m);
+ elseif healthLost > 1200000 then -- 1.2M
+ prettyHealth = string.format("-%dM", healthLost / 1000000);
+ elseif healthLost > 1000 then -- 1K
+ prettyHealth = string.format("-%dK", healthLost / 1000);
+ else
+ prettyHealth = string.format("-%d", healthLost)