main
ck 1 year ago
parent aa34c9e647
commit a972a0c372
  1. 8
      src/APL/APL.lua
  2. 11
      src/Aura/Aura.lua
  3. 4
      src/AuraTable/AuraTable.lua
  4. 3
      src/Module/Module.lua
  5. 20
      src/SpellBook/SpellBook.lua
  6. 23
      src/Unit/Unit.lua
  7. 42
      src/UnitManager/UnitManager.lua
  8. 2
      src/_bastion.lua

@ -1,12 +1,12 @@
-- Create an APL trait for the APL class
---@class APLTrait
---@field cb fun(actor?: APLActor):boolean
---@field cb fun(actor?: APLActorTable):boolean
---@field lastcall number
local APLTrait = {}
APLTrait.__index = APLTrait
-- Constructor
---@param cb fun(actor?: APLActor):boolean
---@param cb fun(actor?: APLActorTable):boolean
---@return APLTrait
function APLTrait:New(cb)
local self = setmetatable({}, APLTrait)
@ -18,7 +18,7 @@ function APLTrait:New(cb)
end
-- Evaulate the APL trait
---@param actor? APLActor
---@param actor? APLActorTable
---@return boolean
function APLTrait:Evaluate(actor)
if GetTime() - self.lastcall > 0.1 then
@ -80,7 +80,7 @@ end
---@return boolean
function APLActor:Evaluate()
for _, trait in ipairs(self.traits) do
if not trait:Evaluate(self) then
if not trait:Evaluate(self:GetActor()) then
return false
end
end

@ -116,7 +116,6 @@ local foodAndDrinkStrings = {
[5] = "Refreshment",
[1] = MINIMAP_TRACKING_VENDOR_FOOD, -- Food & Drink
[2] = POWER_TYPE_FOOD, -- Food
[3] = EMOTE36_TOKEN, -- DRINK
[4] = TUTORIAL_TITLE12, -- Drink
}
@ -128,17 +127,13 @@ function Aura:IsFoodOrDrink()
if cachedFoodAndDrinkIDs[self.aura.spellId] then
return cachedFoodAndDrinkIDs[self.aura.spellId]
else
local auraName = self.aura.name
if auraName then
print("Aura Name", auraName)
if self.aura.name then
for i = 1, #foodAndDrinkStrings do
if auraName:upper():find(foodAndDrinkStrings[i]:upper()) then
if self.aura.name:find(foodAndDrinkStrings[i]) then
cachedFoodAndDrinkIDs[self.aura.spellId] = true
return true
end
end
else
print("No Aura Name", self.aura.spellId)
end
end
end
@ -260,7 +255,7 @@ end
-- Get the auras remaining time
---@return number
function Aura:GetRemainingTime()
local remainingTime = self.aura.expirationTime - GetTime()
local remainingTime = self:GetExpirationTime() - GetTime()
if remainingTime < 0 then
remainingTime = 0

@ -4,6 +4,7 @@ local Tinkr, Bastion = ...
-- Create a new AuraTable class
---@class AuraTable
---@field unit Unit
---@field playerAuras table<number, table<number, Aura>>
local AuraTable = {}
AuraTable.__index = AuraTable
@ -69,6 +70,7 @@ function AuraTable:OnUpdate(auras)
self:RemoveInstanceID(removedAuras[i])
end
end
Bastion.EventManager:TriggerEvent("AURAS_UPDATED")
end
---@param instanceID number
@ -207,6 +209,7 @@ function AuraTable:Update()
-- self.auras = self.auras
-- self.playerAuras = self.playerAuras
Bastion.EventManager:TriggerEvent("AURAS_UPDATED_FULL")
end
-- Get a units auras
@ -234,7 +237,6 @@ function AuraTable:GetUnitAuras()
end
-- Get a units auras
---@return table
function AuraTable:GetMyUnitAuras()
if not self.did then
self.did = true

@ -1,6 +1,9 @@
-- Create a module class for a bastion module
---@class Module
---@field name string
---@field enabled boolean
---@field synced function[]
local Module = {}
Module.__index = Module

@ -1,3 +1,4 @@
---@type Tinkr, Bastion
local Tinkr, Bastion = ...
-- Create a new SpellBook class
@ -11,16 +12,33 @@ SpellBook.__index = SpellBook
function SpellBook:New()
local self = setmetatable({}, SpellBook)
self.spells = {}
--[[ Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_SPELLCAST_SUCCEEDED", function(...)
self:SpellCastSucceeded(...)
end) ]]
return self
end
--[[ function SpellBook:SpellCastSucceeded(...)
local unit, castGUID, spellId = ...
if self.spells[spellId] then
self.spells[spellId].lastCastAt = GetTime()
end
end ]]
-- Get a spell from the spellbook
---@return Spell
function SpellBook:GetSpell(id)
local override = FindSpellOverrideByID(id)
if self.spells[id] == nil then
self.spells[id] = Bastion.Spell:New(id)
end
if override and override ~= id then
if self.spells[override] == nil then
self.spells[override] = Bastion.Spell:New(override)
end
end
return self.spells[id]
end
@ -55,7 +73,7 @@ end
---@return Spell
function SpellBook:GetIfRegistered(id)
return self.spells[id]
return self.spells[id] or self.spells[FindSpellOverrideByID(id)]
end
return SpellBook

