Compare commits

..

No commits in common. '630fcfc3d9ad9c1728789cf08698c6a1547de3ae' and '8cf6ffcb8efb26499e243f310d9246122e211d5e' have entirely different histories.

  1. 4
      .gitignore
  2. 17
      scripts/ExampleModule.lua
  3. 14
      scripts/Libraries/ExampleLibrary.lua
  4. 1
      src/AuraTable/AuraTable.lua
  5. 15
      src/Class/Class.lua
  6. 7
      src/Command/Command.lua
  7. 4
      src/List/List.lua
  8. 5
      src/MythicPlusUtils/MythicPlusUtils.lua
  9. 7
      src/ObjectManager/ObjectManager.lua
  10. 6
      src/Unit/Unit.lua
  11. 53
      src/_bastion.lua

4
.gitignore vendored

@ -7,11 +7,7 @@ DS_Store
## ignore all files in scripts ## ignore all files in scripts
scripts/* scripts/*
!scripts/Libraries
scripts/Libraries/*
!scripts/.gitkeep !scripts/.gitkeep
!scripts/ExampleModule.lua
!scripts/Libraries/ExampleLibrary.lua
## ignore vscode settings ## ignore vscode settings
.vscode/* .vscode/*

@ -1,17 +0,0 @@
local Tinkr, Bastion = ...
local ExampleModule = Bastion.Module:New('ExampleModule')
local Player = Bastion.UnitManager:Get('player')
local FlashHeal = Bastion.SpellBook:GetSpell(2061)
local AdvancedMath = Bastion:GetLibrary('AdvancedMath')
print(AdvancedMath:Add(1, 2))
ExampleModule:Sync(function()
if Player:GetHP() <= 50 then
FlashHeal:Cast(Player)
end
end)
Bastion:Register(ExampleModule)

@ -1,14 +0,0 @@
local Tinkr, Bastion = ...
local ExampleModule = Bastion.Module:New('ExampleModule')
local Player = Bastion.UnitManager:Get('player')
local AdvancedMath = {}
AdvancedMath.__index = AdvancedMath
function AdvancedMath:Add(a, b)
return a + b
end
Bastion:RegisterLibrary('AdvancedMath', AdvancedMath)

@ -275,6 +275,7 @@ function AuraTable:Find(spell)
end end
for k, a in pairs(aurasub) do for k, a in pairs(aurasub) do
print(a)
if a ~= nil then if a ~= nil then
if a:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA if a:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA
return a return a

@ -18,21 +18,12 @@ function Class:__index(k)
return response return response
end end
---@class Class
---@field class Class.class
---@class Class.class
---@field locale string
---@field name string
---@field id number
-- Constructor -- Constructor
---@param locale string ---@param locale string
---@param name string ---@param name string
---@param id number ---@param id number
function Class:New(locale, name, id) function Class:New(locale, name, id)
local self = setmetatable({}, Class) local self = setmetatable({}, Class)
self.class = { self.class = {
locale = locale, locale = locale,
name = name, name = name,
@ -59,16 +50,10 @@ function Class:GetID()
return self.class.id return self.class.id
end end
---@class ColorMixin
---@field r number
---@field g number
---@field b number
-- Return the classes color -- Return the classes color
---@return ColorMixin classColor ---@return ColorMixin classColor
function Class:GetColor() function Class:GetColor()
return C_ClassColor.GetClassColor(self.class.name) return C_ClassColor.GetClassColor(self.class.name)
end end
return Class return Class

@ -1,13 +1,6 @@
-- Create a wow command handler class -- Create a wow command handler class
---@class Command ---@class Command
---@field command string
---@field commands Command.commands[]
local Command = {} local Command = {}
---@class Command.commands
---@field helpmsg string
---@field cb fun(args: table)
Command.__index = Command Command.__index = Command
---@return string ---@return string

@ -1,3 +1,5 @@
local Tinkr, Bastion = ...
---@class List ---@class List
local List = { local List = {
-- Add overload -- Add overload
@ -142,7 +144,7 @@ function List:findIndex(callback)
return nil return nil
end end
---@param callback fun(...): boolean ---@param callback fun(value: any): boolean
---@return nil ---@return nil
function List:sort(callback) function List:sort(callback)
table.sort(self._list, callback) table.sort(self._list, callback)

@ -17,7 +17,6 @@ MythicPlusUtils.__index = MythicPlusUtils
function MythicPlusUtils:New() function MythicPlusUtils:New()
local self = setmetatable({}, MythicPlusUtils) local self = setmetatable({}, MythicPlusUtils)
---@diagnostic disable-next-line: assign-type-mismatch
self.random = math.random(1000000, 9999999) self.random = math.random(1000000, 9999999)
self.aoeBosses = { self.aoeBosses = {
@ -568,4 +567,8 @@ function MythicPlusUtils:IsAOEBoss(unit)
return self.aoeBosses[unit:GetID()] return self.aoeBosses[unit:GetID()]
end end
function MythicPlusUtils:IsTankBuster(spell)
return self.tankBusters[spell:GetID()]
end
return MythicPlusUtils return MythicPlusUtils

@ -1,11 +1,6 @@
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
---@class ObjectManager ---@class ObjectManager
---@field _lists table
---@field enemies List
---@field friends List
---@field activeEnemies List
---@field explosives List
local ObjectManager = {} local ObjectManager = {}
ObjectManager.__index = ObjectManager ObjectManager.__index = ObjectManager
@ -25,7 +20,7 @@ end
-- Register a custom list with a callback -- Register a custom list with a callback
---@param name string ---@param name string
---@param cb function ---@param cb function
---@return List | false ---@return List
function ObjectManager:RegisterList(name, cb) function ObjectManager:RegisterList(name, cb)
if self._lists[name] then if self._lists[name] then
return false return false

@ -505,7 +505,7 @@ end
-- Check if unit is interruptible -- Check if unit is interruptible
---@param percent number ---@param percent number
---@param ignoreInterruptible? boolean ---@param ignoreInterruptible boolean
---@return boolean ---@return boolean
function Unit:IsInterruptibleAt(percent, ignoreInterruptible) function Unit:IsInterruptibleAt(percent, ignoreInterruptible)
if not ignoreInterruptible and not self:IsInterruptible() then if not ignoreInterruptible and not self:IsInterruptible() then
@ -933,6 +933,7 @@ function Unit:IsStealthed()
local Shadowmeld = Bastion.SpellBook:GetSpell(58984) local Shadowmeld = Bastion.SpellBook:GetSpell(58984)
local Sepsis = Bastion.SpellBook:GetSpell(328305) local Sepsis = Bastion.SpellBook:GetSpell(328305)
return self:GetAuras():FindAny(Stealth) or self:GetAuras():FindAny(ShadowDance) return self:GetAuras():FindAny(Stealth) or self:GetAuras():FindAny(ShadowDance)
end end
@ -1106,7 +1107,6 @@ end
---@param Target Unit ---@param Target Unit
---@param Angle number ---@param Angle number
---@param Distance number ---@param Distance number
---@param rotation? number
---@return boolean ---@return boolean
function Unit:IsWithinCone(Target, Angle, Distance, rotation) function Unit:IsWithinCone(Target, Angle, Distance, rotation)
if not Target:Exists() then if not Target:Exists() then
@ -1114,7 +1114,7 @@ function Unit:IsWithinCone(Target, Angle, Distance, rotation)
end end
local angle = self:GetAngle(Target) local angle = self:GetAngle(Target)
rotation = rotation or self:GetFacing() local rotation = rotation or self:GetFacing()
local diff = math.abs(angle - rotation) local diff = math.abs(angle - rotation)

@ -7,7 +7,7 @@ local Bastion = {
Bastion.__index = Bastion Bastion.__index = Bastion
function Bastion.require(class) function Bastion.require(class)
return require("scripts/bastion/src/" .. class .. "/" .. class, Bastion) return Tinkr:require("scripts/bastion/src/" .. class .. "/" .. class, Bastion)
end end
---@type ClassMagic ---@type ClassMagic
@ -62,8 +62,7 @@ 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()
local LIBRARIES = {} Bastion.modules = {}
local MODULES = {}
Bastion.Enabled = false Bastion.Enabled = false
Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras) Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras)
@ -91,7 +90,7 @@ end)
local pguid = UnitGUID("player") local pguid = UnitGUID("player")
local missed = {} local missed = {}
Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function()
local args = {CombatLogGetCurrentEventInfo()} local args = { CombatLogGetCurrentEventInfo() }
local subEvent = args[2] local subEvent = args[2]
local sourceGUID = args[4] local sourceGUID = args[4]
@ -133,16 +132,6 @@ Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function()
end end
end end
end) end)
function Bastion:RegisterLibrary(name, payload)
LIBRARIES[name] = payload
-- Bastion:Print("Registered Library", name)
end
function Bastion:GetLibrary(name)
return LIBRARIES[name]
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()
@ -152,22 +141,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, #MODULES do for i = 1, #Bastion.modules do
MODULES[i]:Tick() Bastion.modules[i]:Tick()
end end
end end
end) end)
function Bastion:Register(module) function Bastion:Register(module)
table.insert(MODULES, module) table.insert(Bastion.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, #MODULES do for i = 1, #Bastion.modules do
if MODULES[i].name == name then if Bastion.modules[i].name == name then
return MODULES[i] return Bastion.modules[i]
end end
end end
@ -175,7 +164,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]) .. " "
@ -187,7 +176,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]) .. " "
@ -220,9 +209,7 @@ Command:Register('dumpspells', 'Dump spells to a file', function()
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 do break end
break
end
end end
-- use spellName and spellSubName here -- use spellName and spellSubName here
@ -277,17 +264,11 @@ Command:Register('missed', 'Dump the list of immune kidney shot spells', functio
end end
end) end)
local function Load(dir) local files = ListFiles("scripts/bastion/scripts")
local files = ListFiles(dir)
for i = 1, #files do for i = 1, #files do
local file = files[i] local file = files[i]
if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then
require(dir .. file:sub(1, -5), Bastion) Tinkr:require("scripts/bastion/scripts/" .. file:sub(1, -5), Bastion)
end
end end
end end
Load("scripts/bastion/scripts/Libraries/")
Load("scripts/bastion/scripts/Modules/")
Load("scripts/bastion/scripts/")

Loading…
Cancel
Save