From e0c2e15a477b5baca30133f92ff60da33db7c153 Mon Sep 17 00:00:00 2001 From: Ryan Crockett Date: Wed, 1 Mar 2023 15:58:18 -0500 Subject: [PATCH] Add HoW --- scripts/paladin/paladin_protection.lua | 17 ++++- scripts/paladin/shared/hammer-of-wrath.lua | 69 +++++++++++++++++++ .../shared/{should-rebuke.lua => rebuke.lua} | 17 ++--- src/Unit/Unit.lua | 2 +- 4 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 scripts/paladin/shared/hammer-of-wrath.lua rename scripts/paladin/shared/{should-rebuke.lua => rebuke.lua} (77%) diff --git a/scripts/paladin/paladin_protection.lua b/scripts/paladin/paladin_protection.lua index 22aa42f..ef4f893 100644 --- a/scripts/paladin/paladin_protection.lua +++ b/scripts/paladin/paladin_protection.lua @@ -20,8 +20,11 @@ local ShieldOfTheRighteous = Bastion.SpellBook:GetSpell(53600) local BlessedHammer = Bastion.SpellBook:GetSpell(204019) local AutoAttack = Bastion.SpellBook:GetSpell(6603) ----@type ShouldRebuke -local ShouldRebuke = Tinkr:require("scripts/bastion/scripts/paladin/shared/should-rebuke", Bastion) +---@type Rebuke +local Rebuke = Tinkr:require("scripts/bastion/scripts/paladin/shared/rebuke", Bastion) + +---@type HammerOfWrath +local HammerOfWrath = Tinkr:require("scripts/bastion/scripts/paladin/shared/hammer-of-wrath", Bastion) local AvengersShieldTarget = Bastion.UnitManager:CreateCustomUnit('avengers_shield', function() local target = nil @@ -66,7 +69,7 @@ local function CombatRotation() end -- Kick - if ShouldRebuke() then return true end + if Rebuke() 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 @@ -101,6 +104,9 @@ local function CombatRotation() return Judgement:Cast(Target) end + -- Hammer of Wrath + if HammerOfWrath() then return true end + -- Avengers shield with lower prio than Judgement in ST. Prefer targets that are casting. if Player:GetEnemies(10) == 1 and AvengersShield:IsKnownAndUsable() and AvengersShieldTarget:Exists() then return AvengersShield:Cast(AvengersShieldTarget) @@ -111,6 +117,11 @@ local function CombatRotation() return BlessedHammer:Cast(Player) end + -- Refresh Consecrate if we've got nothing else to cast. + if Consecrate:IsKnownAndUsable() and Player:GetEnemies(10) >= 1 and not Player:IsMoving() then + return Consecrate:Cast(Player) + end + return false end diff --git a/scripts/paladin/shared/hammer-of-wrath.lua b/scripts/paladin/shared/hammer-of-wrath.lua new file mode 100644 index 0000000..ab7b5ba --- /dev/null +++ b/scripts/paladin/shared/hammer-of-wrath.lua @@ -0,0 +1,69 @@ +local Tinkr, _Bastion = ... + +---@type Bastion +local Bastion = _Bastion + +local Player = Bastion.UnitManager:Get('player') +local Target = Bastion.UnitManager:Get('target') +local None = Bastion.UnitManager:Get('none') + +local _HammerOfWrath = Bastion.SpellBook:GetSpell(24275) +local AvengingWrath = Bastion.SpellBook:GetSpell(389539) + +local HammerOfWrathTarget = Bastion.UnitManager:CreateCustomUnit('hammerofwrath', function() + if not _HammerOfWrath:IsKnownAndUsable() then return None end + + if Player:GetAuras():FindMy(AvengingWrath):IsUp() and _HammerOfWrath:IsKnownAndUsable() and Target:Exists() and Target:IsEnemy() and Target:IsAffectingCombat() and _HammerOfWrath:IsInRange(Target) then + return Target + end + + local how = nil + + Bastion.UnitManager:EnumEnemies(function(unit) + if unit:IsDead() then + return false + end + + if not Player:CanSee(unit) then + return false + end + + if not Player:IsFacing(unit) then + return false + end + + if not _HammerOfWrath:IsInRange(unit) then + return false + end + + if Player:GetAuras():FindMy(AvengingWrath):IsUp() then + how = unit + return true + end + + if unit:GetHealthPercent() <= 20 then + how = unit + return true + end + + return false + end) + + if how == nil then + how = None + end + + return how +end) + +---@alias HammerOfWrath fun():boolean + +---@type HammerOfWrath +function HammerOfWrath() + if HammerOfWrathTarget:Exists() and not Player:IsCastingOrChanneling() then + return _HammerOfWrath:Cast(HammerOfWrathTarget) + end + return false +end + +return HammerOfWrath \ No newline at end of file diff --git a/scripts/paladin/shared/should-rebuke.lua b/scripts/paladin/shared/rebuke.lua similarity index 77% rename from scripts/paladin/shared/should-rebuke.lua rename to scripts/paladin/shared/rebuke.lua index a4caec5..2e59cc1 100644 --- a/scripts/paladin/shared/should-rebuke.lua +++ b/scripts/paladin/shared/rebuke.lua @@ -6,7 +6,7 @@ local Bastion = _Bastion local Player = Bastion.UnitManager:Get('player') local None = Bastion.UnitManager:Get('none') -local Rebuke = Bastion.SpellBook:GetSpell(96231) +local _Rebuke = Bastion.SpellBook:GetSpell(96231) local RebukeTarget = Bastion.UnitManager:CreateCustomUnit('rebuke', function() local kick = nil @@ -24,7 +24,7 @@ local RebukeTarget = Bastion.UnitManager:CreateCustomUnit('rebuke', function() return false end - if unit:IsInterruptible() and Rebuke:IsInRange(unit) and Player:IsFacing(unit) then + if unit:IsInterruptibleAt(10) and _Rebuke:IsInRange(unit) and Player:IsFacing(unit) then kick = unit return true end @@ -45,14 +45,15 @@ local RebukeTarget = Bastion.UnitManager:CreateCustomUnit('rebuke', function() return kick end) ----@alias ShouldRebuke fun():boolean ----@return boolean -function ShouldRebuke() - if RebukeTarget:Exists() and not Player:IsCastingOrChanneling() and Rebuke:IsKnownAndUsable() then +---@alias Rebuke fun():boolean + +---@type Rebuke +function Rebuke() + if RebukeTarget:Exists() and not Player:IsCastingOrChanneling() and _Rebuke:IsKnownAndUsable() then print('HAS KICK TARGET, KICKING') - return Rebuke:Cast(RebukeTarget) + return _Rebuke:Cast(RebukeTarget) end return false end -return ShouldRebuke \ No newline at end of file +return Rebuke \ No newline at end of file diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index 81155cf..eec052b 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -452,7 +452,7 @@ end -- Check if unit is interruptible ---@param percent number ----@param ignoreInterruptible boolean +---@param ignoreInterruptible? boolean ---@return boolean function Unit:IsInterruptibleAt(percent, ignoreInterruptible) if not ignoreInterruptible and not self:IsInterruptible() then