Skip to content

Commit

Permalink
feat: use the modern unit aura api
Browse files Browse the repository at this point in the history
  • Loading branch information
fang2hou committed Aug 15, 2024
1 parent d83c51c commit ba8e715
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions Modules/AvoidableDamage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ local IsInGroup = IsInGroup
local IsInInstance = IsInInstance
local IsInRaid = IsInRaid
local SendChatMessage = SendChatMessage
local UnitBuff = function(unitToken, index, filter)
local auraData = C_UnitAuras.GetBuffDataByIndex(unitToken, index, filter);
if not auraData then
return nil;
end
return AuraUtil.UnpackAuraData(auraData);
end
local UnitDebuff = function(unitToken, index, filter)
local auraData = C_UnitAuras.GetDebuffDataByIndex(unitToken, index, filter);
if not auraData then
return nil;
end
return AuraUtil.UnpackAuraData(auraData);
end
local UnitGUID = UnitGUID
local UnitGroupRolesAssigned = UnitGroupRolesAssigned
local UnitHealthMax = UnitHealthMax
Expand All @@ -51,6 +37,8 @@ local C_ChatInfo_SendAddonMessage = C_ChatInfo.SendAddonMessage
local C_Map_GetBestMapForUnit = C_Map.GetBestMapForUnit
local C_Spell_GetSpellLink = C_Spell.GetSpellLink
local C_Timer_After = C_Timer.After
local C_UnitAuras_GetBuffDataByIndex = C_UnitAuras.GetBuffDataByIndex
local C_UnitAuras_GetDebuffDataByIndex = C_UnitAuras.GetDebuffDataByIndex

local LE_PARTY_CATEGORY_HOME = LE_PARTY_CATEGORY_HOME
local LE_PARTY_CATEGORY_INSTANCE = LE_PARTY_CATEGORY_INSTANCE
Expand Down Expand Up @@ -433,8 +421,8 @@ end

local function PlayerHasBuff(player, spellID)
for i = 1, 40 do
local debuffID = select(10, UnitBuff(player, i))
if debuffID == spellID then
local aura = C_UnitAuras_GetBuffDataByIndex(player, i)
if aura and aura.spellId == spellID then
return true
end
end
Expand All @@ -444,8 +432,8 @@ end

local function PlayerHasDebuff(player, spellID)
for i = 1, 40 do
local debuffID = select(10, UnitDebuff(player, i))
if debuffID == spellID then
local aura = C_UnitAuras_GetDebuffDataByIndex(player, i)
if aura and aura.spellId == spellID then
return true
end
end
Expand Down

0 comments on commit ba8e715

Please sign in to comment.