Call as
Functions.trends.calculateOld(health)
Record it as a dependency named Functions.trends.calculateOld (accepting the completion does this), then call it by that name.
What it does
Run the historical health-snapshot trend formula using the live profile history window, clock and legacy rounding service. Preserve its maximum-health transitions, early stop at full or zero health, weighting, errors and return counts. An empty array, or snapshots that record no weighted change, return only zero rather than a 0/0 result; this is the legacy algorithm rather than a validated forecast.
Arguments
| Name | Type | What it does |
|---|---|---|
health | table | false | nil | Newest-first health snapshots containing time, value and max. Falsy input returns only zero without reading the clock. |
Returns
| 1 | number | Weighted health-snapshot change from the original total/count formula; zero for falsy input or when no weighted change was recorded. |
|---|---|---|
| 2 | number | nil | Original rounded-age bucket count, omitted when the result is the lone zero. |
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
- Not available on that edition (the reason is in the tooltip)
- Only while Blizzard's deprecation fallbacks are on
| Game API | |||||
|---|---|---|---|---|---|
GetTime |
Example
local now = GetTime()
local snapshots = { { time = now, value = 6000, max = 10000 },
{ time = now - 1, value = 7000, max = 10000 }, { time = now - 2, value = 8000, max = 10000 } }
local change = Functions.trends.calculateOld(snapshots)
return change < 0Source
Functions/trends.lua, line 21. Read only in game; Duplicate makes an editable copy.
Functions.trends.calculateOld(health)
if not health then
return 0
end
local damage_history = addon.db.profile.damage_history
local now = GetTime()
local total, count, seconds = 0, 0, 0
local last_health, last_offs, last_max
local offs_total = 0
for _,v in ipairs(health) do
if v.value >= v.max or v.value == 0 then
break
end
if last_max ~= v.max then
last_health = nil
last_max = v.max
end
local offs = addon.round(now - v.time)
if last_health ~= nil then
offs_total = offs_total + (last_health - v.value)
if last_offs ~= offs then
local scale = damage_history - offs
count = count + scale
total = total + (offs_total * scale)
seconds = seconds + 1
offs_total = 0
end
end
last_health = v.value
last_offs = offs
end
-- seconds is a number, so test it: with no change recorded (or no weight)
-- total/count is 0/0, and the trend is zero, not NaN.
if seconds > 0 and count ~= 0 then
return total / count, seconds
end
return 0




