Skip to content

Commit

Permalink
Rework raid buffs to only show available
Browse files Browse the repository at this point in the history
Consumables was hardcoded for showing three, but ReadyCheck was suppose to
be limiting and has been wonky for awhile.
  • Loading branch information
nebularg committed Nov 15, 2022
1 parent a9c4b3f commit bf8fca3
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 58 deletions.
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ globals = {
"UnitCastingInfo",
"UnitChannelInfo",
"UnitClass",
"UnitClassBase",
"UnitDetailedThreatSituation",
"UnitEffectiveLevel",
"UnitExists",
Expand Down
44 changes: 30 additions & 14 deletions modules/Consumables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ local raidBuffNames = {
(GetSpellInfo(6673)), -- ITEM_MOD_ATTACK_POWER_SHORT,
(GetSpellInfo(1126)), -- ITEM_MOD_VERSATILITY,
}
local raidBuffProviders = {
"MAGE",
"PRIEST",
"WARRIOR",
"DRUID",
}

---------------------------------------
-- Options
Expand Down Expand Up @@ -292,7 +298,12 @@ function module:OnRegister()
{[YES] = 1, [NO] = 0},
{[YES] = 1, [NO] = 0},
{[NO] = ""},
{["1/4"] = 1, ["2/4"] = 2, ["3/4"] = 3, ["4/4"] = 4, ["0/4"] = 0}
{ -- these are currently clamped, but just in case
["1/1"] = 1, ["2/1"] = 2, ["3/1"] = 3, ["4/1"] = 4, ["0/1"] = 0,
["1/2"] = 1, ["2/2"] = 2, ["3/2"] = 3, ["4/2"] = 4, ["0/2"] = 0,
["1/3"] = 1, ["2/3"] = 2, ["3/3"] = 3, ["4/3"] = 4, ["0/3"] = 0,
["1/4"] = 1, ["2/4"] = 2, ["3/4"] = 3, ["4/4"] = 4, ["0/4"] = 0,
}
)

oRA.RegisterCallback(self, "OnStartup")
Expand Down Expand Up @@ -368,12 +379,6 @@ do
[307185] = true, -- Spectral Flask of Power
[307187] = true, -- Spectral Stamina Flask

-- Buffs
[1459] = true, -- Arcane Intellect
[21562] = true, -- Power Word: Fortitude
[6637] = true, -- Battle Shout
[1126] = true, -- Mark of the Wild

-- Rune
[367405] = true, -- Eternal Augmentation
}
Expand Down Expand Up @@ -563,8 +568,12 @@ function module:CheckPlayer(player)
local vantus = getVantus(player)
local buffs = cache[5] or {}
for i = 1, #raidBuffs do
local _, _, id = self:UnitBuffByIDs(player, raidBuffs[i])
buffs[i] = id or false
if oRA:HasClassMembers(raidBuffProviders[i]) then
local _, _, id = self:UnitBuffByIDs(player, raidBuffs[i])
buffs[i] = id or false
else
buffs[i] = nil
end
end

cache[0] = t
Expand Down Expand Up @@ -596,6 +605,13 @@ do
wipe(missingRunes)
wipe(missingBuffs)

local numRaidBuffs = 0
for i = 1, #raidBuffs do
if oRA:HasClassMembers(raidBuffProviders[i]) then
numRaidBuffs = numRaidBuffs + 1
end
end

local groupMembers = oRA:GetGroupMembers()
if not groupMembers[1] then groupMembers[1] = UnitName("player") end
for _, player in next, groupMembers do
Expand All @@ -615,11 +631,11 @@ do
missingRunes[player] = true
end

for i = 1, #buffs do
if not buffs[i] then
missingBuffs[raidBuffNames[i]] = true
else
for i = 1, #raidBuffs do
if buffs[i] then
numBuffs = numBuffs + 1
elseif buffs[i] == false then -- missing while available
missingBuffs[raidBuffNames[i]] = true
end
end

