From df988ab75083d14143c73009bc312dbeecb0ed19 Mon Sep 17 00:00:00 2001 From: Ryan Crockett Date: Tue, 28 Feb 2023 16:50:04 -0500 Subject: [PATCH] Seperate out rebuke logic --- scripts/paladin/paladin_protection.lua | 46 ++----------------- scripts/paladin/shared/should-rebuke.lua | 58 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 scripts/paladin/shared/should-rebuke.lua diff --git a/scripts/paladin/paladin_protection.lua b/scripts/paladin/paladin_protection.lua index 4da38fc..22aa42f 100644 --- a/scripts/paladin/paladin_protection.lua +++ b/scripts/paladin/paladin_protection.lua @@ -16,12 +16,13 @@ local Judgement = Bastion.SpellBook:GetSpell(275779) local AvengersShield = Bastion.SpellBook:GetSpell(31935) local OfDuskAndDawn = Bastion.SpellBook:GetSpell(385125) local BlessingOfTheDawn = Bastion.SpellBook:GetSpell(385127) -local BlessingOfTheDusk = Bastion.SpellBook:GetSpell(385126) local ShieldOfTheRighteous = Bastion.SpellBook:GetSpell(53600) local BlessedHammer = Bastion.SpellBook:GetSpell(204019) -local Rebuke = Bastion.SpellBook:GetSpell(96231) local AutoAttack = Bastion.SpellBook:GetSpell(6603) +---@type ShouldRebuke +local ShouldRebuke = Tinkr:require("scripts/bastion/scripts/paladin/shared/should-rebuke", Bastion) + local AvengersShieldTarget = Bastion.UnitManager:CreateCustomUnit('avengers_shield', function() local target = nil @@ -57,43 +58,6 @@ local AvengersShieldTarget = Bastion.UnitManager:CreateCustomUnit('avengers_shie return target end) -local KickTarget = Bastion.UnitManager:CreateCustomUnit('kick', function() - local kick = 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 unit:IsInterruptible() and Rebuke:IsInRange(unit) then - kick = unit - return true - end - - -- TODO: Only consider this if the player is in an M+ dungeon - -- if Player:InMelee(unit) and Player:IsFacing(unit) and Bastion.MythicPlusUtils:CastingCriticalKick(unit, 5) then - -- kick = unit - -- return true - -- end - - return false - end) - - if kick == nil then - kick = None - end - - return kick -end) - ---@return boolean local function CombatRotation() -- Attack the target is auto attack isnt active. @@ -102,9 +66,7 @@ local function CombatRotation() end -- Kick - if KickTarget:Exists() and not Player:IsCastingOrChanneling() and Rebuke:IsKnownAndUsable() then - Rebuke:Cast(KickTarget) - end + if ShouldRebuke() then return true end -- Cast Consecrate if an enemy is in range, and the player isnt moving. if Consecrate:IsKnownAndUsable() and not Player:IsMoving() and not Player:GetAuras():FindMy(ConsecrateAura):IsUp() and Player:GetEnemies(10) >= 1 then diff --git a/scripts/paladin/shared/should-rebuke.lua b/scripts/paladin/shared/should-rebuke.lua new file mode 100644 index 0000000..a4caec5 --- /dev/null +++ b/scripts/paladin/shared/should-rebuke.lua @@ -0,0 +1,58 @@ +local Tinkr, _Bastion = ... + +---@type Bastion +local Bastion = _Bastion + +local Player = Bastion.UnitManager:Get('player') +local None = Bastion.UnitManager:Get('none') + +local Rebuke = Bastion.SpellBook:GetSpell(96231) + +local RebukeTarget = Bastion.UnitManager:CreateCustomUnit('rebuke', function() + local kick = 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 unit:IsInterruptible() and Rebuke:IsInRange(unit) and Player:IsFacing(unit) then + kick = unit + return true + end + + -- TODO: Only consider this if the player is in an M+ dungeon + -- if Player:InMelee(unit) and Player:IsFacing(unit) and Bastion.MythicPlusUtils:CastingCriticalKick(unit, 5) then + -- kick = unit + -- return true + -- end + + return false + end) + + if kick == nil then + kick = None + end + + return kick +end) + +---@alias ShouldRebuke fun():boolean +---@return boolean +function ShouldRebuke() + if RebukeTarget:Exists() and not Player:IsCastingOrChanneling() and Rebuke:IsKnownAndUsable() then + print('HAS KICK TARGET, KICKING') + return Rebuke:Cast(RebukeTarget) + end + return false +end + +return ShouldRebuke \ No newline at end of file