Finish the C_UnitAuras swap in CheckImmunity

CheckImmunity asks "is this NPC immune to that school, and if the entry is
conditional, does it hold the buff that grants it" in two places. The
plain-school path was migrated to C_UnitAuras.GetAuraDataBySpellName -- one
by-name lookup across the unit's auras. The split-damage path was not, and was
still walking 32 buff slots calling C_Spell.GetSpellName on each to compare the
name back, twice over, once for the initial school and once for the DoT's.

Both copies were the same twenty lines with the variable names changed, so they
fold into a SchoolImmune(unitId, school, targetName) helper that the split path
calls twice. Same answer, same order of checks: a permanent entry is immune, a
table entry without a buff is immune, a table entry with one is immune only
while the aura is up.

The plain-school path keeps its own inline version -- it is not the same
predicate. It gates on the recorded spell name first for the "unknown" school,
and a table entry carrying neither buff nor spell falls through to false there
where the split path calls it immune. Unifying those is a behavior change, not a
refactor, so it is left alone.
This commit is contained in:
Brues
2026-09-12 07:48:31 -05:00
parent 5e27e6fe58
commit afc5e513ca
+18 -47
View File
@@ -8391,6 +8391,20 @@ local function ParseAfflictedCombatLog()
end
end
-- True if the recorded immunity data makes `targetName` immune to `school` right
-- now: outright when the entry is permanent, or only while it holds the buff the
-- entry names. The buff test is one by-name lookup across the unit's auras via
-- C_UnitAuras -- no slot scan, and it finds the aura wherever it sits.
local function SchoolImmune(unitId, school, targetName)
local schoolData = school and CleveRoids_ImmunityData[school]
local data = schoolData and schoolData[targetName]
if not data then return false end
if data == true then return true end
if type(data) ~= "table" then return false end
if not data.buff then return true end
return CleveRoids.ClassicAPI.GetAuraDataBySpellName(unitId, data.buff, "HELPFUL") and true or false
end
-- Check if a unit is immune to a spell, damage school, or CC type
-- Supports: CheckImmunity(unitId, "Flame Shock") or CheckImmunity(unitId, "fire") or CheckImmunity(unitId, "stun")
function CleveRoids.CheckImmunity(unitId, spellOrSchool)
@@ -8487,53 +8501,10 @@ function CleveRoids.CheckImmunity(unitId, spellOrSchool)
local initialSchool = splitData.initial
local debuffSchool = splitData.debuff
-- Check initial school immunity (e.g., physical for Rake's initial hit)
local initialImmune = false
if initialSchool and CleveRoids_ImmunityData[initialSchool] then
local initialImmunityData = CleveRoids_ImmunityData[initialSchool][targetName]
if initialImmunityData == true then
initialImmune = true
elseif type(initialImmunityData) == "table" and not initialImmunityData.buff then
initialImmune = true
elseif type(initialImmunityData) == "table" and initialImmunityData.buff then
-- Check if target has the immunity-granting buff
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 == initialImmunityData.buff then
initialImmune = true
break
end
end
end
end
end
-- Check debuff school immunity (e.g., bleed for Rake's DoT)
local debuffImmune = false
if debuffSchool and CleveRoids_ImmunityData[debuffSchool] then
local debuffImmunityData = CleveRoids_ImmunityData[debuffSchool][targetName]
if debuffImmunityData == true then
debuffImmune = true
elseif type(debuffImmunityData) == "table" and not debuffImmunityData.buff then
debuffImmune = true
elseif type(debuffImmunityData) == "table" and debuffImmunityData.buff then
-- Check if target has the immunity-granting buff
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 == debuffImmunityData.buff then
debuffImmune = true
break
end
end
end
end
end
-- Initial school (e.g. physical for Rake's opening hit), then the DoT's
-- school (e.g. bleed). Immunity to either component skips the spell.
local initialImmune = SchoolImmune(unitId, initialSchool, targetName)
local debuffImmune = SchoolImmune(unitId, debuffSchool, targetName)
-- Return true if immune to EITHER component
if initialImmune or debuffImmune then