diff --git a/src/Aura/Aura.lua b/src/Aura/Aura.lua index 33ad2ae..fe39c1b 100644 --- a/src/Aura/Aura.lua +++ b/src/Aura/Aura.lua @@ -1,4 +1,5 @@ -- Document with emmy lua: https://emmylua.github.io/ +---@types Tinkr, Bastion local Tinkr, Bastion = ... -- Create a new Aura class @@ -264,6 +265,10 @@ function Aura:GetRemainingTime() return remainingTime end +function Aura:GetElapsedPercent() + return ((self:GetDuration() - self:GetRemainingTime()) / self:GetDuration()) * 100 +end + -- Get the auras expiration time ---@return number function Aura:GetExpirationTime() diff --git a/src/AuraTable/AuraTable.lua b/src/AuraTable/AuraTable.lua index 9ef5b9d..401d2f7 100644 --- a/src/AuraTable/AuraTable.lua +++ b/src/AuraTable/AuraTable.lua @@ -756,6 +756,20 @@ function AuraTable:HasAnyStealableAura(spell) return false 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 ---@param spell Spell ---@return boolean diff --git a/src/Cacheable/Cacheable.lua b/src/Cacheable/Cacheable.lua index 4623717..1430651 100644 --- a/src/Cacheable/Cacheable.lua +++ b/src/Cacheable/Cacheable.lua @@ -1,3 +1,4 @@ +---@types Tinkr, Bastion local Tinkr, Bastion = ... -- Define a Cacheable class diff --git a/src/Class/Class.lua b/src/Class/Class.lua index 574e3d2..a7e2abc 100644 --- a/src/Class/Class.lua +++ b/src/Class/Class.lua @@ -1,3 +1,4 @@ +---@types Tinkr, Bastion local Tinkr, Bastion = ... -- Create a new Class class diff --git a/src/ItemBook/ItemBook.lua b/src/ItemBook/ItemBook.lua index 535bfa9..1000d6e 100644 --- a/src/ItemBook/ItemBook.lua +++ b/src/ItemBook/ItemBook.lua @@ -1,3 +1,4 @@ +---@types Tinkr, Bastion local Tinkr, Bastion = ... -- Create a new ItemBook class diff --git a/src/Library/Library.lua b/src/Library/Library.lua index ca99870..e5dca10 100644 --- a/src/Library/Library.lua +++ b/src/Library/Library.lua @@ -1,3 +1,4 @@ +---@types Tinkr, Bastion local Tinkr, Bastion = ... ---@class Library diff --git a/src/MythicPlusUtils/MythicPlusUtils.lua b/src/MythicPlusUtils/MythicPlusUtils.lua index a04b1ce..f54a062 100644 --- a/src/MythicPlusUtils/MythicPlusUtils.lua +++ b/src/MythicPlusUtils/MythicPlusUtils.lua @@ -1,3 +1,4 @@ +---@types Tinkr, Bastion local Tinkr, Bastion = ... ---@class MythicPlusUtils diff --git a/src/Refreshable/Refreshable.lua b/src/Refreshable/Refreshable.lua index 3542c8d..80d434b 100644 --- a/src/Refreshable/Refreshable.lua +++ b/src/Refreshable/Refreshable.lua @@ -1,3 +1,4 @@ +---@types Tinkr, Bastion local Tinkr, Bastion = ... -- Define a Refreshable class @@ -7,8 +8,8 @@ local Refreshable = { callback = nil, value = nil, __eq = function(self, other) - return self.value.__eq(rawget(self, 'value'), other) - end + return self.value.__eq(rawget(self, "value"), other) + end, } -- 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 ---@return string function Refreshable:__tostring() - return "Bastion.__Refreshable(" .. tostring(rawget(self, 'value')) .. ")" + return "Bastion.__Refreshable(" .. tostring(rawget(self, "value")) .. ")" end -- Create @@ -38,7 +39,7 @@ function Refreshable:New(value, cb) self.value = value self.callback = cb - self.cache:Set('self', rawget(self, 'value'), 0.5) + self.cache:Set("self", rawget(self, "value"), 0.5) return self end diff --git a/src/Sequencer/Sequencer.lua b/src/Sequencer/Sequencer.lua index 1a5f96d..591ff2d 100644 --- a/src/Sequencer/Sequencer.lua +++ b/src/Sequencer/Sequencer.lua @@ -9,7 +9,7 @@ Sequencer.__index = Sequencer ---@alias SequencerAction fun(sequence: Sequencer):boolean -- Constructor ----@param actions SequencerAction[] +---@param actions table ---@param resetCondition? fun(): boolean ---@return Sequencer function Sequencer:New(actions, resetCondition) diff --git a/src/Spell/Spell.lua b/src/Spell/Spell.lua index 96fd768..8a52048 100644 --- a/src/Spell/Spell.lua +++ b/src/Spell/Spell.lua @@ -280,6 +280,10 @@ function Spell:IsOnCooldown() return select(2, GetSpellCooldown(spellIDName)) > 0 end +function Spell:IsUsableSpell() + return IsUsableSpell(self:GetID()) +end + -- Check if the spell is usable ---@return boolean function Spell:IsUsable() diff --git a/src/Timer/Timer.lua b/src/Timer/Timer.lua index c14b84d..06771bd 100644 --- a/src/Timer/Timer.lua +++ b/src/Timer/Timer.lua @@ -1,3 +1,4 @@ +---@types Tinkr, Bastion local Tinkr, Bastion = ... -- Create a new Timer class diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index 6c08d9b..f74cf1b 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -232,6 +232,12 @@ function Unit:IsHostile() return UnitCanAttack(self:GetOMToken(), "player") end +---@param unit Unit +---@return number +function Unit:GetReaction(unit) + return UnitReaction(unit:GetOMToken(), self:GetOMToken()) +end + -- Is the unit a boss ---@return boolean function Unit:IsBoss() @@ -338,6 +344,18 @@ local isClassicWow = select(4, GetBuildInfo()) < 40000 -- return UnitInMelee(self:GetOMToken(), unit:GetOMToken()) -- 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) -- Check if the unit can see another unit @@ -1029,7 +1047,12 @@ end -- ismounted ---@return boolean 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 -- isindoors