Skip to content

Commit

Permalink
Fix spender usable checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Twintop committed May 8, 2024
1 parent 3941f03 commit 137faa9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 28 deletions.
13 changes: 5 additions & 8 deletions ClassModules/Druid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ local function RefreshLookupData_Balance()
local currentAstralPowerColor = specSettings.colors.text.current
local castingAstralPowerColor = specSettings.colors.text.casting

local astralPowerThreshold = math.min(TRB.Data.character.starsurgeThreshold, TRB.Data.character.starfallThreshold)
local astralPowerThreshold = math.min(spells.starsurge:GetPrimaryResourceCost(), spells.starfall:GetPrimaryResourceCost())

if TRB.Functions.Class:IsValidVariableForSpec("$inCombat") then
if specSettings.colors.text.overcapEnabled and overcap then
Expand Down Expand Up @@ -2336,9 +2336,6 @@ local function UpdateSnapshot_Balance()
local snapshotData = TRB.Data.snapshotData --[[@as TRB.Classes.SnapshotData]]
local currentTime = GetTime()

TRB.Data.character.starsurgeThreshold = spells.starsurge:GetPrimaryResourceCost()
TRB.Data.character.starfallThreshold = spells.starfall:GetPrimaryResourceCost()

snapshotData.snapshots[spells.moonkinForm.id].buff:Refresh()
snapshotData.snapshots[spells.furyOfElune.id].buff:UpdateTicks(currentTime)
snapshotData.snapshots[spells.sunderedFirmament.id].buff:UpdateTicks(currentTime)
Expand Down Expand Up @@ -2539,7 +2536,7 @@ local function UpdateResourceBar()
showThreshold = false
elseif snapshots[spells.starweaversWeft.id].buff.isActive then
thresholdColor = specSettings.colors.threshold.over
elseif currentResource >= TRB.Data.character.starsurgeThreshold then
elseif currentResource >= spells.starsurge:GetPrimaryResourceCost() then
thresholdColor = specSettings.colors.threshold.over
else
thresholdColor = specSettings.colors.threshold.under
Expand Down Expand Up @@ -2588,7 +2585,7 @@ local function UpdateResourceBar()
elseif spell.id == spells.starfall.id then
if spell.isTalent and not talents:IsTalentActive(spell) then -- Talent not selected
showThreshold = false
elseif currentResource >= TRB.Data.character.starfallThreshold then
elseif currentResource >= spells.starfall:GetPrimaryResourceCost() then
if snapshots[spells.starfall.id].buff.isActive and (snapshots[spells.starfall.id].buff.remaining) > (TRB.Data.character.pandemicModifier * spells.starfall.pandemicTime) then
thresholdColor = specSettings.colors.threshold.starfallPandemic
else
Expand Down Expand Up @@ -4078,12 +4075,12 @@ function TRB.Functions.Class:IsValidVariableForSpec(var)
end
elseif var == "$pulsarNextStarsurge" then
if talents:IsTalentActive(spells.primordialArcanicPulsar) and
(((spells.primordialArcanicPulsar.attributes.maxResource or 0) - (snapshots[spells.primordialArcanicPulsar.id].buff.customProperties["currentResource"])) <= TRB.Data.character.starsurgeThreshold) then
(((spells.primordialArcanicPulsar.attributes.maxResource or 0) - (snapshots[spells.primordialArcanicPulsar.id].buff.customProperties["currentResource"])) <= spells.starsurge:GetPrimaryResourceCost()) then
valid = true
end
elseif var == "$pulsarNextStarfall" then
if talents:IsTalentActive(spells.primordialArcanicPulsar) and
(((spells.primordialArcanicPulsar.attributes.maxResource or 0) - (snapshots[spells.primordialArcanicPulsar.id].buff.customProperties["currentResource"])) <= TRB.Data.character.starfallThreshold) then
(((spells.primordialArcanicPulsar.attributes.maxResource or 0) - (snapshots[spells.primordialArcanicPulsar.id].buff.customProperties["currentResource"])) <= spells.starsurge:GetPrimaryResourceCost()) then
valid = true
end
end
Expand Down
15 changes: 4 additions & 11 deletions ClassModules/Priest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1958,11 +1958,7 @@ local function RefreshLookupData_Shadow()
local currentInsanityColor = specSettings.colors.text.currentInsanity
local castingInsanityColor = specSettings.colors.text.castingInsanity

local insanityThreshold = TRB.Data.character.devouringPlagueThreshold

if snapshots[spells.mindDevourer.id].buff.isActive then
insanityThreshold = 0
end
local insanityThreshold = spells.devouringPlague:GetPrimaryResourceCost()

if TRB.Functions.Class:IsValidVariableForSpec("$inCombat") then
if specSettings.colors.text.overcapEnabled and overcap then
Expand Down Expand Up @@ -3836,8 +3832,7 @@ local function UpdateResourceBar()
passiveFrame:SetStatusBarColor(TRB.Functions.Color:GetRGBAFromString(specSettings.colors.bar.passive, true))
end


if snapshots[spells.mindDevourer.id].buff.isActive or currentResource >= TRB.Data.character.devouringPlagueThreshold then
if snapshots[spells.mindDevourer.id].buff.isActive or currentResource >= spells.devouringPlague:GetPrimaryResourceCost() then
castingFrame:SetStatusBarColor(TRB.Functions.Color:GetRGBAFromString(specSettings.colors.bar.devouringPlagueUsableCasting, true))
else
castingFrame:SetStatusBarColor(TRB.Functions.Color:GetRGBAFromString(specSettings.colors.bar.casting, true))
Expand Down Expand Up @@ -3865,13 +3860,13 @@ local function UpdateResourceBar()

