Aufruf als
Functions.trends.calculateOld(health)
Erfassen Sie sie als Abhängigkeit mit dem Namen Functions.trends.calculateOld (das Übernehmen der Vervollständigung erledigt das) und rufen Sie sie dann unter diesem Namen auf.
Was sie bewirkt
Die historische Trendformel für Gesundheits-Momentaufnahmen mit dem Live-Verlaufsfenster des Profils, der Uhr und dem alten Rundungsdienst ausführen. Übergänge der maximalen Gesundheit, frühes Anhalten bei voller oder null Gesundheit, Gewichtung, Fehler und Anzahl der Rückgabewerte bleiben erhalten. Ein leeres Array oder Momentaufnahmen ohne aufgezeichnete gewichtete Änderung ergeben nur null statt eines Ergebnisses von 0/0; dies ist der alte Algorithmus, keine validierte Prognose.
Argumente
| Name | Typ | Was sie bewirkt |
|---|---|---|
health | table | false | nil | Gesundheits-Momentaufnahmen mit time, value und max, neueste zuerst. Bei Eingabe nil oder false wird nur null zurückgegeben, ohne die Uhr zu lesen. |
Rückgabewerte
| 1 | number | Gewichtete Änderung der Gesundheits-Momentaufnahmen aus der ursprünglichen Formel Summe/Anzahl; null bei Eingabe nil oder false oder wenn keine gewichtete Änderung aufgezeichnet wurde. |
|---|---|---|
| 2 | number | nil | Ursprüngliche Anzahl der Klassen mit gerundetem Alter; entfällt, wenn das Ergebnis die alleinige Null ist. |
Editionen
Integrierte Hilfsfunktionen werden auf jeder Edition registriert. Unterschiedlich ist die Spiel-API, die sie lesen; fehlt eine, weicht die Hilfsfunktion aus oder gibt nil mit einem Grund zurück.
- Auf dieser Edition nicht verfügbar (den Grund nennt der Tooltip)
- Nur, solange Blizzards Ersatz für veraltete Funktionen aktiv ist
| Spiel-API | |||||
|---|---|---|---|---|---|
GetTime |
Beispiel
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 < 0Quelle
Functions/trends.lua, Zeile 21. Im Spiel schreibgeschützt; Duplizieren erstellt eine bearbeitbare Kopie.
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




