from retail
This commit is contained in:
@@ -3214,6 +3214,70 @@ function Private.ExecEnv.CheckTotemName(totemName, triggerTotemName, triggerTote
|
||||
return true
|
||||
end
|
||||
|
||||
-- Queueable Spells
|
||||
local queueableSpells
|
||||
local classQueueableSpells = {
|
||||
["WARRIOR"] = {
|
||||
(select(1, GetSpellInfo(78))), -- Heroic Strike
|
||||
(select(1, GetSpellInfo(845))), -- Cleave
|
||||
},
|
||||
["HUNTER"] = {
|
||||
(select(1, GetSpellInfo(2973))), -- Raptor Strike
|
||||
},
|
||||
["DRUID"] = {
|
||||
(select(1, GetSpellInfo(6807))), -- Maul
|
||||
},
|
||||
["DEATHKNIGHT"] = {
|
||||
(select(1, GetSpellInfo(56815))), -- Rune Strike
|
||||
},
|
||||
}
|
||||
local class = select(2, UnitClass("player"))
|
||||
queueableSpells = classQueueableSpells[class]
|
||||
|
||||
local queuedSpellFrame
|
||||
function WeakAuras.WatchForQueuedSpell()
|
||||
if not queuedSpellFrame then
|
||||
queuedSpellFrame = CreateFrame("Frame")
|
||||
Private.frames["Queued Spell Handler"] = queuedSpellFrame
|
||||
queuedSpellFrame:RegisterEvent("CURRENT_SPELL_CAST_CHANGED")
|
||||
|
||||
queuedSpellFrame:SetScript("OnEvent", function(self)
|
||||
local newQueuedSpell
|
||||
if queueableSpells then
|
||||
for _, spellName in ipairs(queueableSpells) do
|
||||
if IsCurrentSpell(spellName) then
|
||||
newQueuedSpell = spellName
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if newQueuedSpell ~= self.queuedSpell then
|
||||
self.queuedSpell = newQueuedSpell
|
||||
Private.ScanEvents("WA_UNIT_QUEUED_SPELL_CHANGED", "player")
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function WeakAuras.GetQueuedSpell()
|
||||
return queuedSpellFrame and queuedSpellFrame.queuedSpell
|
||||
end
|
||||
|
||||
function WeakAuras.GetSpellCost(powerTypeToCheck)
|
||||
local spellName = UnitCastingInfo("player")
|
||||
if not spellName then -- not casting so check if it is queued
|
||||
spellName = WeakAuras.GetQueuedSpell()
|
||||
end
|
||||
if spellName then
|
||||
local _, _, _, powerCost, _, powerType = GetSpellInfo(spellName);
|
||||
if powerType and powerCost then
|
||||
if powerType == powerTypeToCheck then
|
||||
return powerCost;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Weapon Enchants
|
||||
do
|
||||
local mh = GetInventorySlotInfo("MainHandSlot")
|
||||
|
||||
@@ -2233,6 +2233,14 @@ Private.event_prototypes = {
|
||||
if trigger.use_ignoreDead or trigger.use_ignoreDisconnected then
|
||||
AddUnitEventForEvents(result, unit, "UNIT_FLAGS")
|
||||
end
|
||||
-- The api for spell power costs is not meant to be for other units
|
||||
if trigger.use_showCost and trigger.unit == "player" then
|
||||
AddUnitEventForEvents(result, "player", "UNIT_SPELLCAST_START")
|
||||
AddUnitEventForEvents(result, "player", "UNIT_SPELLCAST_STOP")
|
||||
AddUnitEventForEvents(result, "player", "UNIT_SPELLCAST_FAILED")
|
||||
AddUnitEventForEvents(result, "player", "UNIT_SPELLCAST_SUCCEEDED")
|
||||
AddUnitEventForEvents(result, "player", "UPDATE_SHAPESHIFT_FORM")
|
||||
end
|
||||
if unit and not Private.multiUnitUnits[unit] then
|
||||
if not result.events then
|
||||
result.events = {}
|
||||
@@ -2255,9 +2263,15 @@ Private.event_prototypes = {
|
||||
if trigger.use_specId then
|
||||
AddUnitSpecChangeInternalEvents(unit, result)
|
||||
end
|
||||
if trigger.use_showCost and trigger.unit == "player" then
|
||||
tinsert(result, "WA_UNIT_QUEUED_SPELL_CHANGED");
|
||||
end
|
||||
return result
|
||||
end,
|
||||
loadFunc = function(trigger)
|
||||
if trigger.use_showCost and trigger.unit == "player" then
|
||||
WeakAuras.WatchForQueuedSpell()
|
||||
end
|
||||
local includePets = trigger.use_includePets == true and trigger.includePets or nil
|
||||
AddWatchedUnits(trigger.unit, includePets)
|
||||
end,
|
||||
@@ -2277,6 +2291,25 @@ Private.event_prototypes = {
|
||||
|
||||
table.insert(ret, unitHelperFunctions.SpecificUnitCheck(trigger))
|
||||
|
||||
local canEnableShowCost = (not trigger.use_powertype) and trigger.unit == "player";
|
||||
if (canEnableShowCost and trigger.use_showCost) then
|
||||
table.insert(ret, [[
|
||||
if (event == "UPDATE_SHAPESHIFT_FORM") then
|
||||
local cost = WeakAuras.GetSpellCost(powerTypeToCheck)
|
||||
if state.cost ~= cost then
|
||||
state.cost = cost
|
||||
state.changed = true
|
||||
end
|
||||
elseif ( (event == "UNIT_SPELLCAST_START" or event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_SUCCEEDED") and unit == "player") or event == "WA_UNIT_QUEUED_SPELL_CHANGED" then
|
||||
local cost = WeakAuras.GetSpellCost(powerTypeToCheck)
|
||||
if state.cost ~= cost then
|
||||
state.cost = cost
|
||||
state.changed = true
|
||||
end
|
||||
end
|
||||
]])
|
||||
end
|
||||
|
||||
return table.concat(ret)
|
||||
end,
|
||||
statesParameter = "unit",
|
||||
@@ -2312,6 +2345,16 @@ Private.event_prototypes = {
|
||||
return trigger.use_powertype
|
||||
end,
|
||||
},
|
||||
{
|
||||
name = "showCost",
|
||||
display = L["Overlay Cost of Casts"],
|
||||
type = "toggle",
|
||||
test = "true",
|
||||
enable = function(trigger)
|
||||
return (not trigger.use_powertype) and trigger.unit == "player";
|
||||
end,
|
||||
reloadOptions = true
|
||||
},
|
||||
{
|
||||
name = "power",
|
||||
display = L["Power"],
|
||||
@@ -2574,6 +2617,17 @@ Private.event_prototypes = {
|
||||
test = "WeakAuras.UnitExistsFixed(unit, smart) and specificUnitCheck"
|
||||
}
|
||||
},
|
||||
overlayFuncs = {
|
||||
{
|
||||
name = L["Spell Cost"],
|
||||
func = function(trigger, state)
|
||||
return "back", type(state.cost) == "number" and state.cost;
|
||||
end,
|
||||
enable = function(trigger)
|
||||
return trigger.use_showCost and (not trigger.use_powertype) and trigger.unit == "player";
|
||||
end
|
||||
},
|
||||
},
|
||||
automaticrequired = true
|
||||
},
|
||||
["Combat Log"] = {
|
||||
|
||||
Reference in New Issue
Block a user