mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
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.
This commit is contained in:
@@ -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
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
+6
-25
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user