diff --git a/scripts/paladin_protection.lua b/scripts/paladin_protection.lua new file mode 100644 index 0000000..8c96810 --- /dev/null +++ b/scripts/paladin_protection.lua @@ -0,0 +1,66 @@ +local Tinkr, _Bastion = ... + +---@type Bastion +local Bastion = _Bastion + +local ProtModule = Bastion.Module:New('paladin_protection') +local Player = Bastion.UnitManager:Get('player') +local Target = Bastion.UnitManager:Get('target') + +local CrusaderAura = Bastion.SpellBook:GetSpell(32223) +local DevoAura = Bastion.SpellBook:GetSpell(465) +local Consecrate = Bastion.SpellBook:GetSpell(26573) +local ConsecrateAura = Bastion.SpellBook:GetSpell(188370) +local Judgement = Bastion.SpellBook:GetSpell(275779) + +---@return boolean +local function CombatRotation() + -- 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 + return Consecrate:Cast(Player) + end + + if Judgement:IsKnownAndUsable() and Target:Exists() and not Player:IsCastingOrChanneling() and Judgement:IsInRange(Target) then + return Judgement:Cast(Target) + end + + return false +end + +---@return boolean +local function OutOfCombatRotation() + return false +end + +local isRunning = false + +ProtModule:Sync(function() + if not isRunning then + Bastion:Print('Prot Paladin Started') + isRunning = true + end + + if not Player:IsAlive() then + return false + end + + -- Cast Crusader Aura if talented and the player is mounted. + if Player:IsMounted() and CrusaderAura:IsKnownAndUsable() and not Player:GetAuras():FindMy(CrusaderAura):IsUp() and not Player:IsCastingOrChanneling() then + return CrusaderAura:Cast(Player) + end + + -- Cast Devo Aura if the player is not mounted. + if not Player:IsMounted() and DevoAura:IsKnownAndUsable() and not Player:GetAuras():FindMy(DevoAura):IsUp() and not Player:IsCastingOrChanneling() then + return DevoAura:Cast(Player) + end + + if Player:IsAffectingCombat() then + -- Combat Rotation + return CombatRotation() + else + -- Out Of Combat Rotation + return OutOfCombatRotation() + end +end) + +Bastion:Register(ProtModule) diff --git a/scripts/protpaladin.lua b/scripts/protpaladin.lua deleted file mode 100644 index 1c99087..0000000 --- a/scripts/protpaladin.lua +++ /dev/null @@ -1,75 +0,0 @@ -local Tinkr = ... - ----@class Bastion -local Bastion = ... - - -local ProtModule = Bastion.Module:New('prot_paladin') -local Evaluator = Tinkr.Util.Evaluator -local Player = Bastion.UnitManager:Get('player') -local Target = Bastion.UnitManager:Get('target') - -local CrusaderAura = Bastion.SpellBook:GetSpell(32223) -local DevoAura = Bastion.SpellBook:GetSpell(465) - -local PlayerSelfWOGPercent = 40 - -local WOGTarget = Bastion.UnitManager:CreateCustomUnit('wogtarget', function(unit) - local lowest = nil - local lowestHP = math.huge - - Bastion.UnitManager:EnumFriends(function(unit) - if unit:IsDead() then - return false - end - - if Player:GetDistance(unit) > 40 then - return false - end - - if not Player:CanSee(unit) then - return false - end - - local hp = unit:GetHP() - if hp < lowestHP then - lowest = unit - lowestHP = hp - end - - return false - end) - - if not lowest or Player:GetHP() < lowest then - lowest = Player - end - - return lowest -end) - -local isRunning = false - -ProtModule:Sync(function() - if not isRunning then - Bastion:Print('Prot Pally Started') - isRunning = true - end - - -- Cast Crusader Aura if talented and the player is mounted. - if Player:IsMounted() and CrusaderAura:IsKnownAndUsable() and not Player:GetAuras():FindMy(CrusaderAura):IsUp() and not Player:IsCastingOrChanneling() then - return CrusaderAura:Cast(Player) - end - - -- Cast Devo Aura if the player is not mounted. - if not Player:IsMounted() and DevoAura:IsKnownAndUsable() and not Player:GetAuras():FindMy(DevoAura):IsUp() and not Player:IsCastingOrChanneling() then - return DevoAura:Cast(Player) - end - - if Player:IsAffectingCombat() then - -- Combat Rotation - else - -- Out Of Combat Rotation - end -end) - -Bastion:Register(ProtModule) diff --git a/src/_bastion.lua b/src/_bastion.lua index 7e52165..e6d296e 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -34,6 +34,7 @@ Bastion.Unit = Bastion.require("Unit") Bastion.Aura = Bastion.require("Aura") ---@type APL, APLActor, APLTrait Bastion.APL, Bastion.APLActor, Bastion.APLTrait = Bastion.require("APL") +---@type Module Bastion.Module = Bastion.require("Module") ---@type UnitManager Bastion.UnitManager = Bastion.require("UnitManager"):New() @@ -266,11 +267,16 @@ Command:Register('missed', 'Dump the list of immune kidney shot spells', functio end end) -local files = ListFiles("scripts/bastion/scripts") +-- local files = ListFiles("scripts/bastion/scripts") -for i = 1, #files do - local file = files[i] - if file:sub( -4) == ".lua" or file:sub( -5) == '.luac' then - Tinkr:require("scripts/bastion/scripts/" .. file:sub(1, -5), Bastion) - end +-- for i = 1, #files do +-- local file = files[i] +-- if file:sub( -4) == ".lua" or file:sub( -5) == '.luac' then +-- Tinkr:require("scripts/bastion/scripts/" .. file:sub(1, -5), Bastion) +-- end +-- end + +if UnitClass('player') == 'Paladin' and GetSpecialization() == 2 then + Tinkr:require("scripts/bastion/scripts/paladin_protection", Bastion) + Eval('RunMacroText("/bastion module paladin_protection")', 'bastion') end