2020-10-14 03:19:44 +02:00
|
|
|
ThreepT2BS = {}
|
|
|
|
ThreepT2BS.title = GetAddOnMetadata("3pT2BS", "Title")
|
|
|
|
ThreepT2BS.version = GetAddOnMetadata("3pT2BS", "Version")
|
|
|
|
ThreepT2BS.author = GetAddOnMetadata("3pT2BS", "Author")
|
|
|
|
print(("Loaded %s v%s by %s."):format(ThreepT2BS.title, ThreepT2BS.version, ThreepT2BS.author))
|
|
|
|
|
|
|
|
local lastT2BattleShout = 0
|
2020-10-18 04:17:49 +02:00
|
|
|
local actions = {}
|
2020-10-14 03:19:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
local function hasRecentlyBattleShouted()
|
|
|
|
return lastT2BattleShout + ThreepT2BSDB.battleShoutPausePeriod > GetTime()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function has3pT2()
|
|
|
|
return GetNumSetItemsEquipped(ThreepT2BSDB.wrathSetId) >= 3
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function hasEnoughRageForBattleShout()
|
|
|
|
return UnitPower("player") >= GetSpellPowerCost("Battle Shout")[1].cost
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function isBloodRageReady()
|
|
|
|
local start, duration, enabled, modRate = GetSpellCooldown("Bloodrage")
|
|
|
|
return start == 0 and duration == 0
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local button = CreateFrame("Button", "3pT2BS", UIParent, "SecureActionButtonTemplate")
|
|
|
|
button:SetAttribute("type", "macro")
|
2020-10-19 16:12:22 +02:00
|
|
|
button:SetAttribute("macrotext", actions.takeWrathOff)
|
2020-10-14 03:19:44 +02:00
|
|
|
button:SetScript("PreClick", function (self, button, down)
|
|
|
|
if InCombatLockdown() then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if hasRecentlyBattleShouted() then
|
2020-10-18 04:17:49 +02:00
|
|
|
return self:SetAttribute("macrotext", actions.takeWrathOff)
|
2020-10-14 03:19:44 +02:00
|
|
|
end
|
|
|
|
if not hasEnoughRageForBattleShout() then
|
|
|
|
if isBloodRageReady() then
|
2020-10-18 04:17:49 +02:00
|
|
|
return self:SetAttribute("macrotext", actions.putWrathOn .. actions.castBloodRage)
|
2020-10-14 03:19:44 +02:00
|
|
|
end
|
2020-10-18 04:17:49 +02:00
|
|
|
return self:SetAttribute("macrotext", actions.takeWrathOff)
|
2020-10-14 03:19:44 +02:00
|
|
|
end
|
|
|
|
if not has3pT2() then
|
2020-10-18 04:17:49 +02:00
|
|
|
return self:SetAttribute("macrotext", actions.putWrathOn)
|
2020-10-14 03:19:44 +02:00
|
|
|
end
|
2020-10-19 16:12:22 +02:00
|
|
|
return self:SetAttribute("macrotext", actions.castBattleShout .. actions.takeWrathOff)
|
2020-10-14 03:19:44 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local frame, events = CreateFrame("FRAME"), {};
|
|
|
|
|
|
|
|
function events:COMBAT_LOG_EVENT_UNFILTERED()
|
|
|
|
local _, event, _, _, name, _, _, _, _, _, _, _, spellName = CombatLogGetCurrentEventInfo()
|
|
|
|
if spellName == "Battle Shout" and event == "SPELL_CAST_SUCCESS" and name == UnitName("player") and has3pT2() then
|
|
|
|
lastT2BattleShout = GetTime()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2020-10-19 16:13:13 +02:00
|
|
|
function events:ADDON_LOADED(addOnName)
|
2020-10-21 04:41:11 +02:00
|
|
|
if addOnName ~= "3pT2BS" then
|
2020-10-19 16:13:13 +02:00
|
|
|
return
|
|
|
|
end
|
2020-10-14 03:19:44 +02:00
|
|
|
ThreepT2BSDB = ThreepT2BSDB or {
|
|
|
|
["battleShoutPausePeriod"] = 10,
|
|
|
|
["wrathSetId"] = 218,
|
|
|
|
["actions"] = {
|
|
|
|
-- we always stop if in combat, since that means we might not have had a chance to set the correct macrotext
|
|
|
|
["castBloodRage"] = {
|
|
|
|
"/stopmacro [combat]",
|
|
|
|
"/cast Bloodrage",
|
|
|
|
},
|
|
|
|
["putWrathOn"] = {
|
|
|
|
"/cancelaura Bloodrage",
|
|
|
|
"/stopmacro [combat]",
|
|
|
|
"/eq Helm of Wrath",
|
|
|
|
"#/eq Pauldrons of Wrath",
|
|
|
|
"#/eq Breastplate of Wrath",
|
|
|
|
"#/eq Bracelets of Wrath",
|
|
|
|
"#/eq Gauntlets of Wrath",
|
|
|
|
"/eq Waistband of Wrath",
|
|
|
|
"#/eq Legplates of Wrath",
|
|
|
|
"/eq Sabatons of Wrath",
|
|
|
|
},
|
|
|
|
["castBattleShout"] = {
|
|
|
|
"/cancelaura Bloodrage",
|
|
|
|
"/cast Battle Shout",
|
|
|
|
},
|
|
|
|
["takeWrathOff"] = {
|
|
|
|
"/cancelaura Bloodrage",
|
|
|
|
"/stopmacro [combat]",
|
|
|
|
"/eq Lionheart Helm",
|
|
|
|
"/eq Onslaught Girdle",
|
|
|
|
"/eq Chromatic Boots",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for action, lines in pairs(ThreepT2BSDB.actions) do
|
2020-10-18 04:17:49 +02:00
|
|
|
actions[action] = table.concat(lines, "\n") .. "\n" -- extra newline allows for action composition
|
2020-10-14 03:19:44 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
frame:SetScript("OnEvent", function(self, event, ...)
|
2020-10-21 04:41:42 +02:00
|
|
|
events[event](self, ...)
|
2020-10-14 03:19:44 +02:00
|
|
|
end)
|
|
|
|
for k, v in pairs(events) do
|
|
|
|
frame:RegisterEvent(k) -- register all events for which handlers have been defined
|
|
|
|
end
|