Skip to content

Commit

Permalink
Re-re-revise UnitBuff/UnitDebuff, add UnitBuffByID...
Browse files Browse the repository at this point in the history
  • Loading branch information
Hekili committed Jul 24, 2024
1 parent e41673d commit 2350914
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
6 changes: 4 additions & 2 deletions Classes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ local GetItemSpell, GetItemCount, IsUsableItem = C_Item.GetItemSpell, C_Item.Get
local GetSpellInfo = C_Spell.GetSpellInfo
local GetSpellLink = C_Spell.GetSpellLink

local UnitBuff, UnitDebuff = ns.UnitBuff, ns.UnitDebuff

local specTemplate = {
enabled = true,

Expand Down Expand Up @@ -2090,13 +2092,13 @@ all:RegisterAuras( {
dispellable_disease = {
generate = function( t )
local i = 1
local name, _, count, debuffType, duration, expirationTime = UnitDebuff( "player", i, "RAID" )
local name, _, count, debuffType, duration, expirationTime = UnitDebuffCompat( "player", i, "RAID" )

while( name ) do
if debuffType == "Disease" then break end

i = i + 1
name, _, count, debuffType, duration, expirationTime = UnitDebuff( "player", i, "RAID" )
name, _, count, debuffType, duration, expirationTime = UnitDebuff(Co "player", i, "RAID" )
end

if name then
Expand Down
11 changes: 7 additions & 4 deletions Hekili.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Hekili.Flavor = C_AddOns.GetAddOnMetadata( "Hekili", "X-Flavor" ) or "Retail"
local format = string.format
local insert, concat = table.insert, table.concat

local GetBuffDataByIndex, GetDebuffDataByIndex = C_UnitAuras.GetBuffDataByIndex, C_UnitAuras.GetDebuffDataByIndex
local UnpackAuraData = AuraUtil.UnpackAuraData

local buildStr, _, _, buildNum = GetBuildInfo()

Hekili.CurrentBuild = buildNum
Expand Down Expand Up @@ -260,7 +263,7 @@ function Hekili:SaveDebugSnapshot( dispName )
local class = Hekili.Class

for i = 1, 40 do
local name, _, count, debuffType, duration, expirationTime, source, _, _, spellId, canApplyAura, isBossDebuff, castByPlayer = ns.UnitBuff( "player", i )
local name, _, count, debuffType, duration, expirationTime, source, _, _, spellId, canApplyAura, isBossDebuff, castByPlayer = UnpackAuraData( GetBuffDataByIndex( "player", i ) )

if not name then break end

Expand All @@ -274,7 +277,7 @@ function Hekili:SaveDebugSnapshot( dispName )
auraString = auraString .. "\n\nplayer_debuffs:"

for i = 1, 40 do
local name, _, count, debuffType, duration, expirationTime, source, _, _, spellId, canApplyAura, isBossDebuff, castByPlayer = ns.UnitDebuff( "player", i )
local name, _, count, debuffType, duration, expirationTime, source, _, _, spellId, canApplyAura, isBossDebuff, castByPlayer = UnpackAuraData( GetDebuffDataByIndex( "player", i ) )

if not name then break end

Expand All @@ -292,7 +295,7 @@ function Hekili:SaveDebugSnapshot( dispName )
auraString = auraString .. "\n\ntarget_buffs:"

for i = 1, 40 do
local name, _, count, debuffType, duration, expirationTime, source, _, _, spellId, canApplyAura, isBossDebuff, castByPlayer = ns.UnitBuff( "target", i )
local name, _, count, debuffType, duration, expirationTime, source, _, _, spellId, canApplyAura, isBossDebuff, castByPlayer = UnpackAuraData( GetBuffDataByIndex( "target", i ) )

if not name then break end

Expand All @@ -306,7 +309,7 @@ function Hekili:SaveDebugSnapshot( dispName )
auraString = auraString .. "\n\ntarget_debuffs:"

for i = 1, 40 do
local name, _, count, debuffType, duration, expirationTime, source, _, _, spellId, canApplyAura, isBossDebuff, castByPlayer = ns.UnitDebuff( "target", i, "PLAYER" )
local name, _, count, debuffType, duration, expirationTime, source, _, _, spellId, canApplyAura, isBossDebuff, castByPlayer = UnpackAuraData( GetDebuffDataByIndex( "target", i, "PLAYER" ) )

if not name then break end

Expand Down
2 changes: 2 additions & 0 deletions Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ local state = Hekili.State
local format, lower, match = string.format, string.lower, string.match
local insert, remove, sort, wipe = table.insert, table.remove, table.sort, table.wipe

local UnitBuff, UnitDebuff = ns.UnitBuff, ns.UnitDebuff

local callHook = ns.callHook

local SpaceOut = ns.SpaceOut
Expand Down
16 changes: 1 addition & 15 deletions State.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,8 @@ local GetItemSpell = C_Item.GetItemSpell
local GetItemCooldown = C_Item.GetItemCooldown
local IsUsableItem = C_Item.IsUsableItem
local GetSpellLossOfControlCooldown = C_Spell.GetSpellLossOfControlCooldown
local UnitBuff = function(unitToken, index, filter)
local auraData = C_UnitAuras.GetBuffDataByIndex(unitToken, index, filter)
if not auraData then
return nil
end
local UnitBuff, UnitDebuff = ns.UnitBuff, ns.UnitDebuff

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 GetSpellCharges = function(spellID)
local spellChargeInfo = C_Spell.GetSpellCharges(spellID);
if spellChargeInfo then
Expand Down
1 change: 1 addition & 0 deletions TheWarWithin/WarlockAffliction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ spec:RegisterAbilities( {

spend = 0.01,
spendType = "mana",
cycle = "agony",

startsCombat = true,

Expand Down
20 changes: 15 additions & 5 deletions Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ local state = Hekili.State

local GetPlayerAuraBySpellID = C_UnitAuras.GetPlayerAuraBySpellID
local GetBuffDataByIndex, GetDebuffDataByIndex = C_UnitAuras.GetBuffDataByIndex, C_UnitAuras.GetDebuffDataByIndex
local FindAura = AuraUtil.FindAura
local UnpackAuraData = AuraUtil.UnpackAuraData

local GetSpellBookItemName = function(index, bookType)
local spellBank = (bookType == BOOKTYPE_SPELL) and Enum.SpellBookSpellBank.Player or Enum.SpellBookSpellBank.Pet;
return C_SpellBook.GetSpellBookItemName(index, spellBank);
end

local FindAura = AuraUtil.FindAura
ns.UnitBuff = function( unit, index, filter )
return UnpackAuraData( GetBuffDataByIndex( unit, index, filter ) )
end

ns.UnitDebuff = function( unit, index, filter )
return UnpackAuraData( GetDebuffDataByIndex( unit, index, filter ) )
end


ns.UnitBuff = function( unitToken, spellID, filter )
ns.UnitBuffByID = function( unitToken, spellID, filter )
local playerOrPet = UnitIsUnit( "player", unitToken ) or UnitIsUnit( "pet", unitToken )
filter = filter or "HELPFUL"

Expand All @@ -30,7 +39,7 @@ ns.UnitBuff = function( unitToken, spellID, filter )
end, unitToken, filter )
end

ns.UnitDebuff = function( unitToken, spellID, filter )
ns.UnitDebuffByID = function( unitToken, spellID, filter )
local playerOrPet = UnitIsUnit( "player", unitToken ) or UnitIsUnit( "pet", unitToken )
filter = filter or "HARMFUL"

Expand All @@ -41,6 +50,7 @@ ns.UnitDebuff = function( unitToken, spellID, filter )
end

local UnitBuff, UnitDebuff = ns.UnitBuff, ns.UnitDebuff
local UnitBuffByID, UnitDebuffByID = ns.UnitBuffByID, ns.UnitDebuffByID

local GetItemInfo = C_Item.GetItemInfo
local GetSpellInfo = C_Spell.GetSpellInfo
Expand Down Expand Up @@ -558,7 +568,7 @@ ns.FindPlayerAuraByID = FindPlayerAuraByID
-- Duplicate spell info lookup.
function ns.FindUnitBuffByID( unit, id, filter )
if unit == "player" then return FindPlayerAuraByID( id ) end
return UnitBuff( unit, id, filter )
return UnitBuffByID( unit, id, filter )
end


Expand Down Expand Up @@ -986,7 +996,7 @@ function Hekili:GetLoadoutExportString()
if isNodePurchased then
es:AddValue(1, isPartiallyRanked and 1 or 0);
if(isPartiallyRanked) then
es:AddValue(self.bitWidthRanksPurchased, treeNode.ranksPurchased);
es:AddValue(bitWidthRanksPurchased, treeNode.ranksPurchased);
end

es:AddValue(1, isChoiceNode and 1 or 0);
Expand Down

0 comments on commit 2350914

Please sign in to comment.