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
Bastion.Globals.Command = Command:New("bastion")
Bastion.Command = Command
Bastion.Globals.Command = Bastion.Command:New("bastion")

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

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

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

@ -5,14 +5,19 @@ Bastion = ...
-- Create a new Unit class
---@class Bastion.Unit
---@field cache Bastion.Cache
---@field id boolean | number
---@field ttd_ticker false | cbObject
---@field unit? TinkrObjectReference
---@field aura_table Bastion.AuraTable | nil
local Unit = {
---@type Bastion.Cache
cache = 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
unit = nil,
ttd_ticker = false,
@ -75,18 +80,12 @@ end
---@param unit? TinkrObjectReference
---@return Bastion.Unit
function Unit:New(unit)
---@class Bastion.Unit
---@type Bastion.Unit
local self = setmetatable({}, 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.aura_table = Bastion.AuraTable:New(self)
self.regression_history = {}
self.health = {}
return self
end
@ -1006,9 +1005,9 @@ function Unit:GetCombatTime()
end
-- Set last combat time
---@param time number
---@param time? number
function Unit:SetLastCombatTime(time)
self.last_combat_time = time
self.last_combat_time = time or GetTime()
end
-- 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]
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 self.customUnits[k] then

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

Loading…
Cancel
Save