main
ck 1 year ago
parent a972a0c372
commit 46f2f1381d
  1. 5
      src/Aura/Aura.lua
  2. 14
      src/AuraTable/AuraTable.lua
  3. 1
      src/Cacheable/Cacheable.lua
  4. 1
      src/Class/Class.lua
  5. 1
      src/ItemBook/ItemBook.lua
  6. 1
      src/Library/Library.lua
  7. 1
      src/MythicPlusUtils/MythicPlusUtils.lua
  8. 9
      src/Refreshable/Refreshable.lua
  9. 2
      src/Sequencer/Sequencer.lua
  10. 4
      src/Spell/Spell.lua
  11. 1
      src/Timer/Timer.lua
  12. 25
      src/Unit/Unit.lua

@ -1,4 +1,5 @@
-- Document with emmy lua: https://emmylua.github.io/ -- Document with emmy lua: https://emmylua.github.io/
---@types Tinkr, Bastion
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Aura class -- Create a new Aura class
@ -264,6 +265,10 @@ function Aura:GetRemainingTime()
return remainingTime return remainingTime
end end
function Aura:GetElapsedPercent()
return ((self:GetDuration() - self:GetRemainingTime()) / self:GetDuration()) * 100
end
-- Get the auras expiration time -- Get the auras expiration time
---@return number ---@return number
function Aura:GetExpirationTime() function Aura:GetExpirationTime()

@ -756,6 +756,20 @@ function AuraTable:HasAnyStealableAura(spell)
return false return false
end end
function AuraTable:GetStealableAura()
for _, auras in pairs(self:GetUnitAuras()) do
for _, aura in pairs(auras) do
if aura:IsUp() then -- Handle expired and non refreshed dropoffs not coming in UNIT_AURA
if aura:GetIsStealable() then
return aura
end
else
self:RemoveInstanceID(aura:GetAuraInstanceID())
end
end
end
end
-- Has any dispelable aura -- Has any dispelable aura
---@param spell Spell ---@param spell Spell
---@return boolean ---@return boolean

@ -1,3 +1,4 @@
---@types Tinkr, Bastion
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Define a Cacheable class -- Define a Cacheable class

@ -1,3 +1,4 @@
---@types Tinkr, Bastion
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Class class -- Create a new Class class

@ -1,3 +1,4 @@
---@types Tinkr, Bastion
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new ItemBook class -- Create a new ItemBook class

@ -1,3 +1,4 @@
---@types Tinkr, Bastion
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
---@class Library ---@class Library

@ -1,3 +1,4 @@
---@types Tinkr, Bastion
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
---@class MythicPlusUtils ---@class MythicPlusUtils

@ -1,3 +1,4 @@
---@types Tinkr, Bastion
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Define a Refreshable class -- Define a Refreshable class
@ -7,8 +8,8 @@ local Refreshable = {
callback = nil, callback = nil,
value = nil, value = nil,
__eq = function(self, other) __eq = function(self, other)
return self.value.__eq(rawget(self, 'value'), other) return self.value.__eq(rawget(self, "value"), other)
end end,
} }
-- On index check the cache to be valid and return the value or reconstruct the value and return it -- On index check the cache to be valid and return the value or reconstruct the value and return it
@ -24,7 +25,7 @@ end
-- When the object is accessed return the value -- When the object is accessed return the value
---@return string ---@return string
function Refreshable:__tostring() function Refreshable:__tostring()
return "Bastion.__Refreshable(" .. tostring(rawget(self, 'value')) .. ")" return "Bastion.__Refreshable(" .. tostring(rawget(self, "value")) .. ")"
end end
-- Create -- Create
@ -38,7 +39,7 @@ function Refreshable:New(value, cb)
self.value = value self.value = value
self.callback = cb self.callback = cb
self.cache:Set('self', rawget(self, 'value'), 0.5) self.cache:Set("self", rawget(self, "value"), 0.5)
return self return self
end end

@ -9,7 +9,7 @@ Sequencer.__index = Sequencer
---@alias SequencerAction fun(sequence: Sequencer):boolean ---@alias SequencerAction fun(sequence: Sequencer):boolean
-- Constructor -- Constructor
---@param actions SequencerAction[] ---@param actions table<number, SequencerAction>
---@param resetCondition? fun(): boolean ---@param resetCondition? fun(): boolean
---@return Sequencer ---@return Sequencer
function Sequencer:New(actions, resetCondition) function Sequencer:New(actions, resetCondition)

@ -280,6 +280,10 @@ function Spell:IsOnCooldown()
return select(2, GetSpellCooldown(spellIDName)) > 0 return select(2, GetSpellCooldown(spellIDName)) > 0
end end
function Spell:IsUsableSpell()
return IsUsableSpell(self:GetID())
end
-- Check if the spell is usable -- Check if the spell is usable
---@return boolean ---@return boolean
function Spell:IsUsable() function Spell:IsUsable()

@ -1,3 +1,4 @@
---@types Tinkr, Bastion
local Tinkr, Bastion = ... local Tinkr, Bastion = ...
-- Create a new Timer class -- Create a new Timer class

@ -232,6 +232,12 @@ function Unit:IsHostile()
return UnitCanAttack(self:GetOMToken(), "player") return UnitCanAttack(self:GetOMToken(), "player")
end end
---@param unit Unit
---@return number
function Unit:GetReaction(unit)
return UnitReaction(unit:GetOMToken(), self:GetOMToken())
end
-- Is the unit a boss -- Is the unit a boss
---@return boolean ---@return boolean
function Unit:IsBoss() function Unit:IsBoss()
@ -338,6 +344,18 @@ local isClassicWow = select(4, GetBuildInfo()) < 40000
-- return UnitInMelee(self:GetOMToken(), unit:GetOMToken()) -- return UnitInMelee(self:GetOMToken(), unit:GetOMToken())
-- end -- end
--[[
M2Collision = 0x1
M2Render = 0x2
WMOCollision = 0x10
WMORender = 0x20
Terrain = 0x100
WaterWalkableLiquid = 0x10000
Liquid = 0x20000
EntityCollision = 0x100000
Unknown = 0x200000
]]
local losFlag = bit.bor(0x1, 0x10, 0x100000) local losFlag = bit.bor(0x1, 0x10, 0x100000)
-- Check if the unit can see another unit -- Check if the unit can see another unit
@ -1029,7 +1047,12 @@ end
-- ismounted -- ismounted
---@return boolean ---@return boolean
function Unit:IsMounted() function Unit:IsMounted()
return UnitIsMounted(self.unit) local mountedFormId = {
[3] = true, -- Mount / Travel Form
[27] = true, -- Swift Flight Form
[29] = true, -- Flight Form
}
return UnitIsMounted(self.unit) or (GetShapeshiftFormID() and mountedFormId[GetShapeshiftFormID()])
end end
-- isindoors -- isindoors

Loading…
Cancel
Save