diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index d9cd4ef..5477cdb 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -784,7 +784,8 @@ function Unit:PredictHealth(time) table.remove(self.regression_history, 1) end - table.insert(self.regression_history, { time = GetTime(), percent = self:GetHP() }) + local currentTime = GetTime() + table.insert(self.regression_history, { time = currentTime, percent = self:GetHP() }) for i = 1, #self.regression_history do local entry = self.regression_history[i] @@ -793,9 +794,12 @@ function Unit:PredictHealth(time) end local slope, intercept = self:LinearRegression(x, y) - return slope * time + intercept + + return slope * (currentTime + time) + intercept end + + -- Use linear regression to guess the time until a given health percent ---@param percent number ---@return number