4n0n-patch-1
4n0n 2 years ago
parent 0db6aad180
commit 1400e3f4b4
  1. 145
      src/MythicPlusUtils/MythicPlusUtils.lua
  2. 4
      src/ObjectManager/ObjectManager.lua
  3. 24
      src/Spell/Spell.lua
  4. 37
      src/Unit/Unit.lua

@ -19,70 +19,78 @@ function MythicPlusUtils:New()
self.random = math.random(1000000, 9999999) self.random = math.random(1000000, 9999999)
self.kickList = { self.kickList = {
-- Algeth'ar Academy -- Algeth'ar Academy
[396812] = true, -- https://www.wowhead.com/spell=396812/mystic-blast [396812] = { true, true }, -- https://www.wowhead.com/spell=396812/mystic-blast
[388392] = true, -- https://www.wowhead.com/spell=388392/monotonous-lecture [388392] = { true, true }, -- https://www.wowhead.com/spell=388392/monotonous-lecture
[388863] = true, -- https://www.wowhead.com/spell=388863/mana-void [388863] = { true, true }, -- https://www.wowhead.com/spell=388863/mana-void
[388862] = true, -- https://www.wowhead.com/spell=388862/surge [388862] = { true, true }, -- https://www.wowhead.com/spell=388862/surge
[377389] = true, -- https://www.wowhead.com/spell=377389/call-of-the-flock [377389] = { true, true }, -- https://www.wowhead.com/spell=377389/call-of-the-flock
[388623] = true, -- https://www.wowhead.com/spell=388623/branch-out [388623] = { true, true }, -- https://www.wowhead.com/spell=388623/branch-out
[396640] = true, -- https://www.wowhead.com/spell=396640/healing-touch [396640] = { true, true }, -- https://www.wowhead.com/spell=396640/healing-touch
[387975] = true, -- https://www.wowhead.com/spell=387975/arcane-missiles [387975] = { true, true }, -- https://www.wowhead.com/spell=387975/arcane-missiles
[387843] = true, -- https://www.wowhead.com/spell=387843/astral-bomb [387843] = { true, true }, -- https://www.wowhead.com/spell=387843/astral-bomb
-- Court of Stars -- Court of Stars
[211401] = true, -- https://wowhead.com/spell=211401 [211401] = { true, true }, -- https://www.wowhead.com/spell=211401/drifting-embers
[207980] = true, -- https://wowhead.com/spell=207980 [207980] = { true, true }, -- https://www.wowhead.com/spell=207980/disintegration-beam
[208165] = true, -- https://wowhead.com/spell=208165 [208165] = { true, true }, -- https://www.wowhead.com/spell=208165/withering-soul
[207881] = true, -- https://wowhead.com/spell=207881 [207881] = { true, true }, -- https://www.wowhead.com/spell=207881/infernal-eruption
[209413] = true, -- https://wowhead.com/spell=209413 [209413] = { true, false }, -- https://www.wowhead.com/spell=209413/suppress
[209485] = { true, true }, -- https://www.wowhead.com/spell=209485/drain-magic
[209410] = { true, true }, -- https://www.wowhead.com/spell=209410/nightfall-orb
[211470] = { true, true }, -- https://www.wowhead.com/spell=211470/bewitch
[225100] = { true, false }, -- https://www.wowhead.com/spell=225100/charging-station
[211299] = { true, false }, -- https://www.wowhead.com/spell=211299/searing-glare
-- Halls of Valor -- Halls of Valor
[198595] = true, -- https://wowhead.com/spell=198595 [198595] = { true, true }, -- https://www.wowhead.com/spell=198595/thunderous-bolt
[198959] = true, -- https://wowhead.com/spell=198959 [198959] = { true, true }, -- https://www.wowhead.com/spell=198959/etch
[215433] = true, -- https://wowhead.com/spell=215433 [215433] = { true, true }, -- https://www.wowhead.com/spell=215433/holy-radiance
[192288] = true, -- https://wowhead.com/spell=192288 [192288] = { true, true }, -- https://www.wowhead.com/spell=192288/searing-light
[199726] = true, -- https://wowhead.com/spell=199726 [199726] = { true, true }, -- https://www.wowhead.com/spell=199726/unruly-yell
[198750] = true, -- https://wowhead.com/spell=198750 [198750] = { true, true }, -- https://www.wowhead.com/spell=198750/surge
[198934] = { true, true }, -- https://www.wowhead.com/spell=198934/rune-of-healing
[192563] = { true, true }, -- https://www.wowhead.com/spell=192563/cleansing-flames
-- Ruby Life Pools -- Ruby Life Pools
[372749] = true, -- https://wowhead.com/spell=372749 [372749] = { true, true }, -- https://www.wowhead.com/spell=372749/ice-shield
[373803] = true, -- https://wowhead.com/spell=373803 -- [373803] = { true, true }, -- https://www.wowhead.com/spell=373803/cold-claws
[373017] = true, -- https://wowhead.com/spell=373017 [373017] = { true, true }, -- https://www.wowhead.com/spell=373017/roaring-blaze
[392398] = true, -- https://wowhead.com/spell=392398 [392398] = { true, true }, -- https://www.wowhead.com/spell=392398/crackling-detonation
[392451] = true, -- https://wowhead.com/spell=392451 [392451] = { true, true }, -- https://www.wowhead.com/spell=392451/flashfire
[385310] = true, -- https://wowhead.com/spell=385310 [385310] = { true, true }, -- https://www.wowhead.com/spell=385310/lightning-bolt
[384194] = { true, true }, -- https://www.wowhead.com/spell=384194/cinderbolt
[373680] = { true, false }, -- https://www.wowhead.com/spell=373680/frost-overload
-- Shadowmoon Burial Grounds -- Shadowmoon Burial Grounds
[152818] = true, -- https://wowhead.com/spell=152818 [152818] = { true, true }, -- https://www.wowhead.com/spell=152818/shadow-mend
[156776] = true, -- https://wowhead.com/spell=156776 [156776] = { true, true }, -- https://www.wowhead.com/spell=156776/rending-voidlash
[156722] = true, -- https://wowhead.com/spell=156722 [156722] = { true, true }, -- https://www.wowhead.com/spell=156722/void-bolt
[398206] = true, -- https://wowhead.com/spell=398206 [398206] = { true, true }, -- https://www.wowhead.com/spell=398206/death-blast
[153524] = true, -- https://wowhead.com/spell=153524 [153524] = { true, true }, -- https://www.wowhead.com/spell=153524/plague-spit
[156718] = true, -- https://wowhead.com/spell=156718 [156718] = { true, true }, -- https://www.wowhead.com/spell=156718/necrotic-burst
-- Temple of the Jade Serpent -- Temple of the Jade Serpent
[397888] = true, -- https://wowhead.com/spell=397888 [397888] = { true, false }, -- https://www.wowhead.com/spell=397888/hydrolance
[395859] = true, -- https://wowhead.com/spell=395859 [395859] = { true, true }, -- https://www.wowhead.com/spell=395859/haunting-scream
[396073] = true, -- https://wowhead.com/spell=396073 [396073] = { true, true }, -- https://www.wowhead.com/spell=396073/cat-nap
[397914] = true, -- https://wowhead.com/spell=397914 [397914] = { true, true }, -- https://www.wowhead.com/spell=397914/defiling-mist
[397899] = { false, true }, -- https://www.wowhead.com/spell=397899/leg-sweep
[397801] = { true, false }, -- https://www.wowhead.com/spell=397801/hydrolance
[395872] = { true, true }, -- https://www.wowhead.com/spell=395872/sleepy-soliloquy
-- The Azure Vault -- The Azure Vault
[375602] = true, -- https://wowhead.com/spell=375602 [375602] = { true, true }, -- https://www.wowhead.com/spell=375602/erratic-growth
[387564] = true, -- https://wowhead.com/spell=387564 [387564] = { true, true }, -- https://www.wowhead.com/spell=387564/mystic-vapors
[373932] = true, -- https://wowhead.com/spell=373932 [373932] = { true, true }, -- https://www.wowhead.com/spell=373932/illusionary-bolt
[386546] = true, -- https://wowhead.com/spell=386546 [386546] = { true, true }, -- https://www.wowhead.com/spell=386546/waking-bane
[389804] = true, -- https://wowhead.com/spell=389804 [389804] = { true, true }, -- https://www.wowhead.com/spell=389804/heavy-tome
[377488] = true, -- https://wowhead.com/spell=377488 [377488] = { true, true }, -- https://www.wowhead.com/spell=377488/icy-bindings
[377503] = true, -- https://wowhead.com/spell=377503 [377503] = { true, true }, -- https://www.wowhead.com/spell=377503/condensed-frost
[375596] = { true, true }, -- https://www.wowhead.com/spell=375596/erratic-growth
-- NO -- NO
[384365] = true, -- https://wowhead.com/spell=384365 [384365] = { true, true }, -- https://www.wowhead.com/spell=384365/disruptive-shout
[386012] = true, -- https://wowhead.com/spell=386012 [386012] = { true, false }, -- https://www.wowhead.com/spell=386012/stormbolt
[386024] = true, -- https://wowhead.com/spell=386024 [386024] = { true, true }, -- https://www.wowhead.com/spell=386024/tempest
[387411] = true, -- https://wowhead.com/spell=387411 [387411] = { true, true }, -- https://www.wowhead.com/spell=387411/death-bolt-volley
[387606] = true, -- https://wowhead.com/spell=387606 [387606] = { true, true }, -- https://www.wowhead.com/spell=387606/dominate
[373395] = true, -- https://wowhead.com/spell=373395 [373395] = { true, true }, -- https://www.wowhead.com/spell=373395/bloodcurdling-shout
[376725] = true, -- https://wowhead.com/spell=376725 [376725] = { true, true }, -- https://www.wowhead.com/spell=376725/storm-bolt
[384808] = { true, true }, -- https://www.wowhead.com/spell=384808/guardian-wind
-- [363607] = {true, true}, -- https://www.wowhead.com/spell=363607/domination-bolt
} }
Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras) Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras)
@ -101,7 +109,7 @@ function MythicPlusUtils:New()
WriteFile('bastion-MPlusDebuffs-' .. self.random .. '.lua', [[ WriteFile('bastion-MPlusDebuffs-' .. self.random .. '.lua', [[
AuraName: ]] .. aura:GetName() .. [[ AuraName: ]] .. aura:GetName() .. [[
AuraID: ]] .. aura:GetSpell():GetID() .. "\n" .. [[ AuraID: ]] .. aura:GetSpell():GetID() .. "\n" .. [[
]] , true) ]], true)
end end
end end
end end
@ -167,7 +175,26 @@ function MythicPlusUtils:CastingCriticalKick(unit, percent)
if castingSpell then if castingSpell then
local spellID = castingSpell:GetID() local spellID = castingSpell:GetID()
if self.kickList[spellID] and unit:IsInterruptibleAt(percent) then local isKick = unpack(self.kickList[spellID] or { false, false })
if isKick and unit:IsInterruptibleAt(percent) then
return true
end
end
return false
end
---@param unit Unit
---@param percent number
---@return boolean
function MythicPlusUtils:CastingCriticalStun(unit, percent)
local castingSpell = unit:GetCastingOrChannelingSpell()
if castingSpell then
local spellID = castingSpell:GetID()
local _, isStun = unpack(self.kickList[spellID] or { false, false })
if isStun and unit:IsInterruptibleAt(percent, true) then
return true return true
end end
end end

