From 3501714102b554cf2475bba720e5e91f1cbc4cd7 Mon Sep 17 00:00:00 2001 From: Ofrex <30585460+Ofrex@users.noreply.github.com> Date: Mon, 13 Feb 2023 14:23:30 +0000 Subject: [PATCH] 4n0n bug fixes and dispel updates 4n0n updates to unit.lua added spell list to curse/magic/poison/disease checks --- src/Spell/Spell.lua | 43 +++++++++++++++++++++++++++++++++++++++---- src/Unit/Unit.lua | 17 ++++++++++++----- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/Spell/Spell.lua b/src/Spell/Spell.lua index 6d4bdc5..66677cf 100644 --- a/src/Spell/Spell.lua +++ b/src/Spell/Spell.lua @@ -7,6 +7,7 @@ local Spell = { PreCastFunc = false, OnCastFunc = false, PostCastFunc = false, + lastCastAttempt = 0, wasLooking = false, lastCastAt = 0, conditions = {}, @@ -305,6 +306,15 @@ function Spell:GetTimeSinceLastCast() return GetTime() - self:GetLastCastTime() end +-- Get the time since the last cast attempt +---@return number +function Spell:GetTimeSinceLastCastAttempt() + if not self.lastCastAttempt then + return math.huge + end + return GetTime() - self.lastCastAttempt +end + -- Get the spells charges ---@return number function Spell:GetCharges() @@ -404,7 +414,19 @@ end ---@return boolean function Spell:IsMagicDispel() return ({ - [88423] = true + [88423] = true, -- Druid - Natures Cure + [115310] = true, -- Monk - Revival + [77130] = true, -- Shaman - Purify Spirit + [383016] = true, -- Shaman - Improved Purify Spirit + [115450] = true, -- Monk - Detox + [388874] = true, -- Monk - Improved Detox + [4987] = true, -- Paladin - Cleanse + [393024] = true, -- Paladin - Improved Cleanse + [527] = true, -- Priest - Purify + [390632] = true, -- Priest - Improved Purify + [89808] = true, -- Warlock - Singe Magic - Imp Spell + [278326] = true, -- Demon Hunter - Consume Magic + [393278] = true -- Druid - Improved Natures Cure })[self:GetID()] end @@ -412,7 +434,11 @@ end ---@return boolean function Spell:IsCurseDispel() return ({ - [88423] = true + [393278] = true, -- Druid - Improved Natures Cure + [2782] = true, -- Druid - Remove Corruption + [475] = true, -- Mage - Remove Curse + [383016] = true, -- Shaman - Improved Purify Spirit + [51886] = true -- Shaman - Cleanse Spirit })[self:GetID()] end @@ -420,7 +446,11 @@ end ---@return boolean function Spell:IsPoisonDispel() return ({ - [88423] = true + [393278] = true, -- Druid - Improved Natures Cure + [115310] = true, -- Monk - Revival + [388874] = true, -- Monk - Improved Detox + [393024] = true, -- Paladin - Improved Cleanse + [213644] = true -- Paladin - Cleanse Toxins })[self:GetID()] end @@ -428,7 +458,12 @@ end ---@return boolean function Spell:IsDiseaseDispel() return ({ - + [115310] = true, -- Monk - Revival + [388874] = true, -- Monk - Improved Detox + [393024] = true, -- Paladin - Improved Cleanse + [213644] = true, -- Paladin - Cleanse Toxins + [390632] = true, -- Priest - Improved Purify + [213634] = true -- Priest - Purify Disease })[self:GetID()] end diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index 256c078..5f9e06a 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -447,8 +447,8 @@ end -- Check if unit is interruptible ---@param percent number ---@return boolean -function Unit:IsInterruptibleAt(percent) - if not self:IsInterruptible() then +function Unit:IsInterruptibleAt(percent, ignoreInterruptible) + if not ignoreInterruptible and not self:IsInterruptible() then return false end @@ -642,15 +642,22 @@ end ---@param unit Unit ---@return boolean function Unit:InMelee(unit) - local x, y, z = ObjectPosition(self:GetOMToken()) - local x2, y2, z2 = ObjectPosition(unit:GetOMToken()) + local x, y, z = ObjectPosition(self.unit) + local x2, y2, z2 = ObjectPosition(unit.unit) if not x or not x2 then return false end + local scr = ObjectCombatReach(self.unit) + local ucr = ObjectCombatReach(unit.unit) + + if not scr or not ucr then + return false + end + local dist = math.sqrt((x - x2) ^ 2 + (y - y2) ^ 2 + (z - z2) ^ 2) - local maxDist = math.max((ObjectCombatReach(self:GetOMToken()) + 1.3333) + ObjectCombatReach(unit:GetOMToken()), 5.0) + local maxDist = math.max((scr + 1.3333) + ucr, 5.0) maxDist = maxDist + 1.0 + self:GetMeleeBoost() return dist <= maxDist