Add util to check if ability will be cast soon

main
Ryan Crockett 2 years ago
parent ada2b52ca1
commit d65b0c1c26
  1. 87
      src/ContentUtils/ContentUtils.lua
  2. 0
      src/ContentUtils/lists/dispel-list.lua
  3. 2
      src/ContentUtils/lists/group-wide-list.lua
  4. 3
      src/ContentUtils/lists/interrupt-list.lua
  5. 7
      src/ContentUtils/lists/tank-buster-list.lua
  6. 37
      src/_bastion.lua

@ -5,8 +5,8 @@ local Bastion = _Bastion
---@alias BigWigsBars table<string, { spellId: number, duration: number, startTime: number, pauseTime: number | nil }> ---@alias BigWigsBars table<string, { spellId: number, duration: number, startTime: number, pauseTime: number | nil }>
---@class MythicPlusUtils ---@class ContentUtils
local MythicPlusUtils = { local ContentUtils = {
---@type InterruptList ---@type InterruptList
interruptList = {}, interruptList = {},
---@type TankBusterList ---@type TankBusterList
@ -16,7 +16,7 @@ local MythicPlusUtils = {
isBigWigsEnabled = false isBigWigsEnabled = false
} }
MythicPlusUtils.__index = MythicPlusUtils ContentUtils.__index = ContentUtils
local function BWEventCallBack(event, ...) local function BWEventCallBack(event, ...)
if event == "BigWigs_StartBar" then if event == "BigWigs_StartBar" then
@ -25,56 +25,56 @@ local function BWEventCallBack(event, ...)
print('START BAR', text) print('START BAR', text)
MythicPlusUtils.bars[text] = MythicPlusUtils.bars[text] or {} ContentUtils.bars[text] = ContentUtils.bars[text] or {}
MythicPlusUtils.bars[text].duration = duration ContentUtils.bars[text].duration = duration
MythicPlusUtils.bars[text].startTime = now ContentUtils.bars[text].startTime = now
MythicPlusUtils.bars[text].spellId = spellId ContentUtils.bars[text].spellId = spellId
elseif event == "BigWigs_StopBar" then elseif event == "BigWigs_StopBar" then
local addon, text = ... local addon, text = ...
print('STOP BAR', text) print('STOP BAR', text)
if MythicPlusUtils.bars[text] then if ContentUtils.bars[text] then
MythicPlusUtils.bars[text] = nil ContentUtils.bars[text] = nil
end end
elseif event == "BigWigs_PauseBar" then elseif event == "BigWigs_PauseBar" then
local addon, text = ... local addon, text = ...
print('PAUSE BAR', text) print('PAUSE BAR', text)
if MythicPlusUtils.bars[text] then if ContentUtils.bars[text] then
MythicPlusUtils.bars[text].pauseTime = GetTime() ContentUtils.bars[text].pauseTime = GetTime()
end end
elseif event == "BigWigs_ResumeBar" then elseif event == "BigWigs_ResumeBar" then
local addon, text = ... local addon, text = ...
print('RESUME BAR', text) print('RESUME BAR', text)
if MythicPlusUtils.bars[text] and MythicPlusUtils.bars[text].pauseTime then if ContentUtils.bars[text] and ContentUtils.bars[text].pauseTime then
local pauseTime = MythicPlusUtils.bars[text].pauseTime local pauseTime = ContentUtils.bars[text].pauseTime
local startTime = MythicPlusUtils.bars[text].startTime local startTime = ContentUtils.bars[text].startTime
local duration = MythicPlusUtils.bars[text].duration local duration = ContentUtils.bars[text].duration
local newDuration = duration - (pauseTime - startTime) local newDuration = duration - (pauseTime - startTime)
MythicPlusUtils.bars[text].duration = newDuration ContentUtils.bars[text].pauseTime = nil
MythicPlusUtils.bars[text].startTime = GetTime() ContentUtils.bars[text].duration = newDuration
MythicPlusUtils.bars[text].pauseTime = nil ContentUtils.bars[text].startTime = GetTime()
end end
elseif event == "BigWigs_StopBars" or event == "BigWigs_OnBossDisable" then elseif event == "BigWigs_StopBars" or event == "BigWigs_OnBossDisable" then
MythicPlusUtils.bars = {} ContentUtils.bars = {}
end end
end end
---@type InterruptList ---@type InterruptList
local _interruptList = Tinkr:require("scripts/bastion/MythicPlusUtils/lists/interrupt-list", Bastion) local _interruptList = Tinkr:require("scripts/bastion/ContentUtils/lists/interrupt-list", Bastion)
---@type TankBusterList ---@type TankBusterList
local _tankBusterList = Tinkr:require("scripts/bastion/MythicPlusUtils/lists/tank-buster-list", Bastion) local _tankBusterList = Tinkr:require("scripts/bastion/ContentUtils/lists/tank-buster-list", Bastion)
---@return MythicPlusUtils ---@return ContentUtils
function MythicPlusUtils:New() function ContentUtils:New()
local self = setmetatable({}, MythicPlusUtils) local self = setmetatable({}, ContentUtils)
self.interruptList = _interruptList self.interruptList = _interruptList
self.tankBusterList = _tankBusterList self.tankBusterList = _tankBusterList
@ -95,8 +95,8 @@ end
---@param unit Unit ---@param unit Unit
---@param percent number ---@param percent number
---@return { kickable: boolean, paraliseable: boolean, sweepable: boolean } | nil ---@return Interrupt | nil
function MythicPlusUtils:CastingCriticalStop(unit, percent) function ContentUtils:CastingCriticalStop(unit, percent)
local castingSpell = unit:GetCastingOrChannelingSpell() local castingSpell = unit:GetCastingOrChannelingSpell()
local npcSpells = self.interruptList[unit:GetID()] local npcSpells = self.interruptList[unit:GetID()]
@ -120,7 +120,7 @@ function MythicPlusUtils:CastingCriticalStop(unit, percent)
return nil return nil
end end
function MythicPlusUtils:RefreshBars() function ContentUtils:RefreshBars()
if self.isBigWigsEnabled then if self.isBigWigsEnabled then
for key, value in pairs(self.bars) do for key, value in pairs(self.bars) do
local expireTime = value.duration + value.startTime local expireTime = value.duration + value.startTime
@ -135,11 +135,11 @@ end
---@param spellId number ---@param spellId number
---@param timeUntilCast number ---@param timeUntilCast number
---@return boolean ---@return boolean
function MythicPlusUtils:IsSpellCastSoon(spellId, timeUntilCast) function ContentUtils:IsSpellCastSoon(spellId, timeUntilCast)
if self.isBigWigsEnabled then if self.isBigWigsEnabled then
self:RefreshBars() self:RefreshBars()
for key, value in pairs(self.bars) do for key, value in pairs(self.bars) do
if value.spellId == spellId then if value.spellId == spellId and not value.pauseTime then
local expireTime = value.duration + value.startTime local expireTime = value.duration + value.startTime
local timeUntilSpell = expireTime - GetTime() local timeUntilSpell = expireTime - GetTime()
@ -155,10 +155,31 @@ end
---@param unit Unit ---@param unit Unit
---@param timeUntilCast? number ---@param timeUntilCast? number
---@return boolean ---@return TankBuster | nil
function MythicPlusUtils:CastingTankBuster(unit, timeUntilCast) function ContentUtils:CastingTankBuster(unit, timeUntilCast)
local npcSpells = self.tankBusterList[unit:GetID()]
if npcSpells then
-- If timeUntilCast is provided, check if any of this NPC
if timeUntilCast then
for key, value in pairs(self.bars) do
local spellTraits = npcSpells[value.spellId]
if spellTraits and not value.pauseTime and ((value.startTime + value.duration) - GetTime()) <= timeUntilCast then
return spellTraits
end
end
end
return false local castingSpell = unit:GetCastingOrChannelingSpell()
if castingSpell then
if npcSpells[castingSpell:GetID()] then return npcSpells[castingSpell:GetID()] end
end
end
return nil
end end
return MythicPlusUtils return ContentUtils

@ -0,0 +1,2 @@
---@alias GroupWide { shouldDampen: boolean, shouldDiffuse: boolean, shouldFort: boolean, shouldBubble: boolean, shouldKarma: boolean }
---@alias GroupWideList table<number, table<number, GroupWide>>

@ -1,5 +1,6 @@
---@alias InterruptList table<number, table<number, { kickable: boolean, sweepable: boolean, paraliseable: boolean }>> ---@alias Interrupt { kickable: boolean, sweepable: boolean, paraliseable: boolean }
---@alias InterruptList table<number, table<number, Interrupt>>
---@type InterruptList ---@type InterruptList
local _InterruptList = { local _InterruptList = {

@ -1,5 +1,6 @@
---@alias TankBusterList table<number, table<number, { shouldDampen: boolean, shouldDiffuse: boolean, shouldFort: boolean, shouldBubble: boolean }>> ---@alias TankBuster { shouldDampen: boolean, shouldDiffuse: boolean, shouldFort: boolean, shouldBubble: boolean }
---@alias TankBusterList table<number, table<number, TankBuster>>
---@type TankBusterList ---@type TankBusterList
local _TankBusterList = { local _TankBusterList = {
@ -10,7 +11,7 @@ local _TankBusterList = {
[188244] = { [188244] = {
-- Crushing Smash -- Crushing Smash
[372730] = { [372730] = {
shouldBubble = false, shouldBubble = true,
shouldDampen = true, shouldDampen = true,
shouldDiffuse = false, shouldDiffuse = false,
shouldFort = false shouldFort = false
@ -20,7 +21,7 @@ local _TankBusterList = {
[187897] = { [187897] = {
-- Steel Barrage -- Steel Barrage
[372047] = { [372047] = {
shouldBubble = false, shouldBubble = true,
shouldDampen = true, shouldDampen = true,
shouldDiffuse = false, shouldDiffuse = false,
shouldFort = false shouldFort = false

@ -58,8 +58,8 @@ Bastion.Class = Bastion.require("Class")
Bastion.Timer = Bastion.require("Timer") Bastion.Timer = Bastion.require("Timer")
---@type Timer ---@type Timer
Bastion.CombatTimer = Bastion.Timer:New('combat') Bastion.CombatTimer = Bastion.Timer:New('combat')
---@type MythicPlusUtils ---@type ContentUtils
Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New() Bastion.ContentUtils = Bastion.require("ContentUtils"):New()
---@type NotificationsList ---@type NotificationsList
Bastion.Notifications = Bastion.NotificationsList:New() Bastion.Notifications = Bastion.NotificationsList:New()
@ -91,23 +91,12 @@ Bastion.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...)
end) end)
local pguid = UnitGUID("player") local pguid = UnitGUID("player")
local missed = {}
Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function()
local args = { CombatLogGetCurrentEventInfo() } local args = { CombatLogGetCurrentEventInfo() }
local subEvent = args[2]
local sourceGUID = args[4] local sourceGUID = args[4]
local destGUID = args[8] local destGUID = args[8]
local spellID = args[12]
-- if sourceGUID == pguid then
-- local args = { CombatLogGetCurrentEventInfo() }
-- for i = 1, #args do
-- Log(tostring(args[i]))
-- end
-- end
local u = Bastion.UnitManager[sourceGUID] local u = Bastion.UnitManager[sourceGUID]
local u2 = Bastion.UnitManager[destGUID] local u2 = Bastion.UnitManager[destGUID]
@ -120,20 +109,6 @@ Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function()
if u2 then if u2 then
u2:SetLastCombatTime(t) u2:SetLastCombatTime(t)
if subEvent == "SPELL_MISSED" and sourceGUID == pguid and spellID == 408 then
local missType = args[15]
if missType == "IMMUNE" then
local castingSpell = u:GetCastingOrChannelingSpell()
if castingSpell then
if not missed[castingSpell:GetID()] then
missed[castingSpell:GetID()] = true
end
end
end
end
end end
end) end)
@ -269,12 +244,6 @@ Command:Register('pause', 'Pause a module for X seconds', function (args)
end) end)
Command:Register('missed', 'Dump the list of immune kidney shot spells', function()
for k, v in pairs(missed) do
Bastion:Print(k)
end
end)
if UnitClass('player') == 'Monk' and GetSpecialization() == 1 then if UnitClass('player') == 'Monk' and GetSpecialization() == 1 then
Tinkr:require("scripts/bastion/scripts/brewmaster", Bastion) Tinkr:require("scripts/bastion/scripts/brewmaster", Bastion)
Eval('RunMacroText("/bastion module brewmaster")', 'bastion') Eval('RunMacroText("/bastion module brewmaster")', 'bastion')

Loading…
Cancel
Save