Expand All @@ -629,7 +645,7 @@ do
flask and (self:GetFlaskValue(flask) or YES) or NO,
rune and YES or NO,
getVantusBoss(vantus) or NO,
("%d/%d"):format(numBuffs, #buffs),
("%d/%d"):format(numBuffs, numRaidBuffs),
}
else
consumablesList[#consumablesList + 1] = {
Expand Down
77 changes: 33 additions & 44 deletions modules/ReadyCheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@ local list = {} -- temp table to concat from
local lastUpdate = 0

local missingBuffs = {}
local buffAvailable = {}
local buffProvider = {
MAGE = 1,
PRIEST = 2,
WARRIOR = 3,
}

local BUFF_ICON_SIZE = 12
local NUM_RAID_BUFFS = 4

local playerName = UnitName("player")
local _, playerClass = UnitClass("player")
local playerClass = UnitClassBase("player")
local topMemberFrames, bottomMemberFrames = {}, {} -- ready check member frames
local delayedSpellUpdates = {}

Expand Down Expand Up @@ -258,13 +253,12 @@ do
if self.text then
self.text:SetText("")
end
return
else
self.name = name
self.icon:SetTexture(icon)
self.icon:SetDesaturated(false)
self.icon:SetVertexColor(1, 1, 1, 1) -- restore color
end

self.name = name
self.icon:SetTexture(icon)
self.icon:SetDesaturated(false)
self.icon:SetVertexColor(1, 1, 1, 1) -- restore color
end

function addBuffFrame(name, parent, tooltip, icon, ...)
Expand Down Expand Up @@ -315,23 +309,27 @@ local function addIconAndName(frame)

-- Battle Shout
local name, _, icon = GetSpellInfo(6673)
frame.GroupBuff3 = addBuffFrame("GroupBuff3", frame, name, icon, "RIGHT", -6 - (0*BUFF_ICON_SIZE), 0)
frame.GroupBuff3.groupBuff = name -- ITEM_MOD_ATTACK_POWER_SHORT
frame.GroupBuff1 = addBuffFrame("GroupBuff1", frame, name, icon, "RIGHT", -6 - (0*BUFF_ICON_SIZE), 0)
frame.GroupBuff1.groupBuff = name -- ITEM_MOD_ATTACK_POWER_SHORT
frame.GroupBuff1.classProvider = "WARRIOR"

-- Power Word: Fortitude
name, _, icon = GetSpellInfo(21562)
frame.GroupBuff2 = addBuffFrame("GroupBuff2", frame, name, icon, "RIGHT", -6 - (1*BUFF_ICON_SIZE), 0)
frame.GroupBuff2.groupBuff = name -- ITEM_MOD_STAMINA_SHORT
frame.GroupBuff2.classProvider = "PRIEST"

-- Arcane Intellect
name, _, icon = GetSpellInfo(1459)
frame.GroupBuff1 = addBuffFrame("GroupBuff1", frame, name, icon, "RIGHT", -6 - (2*BUFF_ICON_SIZE), 0)
frame.GroupBuff1.groupBuff = name -- ITEM_MOD_INTELLECT_SHORT
frame.GroupBuff3 = addBuffFrame("GroupBuff3", frame, name, icon, "RIGHT", -6 - (2*BUFF_ICON_SIZE), 0)
frame.GroupBuff3.groupBuff = name -- ITEM_MOD_INTELLECT_SHORT
frame.GroupBuff3.classProvider = "MAGE"

-- Mark of the Wild
name, _, icon = GetSpellInfo(1126)
frame.GroupBuff4 = addBuffFrame("GroupBuff4", frame, name, icon, "RIGHT", -6 - (3*BUFF_ICON_SIZE), 0)
frame.GroupBuff4.groupBuff = name -- ITEM_MOD_INTELLECT_SHORT
frame.GroupBuff4.classProvider = "DRUID"

-- consumable buffs
frame.VantusBuff = addBuffFrame("Vantus", frame, "", 1392952, "RIGHT", -6 - (4*BUFF_ICON_SIZE), 0) -- 1392952="Interface/Icons/70_inscription_vantus_rune_nightmare"
Expand Down Expand Up @@ -378,7 +376,17 @@ local function createBottomFrame()
end

local function anchorBuffs(f)
local i = 4
local i = 0
for j = 1, NUM_RAID_BUFFS do
local bf = f[("GroupBuff%d"):format(j)]
if oRA:HasClassMembers(bf.classProvider) then
i = i + 1
bf:SetPoint("RIGHT", -6 - ((i-1)*BUFF_ICON_SIZE), 0)
else
-- just unanchor instead of another show flag? sounds good
bf:ClearAllPoints()
end
end
if module.db.profile.showVantus then
i = i + 1
f.VantusBuff:SetPoint("RIGHT", -6 - ((i-1)*BUFF_ICON_SIZE), 0)
Expand Down Expand Up @@ -415,10 +423,10 @@ local function setMemberStatus(num, bottom, name, class, update)
f.FoodBuff:SetShown(not food)
f.FlaskBuff:SetShown(not flask)
f.RuneBuff:SetShown(not rune)
f.GroupBuff1:SetShown(not buffs[1])
f.GroupBuff2:SetShown(not buffs[2])
f.GroupBuff3:SetShown(not buffs[3])
f.GroupBuff4:SetShown(not buffs[4])
f.GroupBuff1:SetShown(buffs[1] == false)
f.GroupBuff2:SetShown(buffs[2] == false)
f.GroupBuff3:SetShown(buffs[3] == false)
f.GroupBuff4:SetShown(buffs[4] == false)
else
f.FoodBuff:SetShown(food)
f.FlaskBuff:SetShown(flask)
Expand Down Expand Up @@ -471,27 +479,13 @@ local function setMemberStatus(num, bottom, name, class, update)
f.VantusBuff:SetSpell(vantus)
end

for i = 1, #buffs do
for i = 1, NUM_RAID_BUFFS do
local id = buffs[i]
local icon = f[("GroupBuff%d"):format(i)]
icon:SetSpell(id)
if not id then
missingBuffs[icon.groupBuff] = true
end
if buffAvailable[i] and (not id or not consumables:IsBest(id)) then
if id == false then -- missing while available
ready = false
missingBuffs[icon.groupBuff] = true
if id and not consumables:IsBest(id) then -- using a scroll
icon.tooltip = L.notBestBuff
if showMissing then
icon.icon:SetDesaturated(true)
icon.icon:SetVertexColor(1, 1, 0.5, 1) -- yellow
icon:Show()
else
icon.icon:SetDesaturated(true)
icon.icon:SetVertexColor(1, 0.5, 0.5, 1) -- red
end
end
end
end
end
Expand Down Expand Up @@ -591,7 +585,7 @@ function updateWindow(force)
for i = 1, GetNumSubgroupMembers() do
local unit = ("party%d"):format(i)
local name = module:UnitName(unit)
local _, class = UnitClass(unit)
local class = UnitClassBase(unit)
setMemberStatus(i+1, false, name, class, update)
end
end
Expand Down Expand Up @@ -947,7 +941,6 @@ function module:OnGroupChanged(_, status, members)

local checkupdate = readychecking and self.db.profile.readyByGroup
local update = nil
wipe(buffAvailable)

for i = 1, GetNumGroupMembers() do
local name, _, group, _, class = GetRaidRosterInfo(i)
Expand All @@ -961,10 +954,6 @@ function module:OnGroupChanged(_, status, members)
update = true
end
end
local buff = buffProvider[class]
if buff then
buffAvailable[buff] = true
end
end
end

Expand Down
8 changes: 8 additions & 0 deletions oRA3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,14 @@ do
end
return tmp
end
function addon:HasClassMembers(class)
for _, unit in next, groupMembers do
if UnitClassBase(unit) == class then
return true
end
end
return false
end
function addon:GetBlizzardTanks() return tanks end

local tmpGroup = {}
Expand Down

0 comments on commit bf8fca3

Please sign in to comment.