-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Diclah/master
Use cast sequence if possible.
- Loading branch information
Showing
2 changed files
with
87 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,93 @@ | ||
-- This file is loaded from "HealthstoneAutoMacro.toc" | ||
|
||
-- #showtooltip | ||
-- /castsequence reset=combat Healthstone, Coastal Healing Potion | ||
do | ||
|
||
local HealPotMacroIcon = CreateFrame("Frame") | ||
HealPotMacroIcon:RegisterEvent("BAG_UPDATE") | ||
HealPotMacroIcon:RegisterEvent("PLAYER_LOGIN") | ||
local HSId = 5512; | ||
local SilasPotId = 156634; | ||
local NormalPotId = 152494; | ||
local EmeraldId = 166799; -- Emerald of Vigor | ||
|
||
function getPotNames() | ||
SilasPotName = GetItemInfo(SilasPotId); | ||
NormalPotName = GetItemInfo(NormalPotId); | ||
EmeraldName = GetItemInfo(EmeraldId); | ||
|
||
-- fall back on connect sometimes GetItem fail | ||
if SilasPotName==nil then | ||
SilasPotName = "Silas' Vial of Continuous Curing" | ||
end | ||
if NormalPotName==nil then | ||
NormalPotName = "Coastal Healing Potion" | ||
end | ||
if EmeraldName==nil then | ||
EmeraldName = "Emerald of Vigor" | ||
end | ||
return SilasPotName, NormalPotName, EmeraldName | ||
end | ||
|
||
function getPots() | ||
SilasPotName, NormalPotName, EmeraldName = getPotNames() | ||
SilasNbr = GetItemCount(SilasPotId, false, false); | ||
return { | ||
{SilasPotName, SilasNbr}, | ||
{EmeraldName, GetItemCount(EmeraldId, false, false)}, | ||
{NormalPotName, GetItemCount(NormalPotId, false, false)} | ||
} | ||
end | ||
function getHs() | ||
HSName = GetItemInfo(HSId); | ||
if HSName==nil then | ||
HSName = "Healthstone" | ||
end | ||
return HSName, GetItemCount(HSId, false, false); | ||
end | ||
|
||
local onCombat = true; | ||
local HealPotMacroIcon = CreateFrame("Frame"); | ||
HealPotMacroIcon:RegisterEvent("BAG_UPDATE"); | ||
HealPotMacroIcon:RegisterEvent("PLAYER_LOGIN"); | ||
HealPotMacroIcon:RegisterEvent("PLAYER_REGEN_ENABLED"); | ||
HealPotMacroIcon:RegisterEvent("PLAYER_REGEN_DISABLED"); | ||
HealPotMacroIcon:SetScript("OnEvent",function(self,event,...) | ||
pot = GetItemCount("Healthstone")==0 and "Coastal Healing Potion" or "Healthstone" | ||
item = GetItemCount("Silas' Vial of Continuous Curing")==0 and pot or "Silas' Vial of Continuous Curing" | ||
EditMacro("HAMHealthPot", "HAMHealthPot", nil, "#showtooltip \n/use " .. item, 1, nil) | ||
if event=="PLAYER_LOGIN" then | ||
onCombat = false; | ||
end | ||
if event=="PLAYER_REGEN_DISABLED" then | ||
onCombat = true; | ||
return ; | ||
end | ||
if event=="PLAYER_REGEN_ENABLED" then | ||
onCombat = false; | ||
end | ||
|
||
if onCombat==false then | ||
local Pot = getPots() | ||
local HsName, HsNbr = getHs() | ||
local macroStr, potName, found; | ||
|
||
found = false; | ||
for i,v in ipairs(Pot) do | ||
if v[2] > 0 then | ||
found = true; | ||
potName = v[1] | ||
break; | ||
end | ||
end | ||
|
||
if HsNbr > 0 then | ||
if found==true then | ||
macroStr = "#showtooltip \n/castsequence reset=combat " .. HSName .. ", " .. potName; | ||
else | ||
macroStr = "#showtooltip \n/use " .. HSName; | ||
end | ||
elseif found==true then | ||
macroStr = "#showtooltip \n/use " .. potName; | ||
else | ||
macroStr = "#showtooltip" | ||
end | ||
EditMacro("HAMHealthPot", "HAMHealthPot", nil, macroStr, 1, nil) | ||
end | ||
end) | ||
|
||
end |