diff --git a/AutoPotion.toc b/AutoPotion.toc index cfaad48..a12c510 100755 --- a/AutoPotion.toc +++ b/AutoPotion.toc @@ -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 diff --git a/Core/DB.lua b/Core/DB.lua index eadfb3c..b220639 100644 --- a/Core/DB.lua +++ b/Core/DB.lua @@ -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, diff --git a/FrameXML/InterfaceOptionsFrame.lua b/FrameXML/InterfaceOptionsFrame.lua index 453fb15..fe27af8 100644 --- a/FrameXML/InterfaceOptionsFrame.lua +++ b/FrameXML/InterfaceOptionsFrame.lua @@ -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") @@ -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 @@ -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) diff --git a/code.lua b/code.lua index fcfb797..9703be2 100755 --- a/code.lua +++ b/code.lua @@ -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() @@ -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 @@ -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 @@ -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() @@ -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 @@ -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