From d82eeabf22693f06d8da48d23d3f111f996b9ee2 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:12:29 -0500 Subject: [PATCH] Detect Banish via C_UnitAuras.GetUnitAuraBySpellID, not slot scan The Banish immunity check hand-scanned 16 debuff slots plus 32 buff slots (NPC overflow) for spellID 710/18647. ClassicAPI.GetUnitAuraBySpellID walks the whole aura array in one call per rank, so it finds the debuff wherever it lands -- including an NPC's overflow buff slots -- dropping the two loops and the UnitIsPlayer gate. Wrapper added alongside UnitHasDispelType. --- ClassicAPI.lua | 13 +++++++++++++ Utility.lua | 31 ++++++------------------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/ClassicAPI.lua b/ClassicAPI.lua index f2a9c63..67c03ab 100644 --- a/ClassicAPI.lua +++ b/ClassicAPI.lua @@ -82,6 +82,19 @@ function API.UnitHasDispelType(unit, dispelType, helpful) return scanDispel(indexFn, unit, dispelType, wantAny) end +-- First matching aura on `unit` by spellID, or nil. With no filter it walks the +-- whole aura array (helpful then harmful), so it finds a debuff even when it has +-- overflowed into an NPC's buff slots -- no 16+32 slot scan, no UnitIsPlayer +-- gate. filter ("HELPFUL"/"HARMFUL") restricts the search. Returns the modern +-- AuraData (spellId, name, applications, duration, expirationTime, dispelName, ...). +function API.GetUnitAuraBySpellID(unit, spellID, filter) + if not unit or not spellID then return nil end + if type(C_UnitAuras) ~= "table" or type(C_UnitAuras.GetUnitAuraBySpellID) ~= "function" then + return nil + end + return C_UnitAuras.GetUnitAuraBySpellID(unit, spellID, filter) +end + -------------------------------------------------------------------------------- -- GetUnitSpeed -------------------------------------------------------------------------------- diff --git a/Utility.lua b/Utility.lua index 3cce898..35a9fd5 100644 --- a/Utility.lua +++ b/Utility.lua @@ -8629,31 +8629,12 @@ function CleveRoids.CheckImmunity(unitId, spellOrSchool) -- Universal debuff-based immunities (Banish, etc.) -- Banish makes target immune to most damage schools (not all spells) do - local hasBanish = false - - -- Check debuffs first (Banish: 710 = Rank 1, 18647 = Rank 2) - for i = 1, 16 do - local texture, stacks, dtype, spellID = UnitDebuff(unitId, i) - if not texture then break end - - if spellID == 710 or spellID == 18647 then - hasBanish = true - break - end - end - - -- Overflow handling: debuffs can overflow into buffs on NPCs - if not hasBanish and not UnitIsPlayer(unitId) then - for i = 1, 32 do - local texture, stacks, spellID = UnitBuff(unitId, i) - if not texture then break end - - if spellID == 710 or spellID == 18647 then - hasBanish = true - break - end - end - end + -- Banish: 710 = Rank 1, 18647 = Rank 2. One by-spellID lookup each -- + -- C_UnitAuras walks the whole aura array, so it finds the debuff even when + -- it has overflowed into an NPC's buff slots (no manual slot scan / overflow gate). + local API = CleveRoids.ClassicAPI + local hasBanish = (API.GetUnitAuraBySpellID(unitId, 710) + or API.GetUnitAuraBySpellID(unitId, 18647)) and true or false -- If Banished, check what's being tested for immunity if hasBanish then