Add 3pT2BS.

This commit is contained in:
Casper V. Kristensen 2020-10-14 03:19:44 +02:00
parent 20326be23a
commit ecd81ac57a
Signed by: caspervk
GPG key ID: 289CA03790535054
4 changed files with 148 additions and 0 deletions

114
3pT2BS/3pT2BS.lua Normal file
View file

@ -0,0 +1,114 @@
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
local actionMacros = {}
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")
button:SetAttribute("macrotext", wrathOff)
button:SetScript("PreClick", function (self, button, down)
if InCombatLockdown() then
return
end
if hasRecentlyBattleShouted() then
return self:SetAttribute("macrotext", actionMacros.takeWrathOff)
end
if not hasEnoughRageForBattleShout() then
if isBloodRageReady() then
return self:SetAttribute("macrotext", actionMacros.putWrathOn .. actionMacros.castBloodRage)
end
return self:SetAttribute("macrotext", actionMacros.takeWrathOff)
end
if not has3pT2() then
return self:SetAttribute("macrotext", actionMacros.putWrathOn)
end
return self:SetAttribute("macrotext", actionMacros.castBattleShout)
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
function events:ADDON_LOADED()
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",
"/stopmacro [combat]",
"/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
actionMacros[action] = table.concat(lines, "\n")
end
end
frame:SetScript("OnEvent", function(self, event, ...)
events[event](...)
end)
for k, v in pairs(events) do
frame:RegisterEvent(k) -- register all events for which handlers have been defined
end

13
3pT2BS/3pT2BS.toc Normal file
View file

@ -0,0 +1,13 @@
## Interface: 11305
## Title: 3pT2BS
## Notes: Automatically switch to 3/8 Wrath Tier 2, cast Battle Shout, and then switch back to normal gear.
## Author: Caspervk
## Version: 0.0.1
## X-License: GNU General Public License v3 or later (GPLv3+)
##SavedVariablesPerCharacter: ThreepT2BSDB
util.lua
3pT2BS.lua

6
3pT2BS/README.md Normal file
View file

@ -0,0 +1,6 @@
# 3pT2BS
World of Warcraft Classic AddOn for Fury Warriors to automatically switch to 3/8 Wrath Tier 2, cast Battle Shout, and
then switch back to normal gear with the press of one button.
Use `/click 3pT2BS` in a macro to keybind.
Gear-sets needs to be modified in `WTF/Account/x/y/z/SavedVariables/3pT2BS.lua` after first run.

15
3pT2BS/util.lua Normal file
View file

@ -0,0 +1,15 @@
function GetNumSetItemsEquipped(setID)
-- From WeakAuras.GetNumSetItemsEquipped
-- https://github.com/WeakAuras/WeakAuras2/blob/master/WeakAuras/Prototypes.lua#L969
if not setID or not type(setID) == "number" then return end
local equipped = 0
local setName = GetItemSetInfo(setID)
for i = 1, 18 do
local item = GetInventoryItemID("player", i)
if item and select(16, GetItemInfo(item)) == setID then
equipped = equipped + 1
end
end
return equipped, 18, setName
end