From 2969f1f9be9dfb2ed822c79f13dbbebccea2c3d7 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 25 May 2025 13:52:01 +0200 Subject: [PATCH] libdebuff: add method to iterate own debuffs --- libs/libdebuff.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index ebdf0cfa..081ea41b 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -286,5 +286,26 @@ function libdebuff:UnitDebuff(unit, id) return effect, rank, texture, stacks, dtype, duration, timeleft, caster end +local cache = {} +function libdebuff:UnitOwnDebuff(unit, id) + -- clean cache + for k, v in pairs(cache) do cache[k] = nil end + + -- detect own debuffs + local count = 1 + for i=1,16 do + local effect, rank, texture, stacks, dtype, duration, timeleft, caster = libdebuff:UnitDebuff(unit, i) + if effect and not cache[effect] and caster and caster == "player" then + cache[effect] = true + + if count == id then + return effect, rank, texture, stacks, dtype, duration, timeleft, caster + else + count = count + 1 + end + end + end +end + -- add libdebuff to pfUI API pfUI.api.libdebuff = libdebuff