@ -6,10 +6,10 @@ local Tinkr, Bastion = ...
---@field id boolean | number
---@field ttd_ticker false | cbObject
---@field unit TinkrObjectReference
---@field aura_table AuraTable | nil
local Unit = {
---@type Cache
cache = nil,
---@type AuraTable
aura_table = nil,
---@type UnitId | WowGameObject
unit = nil,
@ -148,7 +148,7 @@ function Unit:GetPowerType()
end
-- Get the units power
---@param powerType number | nil
---@param powerType? number
---@return number
function Unit:GetPower(powerType)
local powerType = powerType or self:GetPowerType()
@ -156,7 +156,7 @@ function Unit:GetPower(powerType)
end
-- Get the units max power
---@param powerType number | nil
---@param powerType? number
---@return number
function Unit:GetMaxPower(powerType)
local powerType = powerType or self:GetPowerType()
@ -504,7 +504,7 @@ function Unit:IsInterruptible()
end
-- Check if unit is interruptible
---@param percent number
---@param percent? number
---@param ignoreInterruptible? boolean
---@return boolean
function Unit:IsInterruptibleAt(percent, ignoreInterruptible)
@ -609,7 +609,7 @@ function Unit:IsMovingAtAll()
return ObjectMovementFlag(self:GetOMToken()) ~= 0
end
---@param unit Unit | nil
---@param unit? Unit
---@return number
function Unit:GetComboPoints(unit)
if Tinkr.classic or Tinkr.era then
@ -618,7 +618,7 @@ function Unit:GetComboPoints(unit)
end
return GetComboPoints(self:GetOMToken(), unit:GetOMToken())
end
return UnitPower(self:GetOMToken(), 4)
return UnitPower(self:GetOMToken(), Enum.PowerType.ComboPoints)
end
---@return number
@ -960,7 +960,16 @@ function Unit:IsStealthed()
local Shadowmeld = Bastion.Globals.SpellBook:GetSpell(58984)
local Sepsis = Bastion.Globals.SpellBook:GetSpell(328305)
return self:GetAuras():FindAny(Stealth):IsUp() or self:GetAuras():FindAny(ShadowDance):IsUp()
local stealthList = Bastion.List:New({
Stealth,
Vanish,
ShadowDance,
Subterfuge,
Shadowmeld,
Sepsis,
})
return self:GetAuras():FindAnyOf(stealthList):IsUp()
end
-- Get unit swing timers

@ -1,3 +1,4 @@
---@type Tinkr, Bastion
local Tinkr, Bastion = ...
local ObjectManager = Tinkr.Util.ObjectManager
@ -10,19 +11,19 @@ local UnitManager = {
units = {},
customUnits = {},
objects = {},
cache = {}
cache = {},
}
function UnitManager:__index(k)
if k == 'none' then
return self:Get('none')
if k == "none" then
return self:Get("none")
end
if UnitManager[k] then
return UnitManager[k]
end
local 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
@ -52,7 +53,7 @@ function UnitManager:__index(k)
end
end
return self.objects['none']
return self.objects["none"]
end
-- Constructor
@ -65,7 +66,6 @@ function UnitManager:New()
return self
end
-- Get or create a unit
---@param token string
---@return Unit
@ -77,8 +77,8 @@ function UnitManager:Get(token)
local tguid = ObjectGUID(token)
if tguid and self.objects[tguid] == nil then
if token == 'none' then
self.objects['none'] = Unit:New()
if token == "none" then
self.objects["none"] = Unit:New()
else
self.objects[tguid] = Unit:New(Object(tguid))
end
@ -88,8 +88,8 @@ function UnitManager:Get(token)
local tguid = ObjectGUID(token) or "none"
if self.objects[tguid] == nil then
if token == 'none' then
self.objects['none'] = Unit:New()
if token == "none" then
self.objects["none"] = Unit:New()
else
self.objects[tguid] = Unit:New(Object(tguid))
end
@ -127,7 +127,7 @@ function UnitManager:CreateCustomUnit(token, cb)
if self.customUnits[token] == nil then
self.customUnits[token] = {
unit = cachedUnit,
cb = cb
cb = cb,
}
end
@ -303,15 +303,7 @@ function UnitManager:FindFriendsCentroid(radius, range)
return unit:GetPosition()
end
local _, _, z = TraceLine(
centroid.x,
centroid.y,
centroid.z + 5,
centroid.x,
centroid.y,
centroid.z - 5,
0x100151
)
local _, _, z = TraceLine(centroid.x, centroid.y, centroid.z + 5, centroid.x, centroid.y, centroid.z - 5, 0x100151)
centroid.z = z + 0.01
@ -342,15 +334,7 @@ function UnitManager:FindEnemiesCentroid(radius, range)
return unit:GetPosition()
end
local _, _, z = TraceLine(
centroid.x,
centroid.y,
centroid.z + 5,
centroid.x,
centroid.y,
centroid.z - 5,
0x100151
)
local _, _, z = TraceLine(centroid.x, centroid.y, centroid.z + 5, centroid.x, centroid.y, centroid.z - 5, 0x100151)
centroid.z = z + 0.01

@ -149,11 +149,13 @@ Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New()
Bastion.Notifications = Bastion.NotificationsList:New()
local LIBRARIES = {}
---@type Module[]
local MODULES = {}
Bastion.Enabled = false
Bastion.Globals.EventManager:RegisterWoWEvent("UNIT_AURA", function(unit, auras)
---@type Unit | nil
local u = Bastion.UnitManager[unit]
if u then

Loading…
Cancel
Save