nameplates: add support for mobhealth and mobinfo

This commit is contained in:
Lichery
2018-05-26 01:11:45 +02:00
committed by shagu
parent 7328cf9937
commit 40d19fc606
2 changed files with 29 additions and 52 deletions
+26 -52
View File
@@ -1674,6 +1674,12 @@ function pfUI.uf:GetStatusValue(unit, pos)
config = "unit" config = "unit"
end 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()
end
if config == "unit" then if config == "unit" then
local name = unit:GetColor("unit") .. UnitName(unitstr) local name = unit:GetColor("unit") .. UnitName(unitstr)
local level = unit:GetColor("level") .. pfUI.uf:GetLevelString(unitstr) local level = unit:GetColor("level") .. pfUI.uf:GetLevelString(unitstr)
@@ -1689,84 +1695,52 @@ function pfUI.uf:GetStatusValue(unit, pos)
-- health -- health
elseif config == "health" then elseif config == "health" then
if unit.label == "target" and MobHealth3 then return unit:GetColor("health") .. pfUI.api.Abbreviate(hp)
local hp, hpmax = MobHealth3:GetUnitHealth(unit.label)
return unit:GetColor("health") .. pfUI.api.Abbreviate(hp)
elseif unit.label == "target" and MobHealthFrame and MobHealth_GetTargetCurHP() then
local hp = MobHealth_GetTargetCurHP()
return unit:GetColor("health") .. pfUI.api.Abbreviate(hp)
end
return unit:GetColor("health") .. pfUI.api.Abbreviate(UnitHealth(unitstr))
elseif config == "healthmax" then elseif config == "healthmax" then
if unit.label == "target" and MobHealth3 then return unit:GetColor("health") .. pfUI.api.Abbreviate(hpmax)
local hp, hpmax = MobHealth3:GetUnitHealth(unit.label)
return unit:GetColor("health") .. pfUI.api.Abbreviate(hpmax)
elseif unit.label == "target" and MobHealthFrame and MobHealth_GetTargetMaxHP() then
local hpmax = MobHealth_GetTargetMaxHP()
return unit:GetColor("health") .. pfUI.api.Abbreviate(hpmax)
end
return unit:GetColor("health") .. pfUI.api.Abbreviate(UnitHealthMax(unitstr))
elseif config == "healthperc" then elseif config == "healthperc" then
return unit:GetColor("health") .. ceil(UnitHealth(unitstr) / UnitHealthMax(unitstr) * 100) return unit:GetColor("health") .. ceil(hp / hpmax * 100)
elseif config == "healthmiss" then elseif config == "healthmiss" then
local health = ceil(UnitHealth(unitstr) - UnitHealthMax(unitstr)) local health = ceil(hp - hpmax)
if health == 0 or UnitIsDead(unitstr) then if UnitIsDead(unitstr) then
return "" return unit:GetColor("health") .. DEAD
elseif health == 0 then
return unit:GetColor("health") .. "0"
else else
return unit:GetColor("health") .. pfUI.api.Abbreviate(health) return unit:GetColor("health") .. pfUI.api.Abbreviate(health)
end end
elseif config == "healthdyn" then elseif config == "healthdyn" then
if UnitHealth(unitstr) ~= UnitHealthMax(unitstr) then if hp ~= hpmax then
if unit.label == "target" and MobHealth3 then return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) .. " - " .. ceil(hp / hpmax * 100) .. "%"
local hp, hpmax = MobHealth3:GetUnitHealth(unit.label)
return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) .. " - " .. ceil(hp / hpmax * 100) .. "%"
elseif unit.label == "target" and MobHealthFrame and MobHealth_GetTargetCurHP() then
local hp, hpmax = MobHealth_GetTargetCurHP(),MobHealth_GetTargetMaxHP()
return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) .. " - " .. ceil(hp / hpmax * 100) .. "%"
end
return unit:GetColor("health") .. pfUI.api.Abbreviate(UnitHealth(unitstr)) .. " - " .. ceil(UnitHealth(unitstr) / UnitHealthMax(unitstr) * 100) .. "%"
else else
if unit.label == "target" and MobHealth3 then return unit:GetColor("health") .. pfUI.api.Abbreviate(hp)
local hp, hpmax = MobHealth3:GetUnitHealth(unit.label)
return unit:GetColor("health") .. pfUI.api.Abbreviate(hp)
elseif unit.label == "target" and MobHealthFrame and MobHealth_GetTargetCurHP() then
local hp = MobHealth_GetTargetCurHP()
return unit:GetColor("health") .. pfUI.api.Abbreviate(hp)
end
return unit:GetColor("health") .. pfUI.api.Abbreviate(UnitHealth(unitstr))
end end
elseif config == "healthminmax" then elseif config == "healthminmax" then
local hp, hpmax = UnitHealth(unitstr), UnitHealthMax(unitstr)
if unit.label == "target" and MobHealth3 then
hp, hpmax = MobHealth3:GetUnitHealth(unit.label)
elseif unit.label == "target" and MobHealthFrame and MobHealth_GetTargetCurHP() then
local hp, hpmax = MobHealth_GetTargetCurHP(), MobHealth_GetTargetMaxHP()
end
return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) .. "/" .. pfUI.api.Abbreviate(hpmax) return unit:GetColor("health") .. pfUI.api.Abbreviate(hp) .. "/" .. pfUI.api.Abbreviate(hpmax)
-- mana/power/focus -- mana/power/focus
elseif config == "power" then elseif config == "power" then
return unit:GetColor("power") .. pfUI.api.Abbreviate(UnitMana(unitstr)) return unit:GetColor("power") .. pfUI.api.Abbreviate(mp)
elseif config == "powermax" then elseif config == "powermax" then
return unit:GetColor("power") .. pfUI.api.Abbreviate(UnitManaMax(unitstr)) return unit:GetColor("power") .. pfUI.api.Abbreviate(mpmax)
elseif config == "powerperc" then elseif config == "powerperc" then
local perc = UnitManaMax(unitstr) > 0 and ceil(UnitMana(unitstr) / UnitManaMax(unitstr) * 100) or 0 local perc = UnitManaMax(unitstr) > 0 and ceil(mp / mpmax * 100) or 0
return unit:GetColor("power") .. perc return unit:GetColor("power") .. perc
elseif config == "powermiss" then elseif config == "powermiss" then
local power = ceil(UnitMana(unitstr) - UnitManaMax(unitstr)) local power = ceil(mp - mpmax)
if power == 0 then if power == 0 then
return "" return unit:GetColor("power") .. "0"
else else
return unit:GetColor("power") .. pfUI.api.Abbreviate(power) return unit:GetColor("power") .. pfUI.api.Abbreviate(power)
end end
elseif config == "powerdyn" then elseif config == "powerdyn" then
if UnitMana(unitstr) ~= UnitManaMax(unitstr) then if mp ~= mpmax then
return unit:GetColor("power") .. pfUI.api.Abbreviate(UnitMana(unitstr)) .. " - " .. ceil(UnitMana(unitstr) / UnitManaMax(unitstr) * 100) .. "%" return unit:GetColor("power") .. pfUI.api.Abbreviate(mp) .. " - " .. ceil(mp / mpmax * 100) .. "%"
else else
return unit:GetColor("power") .. pfUI.api.Abbreviate(UnitMana(unitstr)) return unit:GetColor("power") .. pfUI.api.Abbreviate(mp)
end end
elseif config == "powerminmax" then elseif config == "powerminmax" then
return unit:GetColor("power") .. pfUI.api.Abbreviate(UnitMana(unitstr)) .. "/" .. pfUI.api.Abbreviate(UnitManaMax(unitstr)) return unit:GetColor("power") .. pfUI.api.Abbreviate(mp) .. "/" .. pfUI.api.Abbreviate(mpmax)
else else
return "" return ""
end end
+3
View File
@@ -548,6 +548,9 @@ pfUI:RegisterModule("nameplates", function ()
if C.nameplates.showhp == "1" and healthbar.hptext then if C.nameplates.showhp == "1" and healthbar.hptext then
local min, max = healthbar:GetMinMaxValues() local min, max = healthbar:GetMinMaxValues()
local cur = healthbar:GetValue() local cur = healthbar:GetValue()
if (MobHealth3 or MobHealthFrame) and unitname == UnitName('target') and healthbar:GetAlpha() == 1 and MobHealth_GetTargetCurHP() then
cur, max = MobHealth_GetTargetCurHP(), MobHealth_GetTargetMaxHP()
end
healthbar.hptext:SetText(cur .. " / " .. max) healthbar.hptext:SetText(cur .. " / " .. max)
end end
end end