diff --git a/scripts/restodruid.lua b/scripts/restodruid.lua index 58fcc15..c5c2954 100644 --- a/scripts/restodruid.lua +++ b/scripts/restodruid.lua @@ -107,6 +107,8 @@ local RakeAura = Bastion.SpellBook:GetSpell(155722) local Starsurge = Bastion.SpellBook:GetSpell(197626) local NaturesVigil = Bastion.SpellBook:GetSpell(124974) local SpringBlossoms = Bastion.SpellBook:GetSpell(207386) +local RakeDebuff = Bastion.SpellBook:GetSpell(155722) + local Lowest = Bastion.UnitManager:CreateCustomUnit('lowest', function(unit) local lowest = nil @@ -385,6 +387,104 @@ local Explosive = Bastion.UnitManager:CreateCustomUnit('explosive', function(uni return explosive end) +local RakeTarget = Bastion.UnitManager:CreateCustomUnit('rake', function(unit) + local rakeTarget = nil + + Bastion.UnitManager:EnumEnemies(function(unit) + if unit:IsDead() then + return false + end + + if not Player:CanSee(unit) then + return false + end + + if Player:GetDistance(unit) > 40 then + return false + end + + if not unit:IsDead() and Player:CanSee(unit) and unit:InCombatOdds() > 80 and unit:InMelee(Player) and + Player:IsFacing(unit) and + ( + not unit:GetAuras():FindMy(RakeDebuff):IsUp() or + unit:GetAuras():FindMy(RakeDebuff):GetRemainingTime() <= 3.6) then + rakeTarget = unit + end + + end) + + + if rakeTarget == nil then + rakeTarget = None + end + + return rakeTarget +end) + +local MoonfireTarget = Bastion.UnitManager:CreateCustomUnit('moonfire', function(unit) + local moonfireTarget = nil + + Bastion.UnitManager:EnumEnemies(function(unit) + if unit:IsDead() then + return false + end + + if not Player:CanSee(unit) then + return false + end + + if Player:GetDistance(unit) > 40 then + return false + end + + if not unit:IsDead() and Player:CanSee(unit) and unit:InCombatOdds() > 80 and + ( + not unit:GetAuras():FindMy(MoonfireAura):IsUp() or + unit:GetAuras():FindMy(MoonfireAura):GetRemainingTime() <= 3.6) then + moonfireTarget = unit + end + + end) + + if moonfireTarget == nil then + moonfireTarget = None + end + + return moonfireTarget +end) + +local SunfireTarget = Bastion.UnitManager:CreateCustomUnit('sunfire', function(unit) + local sunfireTarget = nil + + Bastion.UnitManager:EnumEnemies(function(unit) + if unit:IsDead() then + return false + end + + if not Player:CanSee(unit) then + return false + end + + if Player:GetDistance(unit) > 40 then + return false + end + + if not unit:IsDead() and Player:CanSee(unit) and unit:InCombatOdds() > 80 and + ( + not unit:GetAuras():FindMy(SunfireAura):IsUp() or + unit:GetAuras():FindMy(SunfireAura):GetRemainingTime() <= 3.6) then + sunfireTarget = unit + end + + end) + + if sunfireTarget == nil then + sunfireTarget = None + end + + return sunfireTarget +end) + local RestoCommands = Bastion.Command:New('resto') local PLACE_EFFLO = false @@ -397,6 +497,29 @@ end) local DefaultAPL = Bastion.APL:New('default') local DamageAPL = Bastion.APL:New('damage') +DamageAPL:AddSpell( + Rake:CastableIf(function(self) + return RakeTarget:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() and + ( + not RakeTarget:GetAuras():FindMy(RakeDebuff):IsUp() or + RakeTarget:GetAuras():FindMy(RakeDebuff):GetRemainingTime() <= 3.6) + end):SetTarget(RakeTarget) +) + +DamageAPL:AddSpell( + FerociousBite:CastableIf(function(self) + return Target:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() and + Player:GetComboPoints() >= 5 + end):SetTarget(Target) +) + +DamageAPL:AddSpell( + Shred:CastableIf(function(self) + return Target:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() and + Player:GetComboPoints() < 5 + end):SetTarget(Target) +) + DefaultAPL:AddSpell( Moonfire:CastableIf(function(self) return Explosive:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() @@ -413,12 +536,20 @@ DefaultAPL:AddSpell( end) ) +CatForm:OnCast(function(self) + if not Player:GetAuras():FindMy(Prowl):IsUp() and not Player:IsAffectingCombat() then + Prowl:Cast(Player) + end +end) + DefaultAPL:AddAction( 'cat_form_shift', function() - if IsShiftKeyDown() and not Player:GetAuras():FindMy(CatForm):IsUp() and not Player:IsCastingOrChanneling() then + if (IsShiftKeyDown() or not Player:IsAffectingCombat()) and not Player:IsMounted() and + not Player:GetAuras():FindMy(CatForm):IsUp() and + not Player:IsCastingOrChanneling() then CatForm:Cast(Player) - elseif not IsShiftKeyDown() and Player:GetAuras():FindMy(CatForm):IsUp() then + elseif (not IsShiftKeyDown() and Player:IsAffectingCombat()) and Player:GetAuras():FindMy(CatForm):IsUp() then CancelShapeshiftForm() end end @@ -585,26 +716,26 @@ DefaultAPL:AddSpell( DefaultAPL:AddSpell( Sunfire:CastableIf(function(self) - return Target:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() - and Player:CanSee(Target) and + return SunfireTarget:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() + and Player:CanSee(SunfireTarget) and ( - not Target:GetAuras():FindMy(SunfireAura):IsUp() or - Target:GetAuras():FindMy(SunfireAura):GetRemainingTime() <= 5.4) and - Target:IsHostile() and - Target:IsAffectingCombat() and Player:GetPP() >= 25 - end):SetTarget(Target) + not SunfireTarget:GetAuras():FindMy(SunfireAura):IsUp() or + SunfireTarget:GetAuras():FindMy(SunfireAura):GetRemainingTime() <= 5.4) and + SunfireTarget:IsHostile() and + SunfireTarget:IsAffectingCombat() and Player:GetPP() >= 25 + end):SetTarget(SunfireTarget) ) DefaultAPL:AddSpell( Moonfire:CastableIf(function(self) - return Target:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() - and Player:CanSee(Target) and + return MoonfireTarget:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() + and Player:CanSee(MoonfireTarget) and ( - not Target:GetAuras():FindMy(MoonfireAura):IsUp() or - Target:GetAuras():FindMy(MoonfireAura):GetRemainingTime() <= 5.4) and - Target:IsHostile() and - Target:IsAffectingCombat() and Player:GetPP() >= 25 - end):SetTarget(Target) + not MoonfireTarget:GetAuras():FindMy(MoonfireAura):IsUp() or + MoonfireTarget:GetAuras():FindMy(MoonfireAura):GetRemainingTime() <= 5.4) and + MoonfireTarget:IsHostile() and + MoonfireTarget:IsAffectingCombat() and Player:GetPP() >= 25 + end):SetTarget(MoonfireTarget) ) DefaultAPL:AddSpell( diff --git a/scripts/subtlety.lua b/scripts/subtlety.lua index 770186c..640c1f5 100644 --- a/scripts/subtlety.lua +++ b/scripts/subtlety.lua @@ -992,8 +992,6 @@ local RuptureTarget = Bastion.UnitManager:CreateCustomUnit('rupture', function() end) local function GetRimeDuration(topCard) - -- // card order is [ 2 3 4 5 6 7 8 A ] - if topCard == RimeCards.Two then return 0 elseif topCard == RimeCards.Three then @@ -1248,6 +1246,52 @@ DefaultAPL:AddVariable( -- # Account for ShT reaction time by ignoring low-CP animacharged matches in the 0.5s preceeding a potential ShT proc -- actions+=/variable,name=effective_combo_points,value=effective_combo_points +-- DefaultAPL:AddVariable( +-- 'effective_combo_points', +-- function() +-- local cur = Player:GetComboPoints() or 0 +-- if not EchoingReprimand:IsKnown() then +-- return cur +-- end + +-- if cur < 2 or cur > 5 then +-- return cur +-- end + +-- if Player:GetAuras():FindMy(EchoingReprimand):IsUp() or Player:GetAuras():FindMy(EchoingReprimand2):IsUp() or +-- Player:GetAuras():FindMy(EchoingReprimand3):IsUp() or +-- Player:GetAuras():FindMy(EchoingReprimand4):IsUp() or +-- Player:GetAuras():FindMy(EchoingReprimand5):IsUp() +-- then +-- return 7 +-- end + +-- return cur +-- end +-- ) + +-- -- actions+=/variable,name=effective_combo_points,if=talent.echoing_reprimand.enabled&effective_combo_points>combo_points&combo_points.deficit>2&time_to_sht.4.plus<0.5&!variable.is_next_cp_animacharged,value=combo_points +-- DefaultAPL:AddVariable( +-- 'effective_combo_points', +-- function() +-- if not EchoingReprimand:IsKnown() then +-- return 0 +-- end + +-- local cur = Player:GetComboPoints() or 0 +-- local deficit = Player:GetComboPointsDeficit() or 0 + +-- if cur > Player:GetComboPoints() and deficit > 2 and +-- Player:GetAuras():FindMy(EchoingReprimand4):GetRemainingTime() < 0.5 and +-- not DefaultAPL:GetVariable('is_next_cp_animacharged') +-- then +-- return cur +-- end + +-- return 0 +-- end +-- ) + DefaultAPL:AddVariable( 'effective_combo_points', function() @@ -1268,14 +1312,6 @@ DefaultAPL:AddVariable( return 7 end - return cur - end -) - --- actions+=/variable,name=effective_combo_points,if=talent.echoing_reprimand.enabled&effective_combo_points>combo_points&combo_points.deficit>2&time_to_sht.4.plus<0.5&!variable.is_next_cp_animacharged,value=combo_points -DefaultAPL:AddVariable( - 'effective_combo_points', - function() if not EchoingReprimand:IsKnown() then return 0 end @@ -1290,10 +1326,10 @@ DefaultAPL:AddVariable( return cur end - return 0 + -- return 0 + return cur end ) - -- # Check CDs at first -- actions+=/call_action_list,name=cds DefaultAPL:AddAPL( @@ -1995,31 +2031,41 @@ StealthCDsAPL:AddSpell( -- # CP thresholds for entering Shadow Dance Default to start dance with 0 or 1 combo point -- actions.stealth_cds+=/variable,name=shd_combo_points,value=combo_points<=1 -StealthCDsAPL:AddVariable( - 'shd_combo_points', - function(self) - return Player:GetComboPoints() <= 1 - end -) +-- StealthCDsAPL:AddVariable( +-- 'shd_combo_points', +-- function(self) +-- return Player:GetComboPoints() <= 1 +-- end +-- ) + +-- -- # Use stealth cooldowns with high combo points when playing shuriken tornado or with high target counts +-- -- actions.stealth_cds+=/variable,name=shd_combo_points,value=combo_points.deficit<=1,if=spell_targets.shuriken_storm>(4-2*talent.shuriken_tornado.enabled)|variable.priority_rotation&spell_targets.shuriken_storm>=4 +-- StealthCDsAPL:AddVariable( +-- 'shd_combo_points', +-- function(self) +-- return Player:GetComboPointsDeficit() <= 1 and +-- ((Player:GetEnemies(10) > (4 - 2 * (ShurikenTornado:IsKnown() and 1 or 0))) or +-- (DefaultAPL:GetVariable('priority_rotation') and +-- Player:GetEnemies(10) >= 4)) +-- end +-- ) + +-- -- # Use stealth cooldowns on any combo point on 4 targets +-- -- actions.stealth_cds+=/variable,name=shd_combo_points,value=1,if=spell_targets.shuriken_storm=(4-talent.seal_fate) +-- StealthCDsAPL:AddVariable( +-- 'shd_combo_points', +-- function(self) +-- return Player:GetEnemies(10) == (4 - (SealFate:IsKnown() and 1 or 0)) +-- end +-- ) --- # Use stealth cooldowns with high combo points when playing shuriken tornado or with high target counts --- actions.stealth_cds+=/variable,name=shd_combo_points,value=combo_points.deficit<=1,if=spell_targets.shuriken_storm>(4-2*talent.shuriken_tornado.enabled)|variable.priority_rotation&spell_targets.shuriken_storm>=4 StealthCDsAPL:AddVariable( 'shd_combo_points', function(self) - return Player:GetComboPointsDeficit() <= 1 and + return (Player:GetComboPoints() <= 1) or (Player:GetComboPointsDeficit() <= 1 and ((Player:GetEnemies(10) > (4 - 2 * (ShurikenTornado:IsKnown() and 1 or 0))) or (DefaultAPL:GetVariable('priority_rotation') and - Player:GetEnemies(10) >= 4)) - end -) - --- # Use stealth cooldowns on any combo point on 4 targets --- actions.stealth_cds+=/variable,name=shd_combo_points,value=1,if=spell_targets.shuriken_storm=(4-talent.seal_fate) -StealthCDsAPL:AddVariable( - 'shd_combo_points', - function(self) - return Player:GetEnemies(10) == (4 - (SealFate:IsKnown() and 1 or 0)) + Player:GetEnemies(10) >= 4))) or (Player:GetEnemies(10) == (4 - (SealFate:IsKnown() and 1 or 0))) end ) diff --git a/src/MythicPlusUtils/MythicPlusUtils.lua b/src/MythicPlusUtils/MythicPlusUtils.lua index 6384383..7e0ee3c 100644 --- a/src/MythicPlusUtils/MythicPlusUtils.lua +++ b/src/MythicPlusUtils/MythicPlusUtils.lua @@ -19,70 +19,78 @@ function MythicPlusUtils:New() self.random = math.random(1000000, 9999999) self.kickList = { -- Algeth'ar Academy - [396812] = true, -- https://www.wowhead.com/spell=396812/mystic-blast - [388392] = true, -- https://www.wowhead.com/spell=388392/monotonous-lecture - [388863] = true, -- https://www.wowhead.com/spell=388863/mana-void - [388862] = true, -- https://www.wowhead.com/spell=388862/surge - [377389] = true, -- https://www.wowhead.com/spell=377389/call-of-the-flock - [388623] = true, -- https://www.wowhead.com/spell=388623/branch-out - [396640] = true, -- https://www.wowhead.com/spell=396640/healing-touch - [387975] = true, -- https://www.wowhead.com/spell=387975/arcane-missiles - [387843] = true, -- https://www.wowhead.com/spell=387843/astral-bomb - + [396812] = { true, true }, -- https://www.wowhead.com/spell=396812/mystic-blast + [388392] = { true, true }, -- https://www.wowhead.com/spell=388392/monotonous-lecture + [388863] = { true, true }, -- https://www.wowhead.com/spell=388863/mana-void + [388862] = { true, true }, -- https://www.wowhead.com/spell=388862/surge + [377389] = { true, true }, -- https://www.wowhead.com/spell=377389/call-of-the-flock + [388623] = { true, true }, -- https://www.wowhead.com/spell=388623/branch-out + [396640] = { true, true }, -- https://www.wowhead.com/spell=396640/healing-touch + [387975] = { true, true }, -- https://www.wowhead.com/spell=387975/arcane-missiles + [387843] = { true, true }, -- https://www.wowhead.com/spell=387843/astral-bomb -- Court of Stars - [211401] = true, -- https://wowhead.com/spell=211401 - [207980] = true, -- https://wowhead.com/spell=207980 - [208165] = true, -- https://wowhead.com/spell=208165 - [207881] = true, -- https://wowhead.com/spell=207881 - [209413] = true, -- https://wowhead.com/spell=209413 - + [211401] = { true, true }, -- https://www.wowhead.com/spell=211401/drifting-embers + [207980] = { true, true }, -- https://www.wowhead.com/spell=207980/disintegration-beam + [208165] = { true, true }, -- https://www.wowhead.com/spell=208165/withering-soul + [207881] = { true, true }, -- https://www.wowhead.com/spell=207881/infernal-eruption + [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 - [198595] = true, -- https://wowhead.com/spell=198595 - [198959] = true, -- https://wowhead.com/spell=198959 - [215433] = true, -- https://wowhead.com/spell=215433 - [192288] = true, -- https://wowhead.com/spell=192288 - [199726] = true, -- https://wowhead.com/spell=199726 - [198750] = true, -- https://wowhead.com/spell=198750 - + [198595] = { true, true }, -- https://www.wowhead.com/spell=198595/thunderous-bolt + [198959] = { true, true }, -- https://www.wowhead.com/spell=198959/etch + [215433] = { true, true }, -- https://www.wowhead.com/spell=215433/holy-radiance + [192288] = { true, true }, -- https://www.wowhead.com/spell=192288/searing-light + [199726] = { true, true }, -- https://www.wowhead.com/spell=199726/unruly-yell + [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 - [372749] = true, -- https://wowhead.com/spell=372749 - [373803] = true, -- https://wowhead.com/spell=373803 - [373017] = true, -- https://wowhead.com/spell=373017 - [392398] = true, -- https://wowhead.com/spell=392398 - [392451] = true, -- https://wowhead.com/spell=392451 - [385310] = true, -- https://wowhead.com/spell=385310 - + [372749] = { true, true }, -- https://www.wowhead.com/spell=372749/ice-shield + -- [373803] = { true, true }, -- https://www.wowhead.com/spell=373803/cold-claws + [373017] = { true, true }, -- https://www.wowhead.com/spell=373017/roaring-blaze + [392398] = { true, true }, -- https://www.wowhead.com/spell=392398/crackling-detonation + [392451] = { true, true }, -- https://www.wowhead.com/spell=392451/flashfire + [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 - [152818] = true, -- https://wowhead.com/spell=152818 - [156776] = true, -- https://wowhead.com/spell=156776 - [156722] = true, -- https://wowhead.com/spell=156722 - [398206] = true, -- https://wowhead.com/spell=398206 - [153524] = true, -- https://wowhead.com/spell=153524 - [156718] = true, -- https://wowhead.com/spell=156718 - + [152818] = { true, true }, -- https://www.wowhead.com/spell=152818/shadow-mend + [156776] = { true, true }, -- https://www.wowhead.com/spell=156776/rending-voidlash + [156722] = { true, true }, -- https://www.wowhead.com/spell=156722/void-bolt + [398206] = { true, true }, -- https://www.wowhead.com/spell=398206/death-blast + [153524] = { true, true }, -- https://www.wowhead.com/spell=153524/plague-spit + [156718] = { true, true }, -- https://www.wowhead.com/spell=156718/necrotic-burst -- Temple of the Jade Serpent - [397888] = true, -- https://wowhead.com/spell=397888 - [395859] = true, -- https://wowhead.com/spell=395859 - [396073] = true, -- https://wowhead.com/spell=396073 - [397914] = true, -- https://wowhead.com/spell=397914 - + [397888] = { true, false }, -- https://www.wowhead.com/spell=397888/hydrolance + [395859] = { true, true }, -- https://www.wowhead.com/spell=395859/haunting-scream + [396073] = { true, true }, -- https://www.wowhead.com/spell=396073/cat-nap + [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 - [375602] = true, -- https://wowhead.com/spell=375602 - [387564] = true, -- https://wowhead.com/spell=387564 - [373932] = true, -- https://wowhead.com/spell=373932 - [386546] = true, -- https://wowhead.com/spell=386546 - [389804] = true, -- https://wowhead.com/spell=389804 - [377488] = true, -- https://wowhead.com/spell=377488 - [377503] = true, -- https://wowhead.com/spell=377503 - + [375602] = { true, true }, -- https://www.wowhead.com/spell=375602/erratic-growth + [387564] = { true, true }, -- https://www.wowhead.com/spell=387564/mystic-vapors + [373932] = { true, true }, -- https://www.wowhead.com/spell=373932/illusionary-bolt + [386546] = { true, true }, -- https://www.wowhead.com/spell=386546/waking-bane + [389804] = { true, true }, -- https://www.wowhead.com/spell=389804/heavy-tome + [377488] = { true, true }, -- https://www.wowhead.com/spell=377488/icy-bindings + [377503] = { true, true }, -- https://www.wowhead.com/spell=377503/condensed-frost + [375596] = { true, true }, -- https://www.wowhead.com/spell=375596/erratic-growth -- NO - [384365] = true, -- https://wowhead.com/spell=384365 - [386012] = true, -- https://wowhead.com/spell=386012 - [386024] = true, -- https://wowhead.com/spell=386024 - [387411] = true, -- https://wowhead.com/spell=387411 - [387606] = true, -- https://wowhead.com/spell=387606 - [373395] = true, -- https://wowhead.com/spell=373395 - [376725] = true, -- https://wowhead.com/spell=376725 + [384365] = { true, true }, -- https://www.wowhead.com/spell=384365/disruptive-shout + [386012] = { true, false }, -- https://www.wowhead.com/spell=386012/stormbolt + [386024] = { true, true }, -- https://www.wowhead.com/spell=386024/tempest + [387411] = { true, true }, -- https://www.wowhead.com/spell=387411/death-bolt-volley + [387606] = { true, true }, -- https://www.wowhead.com/spell=387606/dominate + [373395] = { true, true }, -- https://www.wowhead.com/spell=373395/bloodcurdling-shout + [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) @@ -101,7 +109,7 @@ function MythicPlusUtils:New() WriteFile('bastion-MPlusDebuffs-' .. self.random .. '.lua', [[ AuraName: ]] .. aura:GetName() .. [[ AuraID: ]] .. aura:GetSpell():GetID() .. "\n" .. [[ - ]] , true) + ]], true) end end end @@ -167,7 +175,26 @@ function MythicPlusUtils:CastingCriticalKick(unit, percent) if castingSpell then 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 end end diff --git a/src/ObjectManager/ObjectManager.lua b/src/ObjectManager/ObjectManager.lua index 947be6b..1aaca3d 100644 --- a/src/ObjectManager/ObjectManager.lua +++ b/src/ObjectManager/ObjectManager.lua @@ -75,7 +75,7 @@ function ObjectManager:Refresh() for _, object in pairs(objects) do 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)) if not unit then unit = Bastion.Unit:New(object) @@ -84,7 +84,7 @@ function ObjectManager:Refresh() if unit:GetID() == 120651 then 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) elseif unit:IsEnemy() then self.enemies:push(unit) diff --git a/src/Spell/Spell.lua b/src/Spell/Spell.lua index 6d4bdc5..aed4458 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,24 +414,24 @@ end ---@return boolean function Spell:IsMagicDispel() return ({ - [88423] = true - })[self:GetID()] + [88423] = true + })[self:GetID()] end -- IsCurseDispel ---@return boolean function Spell:IsCurseDispel() return ({ - [88423] = true - })[self:GetID()] + [88423] = true + })[self:GetID()] end -- IsPoisonDispel ---@return boolean function Spell:IsPoisonDispel() return ({ - [88423] = true - })[self:GetID()] + [88423] = true + })[self:GetID()] end -- IsDiseaseDispel @@ -429,7 +439,7 @@ end function Spell:IsDiseaseDispel() return ({ - })[self:GetID()] + })[self:GetID()] end -- IsSpell diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index 9e8ddf4..5e1f549 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -41,6 +41,11 @@ function Unit:__eq(other) end -- tostring +---ToString +--- +---```lua +---print(Unit:New('player')) +---``` ---@return string function Unit:__tostring() return "Bastion.__Unit(" .. tostring(self:GetOMToken()) .. ")" .. " - " .. (self:GetName() or '') @@ -367,8 +372,9 @@ end -- Get Casting or channeling spell ---@return Spell | nil function Unit:GetCastingOrChannelingSpell() - local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self - .unit) + local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo( + self + .unit) if not name then name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit @@ -403,8 +409,9 @@ end ---@return number function Unit:GetChannelOrCastPercentComplete() - local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self - .unit) + local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo( + self + .unit) if not name then name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit @@ -424,8 +431,9 @@ end -- Check if unit is interruptible ---@return boolean function Unit:IsInterruptible() - local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo(self - .unit) + local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, castID, notInterruptible, spellId = UnitCastingInfo( + self + .unit) if not name then name, text, texture, startTimeMS, endTimeMS, isTradeSkill, notInterruptible, spellId = UnitChannelInfo(self.unit @@ -442,8 +450,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 @@ -570,7 +578,7 @@ end ---@return boolean function Unit:IsTanking(unit) local isTanking, status, threatpct, rawthreatpct, threatvalue = UnitDetailedThreatSituation(self:GetOMToken(), - unit:GetOMToken()) + unit:GetOMToken()) return isTanking end @@ -637,15 +645,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 @@ -846,7 +861,8 @@ end ---@return nil function Unit:WatchForSwings() 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 subtype == "SPELL_ENERGIZE" and spellID == 196911 then diff --git a/src/UnitManager/UnitManager.lua b/src/UnitManager/UnitManager.lua index 7c6f239..059fd92 100644 --- a/src/UnitManager/UnitManager.lua +++ b/src/UnitManager/UnitManager.lua @@ -182,7 +182,7 @@ function UnitManager:CreateCustomUnit(token, cb) return cachedUnit end --- Enum Friends (party/raid members) +---@description Enumerates all friendly units in the battlefield ---@param cb fun(unit: Unit):boolean ---@return nil function UnitManager:EnumFriends(cb)