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 }>
---@class MythicPlusUtils
local MythicPlusUtils = {
---@class ContentUtils
local ContentUtils = {
---@type InterruptList
interruptList = {},
---@type TankBusterList
@ -16,7 +16,7 @@ local MythicPlusUtils = {
isBigWigsEnabled = false
}
MythicPlusUtils.__index = MythicPlusUtils
ContentUtils.__index = ContentUtils
local function BWEventCallBack(event, ...)
if event == "BigWigs_StartBar" then
@ -25,56 +25,56 @@ local function BWEventCallBack(event, ...)
print('START BAR', text)
MythicPlusUtils.bars[text] = MythicPlusUtils.bars[text] or {}
ContentUtils.bars[text] = ContentUtils.bars[text] or {}
MythicPlusUtils.bars[text].duration = duration
MythicPlusUtils.bars[text].startTime = now
MythicPlusUtils.bars[text].spellId = spellId
ContentUtils.bars[text].duration = duration
ContentUtils.bars[text].startTime = now
ContentUtils.bars[text].spellId = spellId
elseif event == "BigWigs_StopBar" then
local addon, text = ...
print('STOP BAR', text)
if MythicPlusUtils.bars[text] then
MythicPlusUtils.bars[text] = nil
if ContentUtils.bars[text] then
ContentUtils.bars[text] = nil
end
elseif event == "BigWigs_PauseBar" then
local addon, text = ...
print('PAUSE BAR', text)
if MythicPlusUtils.bars[text] then
MythicPlusUtils.bars[text].pauseTime = GetTime()
if ContentUtils.bars[text] then
ContentUtils.bars[text].pauseTime = GetTime()
end
elseif event == "BigWigs_ResumeBar" then
local addon, text = ...
print('RESUME BAR', text)
if MythicPlusUtils.bars[text] and MythicPlusUtils.bars[text].pauseTime then
local pauseTime = MythicPlusUtils.bars[text].pauseTime
local startTime = MythicPlusUtils.bars[text].startTime
local duration = MythicPlusUtils.bars[text].duration
if ContentUtils.bars[text] and ContentUtils.bars[text].pauseTime then
local pauseTime = ContentUtils.bars[text].pauseTime
local startTime = ContentUtils.bars[text].startTime
local duration = ContentUtils.bars[text].duration
local newDuration = duration - (pauseTime - startTime)
MythicPlusUtils.bars[text].duration = newDuration
MythicPlusUtils.bars[text].startTime = GetTime()
MythicPlusUtils.bars[text].pauseTime = nil
ContentUtils.bars[text].pauseTime = nil
ContentUtils.bars[text].duration = newDuration
ContentUtils.bars[text].startTime = GetTime()
end
elseif event == "BigWigs_StopBars" or event == "BigWigs_OnBossDisable" then
MythicPlusUtils.bars = {}
ContentUtils.bars = {}
end
end
---@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
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
function MythicPlusUtils:New()
local self = setmetatable({}, MythicPlusUtils)
---@return ContentUtils
function ContentUtils:New()
local self = setmetatable({}, ContentUtils)
self.interruptList = _interruptList
self.tankBusterList = _tankBusterList
@ -95,8 +95,8 @@ end
---@param unit Unit
---@param percent number
---@return { kickable: boolean, paraliseable: boolean, sweepable: boolean } | nil
function MythicPlusUtils:CastingCriticalStop(unit, percent)
---@return Interrupt | nil
function ContentUtils:CastingCriticalStop(unit, percent)
local castingSpell = unit:GetCastingOrChannelingSpell()
local npcSpells = self.interruptList[unit:GetID()]
@ -120,7 +120,7 @@ function MythicPlusUtils:CastingCriticalStop(unit, percent)
return nil
end
function MythicPlusUtils:RefreshBars()
function ContentUtils:RefreshBars()
if self.isBigWigsEnabled then
for key, value in pairs(self.bars) do
local expireTime = value.duration + value.startTime
@ -135,11 +135,11 @@ end
---@param spellId number
---@param timeUntilCast number
---@return boolean
function MythicPlusUtils:IsSpellCastSoon(spellId, timeUntilCast)
function ContentUtils:IsSpellCastSoon(spellId, timeUntilCast)
if self.isBigWigsEnabled then
self:RefreshBars()
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 timeUntilSpell = expireTime - GetTime()
@ -155,10 +155,31 @@ end
---@param unit Unit
---@param timeUntilCast? number
---@return boolean
function MythicPlusUtils:CastingTankBuster(unit, timeUntilCast)
---@return TankBuster | nil
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
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
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
local _TankBusterList = {
@ -10,7 +11,7 @@ local _TankBusterList = {
[188244] = {
-- Crushing Smash
[372730] = {
shouldBubble = false,
shouldBubble = true,
shouldDampen = true,
shouldDiffuse = false,
shouldFort = false
@ -20,7 +21,7 @@ local _TankBusterList = {
[187897] = {
-- Steel Barrage
[372047] = {
shouldBubble = false,
shouldBubble = true,
shouldDampen = true,
shouldDiffuse = false,
shouldFort = false

@ -58,8 +58,8 @@ Bastion.Class = Bastion.require("Class")
Bastion.Timer = Bastion.require("Timer")
---@type Timer
Bastion.CombatTimer = Bastion.Timer:New('combat')
---@type MythicPlusUtils
Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New()
---@type ContentUtils
Bastion.ContentUtils = Bastion.require("ContentUtils"):New()
---@type NotificationsList
Bastion.Notifications = Bastion.NotificationsList:New()
@ -91,23 +91,12 @@ Bastion.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...)
end)
local pguid = UnitGUID("player")
local missed = {}
Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function()
local args = { CombatLogGetCurrentEventInfo() }
local subEvent = args[2]
local sourceGUID = args[4]
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 destGUID = args[8]
local u = Bastion.UnitManager[sourceGUID]
local u2 = Bastion.UnitManager[destGUID]
@ -120,20 +109,6 @@ Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function()
if u2 then
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)
@ -269,12 +244,6 @@ Command:Register('pause', 'Pause a module for X seconds', function (args)
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
Tinkr:require("scripts/bastion/scripts/brewmaster", Bastion)
Eval('RunMacroText("/bastion module brewmaster")', 'bastion')

Loading…
Cancel
Save