I just wrote this by memory really quickly, I have not tested or debugged it so if you have any problems turn on script errors and post back here and I will fix.
This code can be placed anywhere in a custom addon and will maintain a macro named “Heal” (you can change this to whatever you like". It will update whenever your bags changes, when you are not in combat, or enter into a new zone. It will check to see if you have any of those healthpotions or a healthstone available and will keep your macro updated to use the most relevant healing item as you requested.
local PotFrame = CreateFrame("Frame")
PotFrame:RegisterEvent("BAG_UPDATE")
PotFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
PotFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
PotFrame:SetScript("OnEvent", function(...)
if InCombatLockdown() then return end
local healthstone = 5512 -- Healthstone
local normalPot = 169451 -- Abyssal Healing Potion
local pvpPot = 216431 -- "Third Wind" Potion
local name, type = GetInstanceInfo()
local macro = "#showtooltip\n/use "
local macroName = "Heal"
local itemName = "";
for i = 0, 4 do
for z = 1, GetContainerNumSlots(i) do
local item = GetContainerItemID(i, z)
if item == healthstone then
local _, duration = GetContainerItemCooldown(i, z)
if duration == 0 then
itemName = select(1,GetItemInfo(healthstone)) -- Healthstone available
break
end
elseif item == pvpPot and type == "pvp" then
local _, duration = GetContainerItemCooldown(i, z)
if duration == 0 then
itemName = select(1,GetItemInfo(pvpPot)) -- PVP healing potion available
break
end
elseif item == normalPot then
local _, duration = GetContainerItemCooldown(i, z)
if duration == 0 then
itemName = select(1,GetItemInfo(normalPot)) -- Normal healing potion available
break
end
end
end
end
if itemName ~= "" then
EditMacro(macroName,macroName,nil,macro..itemName)
print("Macro "..macroName.." is now using "..itemName)
else
print("Macro "..macroName.." was not modified: No healing items were found")
end
end)
I was in a BG and it defaulted to the Abyssal Healing potion but once I used that it didn’t update to using a Healthstone until I left combat.
The chat output is also kind of spammy, I got about 100 Macro Heal is now using Abyssal Healing Potion just in a single BG so I wonder if maybe I did something wrong?
Do you have any ideas? I am not very knowledgeable with Addons.
edit: I think 3rd wind is item 138486, so I’m trying that now
Yeah that is expected, the macro can’t be updated in combat because it would allow for too much automated gameplay. But it should always use the Healthstone first if you pick one up before combat.
Maybe it could do a /castsequence for you instead? So during combat you can hit it twice and get a Healthstone then a Healing potion?
Oh yeah, I thought that might happen. Just remove the 2 print() lines at the end and everything else should still work properly.
This is great. Has some functionality, but a little quirky with how it picks the item. It appears to “miss” the hearthstone as preferred if both it and a regular pot are in the last bag. If I have just a hearthstone in the last bag, it picks the hearthstone every time. If I have just a pot in the last bag (and a hearthstone elsewhere) it picks the pot every time.
If you are interested in an addon that does this instead- check out autobar. It automatically fills the buttons based on what you have in your bags. So it will scroll through your water/food/potions. Also will let you pick between health pot and lock rocks with one button. I’ve been looking for some water/mage food macros and health pot/lock rocks macros and I think just keeping this addon and keybinding the buttons is an easier solution until the addon is no longer supported.