if useEndOfVoidformColor and timeLeft <= timeThreshold then
barColor = specSettings.colors.bar.inVoidform1GCD
elseif snapshots[spells.mindDevourer.id].buff.isActive or currentResource >= TRB.Data.character.devouringPlagueThreshold then
elseif snapshots[spells.mindDevourer.id].buff.isActive or currentResource >= spells.devouringPlague:GetPrimaryResourceCost() then
barColor = specSettings.colors.bar.devouringPlagueUsable
else
barColor = specSettings.colors.bar.inVoidform
end
else
if snapshots[spells.mindDevourer.id].buff.isActive or currentResource >= TRB.Data.character.devouringPlagueThreshold then
if snapshots[spells.mindDevourer.id].buff.isActive or currentResource >= spells.devouringPlague:GetPrimaryResourceCost() then
barColor = specSettings.colors.bar.devouringPlagueUsable
else
barColor = specSettings.colors.bar.base
Expand Down Expand Up @@ -4643,8 +4638,6 @@ function TRB.Functions.Class:CheckCharacter()
TRB.Data.character.specName = "shadow"
---@diagnostic disable-next-line: missing-parameter
TRB.Data.character.maxResource = UnitPowerMax("player", Enum.PowerType.Resource)

TRB.Data.character.devouringPlagueThreshold = -spells.devouringPlague:GetPrimaryResourceCost()

if talents:IsTalentActive(spells.mindbender) then
snapshots[spells.shadowfiend.id].spell = spells.mindbender
Expand Down
33 changes: 25 additions & 8 deletions ClassModules/Shaman.lua
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,17 @@ local function RefreshLookupData_Elemental()
local currentMaelstromColor = specSettings.colors.text.currentMaelstrom
local castingMaelstromColor = specSettings.colors.text.castingMaelstrom

local maelstromThreshold = spells.earthShock:GetPrimaryResourceCost()
local maelstromThreshold = TRB.Data.character.maxResource

if talents:IsTalentActive(spells.earthquake) then
maelstromThreshold = math.min(maelstromThreshold, spells.earthquake:GetPrimaryResourceCost())
end

if talents:IsTalentActive(spells.earthShock) and not talents:IsTalentActive(spells.elementalBlast) then
maelstromThreshold = math.min(maelstromThreshold, spells.earthShock:GetPrimaryResourceCost())
elseif talents:IsTalentActive(spells.elementalBlast) then
maelstromThreshold = math.min(maelstromThreshold, spells.elementalBlast:GetPrimaryResourceCost())
end

if TRB.Functions.Class:IsValidVariableForSpec("$inCombat") then
if specSettings.colors.text.overcapEnabled and overcap then
Expand Down Expand Up @@ -1569,7 +1579,20 @@ local function UpdateResourceBar()
end
end

if currentResource >= spells.earthShock:GetPrimaryResourceCost() then
local maelstromThreshold = TRB.Data.character.maxResource

if talents:IsTalentActive(spells.earthquake) then
maelstromThreshold = math.min(maelstromThreshold, spells.earthquake:GetPrimaryResourceCost())
end

if talents:IsTalentActive(spells.earthShock) and not talents:IsTalentActive(spells.elementalBlast) then
maelstromThreshold = math.min(maelstromThreshold, spells.earthShock:GetPrimaryResourceCost())
elseif talents:IsTalentActive(spells.elementalBlast) then
maelstromThreshold = math.min(maelstromThreshold, spells.elementalBlast:GetPrimaryResourceCost())
end

if currentResource >= maelstromThreshold then
barColor = specSettings.colors.bar.earthShock
if specSettings.colors.bar.flashEnabled then
TRB.Functions.Bar:PulseFrame(barContainerFrame, specSettings.colors.bar.flashAlpha, specSettings.colors.bar.flashPeriod)
else
Expand Down Expand Up @@ -2172,12 +2195,6 @@ function TRB.Functions.Class:CheckCharacter()

TRB.Functions.Threshold:SetThresholdIcon(resourceFrame.thresholds[1], spells.earthShock, TRB.Data.settings.shaman.elemental)
TRB.Functions.Threshold:SetThresholdIcon(resourceFrame.thresholds[2], spells.elementalBlast, TRB.Data.settings.shaman.elemental)

if (talents:IsTalentActive(spells.elementalBlast) and spells.elementalBlast:GetPrimaryResourceCost() < TRB.Data.character.maxResource) then
TRB.Data.character.earthShockThreshold = -spells.elementalBlast:GetPrimaryResourceCost()
else
TRB.Data.character.earthShockThreshold = -spells.earthShock:GetPrimaryResourceCost()
end
elseif specId == 2 and TRB.Data.settings.core.experimental.specs.shaman.enhancement then
TRB.Data.character.specName = "enhancement"
local maxComboPoints = 10
Expand Down
7 changes: 7 additions & 0 deletions Functions/News.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ local content = [====[
---
# 10.2.7.2-release (2024-05-08)
## General
- (FIX (Twintop)) Fix bar and primary resource color change when you have enough primary resource to use an ability. Specifically affected specs: Balance Druid, Shadow Priest, and Elemental Shaman.
---
# 10.2.7.1-release (2024-05-08)
## General
Expand Down
2 changes: 1 addition & 1 deletion TwintopInsanityBar.toc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## Title-zhTW: Twintop 的資源欄
## Author: Twintop
## X-AuthorServer: Frostmourne-US/OCE
## Version: 10.2.7.1
## Version: 10.2.7.2
## X-ReleaseType: release
## X-ReleaseDate: 2024-05-08
## SavedVariables: TwintopInsanityBarSettings
Expand Down

0 comments on commit 137faa9

Please sign in to comment.