libhealth: add function to query by name

This commit is contained in:
shagu
2020-05-03 13:30:33 +02:00
parent 556876b04e
commit 241272748a
+13 -1
View File
@@ -64,7 +64,18 @@ local function GetUnitHealth(self, unitstr)
if unit and level and max == 100 then
dbstring = string.format("%s:%s", unit, level)
if mobdb[dbstring] and mobdb[dbstring][1] and mobdb[dbstring][2] > libhealth.reqdmg and mobdb[dbstring][3] > libhealth.reqhit then
return ceil(mobdb[dbstring][1]/100*cur), mobdb[dbstring][1]
return ceil(mobdb[dbstring][1]/100*cur), mobdb[dbstring][1], true
end
end
return cur, max
end
local function GetUnitHealthByName(self, unit, level, cur, max)
if max == 100 then
dbstring = string.format("%s:%s", unit, (level or 0))
if mobdb[dbstring] and mobdb[dbstring][1] and mobdb[dbstring][2] > libhealth.reqdmg and mobdb[dbstring][3] > libhealth.reqhit then
return ceil(mobdb[dbstring][1]/100*cur), mobdb[dbstring][1], true
end
end
@@ -82,4 +93,5 @@ end
-- add api calls to global tree
pfUI.libhealth = libhealth
pfUI.libhealth.GetUnitHealth = GetUnitHealth
pfUI.libhealth.GetUnitHealthByName = GetUnitHealthByName
pfUI.libhealth.GetDBHealth = GetDBHealth