Skip to content

Commit

Permalink
Raid Healthstone priority (#47)
Browse files Browse the repository at this point in the history
* Raid Healthstones

Add a checkbox to lower the priority of healthstones in raid

* added DB settings and adjusted conditions

---------

Co-authored-by: davethemage <[email protected]>
  • Loading branch information
ollidiemaus and davethemage authored Aug 27, 2024
1 parent 5fb5ed0 commit 95c193c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
2 changes: 1 addition & 1 deletion AutoPotion.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Interface-Classic: 11503
## Interface-WOTLKC: 30403
## Interface-Cata: 40400
## Version: 3.5.8
## Version: 3.5.9
## Title: Auto Potion
## Author: ollidiemaus
## Notes: Updates the Macro AutoPotion to use either Healthstone or the highest Potion found in Bags
Expand Down
1 change: 1 addition & 0 deletions Core/DB.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local addonName, ham = ...
ham.defaults = {
cdReset = false,
raidStone = false,
witheringPotion = false,
witheringDreamsPotion = false,
activatedSpells = { ham.crimsonVialSpell, ham.renewal, ham.exhilaration, ham.fortitudeOfTheBear, ham.bitterImmunity,
Expand Down
36 changes: 32 additions & 4 deletions FrameXML/InterfaceOptionsFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,37 @@ function panel:InitializeOptions()

lastStaticElement = cdResetButton

------------- Healthstone button -------------
local raidStoneButton = CreateFrame("CheckButton", nil, self.panel, "InterfaceOptionsCheckButtonTemplate")
raidStoneButton:SetPoint("TOPLEFT", lastStaticElement, 0, -PADDING)
---@diagnostic disable-next-line: undefined-field
raidStoneButton.Text:SetText("Low Priority Healthstones(Instance only)")
raidStoneButton:HookScript("OnClick", function(_, btn, down)
HAMDB.raidStone = raidStoneButton:GetChecked()
self:updatePrio()
end)
raidStoneButton:HookScript("OnEnter", function(_, btn, down)
---@diagnostic disable-next-line: param-type-mismatch
GameTooltip:SetOwner(raidStoneButton, "ANCHOR_TOPRIGHT")
GameTooltip:SetText(
"This option will prioritize health potions over a healthstone while in a Instance")
GameTooltip:Show()
end)
raidStoneButton:HookScript("OnLeave", function(_, btn, down)
GameTooltip:Hide()
end)
raidStoneButton:SetChecked(HAMDB.raidStone)
lastStaticElement = raidStoneButton

------------- ITEMS -------------
local witheringPotionButton = nil
local witheringDreamsPotionButton = nil
if isRetail then
local itemsTitle = self.panel:CreateFontString("ARTWORK", nil, "GameFontNormalHuge")
itemsTitle:SetPoint("TOPLEFT", cdResetButton, 0, -PADDING_CATERGORY)
itemsTitle:SetPoint("TOPLEFT", lastStaticElement, 0, -PADDING_CATERGORY)
itemsTitle:SetText("Items")

local witheringPotionButton = CreateFrame("CheckButton", nil, self.panel, "InterfaceOptionsCheckButtonTemplate")
witheringPotionButton = CreateFrame("CheckButton", nil, self.panel, "InterfaceOptionsCheckButtonTemplate")
witheringPotionButton:SetPoint("TOPLEFT", itemsTitle, 0, -PADDING)
---@diagnostic disable-next-line: undefined-field
witheringPotionButton.Text:SetText("Use Potion of Withering Vitality")
Expand All @@ -237,7 +261,7 @@ function panel:InitializeOptions()
witheringPotionButton:SetChecked(HAMDB.witheringPotion)


local witheringDreamsPotionButton = CreateFrame("CheckButton", nil, self.panel,
witheringDreamsPotionButton = CreateFrame("CheckButton", nil, self.panel,
"InterfaceOptionsCheckButtonTemplate")
witheringDreamsPotionButton:SetPoint("TOPLEFT", itemsTitle, 300, -PADDING)
---@diagnostic disable-next-line: undefined-field
Expand Down Expand Up @@ -285,7 +309,11 @@ function panel:InitializeOptions()
end
end
cdResetButton:SetChecked(HAMDB.cdReset)
witheringPotionButton:SetChecked(HAMDB.witheringPotion)
raidStoneButton:SetChecked(HAMDB.raidStone)
if isRetail then
witheringPotionButton:SetChecked(HAMDB.witheringPotion)
witheringDreamsPotionButton:SetChecked(HAMDB.witheringDreamsPotion)
end
self:updatePrio()
print("Reset successful!")
end)
Expand Down
25 changes: 18 additions & 7 deletions code.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local isRetail = (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE)
local isClassic = (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC)
local isWrath = (WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC)
local isCata = (WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC)
local isRetail = (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE)


ham.myPlayer = ham.Player.new()
Expand All @@ -12,6 +13,7 @@ local spellsMacroString = ''
local itemsMacroString = ''
local macroStr = ''
local resetType = "combat"
local shortestCD = nil

local function addPlayerHealingItemIfAvailable()
for i, value in ipairs(ham.myPlayer.getHealingItems()) do
Expand Down Expand Up @@ -42,6 +44,10 @@ local function addPotIfAvailable()
for i, value in ipairs(ham.getPots()) do
if value.getCount() > 0 then
table.insert(ham.itemIdList, value.getId())
-- if healthstone does not has priority, remember healing potion's CD
if isRetail and HAMDB.raidStone and IsInInstance() then
shortestCD = 300 --potion CD
end
--we break because all Pots share a cd so we only want the highest healing one
break;
end
Expand All @@ -55,8 +61,14 @@ function ham.updateHeals()
ham.spellIDs = ham.myPlayer.getHealingSpells()

addPlayerHealingItemIfAvailable()
addHealthstoneIfAvailable()
addPotIfAvailable()
-- lower the priority of healthstones in a raid environment if selected
if HAMDB.raidStone and IsInInstance() then
addPotIfAvailable()
addHealthstoneIfAvailable()
else
addHealthstoneIfAvailable()
addPotIfAvailable()
end
end

local function createMacroIfMissing()
Expand All @@ -70,7 +82,6 @@ local function buildSpellMacroString()
spellsMacroString = ''

if next(ham.spellIDs) ~= nil then
local shortestCD = nil
for i, spell in ipairs(ham.spellIDs) do
local name
if isRetail == true then
Expand Down Expand Up @@ -103,10 +114,10 @@ local function buildSpellMacroString()
spellsMacroString = spellsMacroString .. ", " .. name;
end
end
--add if ham.cdReset == true then combat/spelltime
if HAMDB.cdReset then
resetType = "combat/" .. shortestCD
end
end
--add if ham.cdReset == true then combat/spelltime
if HAMDB.cdReset and shortestCD ~= nil then
resetType = "combat/" .. shortestCD
end
end

Expand Down

0 comments on commit 95c193c

Please sign in to comment.