@ -75,7 +75,7 @@ function ObjectManager:Refresh()
for _, object in pairs(objects) do for _, object in pairs(objects) do
self:EnumLists(object) self:EnumLists(object)
if ObjectType(object) == 5 or ObjectType(object) == 6 then if ({ [5] = true,[6] = true,[7] = true })[ObjectType(object)] then
local unit = Bastion.UnitManager:GetObject(ObjectGUID(object)) local unit = Bastion.UnitManager:GetObject(ObjectGUID(object))
if not unit then if not unit then
unit = Bastion.Unit:New(object) unit = Bastion.Unit:New(object)
@ -84,7 +84,7 @@ function ObjectManager:Refresh()
if unit:GetID() == 120651 then if unit:GetID() == 120651 then
self.explosives:push(unit) self.explosives:push(unit)
elseif unit:IsPlayer() and unit:IsInParty() then elseif unit:IsPlayer() and (unit:IsInParty() or unit == Bastion.UnitManager['player']) then
self.friends:push(unit) self.friends:push(unit)
elseif unit:IsEnemy() then elseif unit:IsEnemy() then
self.enemies:push(unit) self.enemies:push(unit)

@ -7,6 +7,7 @@ local Spell = {
PreCastFunc = false, PreCastFunc = false,
OnCastFunc = false, OnCastFunc = false,
PostCastFunc = false, PostCastFunc = false,
lastCastAttempt = 0,
wasLooking = false, wasLooking = false,
lastCastAt = 0, lastCastAt = 0,
conditions = {}, conditions = {},
@ -305,6 +306,15 @@ function Spell:GetTimeSinceLastCast()
return GetTime() - self:GetLastCastTime() return GetTime() - self:GetLastCastTime()
end 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 -- Get the spells charges
---@return number ---@return number
function Spell:GetCharges() function Spell:GetCharges()
@ -404,24 +414,24 @@ end
---@return boolean ---@return boolean
function Spell:IsMagicDispel() function Spell:IsMagicDispel()
return ({ return ({
[88423] = true [88423] = true
})[self:GetID()] })[self:GetID()]
end end
-- IsCurseDispel -- IsCurseDispel
---@return boolean ---@return boolean
function Spell:IsCurseDispel() function Spell:IsCurseDispel()
return ({ return ({
[88423] = true [88423] = true
})[self:GetID()] })[self:GetID()]
end end
-- IsPoisonDispel -- IsPoisonDispel
---@return boolean ---@return boolean
function Spell:IsPoisonDispel() function Spell:IsPoisonDispel()
return ({ return ({
[88423] = true [88423] = true
})[self:GetID()] })[self:GetID()]
end end
-- IsDiseaseDispel -- IsDiseaseDispel
@ -429,7 +439,7 @@ end
function Spell:IsDiseaseDispel() function Spell:IsDiseaseDispel()
return ({ return ({
})[self:GetID()] })[self:GetID()]
end end
-- IsSpell -- IsSpell

@ -372,8 +372,9 @@ end
-- Get Casting or channeling spell -- Get Casting or channeling spell
---@return Spell | nil ---@return Spell | nil
function Unit:GetCastingOrChannelingSpell() function Unit:GetCastingOrChannelingSpell()
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(
.unit) self
.unit)
if not name then if not name then
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit
@ -408,8 +409,9 @@ end
---@return number ---@return number
function Unit:GetChannelOrCastPercentComplete() function Unit:GetChannelOrCastPercentComplete()
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(
.unit) self
.unit)
if not name then if not name then
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit
@ -429,8 +431,9 @@ end
-- Check if unit is interruptible -- Check if unit is interruptible
---@return boolean ---@return boolean
function Unit:IsInterruptible() function Unit:IsInterruptible()
local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(
.unit) self
.unit)
if not name then if not name then
name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit
@ -447,8 +450,8 @@ end
-- Check if unit is interruptible -- Check if unit is interruptible
---@param percent number ---@param percent number
---@return boolean ---@return boolean
function Unit:IsInterruptibleAt(percent) function Unit:IsInterruptibleAt(percent, ignoreInterruptible)
if not self:IsInterruptible() then if not ignoreInterruptible and not self:IsInterruptible() then
return false return false
end end
@ -575,7 +578,7 @@ end
---@return boolean ---@return boolean
function Unit:IsTanking(unit) function Unit:IsTanking(unit)
local isTanking, status, threatpct, rawthreatpct, threatvalue = UnitDetailedThreatSituation(self:GetOMToken(), local isTanking, status, threatpct, rawthreatpct, threatvalue = UnitDetailedThreatSituation(self:GetOMToken(),
unit:GetOMToken()) unit:GetOMToken())
return isTanking return isTanking
end end
@ -642,15 +645,22 @@ end
---@param unit Unit ---@param unit Unit
---@return boolean ---@return boolean
function Unit:InMelee(unit) function Unit:InMelee(unit)
local x, y, z = ObjectPosition(self:GetOMToken()) local x, y, z = ObjectPosition(self.unit)
local x2, y2, z2 = ObjectPosition(unit:GetOMToken()) local x2, y2, z2 = ObjectPosition(unit.unit)
if not x or not x2 then if not x or not x2 then
return false return false
end 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 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() maxDist = maxDist + 1.0 + self:GetMeleeBoost()
return dist <= maxDist return dist <= maxDist
@ -851,7 +861,8 @@ end
---@return nil ---@return nil
function Unit:WatchForSwings() function Unit:WatchForSwings()
Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function() Bastion.EventManager:RegisterWoWEvent("COMBAT_LOG_EVENT_UNFILTERED", function()
local _, subtype, _, sourceGUID, sourceName, _, _, destGUID, destName, destFlags, _, spellID, spellName, _, amount, interrupt, a, b, c, d, offhand, multistrike = CombatLogGetCurrentEventInfo() local _, subtype, _, sourceGUID, sourceName, _, _, destGUID, destName, destFlags, _, spellID, spellName, _, amount, interrupt, a, b, c, d, offhand, multistrike =
CombatLogGetCurrentEventInfo()
if sourceGUID == self:GetGUID() then if sourceGUID == self:GetGUID() then
if subtype == "SPELL_ENERGIZE" and spellID == 196911 then if subtype == "SPELL_ENERGIZE" and spellID == 196911 then

Loading…
Cancel
Save