From a029f46b99575fc82e1b7f479d0d441ae503f837 Mon Sep 17 00:00:00 2001 From: 4n0n <4n0n@tinkr.site> Date: Mon, 30 Jan 2023 06:49:21 -0600 Subject: [PATCH] Add findtheirs/findfrom --- src/AuraTable/AuraTable.lua | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/AuraTable/AuraTable.lua b/src/AuraTable/AuraTable.lua index 5acf994..a924294 100644 --- a/src/AuraTable/AuraTable.lua +++ b/src/AuraTable/AuraTable.lua @@ -305,6 +305,57 @@ function AuraTable:FindMy(spell) return Bastion.Aura:New() end +function AuraTable:FindFrom(spell, source) + local auras = self:GetUnitAuras() + local aurasub = auras[spell:GetID()] + + if not aurasub then + return Bastion.Aura:New() + end + + for k, a in pairs(aurasub) do + if a ~= nil then + if a:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA + if a:GetSource() == source then + return a + end + else + if not Tinkr.classic then + self:RemoveInstanceID(a:GetAuraInstanceID()) + end + end + end + end + + return Bastion.Aura:New() +end + +-- Find the aura from the current unit +function AuraTable:FindTheirs(spell) + local auras = self:GetUnitAuras() + local aurasub = auras[spell:GetID()] + + if not aurasub then + return Bastion.Aura:New() + end + + for k, a in pairs(aurasub) do + if a ~= nil then + if a:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA + if self.unit:IsUnit(a:GetSource()) then + return a + end + else + if not Tinkr.classic then + self:RemoveInstanceID(a:GetAuraInstanceID()) + end + end + end + end + + return Bastion.Aura:New() +end + -- Find any ---@return Aura function AuraTable:FindAny(spell)