Commit a0bb39d2 authored by momo's avatar momo
Browse files

fix the bug :the health bar may jump bak because UNIT_HEALTH_FREQUENT may...

fix the bug :the health bar may jump bak because UNIT_HEALTH_FREQUENT may delay within 400ms in classic
parent 6e9b1aa1
......@@ -334,6 +334,7 @@ function VUHDO_setHealth(aUnit, aMode)
tInfo["healthmax"] = UnitHealthMax(aUnit);
tInfo["health"] = UnitHealth(aUnit);
tInfo["loghealth"] = UnitHealth(aUnit);
tInfo["updateTime"] = GetTime();
tInfo["name"] = tName;
tInfo["number"] = VUHDO_getUnitNo(aUnit);
tInfo["unit"] = aUnit;
......@@ -394,12 +395,12 @@ function VUHDO_setHealth(aUnit, aMode)
if 2 == aMode then
-- Filter exception UNIT_HEALTH_FREQUENT event in classic
-- Sometimes there is a UNIT_HEALTH_FREQUENT event in the interim period
if tInfo["updateTime"] == GetTime() then
if tInfo["updateTime"] and abs(tonumber(tInfo["updateTime"]) - tonumber(GetTime())) < 0.4 then
return;
-- Filter exception health data from UnitHealth API
-- UnitHealth will return 0 if the hunter cast FeignDeath
-- Sometimes UnitIsDeadOrGhost return false and UnitHealth return 0 before UnitIsFeignDeath return true
elseif UnitIsFeignDeath(aUnit) or not UnitIsDeadOrGhost(aUnit) and UnitHealth(aUnit) == 0 then
elseif (UnitIsFeignDeath(aUnit) or not UnitIsDeadOrGhost(aUnit)) and UnitHealth(aUnit) == 0 then
return;
else
tNewHealth = UnitHealth(aUnit);
......@@ -425,6 +426,10 @@ function VUHDO_setHealth(aUnit, aMode)
tInfo["healthmax"] = UnitHealthMax(aUnit);
tInfo["sortMaxHp"] = VUHDO_getUnitSortMaxHp(aUnit);
tInfo["loghealth"] = UnitHealth(aUnit);
if UnitHealth(aUnit) ~= 0 then
tInfo["health"] = UnitHealth(aUnit);
end
tInfo["updateTime"] = GetTime();
elseif 6 == aMode then -- VUHDO_UPDATE_AFK
tInfo["afk"] = tIsAfk;
......
......@@ -48,7 +48,7 @@ local function VUHDO_addUnitHealth(aUnit, aDelta, aSrcGUID)
end
-- avoid the calculation to be disturbed by the exception data
if tInfo["health"] ~= 0 then
if UnitHealth(aUnit) ~= 0 or tInfo["health"] ~= 0 then
tNewHealth = tInfo["health"] + aDelta;
else
tNewHealth = tInfo["loghealth"] + aDelta;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment