|
|
@ -6,14 +6,58 @@ local Bastion = { |
|
|
|
} |
|
|
|
} |
|
|
|
Bastion.__index = Bastion |
|
|
|
Bastion.__index = Bastion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Bastion:Require(file) |
|
|
|
|
|
|
|
-- If require starts with an @ then we require from the scripts/bastion/scripts folder |
|
|
|
|
|
|
|
if file:sub(1, 1) == '@' then |
|
|
|
|
|
|
|
file = file:sub(2) |
|
|
|
|
|
|
|
-- print('1') |
|
|
|
|
|
|
|
return require('scripts/bastion/scripts/' .. file, Bastion) |
|
|
|
|
|
|
|
elseif file:sub(1, 1) == "~" then |
|
|
|
|
|
|
|
file = file:sub(2) |
|
|
|
|
|
|
|
-- print("2") |
|
|
|
|
|
|
|
return require('scripts/bastion/' .. file, Bastion) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
-- print("Normal req") |
|
|
|
|
|
|
|
return require(file, Bastion) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function Load(dir) |
|
|
|
|
|
|
|
local dir = dir |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if dir:sub(1, 1) == '@' then |
|
|
|
|
|
|
|
dir = dir:sub(2) |
|
|
|
|
|
|
|
dir = 'scripts/bastion/scripts/' .. dir |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if dir:sub(1, 1) == '~' then |
|
|
|
|
|
|
|
dir = dir:sub(2) |
|
|
|
|
|
|
|
dir = 'scripts/bastion/' .. dir |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local files = ListFiles(dir) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i = 1, #files do |
|
|
|
|
|
|
|
local file = files[i] |
|
|
|
|
|
|
|
if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then |
|
|
|
|
|
|
|
Bastion:Require(dir .. file:sub(1, -5)) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Bastion.require(class) |
|
|
|
function Bastion.require(class) |
|
|
|
return Tinkr:require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) |
|
|
|
-- return require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) |
|
|
|
|
|
|
|
return Bastion:Require("~/src/" .. class .. "/" .. class) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bastion.Globals = {} |
|
|
|
|
|
|
|
|
|
|
|
---@type ClassMagic |
|
|
|
---@type ClassMagic |
|
|
|
Bastion.ClassMagic = Bastion.require("ClassMagic") |
|
|
|
Bastion.ClassMagic = Bastion.require("ClassMagic") |
|
|
|
---@type List |
|
|
|
---@type List |
|
|
|
Bastion.List = Bastion.require("List") |
|
|
|
Bastion.List = Bastion.require("List") |
|
|
|
|
|
|
|
---@type Library |
|
|
|
|
|
|
|
Bastion.Library = Bastion.require("Library") |
|
|
|
---@type NotificationsList, Notification |
|
|
|
---@type NotificationsList, Notification |
|
|
|
Bastion.NotificationsList, Bastion.Notification = Bastion.require("NotificationsList") |
|
|
|
Bastion.NotificationsList, Bastion.Notification = Bastion.require("NotificationsList") |
|
|
|
---@type Vector3 |
|
|
|
---@type Vector3 |
|
|
@ -41,15 +85,18 @@ Bastion.UnitManager = Bastion.require("UnitManager"):New() |
|
|
|
---@type ObjectManager |
|
|
|
---@type ObjectManager |
|
|
|
Bastion.ObjectManager = Bastion.require("ObjectManager"):New() |
|
|
|
Bastion.ObjectManager = Bastion.require("ObjectManager"):New() |
|
|
|
---@type EventManager |
|
|
|
---@type EventManager |
|
|
|
Bastion.EventManager = Bastion.require("EventManager"):New() |
|
|
|
Bastion.EventManager = Bastion.require("EventManager") |
|
|
|
|
|
|
|
Bastion.Globals.EventManager = Bastion.EventManager:New() |
|
|
|
---@type Spell |
|
|
|
---@type Spell |
|
|
|
Bastion.Spell = Bastion.require("Spell") |
|
|
|
Bastion.Spell = Bastion.require("Spell") |
|
|
|
---@type SpellBook |
|
|
|
---@type SpellBook |
|
|
|
Bastion.SpellBook = Bastion.require("SpellBook"):New() |
|
|
|
Bastion.SpellBook = Bastion.require("SpellBook") |
|
|
|
|
|
|
|
Bastion.Globals.SpellBook = Bastion.SpellBook:New() |
|
|
|
---@type Item |
|
|
|
---@type Item |
|
|
|
Bastion.Item = Bastion.require("Item") |
|
|
|
Bastion.Item = Bastion.require("Item") |
|
|
|
---@type ItemBook |
|
|
|
---@type ItemBook |
|
|
|
Bastion.ItemBook = Bastion.require("ItemBook"):New() |
|
|
|
Bastion.ItemBook = Bastion.require("ItemBook") |
|
|
|
|
|
|
|
Bastion.Globals.ItemBook = Bastion.ItemBook:New() |
|
|
|
---@type AuraTable |
|
|
|
---@type AuraTable |
|
|
|
Bastion.AuraTable = Bastion.require("AuraTable") |
|
|
|
Bastion.AuraTable = Bastion.require("AuraTable") |
|
|
|
---@type Class |
|
|
|
---@type Class |
|
|
@ -62,10 +109,13 @@ Bastion.CombatTimer = Bastion.Timer:New('combat') |
|
|
|
Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New() |
|
|
|
Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New() |
|
|
|
---@type NotificationsList |
|
|
|
---@type NotificationsList |
|
|
|
Bastion.Notifications = Bastion.NotificationsList:New() |
|
|
|
Bastion.Notifications = Bastion.NotificationsList:New() |
|
|
|
Bastion.modules = {} |
|
|
|
|
|
|
|
|
|
|
|
local LIBRARIES = {} |
|
|
|
|
|
|
|
local MODULES = {} |
|
|
|
|
|
|
|
|
|
|
|
Bastion.Enabled = false |
|
|
|
Bastion.Enabled = false |
|
|
|
|
|
|
|
|
|
|
|
Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras) |
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras) |
|
|
|
local u = Bastion.UnitManager[unit] |
|
|
|
local u = Bastion.UnitManager[unit] |
|
|
|
|
|
|
|
|
|
|
|
if u then |
|
|
|
if u then |
|
|
@ -73,10 +123,10 @@ Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras) |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
Bastion.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...) |
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...) |
|
|
|
local unit, castGUID, spellID = ... |
|
|
|
local unit, castGUID, spellID = ... |
|
|
|
|
|
|
|
|
|
|
|
local spell = Bastion.SpellBook:GetIfRegistered(spellID) |
|
|
|
local spell = Bastion.Globals.SpellBook:GetIfRegistered(spellID) |
|
|
|
|
|
|
|
|
|
|
|
if unit == "player" and spell then |
|
|
|
if unit == "player" and spell then |
|
|
|
spell.lastCastAt = GetTime() |
|
|
|
spell.lastCastAt = GetTime() |
|
|
@ -89,8 +139,9 @@ end) |
|
|
|
|
|
|
|
|
|
|
|
local pguid = UnitGUID("player") |
|
|
|
local pguid = UnitGUID("player") |
|
|
|
local missed = {} |
|
|
|
local missed = {} |
|
|
|
Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
|
|
|
|
local args = { CombatLogGetCurrentEventInfo() } |
|
|
|
Bastion.Globals.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
|
|
|
|
local args = {CombatLogGetCurrentEventInfo()} |
|
|
|
|
|
|
|
|
|
|
|
local subEvent = args[2] |
|
|
|
local subEvent = args[2] |
|
|
|
local sourceGUID = args[4] |
|
|
|
local sourceGUID = args[4] |
|
|
@ -132,6 +183,7 @@ Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
Bastion.Ticker = C_Timer.NewTicker(0.1, function() |
|
|
|
Bastion.Ticker = C_Timer.NewTicker(0.1, function() |
|
|
|
if not Bastion.CombatTimer:IsRunning() and UnitAffectingCombat("player") then |
|
|
|
if not Bastion.CombatTimer:IsRunning() and UnitAffectingCombat("player") then |
|
|
|
Bastion.CombatTimer:Start() |
|
|
|
Bastion.CombatTimer:Start() |
|
|
@ -141,22 +193,22 @@ Bastion.Ticker = C_Timer.NewTicker(0.1, function() |
|
|
|
|
|
|
|
|
|
|
|
if Bastion.Enabled then |
|
|
|
if Bastion.Enabled then |
|
|
|
Bastion.ObjectManager:Refresh() |
|
|
|
Bastion.ObjectManager:Refresh() |
|
|
|
for i = 1, #Bastion.modules do |
|
|
|
for i = 1, #MODULES do |
|
|
|
Bastion.modules[i]:Tick() |
|
|
|
MODULES[i]:Tick() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
function Bastion:Register(module) |
|
|
|
function Bastion:Register(module) |
|
|
|
table.insert(Bastion.modules, module) |
|
|
|
table.insert(MODULES, module) |
|
|
|
Bastion:Print("Registered", module) |
|
|
|
Bastion:Print("Registered", module) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- Find a module by name |
|
|
|
-- Find a module by name |
|
|
|
function Bastion:FindModule(name) |
|
|
|
function Bastion:FindModule(name) |
|
|
|
for i = 1, #Bastion.modules do |
|
|
|
for i = 1, #MODULES do |
|
|
|
if Bastion.modules[i].name == name then |
|
|
|
if MODULES[i].name == name then |
|
|
|
return Bastion.modules[i] |
|
|
|
return MODULES[i] |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -164,7 +216,7 @@ function Bastion:FindModule(name) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function Bastion:Print(...) |
|
|
|
function Bastion:Print(...) |
|
|
|
local args = { ... } |
|
|
|
local args = {...} |
|
|
|
local str = "|cFFDF362D[Bastion]|r |cFFFFFFFF" |
|
|
|
local str = "|cFFDF362D[Bastion]|r |cFFFFFFFF" |
|
|
|
for i = 1, #args do |
|
|
|
for i = 1, #args do |
|
|
|
str = str .. tostring(args[i]) .. " " |
|
|
|
str = str .. tostring(args[i]) .. " " |
|
|
@ -176,7 +228,7 @@ function Bastion:Debug(...) |
|
|
|
if not Bastion.DebugMode then |
|
|
|
if not Bastion.DebugMode then |
|
|
|
return |
|
|
|
return |
|
|
|
end |
|
|
|
end |
|
|
|
local args = { ... } |
|
|
|
local args = {...} |
|
|
|
local str = "|cFFDF6520[Bastion]|r |cFFFFFFFF" |
|
|
|
local str = "|cFFDF6520[Bastion]|r |cFFFFFFFF" |
|
|
|
for i = 1, #args do |
|
|
|
for i = 1, #args do |
|
|
|
str = str .. tostring(args[i]) .. " " |
|
|
|
str = str .. tostring(args[i]) .. " " |
|
|
@ -203,13 +255,16 @@ Command:Register('debug', 'Toggle debug mode on/off', function() |
|
|
|
Bastion:Print("Debug mode disabled") |
|
|
|
Bastion:Print("Debug mode disabled") |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
Command:Register('dumpspells', 'Dump spells to a file', function() |
|
|
|
Command:Register('dumpspells', 'Dump spells to a file', function() |
|
|
|
local i = 1 |
|
|
|
local i = 1 |
|
|
|
local rand = math.random(100000, 999999) |
|
|
|
local rand = math.random(100000, 999999) |
|
|
|
while true do |
|
|
|
while true do |
|
|
|
local spellName, spellSubName = GetSpellBookItemName(i, BOOKTYPE_SPELL) |
|
|
|
local spellName, spellSubName = GetSpellBookItemName(i, BOOKTYPE_SPELL) |
|
|
|
if not spellName then |
|
|
|
if not spellName then |
|
|
|
do break end |
|
|
|
do |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
-- use spellName and spellSubName here |
|
|
|
-- use spellName and spellSubName here |
|
|
@ -218,7 +273,7 @@ Command:Register('dumpspells', 'Dump spells to a file', function() |
|
|
|
if spellID then |
|
|
|
if spellID then |
|
|
|
spellName = spellName:gsub("[%W%s]", "") |
|
|
|
spellName = spellName:gsub("[%W%s]", "") |
|
|
|
WriteFile('bastion-' .. UnitClass('player') .. '-' .. rand .. '.lua', |
|
|
|
WriteFile('bastion-' .. UnitClass('player') .. '-' .. rand .. '.lua', |
|
|
|
"local " .. spellName .. " = Bastion.SpellBook:GetSpell(" .. spellID .. ")", true) |
|
|
|
"local " .. spellName .. " = Bastion.Globals.SpellBook:GetSpell(" .. spellID .. ")\n", true) |
|
|
|
end |
|
|
|
end |
|
|
|
i = i + 1 |
|
|
|
i = i + 1 |
|
|
|
end |
|
|
|
end |
|
|
@ -264,11 +319,79 @@ Command:Register('missed', 'Dump the list of immune kidney shot spells', functio |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
local files = ListFiles("scripts/bastion/scripts") |
|
|
|
---@param library 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Bastion:Import(library) |
|
|
|
|
|
|
|
local lib = self:GetLibrary(library) |
|
|
|
|
|
|
|
|
|
|
|
for i = 1, #files do |
|
|
|
if not lib then |
|
|
|
local file = files[i] |
|
|
|
error("Library " .. library .. " not found") |
|
|
|
if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then |
|
|
|
|
|
|
|
Tinkr:require("scripts/bastion/scripts/" .. file:sub(1, -5), Bastion) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return lib:Resolve() |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- if not Bastion:CheckLibraryDependencies() then |
|
|
|
|
|
|
|
-- return |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load("@Libraries/") |
|
|
|
|
|
|
|
Load("@Modules/") |
|
|
|
|
|
|
|
Load("@") |
|
|
|