|
|
|
@ -1,16 +1,21 @@ |
|
|
|
|
---@type Tinkr |
|
|
|
|
local Tinkr = ... |
|
|
|
|
|
|
|
|
|
---@class Bastion.Globals.SpellName : { [spellId]: string } |
|
|
|
|
|
|
|
|
|
---@class Bastion |
|
|
|
|
local Bastion = { |
|
|
|
|
DebugMode = false, |
|
|
|
|
Globals = {}, |
|
|
|
|
Enabled = false, |
|
|
|
|
Globals = { |
|
|
|
|
---@type Bastion.Globals.SpellName |
|
|
|
|
SpellName = {} |
|
|
|
|
}, |
|
|
|
|
Tick = GetGameTick() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
local TinkrScriptsBase = "scripts" |
|
|
|
|
local BastionBase = string.format("%s/%s", TinkrScriptsBase, "bastion") |
|
|
|
|
local BastionBase = string.format("%s/%s", "scripts", "bastion") |
|
|
|
|
local BastionScriptsBase = string.format("%s/%s", BastionBase, "scripts") |
|
|
|
|
local ThirdPartyModulesBase = string.format("%s/%s", TinkrScriptsBase, "BastionScripts") |
|
|
|
|
local ThirdPartyModulesBase = string.format("%s/%s", "scripts", "BastionScripts") |
|
|
|
|
|
|
|
|
|
Bastion.__index = Bastion |
|
|
|
|
|
|
|
|
@ -149,13 +154,13 @@ end |
|
|
|
|
local bastionFiles = { |
|
|
|
|
"~/src/ClassMagic/ClassMagic", |
|
|
|
|
"~/src/List/List", |
|
|
|
|
"~/src/Command/Command", |
|
|
|
|
"~/src/Util/Util", |
|
|
|
|
"~/src/Library/Library", |
|
|
|
|
"~/src/Notification/Notification", |
|
|
|
|
"~/src/NotificationList/NotificationList", |
|
|
|
|
"~/src/Vector3/Vector3", |
|
|
|
|
"~/src/Sequencer/Sequencer", |
|
|
|
|
"~/src/Command/Command", |
|
|
|
|
"~/src/Cache/Cache", |
|
|
|
|
"~/src/Cacheable/Cacheable", |
|
|
|
|
"~/src/Refreshable/Refreshable", |
|
|
|
@ -184,23 +189,15 @@ for i = 1, #bastionFiles do |
|
|
|
|
Bastion:Require(bastionFiles[i]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion.Globals.CombatTimer = Bastion.Timer:New("combat") |
|
|
|
|
Bastion.Globals.Notifications = Bastion.NotificationList:New() |
|
|
|
|
Bastion.Globals.CombatTimer = Bastion.Timer:New("combat", function() |
|
|
|
|
return UnitAffectingCombat("player") |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
---@param unitTarget UnitId |
|
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_HEALTH", function(unitTarget) |
|
|
|
|
--Bastion.UnitManager:Get(unitTarget):UpdateHealth() |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@type table<string, Bastion.Library> |
|
|
|
|
local LIBRARIES = {} |
|
|
|
|
|
|
|
|
|
---@type Bastion.Module[] |
|
|
|
|
local MODULES = {} |
|
|
|
|
|
|
|
|
|
Bastion.Enabled = false |
|
|
|
|
|
|
|
|
|
---@param unit UnitToken |
|
|
|
|
---@param auras UnitAuraUpdateInfo |
|
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_AURA", function(unit, auras) |
|
|
|
@ -229,9 +226,6 @@ end) |
|
|
|
|
local playerGuid = UnitGUID("player") |
|
|
|
|
local missed = {} |
|
|
|
|
|
|
|
|
|
---@class Bastion.Globals.SpellName : { [spellId]: string } |
|
|
|
|
Bastion.Globals.SpellName = {} |
|
|
|
|
|
|
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
|
local args = { CombatLogGetCurrentEventInfo() } |
|
|
|
|
|
|
|
|
@ -246,30 +240,32 @@ Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", fun |
|
|
|
|
---@type string |
|
|
|
|
local spellName = args[13] |
|
|
|
|
|
|
|
|
|
if subEvent:find("SPELL") == 1 or subEvent:find("RANGE") == 1 then |
|
|
|
|
if subEvent == "SPELL_CAST_SUCCESS" then |
|
|
|
|
if (not Bastion.Globals.SpellName[spellID] or Bastion.Globals.SpellName[spellID] ~= spellName) then |
|
|
|
|
Bastion.Globals.SpellName[spellID] = spellName |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
---@type Bastion.Unit? |
|
|
|
|
local u = Bastion.UnitManager[sourceGUID] |
|
|
|
|
---@type Bastion.Unit |
|
|
|
|
local u2 = Bastion.UnitManager[destGUID] |
|
|
|
|
|
|
|
|
|
local t = GetTime() |
|
|
|
|
|
|
|
|
|
if u then |
|
|
|
|
if type(u) ~= "nil" then |
|
|
|
|
u:SetLastCombatTime(t) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if u2 then |
|
|
|
|
if type(u2) ~= "nil" then |
|
|
|
|
u2:SetLastCombatTime(t) |
|
|
|
|
if subEvent == "SPELL_MISSED" and sourceGUID == playerGuid and spellID == 408 then |
|
|
|
|
local missType = args[15] |
|
|
|
|
|
|
|
|
|
if missType == "IMMUNE" then |
|
|
|
|
if type(u) ~= "nil" and missType == "IMMUNE" then |
|
|
|
|
local castingSpell = u:GetCastingOrChannelingSpell() |
|
|
|
|
|
|
|
|
|
if castingSpell then |
|
|
|
|
if castingSpell and type(castingSpell) == "table" then |
|
|
|
|
if not missed[castingSpell:GetID()] then |
|
|
|
|
missed[castingSpell:GetID()] = true |
|
|
|
|
end |
|
|
|
@ -279,97 +275,18 @@ Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", fun |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
local Timer = { |
|
|
|
|
TTD = 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Bastion.Now = GetTime() |
|
|
|
|
Bastion.Tick = GetGameTick() |
|
|
|
|
|
|
|
|
|
Bastion.Ticker = C_Timer.NewTicker(0.1, function() |
|
|
|
|
Bastion.Now = GetTime() |
|
|
|
|
Bastion.Tick = GetGameTick() |
|
|
|
|
|
|
|
|
|
if not Bastion.Globals.CombatTimer:IsRunning() and UnitAffectingCombat("player") then |
|
|
|
|
Bastion.Globals.CombatTimer:Start() |
|
|
|
|
elseif Bastion.Globals.CombatTimer:IsRunning() and not UnitAffectingCombat("player") then |
|
|
|
|
Bastion.Globals.CombatTimer:Reset() |
|
|
|
|
end |
|
|
|
|
Bastion.Globals.CombatTimer:Check() |
|
|
|
|
|
|
|
|
|
if Bastion.Enabled then |
|
|
|
|
Bastion.ObjectManager:Refresh() |
|
|
|
|
if Bastion.Now > Timer.TTD then |
|
|
|
|
Timer.TTD = Bastion.Now + Bastion.TimeToDie.Settings.Refresh |
|
|
|
|
Bastion.TimeToDie:Refresh() |
|
|
|
|
end |
|
|
|
|
for i = 1, #MODULES do |
|
|
|
|
MODULES[i]:Tick() |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
---@param module Bastion.Module |
|
|
|
|
function Bastion:Register(module) |
|
|
|
|
table.insert(MODULES, module) |
|
|
|
|
Bastion:Print("Registered", module) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Find a module by name |
|
|
|
|
function Bastion:FindModule(name) |
|
|
|
|
for i = 1, #MODULES do |
|
|
|
|
if MODULES[i].name == name then |
|
|
|
|
return MODULES[i] |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion.PrintEnabled = false |
|
|
|
|
|
|
|
|
|
function Bastion:Print(...) |
|
|
|
|
if not Bastion.PrintEnabled then |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
local args = { ... } |
|
|
|
|
local str = "|cFFDF362D[Bastion]|r |cFFFFFFFF" |
|
|
|
|
for i = 1, #args do |
|
|
|
|
str = str .. tostring(args[i]) .. " " |
|
|
|
|
end |
|
|
|
|
print(str) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Bastion:Debug(...) |
|
|
|
|
if not Bastion.DebugMode then |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
local args = { ... } |
|
|
|
|
local str = "|cFFDF6520[Bastion]|r |cFFFFFFFF" |
|
|
|
|
for i = 1, #args do |
|
|
|
|
str = str .. tostring(args[i]) .. " " |
|
|
|
|
end |
|
|
|
|
print(str) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local Command = Bastion.Command:New("bastion") |
|
|
|
|
|
|
|
|
|
Command:Register("toggle", "Toggle bastion on/off", function() |
|
|
|
|
Bastion.Enabled = not Bastion.Enabled |
|
|
|
|
if Bastion.Enabled then |
|
|
|
|
Bastion:Print("Enabled") |
|
|
|
|
else |
|
|
|
|
Bastion:Print("Disabled") |
|
|
|
|
Bastion:TickModules() |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
Command:Register("debug", "Toggle debug mode on/off", function() |
|
|
|
|
Bastion.DebugMode = not Bastion.DebugMode |
|
|
|
|
if Bastion.DebugMode then |
|
|
|
|
Bastion:Print("Debug mode enabled") |
|
|
|
|
else |
|
|
|
|
Bastion:Print("Debug mode disabled") |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
Command:Register("dumpspells", "Dump spells to a file", function() |
|
|
|
|
Bastion.Globals.Command:Register("dumpspells", "Dump spells to a file", function() |
|
|
|
|
local i = 1 |
|
|
|
|
local rand = math.random(100000, 999999) |
|
|
|
|
while true do |
|
|
|
@ -392,121 +309,12 @@ Command:Register("dumpspells", "Dump spells to a file", function() |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
Command:Register("module", "Toggle a module on/off", function(args) |
|
|
|
|
local module = Bastion:FindModule(args[2]) |
|
|
|
|
if module then |
|
|
|
|
module:Toggle() |
|
|
|
|
if module.enabled then |
|
|
|
|
Bastion:Print("Enabled", module.name) |
|
|
|
|
else |
|
|
|
|
Bastion:Print("Disabled", module.name) |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
Bastion:Print("Module not found") |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
Command:Register("mplus", "Toggle m+ module on/off", function(args) |
|
|
|
|
local cmd = args[2] |
|
|
|
|
if cmd == "debuffs" then |
|
|
|
|
Bastion.MythicPlusUtils:ToggleDebuffLogging() |
|
|
|
|
Bastion:Print("Debuff logging", Bastion.MythicPlusUtils.debuffLogging and "enabled" or "disabled") |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if cmd == "casts" then |
|
|
|
|
Bastion.MythicPlusUtils:ToggleCastLogging() |
|
|
|
|
Bastion:Print("Cast logging", Bastion.MythicPlusUtils.castLogging and "enabled" or "disabled") |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
Bastion:Print("[MythicPlusUtils] Unknown command") |
|
|
|
|
Bastion:Print("Available commands:") |
|
|
|
|
Bastion:Print("debuffs") |
|
|
|
|
Bastion:Print("casts") |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
Command:Register("missed", "Dump the list of immune kidney shot spells", function() |
|
|
|
|
Bastion.Globals.Command:Register("missed", "Dump the list of immune kidney shot spells", function() |
|
|
|
|
for k, v in pairs(missed) do |
|
|
|
|
Bastion:Print(k) |
|
|
|
|
Bastion.Util:Print(k) |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
---@param library Bastion.Library |
|
|
|
|
function Bastion:RegisterLibrary(library) |
|
|
|
|
LIBRARIES[library.name] = library |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Bastion:CheckLibraryDependencies() |
|
|
|
|
for k, v in pairs(LIBRARIES) do |
|
|
|
|
if v.dependencies then |
|
|
|
|
for i = 1, #v.dependencies do |
|
|
|
|
local dep = v.dependencies[i] |
|
|
|
|
if LIBRARIES[dep] then |
|
|
|
|
if LIBRARIES[dep].dependencies then |
|
|
|
|
for j = 1, #LIBRARIES[dep].dependencies do |
|
|
|
|
if LIBRARIES[dep].dependencies[j] == v.name then |
|
|
|
|
Bastion:Print("Circular dependency detected between " .. v.name .. " and " .. dep) |
|
|
|
|
return false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
else |
|
|
|
|
Bastion:Print("Library " .. v.name .. " depends on " .. dep .. " but it's not registered") |
|
|
|
|
return false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return true |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
---@param library string |
|
|
|
|
function Bastion:Import(library) |
|
|
|
|
local lib = self:GetLibrary(library) |
|
|
|
|
|
|
|
|
|
if not lib then |
|
|
|
|
error("Library " .. library .. " not found") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return lib:Resolve() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
---@param name string |
|
|
|
|
function Bastion:GetLibrary(name) |
|
|
|
|
if not LIBRARIES[name] then |
|
|
|
|
error("Library " .. name .. " not found") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local library = LIBRARIES[name] |
|
|
|
|
|
|
|
|
|
-- if library.dependencies then |
|
|
|
|
-- for i = 1, #library.dependencies do |
|
|
|
|
-- local dep = library.dependencies[i] |
|
|
|
|
-- if LIBRARIES[dep] then |
|
|
|
|
-- if LIBRARIES[dep].dependencies then |
|
|
|
|
-- for j = 1, #LIBRARIES[dep].dependencies do |
|
|
|
|
-- if LIBRARIES[dep].dependencies[j] == library.name then |
|
|
|
|
-- Bastion:Print("Circular dependency detected between " .. library.name .. " and " .. dep) |
|
|
|
|
-- return false |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- else |
|
|
|
|
-- Bastion:Print("Library " .. v.name .. " depends on " .. dep .. " but it's not registered") |
|
|
|
|
-- return false |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
return library |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- if not Bastion:CheckLibraryDependencies() then |
|
|
|
|
-- return |
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
Load("@Libraries/") |
|
|
|
|
Load("@Modules/") |
|
|
|
|
Load("@") |
|
|
|
|