From e3d52b41c4b3601018b655404c5dab53ba7eabe7 Mon Sep 17 00:00:00 2001 From: 4n0n <4n0n@tinkr.site> Date: Mon, 19 Jun 2023 14:32:28 -0500 Subject: [PATCH] Methods --- src/Spell/Spell.lua | 8 ++++++++ src/Unit/Unit.lua | 18 ++++++++++++++++++ src/_bastion.lua | 8 +++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/Spell/Spell.lua b/src/Spell/Spell.lua index f96493d..62e0bc2 100644 --- a/src/Spell/Spell.lua +++ b/src/Spell/Spell.lua @@ -343,6 +343,14 @@ function Spell:HasRange() return SpellHasRange(self:GetName()) end +-- Get the range of the spell +---@return number +---@return number +function Spell:GetRange() + local name, rank, icon, castTime, minRange, maxRange, spellID, originalIcon = GetSpellInfo(self:GetID()) + return maxRange, minRange +end + -- Check if the spell is in range of the unit ---@param unit Unit ---@return boolean diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index 0c34681..07182b0 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -114,6 +114,24 @@ function Unit:GetHP() return self:GetHealth() / self:GetMaxHealth() * 100 end +-- Get realized health +---@return number +function Unit:GetRealizedHealth() + return self:GetHealth() - self:GetHealAbsorbedHealth() +end + +-- get realized health percentage +---@return number +function Unit:GetRealizedHP() + return self:GetRealizedHealth() / self:GetMaxHealth() * 100 +end + +-- Get the abosorbed unit health +---@return number +function Unit:GetHealAbsorbedHealth() + return UnitGetTotalHealAbsorbs(self:GetOMToken()) +end + -- Get the units health deficit ---@return number function Unit:GetHealthPercent() diff --git a/src/_bastion.lua b/src/_bastion.lua index 5e84909..b64c986 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -61,7 +61,6 @@ Bastion.CombatTimer = Bastion.Timer:New('combat') Bastion.MythicPlusUtils = Bastion.require("MythicPlusUtils"):New() ---@type NotificationsList Bastion.Notifications = Bastion.NotificationsList:New() - Bastion.modules = {} Bastion.Enabled = false @@ -89,7 +88,6 @@ end) local pguid = UnitGUID("player") local missed = {} - Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() local args = { CombatLogGetCurrentEventInfo() } @@ -133,7 +131,6 @@ Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() end end end) - Bastion.Ticker = C_Timer.NewTicker(0.1, function() if not Bastion.CombatTimer:IsRunning() and UnitAffectingCombat("player") then Bastion.CombatTimer:Start() @@ -164,7 +161,6 @@ function Bastion:FindModule(name) return nil end - function Bastion:Print(...) local args = { ... } local str = "|cFFDF362D[Bastion]|r |cFFFFFFFF" @@ -205,7 +201,6 @@ Command:Register('debug', 'Toggle debug mode on/off', function() Bastion:Print("Debug mode disabled") end end) - Command:Register('dumpspells', 'Dump spells to a file', function() local i = 1 local rand = math.random(100000, 999999) @@ -271,6 +266,9 @@ local files = ListFiles("scripts/bastion/scripts") for i = 1, #files do local file = files[i] if file:sub(-4) == ".lua" or file:sub(-5) == '.luac' then + Tinkr:require("scripts/bastion/scripts/" .. file:sub(1, -5), Bastion) end end + +