mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
Match buff-based immunity via C_UnitAuras.GetAuraDataBySpellName
Replaces the 32-slot UnitBuff + C_Spell.GetSpellName name-compare loop with a single ClassicAPI.GetAuraDataBySpellName(unit, name, "HELPFUL") lookup. Locale-identical to the old compare (both use the localized Spell.dbc name). Wrapper added next to GetUnitAuraBySpellID.
This commit is contained in:
@@ -95,6 +95,19 @@ function API.GetUnitAuraBySpellID(unit, spellID, filter)
|
||||
return C_UnitAuras.GetUnitAuraBySpellID(unit, spellID, filter)
|
||||
end
|
||||
|
||||
-- First matching aura on `unit` by spell NAME, or nil. Same whole-array search as
|
||||
-- GetUnitAuraBySpellID; the name is case-sensitive and locale-resolved, so pass it
|
||||
-- in the client's locale (what C_Spell.GetSpellName returns). filter
|
||||
-- ("HELPFUL"/"HARMFUL") restricts the search. Prefer the by-ID variant for
|
||||
-- portability where a spellID is known.
|
||||
function API.GetAuraDataBySpellName(unit, spellName, filter)
|
||||
if not unit or not spellName or spellName == "" then return nil end
|
||||
if type(C_UnitAuras) ~= "table" or type(C_UnitAuras.GetAuraDataBySpellName) ~= "function" then
|
||||
return nil
|
||||
end
|
||||
return C_UnitAuras.GetAuraDataBySpellName(unit, spellName, filter)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- GetUnitSpeed
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
+4
-15
@@ -8800,23 +8800,12 @@ function CleveRoids.CheckImmunity(unitId, spellOrSchool)
|
||||
end
|
||||
end
|
||||
|
||||
-- Check buff-based immunity (if NPC has the required buff)
|
||||
-- Check buff-based immunity (if NPC has the required buff). One by-name
|
||||
-- lookup across the unit's buffs via C_UnitAuras -- no 32-slot scan.
|
||||
if immunityData.buff then
|
||||
local requiredBuff = immunityData.buff
|
||||
|
||||
-- Check target's buffs
|
||||
for i = 1, 32 do
|
||||
local texture, stacks, spellID = UnitBuff(unitId, i)
|
||||
if not texture then break end
|
||||
|
||||
if spellID then
|
||||
local buffName = C_Spell.GetSpellName(spellID)
|
||||
if buffName and buffName == requiredBuff then
|
||||
return true
|
||||
end
|
||||
end
|
||||
if CleveRoids.ClassicAPI.GetAuraDataBySpellName(unitId, immunityData.buff, "HELPFUL") then
|
||||
return true
|
||||
end
|
||||
|
||||
-- Buff not found, not currently immune
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user