main
ck 11 months ago
parent e852e8ed69
commit 9cafc2585d
  1. 3
      src/Command/Command.lua
  2. 9
      src/EventManager/EventManager.lua
  3. 6
      src/List/List.lua
  4. 7
      src/Timer/Timer.lua
  5. 19
      src/Unit/Unit.lua
  6. 2
      src/UnitManager/UnitManager.lua
  7. 20
      src/_bastion.lua

@ -81,6 +81,5 @@ function Command:PrintHelp()
end end
end end
Bastion.Globals.Command = Command:New("bastion")
Bastion.Command = Command Bastion.Command = Command
Bastion.Globals.Command = Bastion.Command:New("bastion")

@ -25,11 +25,6 @@ EventManager.__index = EventManager
---@return Bastion.EventManager ---@return Bastion.EventManager
function EventManager:New() function EventManager:New()
local self = setmetatable({}, EventManager) local self = setmetatable({}, EventManager)
self.events = {}
self.eventHandlers = {}
self.wowEventHandlers = {}
self.selfCombatEventHandlers = {}
self.CombatEventHandlers = {}
self.playerGUID = UnitGUID("player") or false self.playerGUID = UnitGUID("player") or false
-- Frame for wow events -- Frame for wow events
@ -138,6 +133,6 @@ function EventManager:CLEUHandler(timestamp, subevent, ...)
end end
end end
Bastion.Globals.EventManager = EventManager:New()
Bastion.EventManager = EventManager Bastion.EventManager = EventManager
Bastion.Globals.EventManager = Bastion.EventManager:New()

@ -26,6 +26,10 @@ local List = {
self:remove(value) self:remove(value)
return self return self
end, end,
__concat = function(a, b)
return a:concat(b)
end,
} }
List.__index = List List.__index = List
@ -203,7 +207,7 @@ end
function List:join(separator) function List:join(separator)
local result = "" local result = ""
for i, v in ipairs(self._list) do for i, v in ipairs(self._list) do
result = result .. v result = result .. tostring(v)
if i < #self._list then if i < #self._list then
result = result .. separator result = result .. separator
end end

@ -6,11 +6,10 @@ Bastion = ...
-- Create a new Timer class -- Create a new Timer class
---@class Bastion.Timer ---@class Bastion.Timer
---@field type string ---@field type string
---@field cb false | fun():boolean ---@field cb? fun():boolean
local Timer = { local Timer = {
startTime = nil, startTime = nil,
resetAfterCombat = false, resetAfterCombat = false,
cb = false
} }
Timer.__index = Timer Timer.__index = Timer
@ -22,9 +21,7 @@ function Timer:New(type, cb)
local self = setmetatable({}, Timer) local self = setmetatable({}, Timer)
self.startTime = nil self.startTime = nil
self.type = type self.type = type
if cb then self.cb = cb
self.cb = cb
end
return self return self
end end

