From 2c7447c41091b77470b8c98c77379c9454c842d9 Mon Sep 17 00:00:00 2001 From: Ryan Crockett Date: Mon, 20 Mar 2023 09:33:36 -0400 Subject: [PATCH] Add some CDs --- scripts/frost/frost-gui.lua | 24 ++++++++++++---------- scripts/frost/frost.lua | 26 +++++++++++++++++++++++- src/ToggleManager/ToggleManager.lua | 31 +++++++++++++++++++++-------- 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/scripts/frost/frost-gui.lua b/scripts/frost/frost-gui.lua index 793a8da..0e3fa58 100644 --- a/scripts/frost/frost-gui.lua +++ b/scripts/frost/frost-gui.lua @@ -7,35 +7,29 @@ local IcyVeins = Bastion.SpellBook:GetSpell(12472) local FrozenOrb = Bastion.SpellBook:GetSpell(84714) local Blizzard = Bastion.SpellBook:GetSpell(190356) -local FrostOptions = { - CdsEnabled = false, - FrozenOrbEnabled = false, - AutoAOE = true -} - Bastion.ToggleManager:Add({ id = 'Frost_CdsEnabled', icon = IcyVeins:GetIcon(), - state = FrostOptions.CdsEnabled + state = false }) Bastion.ToggleManager:Add({ id = 'Frost_FrozenOrbEnabled', icon = FrozenOrb:GetIcon(), - state = FrostOptions.FrozenOrbEnabled + state = false }) Bastion.ToggleManager:Add({ id = 'Frost_AutoAOE', icon = Blizzard:GetIcon(), - state = FrostOptions.AutoAOE + state = true }) ---@alias GetFrostOption fun(option: "CdsEnabled" | "FrozenOrbEnabled" | 'AutoAOE'): boolean ---@type GetFrostOption local function GetFrostOption(option) - return FrostOptions[option] + return Bastion.ToggleManager:GetState("Frost_" .. option) end local Command = Bastion.Command:New('frost') @@ -46,10 +40,20 @@ end) Command:Register('cds', 'Toggle bastion on/off', function() Bastion.ToggleManager:Toggle("Frost_CdsEnabled") + + if GetFrostOption("FrozenOrbEnabled") and not GetFrostOption("CdsEnabled") then + Bastion.ToggleManager:Toggle("Frost_FrozenOrbEnabled") + elseif not GetFrostOption("FrozenOrbEnabled") and GetFrostOption("CdsEnabled") then + Bastion.ToggleManager:Toggle("Frost_FrozenOrbEnabled") + end end) Command:Register('orb', 'Toggle bastion on/off', function() Bastion.ToggleManager:Toggle("Frost_FrozenOrbEnabled") + + if not GetFrostOption("FrozenOrbEnabled") and GetFrostOption("CdsEnabled") then + Bastion.ToggleManager:Toggle("Frost_CdsEnabled") + end end) return GetFrostOption \ No newline at end of file diff --git a/scripts/frost/frost.lua b/scripts/frost/frost.lua index f9daebb..c7cd0d3 100644 --- a/scripts/frost/frost.lua +++ b/scripts/frost/frost.lua @@ -83,14 +83,38 @@ local IceLanceTarget = Bastion.UnitManager:CreateCustomUnit('icelance', function return icelance_target end) +local FrozenOrbTarget = Bastion.UnitManager:CreateCustomUnit('frozen_orb', function() + local unit = Bastion.UnitManager:GetEnemyWithMostEnemies(11) + + if not unit then + if Target:Exists() and Target:GetDistance(Player) <= 40 then + unit = Target + else + unit = None + end + end + + return unit +end) + + ---@return boolean local function CombatRotation() local targetCount = GetRangedTargetCount(40) - if GetFrostOption("CdsEnabled") and IcyVeins:IsKnown() and not Player:IsCastingOrChanneling() then + if GetFrostOption("CdsEnabled") and IcyVeins:IsKnown() and not Player:IsCastingOrChanneling() and not Player:IsMoving() then IcyVeins:Cast(Player) end + if GetFrostOption("CdsEnabled") and RuneOfPower:IsKnownAndUsable() and not Player:GetAuras():FindMy(RuneOfPower):IsUp() and not Player:IsMoving() then + return RuneOfPower:Cast(Player) + end + + if FrozenOrb:IsKnownAndUsable() and GetFrostOption("FrozenOrbEnabled") and FrozenOrbTarget:Exists() then + FaceObject(FrozenOrbTarget:GetGUID()) + return FrozenOrb:Cast(Player) + end + if IceLance:IsKnownAndUsable() and IceLanceTarget:Exists() then return IceLance:Cast(IceLanceTarget) end diff --git a/src/ToggleManager/ToggleManager.lua b/src/ToggleManager/ToggleManager.lua index 22cce04..c330015 100644 --- a/src/ToggleManager/ToggleManager.lua +++ b/src/ToggleManager/ToggleManager.lua @@ -67,15 +67,16 @@ function ToggleManager:Refresh() Texture:SetDesaturated(true) end self.toggles[toggle.id].texture = Texture - else - local desaturation = toggle.texture:GetDesaturation() - - if not toggle.state and desaturation == 0 then - toggle.texture:SetDesaturated(true) - elseif toggle.state and desaturation == 1 then - toggle.texture:SetDesaturated(false) - end end + -- else + -- local desaturation = toggle.texture:GetDesaturation() + + -- if not toggle.state and desaturation == 0 then + -- toggle.texture:SetDesaturated(true) + -- elseif toggle.state and desaturation == 1 then + -- toggle.texture:SetDesaturated(false) + -- end + -- end end end @@ -83,7 +84,21 @@ end function ToggleManager:Toggle(id) if self.toggles[id] then self.toggles[id].state = not self.toggles[id].state + + local desaturation = self.toggles[id].texture:GetDesaturation() + + if not self.toggles[id].state and desaturation == 0 then + self.toggles[id].texture:SetDesaturated(true) + elseif self.toggles[id].state and desaturation == 1 then + self.toggles[id].texture:SetDesaturated(false) + end end end +---@param id string +---@return boolean +function ToggleManager:GetState(id) + if self.toggles[id] then return self.toggles[id].state else return false end +end + return ToggleManager