Skip to content

Commit

Permalink
Add logic to handle new aura functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharparam committed Mar 14, 2024
1 parent a8ca095 commit 91662d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Chocobo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,13 @@ function C:CheckMount()
local found = false
local index = 1
repeat
local name = UnitBuff("player", index, "PLAYER CANCELABLE")
local name
if WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC then
name = UnitBuff("player", index, "PLAYER CANCELABLE")
else
local aura = C_UnitAuras.GetBuffDataByIndex("player", index, "PLAYER CANCELABLE")
name = aura and aura.name
end
if not name then break end -- No more buffs to check
if self.Global["CUSTOM"][name:lower()] then
self:PlayRandomMusic(name)
Expand Down
18 changes: 17 additions & 1 deletion libs/ChocoboLib/ChocoboLib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,26 @@ end
--[[ChocoboLib Specific Functions]]--
-- Buff/Aura functions

local G_UnitBuff = _G.UnitBuff
local UnitBuff

if WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC then
UnitBuff = function(unit, index, filter)
local name, _, _, _, _, _, _, _, _, id = G_UnitBuff(unit, index, filter)
return name, id
end
else
UnitBuff = function(unit, index, filter)
local aura = C_UnitAuras.GetBuffDataByIndex(unit, index, filter)
if not aura then return nil, nil end
return aura.name, aura.spellId
end
end

local function GetBuffs()
local buffs = {}
for i=1,40 do -- Loop through all 40 possible buff indexes
local name, _, _, _, _, _, _, _, _, id = UnitBuff("player", i, "PLAYER CANCELABLE") -- Get buff on index i
local name, id = UnitBuff("player", i, "PLAYER CANCELABLE") -- Get buff on index i
-- Insert it into the buffs table, break if buff is nil (that means no other buffs exist on the player)
if name and id then buffs[name] = id else break end
end
Expand Down

0 comments on commit 91662d1

Please sign in to comment.