Get started with queue functionality

main
Ryan Crockett 2 years ago
parent e0c2e15a47
commit 82af0e2e38
  1. 60
      scripts/paladin/paladin_protection.lua
  2. 50
      src/Queue/Queue.lua
  3. 30
      src/_bastion.lua

@ -19,6 +19,10 @@ local BlessingOfTheDawn = Bastion.SpellBook:GetSpell(385127)
local ShieldOfTheRighteous = Bastion.SpellBook:GetSpell(53600)
local BlessedHammer = Bastion.SpellBook:GetSpell(204019)
local AutoAttack = Bastion.SpellBook:GetSpell(6603)
local WoG = Bastion.SpellBook:GetSpell(85673)
local ShinningLight = Bastion.SpellBook:GetSpell(327510)
local HolyPower = Enum.PowerType.HolyPower
---@type Rebuke
local Rebuke = Tinkr:require("scripts/bastion/scripts/paladin/shared/rebuke", Bastion)
@ -26,7 +30,7 @@ local Rebuke = Tinkr:require("scripts/bastion/scripts/paladin/shared/rebuke", Ba
---@type HammerOfWrath
local HammerOfWrath = Tinkr:require("scripts/bastion/scripts/paladin/shared/hammer-of-wrath", Bastion)
local AvengersShieldTarget = Bastion.UnitManager:CreateCustomUnit('avengers_shield', function()
local AvengersShieldTarget = Bastion.UnitManager:CreateCustomUnit('avengersshield', function()
local target = nil
Bastion.UnitManager:EnumEnemies(function(unit)
@ -61,6 +65,45 @@ local AvengersShieldTarget = Bastion.UnitManager:CreateCustomUnit('avengers_shie
return target
end)
local WoGTarget = Bastion.UnitManager:CreateCustomUnit('wordofglory', function()
if not WoG:IsKnownAndUsable() then return None end
local lowest = nil
local lowestHP = math.huge
Bastion.UnitManager:EnumFriends(function(unit)
if unit:IsDead() then
return false
end
if WoG:IsInRange(unit) then
return false
end
if not Player:CanSee(unit) then
return false
end
if not unit:GetHealthPercent() <= 55 then
return false
end
local hp = unit:GetHP()
if hp < lowestHP then
lowest = unit
lowestHP = hp
end
return false
end)
if not lowest then
lowest = None
end
return lowest
end)
---@return boolean
local function CombatRotation()
-- Attack the target is auto attack isnt active.
@ -80,20 +123,24 @@ local function CombatRotation()
if OfDuskAndDawn:IsKnown() then
-- If Blessing of Dawn isnt up, or will expire soon then wait for 5 HP to cast it.
if not Player:GetAuras():FindMy(BlessingOfTheDawn):IsUp() or Player:GetAuras():FindMy(BlessingOfTheDawn):GetRemainingTime() < 7 then
if Player:GetPower(Enum.PowerType.HolyPower) > 4 and ShieldOfTheRighteous:IsKnownAndUsable() and ShieldOfTheRighteous:IsInRange(Target) then
if Player:GetPower(HolyPower) > 4 and ShieldOfTheRighteous:IsKnownAndUsable() and ShieldOfTheRighteous:IsInRange(Target) and not Player:IsCastingOrChanneling() then
return ShieldOfTheRighteous:Cast(Target)
end
-- If Blessing of Dawn is up, cast SoR at 3 or more HP
elseif Player:GetPower(Enum.PowerType.HolyPower) >= 3 and ShieldOfTheRighteous:IsKnownAndUsable() and ShieldOfTheRighteous:IsInRange(Target) then
elseif Player:GetPower(HolyPower) >= 3 and not Player:IsCastingOrChanneling() and ShieldOfTheRighteous:IsKnownAndUsable() and ShieldOfTheRighteous:IsInRange(Target) then
return ShieldOfTheRighteous:Cast(Target)
end
else
-- If Dusk And Dawn isnt known, rip SoR normally.
if ShieldOfTheRighteous:IsKnownAndUsable() and ShieldOfTheRighteous:IsInRange(Target) then
if ShieldOfTheRighteous:IsKnownAndUsable() and ShieldOfTheRighteous:IsInRange(Target) and not Player:IsCastingOrChanneling() then
return ShieldOfTheRighteous:Cast(Target)
end
end
if WoG:IsKnownAndUsable() and Player:GetAuras():FindMy(ShinningLight):IsUp() and Player:GetHealthPercent() <= 51 and not Player:IsCastingOrChanneling() then
return WoG:Cast(Player)
end
-- Avengers shield with higher prio than Judgement in AOE. Prefer targets that are casting.
if Player:GetEnemies(10) > 1 and AvengersShield:IsKnownAndUsable() and AvengersShieldTarget:Exists() then
return AvengersShield:Cast(AvengersShieldTarget)
@ -117,6 +164,11 @@ local function CombatRotation()
return BlessedHammer:Cast(Player)
end
if WoGTarget:Exists() and not Player:IsCastingOrChanneling() then
print('FOUND WoG TARGET')
return WoG:Cast(WoGTarget)
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)

@ -0,0 +1,50 @@
local Tinkr, _Bastion = ...
---@type Bastion
local Bastion = _Bastion
-- Create a new Queue class
---@class Queue
local Queue = {
---@type table<number, { spell: number, unit: Unit }>
queued = {}
}
Queue.__index = Queue
-- Constructor
---@return Queue
function Queue:New()
local self = setmetatable({}, Queue)
self.queued = {}
return self
end
-- Add an spell to the queue
---@param id number
---@param unit "mouseover"|"target"|"player"
---@return boolean
function Queue:Add(id, unit)
local isUsable = IsSpellKnown(id)
if not isUsable then
return false
end
local _unit = nil
if unit == 'mouseover' then
_unit = Bastion.UnitManager:Get('mouseover')
elseif unit == 'target' then
_unit = Bastion.UnitManager:Get('target')
else
_unit = Bastion.UnitManager:Get('player')
end
if not _unit == nil and self.queued[id] == nil then
self.queued[id]['spell'] = id
self.queued[id]['unit'] = _unit
return true
end
return false
end

@ -261,21 +261,33 @@ Command:Register('mplus', 'Toggle m+ module on/off', function(args)
Bastion:Print("casts")
end)
Command:Register('queue', 'Queue a spell or macro', function(args)
local queuedId = args[2]
local isUsable = IsSpellKnown(queuedId)
if isUsable then
local QueuedSpell = Bastion.SpellBook:GetSpell(queuedId)
if QueuedSpell == nil then
print('Unable to queue invalid spell')
else
if QueuedSpell:IsKnownAndUsable() then
print(QueuedSpell:GetName())
else
print("Cant queue unlearned spell ", queuedId)
end
end
else
print('Unable to queue invalid spell')
end
end)
Command:Register('missed', 'Dump the list of immune kidney shot spells', function()
for k, v in pairs(missed) do
Bastion:Print(k)
end
end)
-- 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
-- end
if UnitClass('player') == 'Paladin' and GetSpecialization() == 2 then
Tinkr:require("scripts/bastion/scripts/paladin/paladin_protection", Bastion)
Eval('RunMacroText("/bastion module paladin_protection")', 'bastion')

Loading…
Cancel
Save