From 85823fc30a32d3ea678ba82dc7a0a5d63ceed7f5 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 11 Apr 2020 16:31:42 +0200 Subject: [PATCH] unitframes: use libhealth values if existing --- api/unitframes.lua | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 4ded82a9..7c370afc 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -1964,10 +1964,15 @@ function pfUI.uf:GetStatusValue(unit, pos) config = "unit" end + local mp, mpmax = UnitMana(unitstr), UnitManaMax(unitstr) local hp, hpmax = UnitHealth(unitstr), UnitHealthMax(unitstr) - if unit.label == "target" and (MobHealth3 or MobHealthFrame) and MobHealth_GetTargetCurHP() then - hp, hpmax = MobHealth_GetTargetCurHP(), MobHealth_GetTargetMaxHP() + local rhp, rhpmax = hp, hpmax + + if pfUI.libhealth and pfUI.libhealth.enabled then + rhp, rhpmax = pfUI.libhealth:GetUnitHealth(unitstr) + elseif unit.label == "target" and (MobHealth3 or MobHealthFrame) and MobHealth_GetTargetCurHP() then + rhp, rhpmax = MobHealth_GetTargetCurHP(), MobHealth_GetTargetMaxHP() end if config == "unit" then @@ -1985,13 +1990,13 @@ function pfUI.uf:GetStatusValue(unit, pos) -- health elseif config == "health" then - return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) + return unit:GetColor("health") .. pfUI.api.Abbreviate(rhp) elseif config == "healthmax" then - return unit:GetColor("health") .. pfUI.api.Abbreviate(hpmax) + return unit:GetColor("health") .. pfUI.api.Abbreviate(rhpmax) elseif config == "healthperc" then return unit:GetColor("health") .. ceil(hp / hpmax * 100) elseif config == "healthmiss" then - local health = ceil(hp - hpmax) + local health = ceil(rhp - rhpmax) if UnitIsDead(unitstr) then return unit:GetColor("health") .. DEAD elseif health == 0 then @@ -2001,12 +2006,12 @@ function pfUI.uf:GetStatusValue(unit, pos) end elseif config == "healthdyn" then if hp ~= hpmax then - return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) .. " - " .. ceil(hp / hpmax * 100) .. "%" + return unit:GetColor("health") .. pfUI.api.Abbreviate(rhp) .. " - " .. ceil(hp / hpmax * 100) .. "%" else - return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) + return unit:GetColor("health") .. pfUI.api.Abbreviate(rhp) end elseif config == "namehealth" then - local health = ceil(hp - hpmax) + local health = ceil(rhp - rhpmax) if UnitIsDead(unitstr) then return unit:GetColor("health") .. DEAD elseif health == 0 then @@ -2015,7 +2020,7 @@ function pfUI.uf:GetStatusValue(unit, pos) return unit:GetColor("health") .. pfUI.api.Abbreviate(health) end elseif config == "shortnamehealth" then - local health = ceil(hp - hpmax) + local health = ceil(rhp - rhpmax) if UnitIsDead(unitstr) then return unit:GetColor("health") .. DEAD elseif health == 0 then @@ -2024,7 +2029,7 @@ function pfUI.uf:GetStatusValue(unit, pos) return unit:GetColor("health") .. pfUI.api.Abbreviate(health) end elseif config == "healthminmax" then - return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) .. "/" .. pfUI.api.Abbreviate(hpmax) + return unit:GetColor("health") .. pfUI.api.Abbreviate(rhp) .. "/" .. pfUI.api.Abbreviate(rhpmax) -- mana/power/focus elseif config == "power" then