@ -5,14 +5,19 @@ Bastion = ...
-- Create a new Unit class -- Create a new Unit class
---@class Bastion.Unit ---@class Bastion.Unit
---@field cache Bastion.Cache
---@field id boolean | number ---@field id boolean | number
---@field ttd_ticker false | cbObject ---@field ttd_ticker false | cbObject
---@field unit? TinkrObjectReference ---@field unit? TinkrObjectReference
---@field aura_table Bastion.AuraTable | nil ---@field aura_table Bastion.AuraTable | nil
local Unit = { local Unit = {
---@type Bastion.Cache ---@type Bastion.Cache
cache = nil,
aura_table = nil, aura_table = nil,
last_shadow_techniques = 0,
swings_since_sht = 0,
last_off_attack = 0,
last_main_attack = 0,
last_combat_time = 0,
---@type UnitId | WowGameObject ---@type UnitId | WowGameObject
unit = nil, unit = nil,
ttd_ticker = false, ttd_ticker = false,
@ -75,18 +80,12 @@ end
---@param unit? TinkrObjectReference ---@param unit? TinkrObjectReference
---@return Bastion.Unit ---@return Bastion.Unit
function Unit:New(unit) function Unit:New(unit)
---@class Bastion.Unit ---@type Bastion.Unit
local self = setmetatable({}, Unit) local self = setmetatable({}, Unit)
self.unit = unit self.unit = unit
self.last_shadow_techniques = 0
self.swings_since_sht = 0
self.last_off_attack = 0
self.last_main_attack = 0
self.last_combat_time = 0
self.cache = Bastion.Cache:New() self.cache = Bastion.Cache:New()
self.aura_table = Bastion.AuraTable:New(self) self.aura_table = Bastion.AuraTable:New(self)
self.regression_history = {} self.regression_history = {}
self.health = {}
return self return self
end end
@ -1006,9 +1005,9 @@ function Unit:GetCombatTime()
end end
-- Set last combat time -- Set last combat time
---@param time number ---@param time? number
function Unit:SetLastCombatTime(time) function Unit:SetLastCombatTime(time)
self.last_combat_time = time self.last_combat_time = time or GetTime()
end end
-- Get combat odds (if the last combat time is less than 1 minute ago return 1 / time, else return 0) -- Get combat odds (if the last combat time is less than 1 minute ago return 1 / time, else return 0)

@ -31,7 +31,7 @@ function UnitManager:__index(k)
return UnitManager[k] return UnitManager[k]
end end
k = k or "none" local k = k or "none"
-- if custom unit exists, return it it's cache expired return a new one -- if custom unit exists, return it it's cache expired return a new one
if self.customUnits[k] then if self.customUnits[k] then

@ -13,12 +13,12 @@ local Bastion = {
Tick = GetGameTick() Tick = GetGameTick()
} }
Bastion.__index = Bastion
local BastionBase = string.format("%s/%s", "scripts", "bastion") local BastionBase = string.format("%s/%s", "scripts", "bastion")
local BastionScriptsBase = string.format("%s/%s", BastionBase, "scripts") local BastionScriptsBase = string.format("%s/%s", BastionBase, "scripts")
local ThirdPartyModulesBase = string.format("%s/%s", "scripts", "BastionScripts") local ThirdPartyModulesBase = string.format("%s/%s", "scripts", "BastionScripts")
Bastion.__index = Bastion
---@class Bastion.LoadedFiles.Table ---@class Bastion.LoadedFiles.Table
---@field [number] { originalPath: string, loadedPath: string, reloadable: boolean, order: number, newPath: string } ---@field [number] { originalPath: string, loadedPath: string, reloadable: boolean, order: number, newPath: string }
Bastion.LoadedFiles = {} Bastion.LoadedFiles = {}
@ -164,6 +164,7 @@ local bastionFiles = {
"~/src/Cache/Cache", "~/src/Cache/Cache",
"~/src/Cacheable/Cacheable", "~/src/Cacheable/Cacheable",
"~/src/Refreshable/Refreshable", "~/src/Refreshable/Refreshable",
"~/src/EventManager/EventManager",
"~/src/Unit/Unit", "~/src/Unit/Unit",
"~/src/Aura/Aura", "~/src/Aura/Aura",
"~/src/APLTrait/APLTrait", "~/src/APLTrait/APLTrait",
@ -172,7 +173,6 @@ local bastionFiles = {
"~/src/Module/Module", "~/src/Module/Module",
"~/src/UnitManager/UnitManager", "~/src/UnitManager/UnitManager",
"~/src/ObjectManager/ObjectManager", "~/src/ObjectManager/ObjectManager",
"~/src/EventManager/EventManager",
"~/src/Spell/Spell", "~/src/Spell/Spell",
"~/src/SpellBook/SpellBook", "~/src/SpellBook/SpellBook",
"~/src/Item/Item", "~/src/Item/Item",
@ -243,15 +243,10 @@ local missed = {}
Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function()
local args = { CombatLogGetCurrentEventInfo() } local args = { CombatLogGetCurrentEventInfo() }
---@type string
local subEvent = args[2] local subEvent = args[2]
---@type string
local sourceGUID = args[4] local sourceGUID = args[4]
---@type string
local destGUID = args[8] local destGUID = args[8]
---@type number
local spellID = args[12] local spellID = args[12]
---@type string
local spellName = args[13] local spellName = args[13]
if subEvent == "SPELL_CAST_SUCCESS" then if subEvent == "SPELL_CAST_SUCCESS" then
@ -260,23 +255,20 @@ Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", fun
end end
end end
---@type Bastion.Unit?
local u = Bastion.UnitManager[sourceGUID] local u = Bastion.UnitManager[sourceGUID]
---@type Bastion.Unit
local u2 = Bastion.UnitManager[destGUID] local u2 = Bastion.UnitManager[destGUID]
local t = GetTime() local t = GetTime()
if type(u) ~= "nil" then if u then
u:SetLastCombatTime(t) u:SetLastCombatTime(t)
end end
if type(u2) ~= "nil" then if u2 then
u2:SetLastCombatTime(t) u2:SetLastCombatTime(t)
if subEvent == "SPELL_MISSED" and sourceGUID == playerGuid and spellID == 408 then if subEvent == "SPELL_MISSED" and sourceGUID == playerGuid and spellID == 408 then
local missType = args[15] local missType = args[15]
if type(u) ~= "nil" and missType == "IMMUNE" then if missType == "IMMUNE" then
local castingSpell = u:GetCastingOrChannelingSpell() local castingSpell = u:GetCastingOrChannelingSpell()
if castingSpell and type(castingSpell) == "table" then if castingSpell and type(castingSpell) == "table" then

Loading…
Cancel
Save