호출 방법
Functions.trends.calculate(history, window, noheals, nodmg)
Functions.trends.calculate(이)라는 이름의 의존성으로 기록한 뒤(자동 완성을 수락하면 이렇게 됩니다) 그 이름으로 호출하세요.
하는 일
가중치를 둔 피해 및 치유 기록으로 부호 있는 생명력 변화를 추정합니다. 피해는 음의 변화율, 치유는 양의 변화율에 기여합니다. 구간을 전달하지 않으면 실시간 프로필 구간을 읽고, 실시간 시각과 이전 반올림 방식을 사용하며, 기존 가중치와 반올림된 경과 시간 계산을 유지합니다. 이 도우미는 기록을 검증하거나 정리하지 않고, 타임스탬프를 제한하지 않으며, 유한한 결과를 보장하지 않습니다.
인수
| 이름 | 유형 | 하는 일 |
|---|---|---|
history | table | false | nil | 시간/값 항목으로 된 최신순 피해 및 치유 배열을 담은 기록 레코드. 기록이 거짓 값이면 시각을 읽지 않고 0만 반환합니다. |
window | number | false | nil | 초 단위 가중치 구간. nil이나 false면 현재 프로필의 damage_history 설정을 사용합니다. |
noheals | boolean | nil | 참 값이면 치유 스트림의 배열을 읽지 않고 건너뜁니다. |
nodmg | boolean | nil | 참 값이면 피해 스트림의 배열을 읽지 않고 건너뜁니다. |
반환값
| 1 | number | 원래 공식에 따른 부호 있는 가중 변화율 합계. 잘못되었거나 유한하지 않은 입력은 이전의 오류/숫자 동작을 유지합니다. |
|---|---|---|
| 2 | number | nil | 반올림한 스트림 경과 시간 중 큰 값(초). 표본 수나 연속 관찰의 증거가 아닙니다. 기록이 거짓 값이면 생략됩니다. |
버전
기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.
- 해당 버전에서 사용할 수 없음 (이유는 툴팁에 표시)
- Blizzard의 지원 중단 대체 함수가 켜져 있을 때만
| 게임 API | |||||
|---|---|---|---|---|---|
GetTime |
예시
local guid = UnitGUID("target")
local history = guid and addon.damageHistory[guid]
if not history then return false end
local rate = Functions.trends.calculate(history, 5, true)
return rate < -1000소스
Functions/trends.lua, 75번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.
Functions.trends.calculate(history, window, noheals, nodmg)
if not history then
return 0
end
if not window then
window = addon.db.profile.damage_history
end
local now = GetTime()
local damage_total, damage_count, damage_seconds = 0, 0, 0
local heal_total, heal_count, heal_seconds = 0, 0, 0
local maxoffs, data = 0, {}
if not nodmg then
for _,v in ipairs(history.damage) do
local diff = now - v.time
local scale = window - diff
maxoffs = addon.round(diff)
if maxoffs > window then
break
end
if v.value then
data[maxoffs] = (data[maxoffs] or 0) + (v.value * scale)
end
end
damage_seconds = maxoffs
for i=0,maxoffs do
damage_total = damage_total + (data[i] or 0)
damage_count = damage_count + (window - i)
end
end
if not noheals then
maxoffs, data = 0, {}
for _,v in ipairs(history.heals) do
local diff = now - v.time
local scale = window - diff
maxoffs = addon.round(diff)
if maxoffs > window then
break
end
if v.value then
data[maxoffs] = (data[maxoffs] or 0) + (v.value * scale)
end
end
heal_seconds = maxoffs
for i=0,maxoffs do
heal_total = heal_total + (data[i] or 0)
heal_count = heal_count + (window - i)
end
end
return (((damage_count > 0) and (-damage_total / damage_count) or 0) +
((heal_count > 0) and (heal_total / heal_count) or 0)),
(damage_seconds > heal_seconds and damage_seconds or heal_seconds)




