More optomization

main
Ryan Crockett 2 years ago
parent 2c7447c410
commit 22b48bb284
  1. 49
      scripts/frost/frost.lua
  2. 7
      src/Unit/Unit.lua
  3. 17
      src/UnitManager/UnitManager.lua

@ -35,7 +35,7 @@ local GetFrostOption = Tinkr:require("scripts/bastion/scripts/frost/frost-gui",
local function isUnitFrozen(unit)
if not unit:Exists() then return false end
if unit:GetAuras():FindMy(IceNova):IsUp() or unit:GetAuras():FindMy(FrostNova):IsUp() or unit:GetAuras():FindMy(WintersChill):IsUp() then
if unit:GetAuras():FindMy(IceNova):IsUp() or unit:GetAuras():FindMy(FrostNova):IsUp() then
return true
end
@ -84,7 +84,7 @@ local IceLanceTarget = Bastion.UnitManager:CreateCustomUnit('icelance', function
end)
local FrozenOrbTarget = Bastion.UnitManager:CreateCustomUnit('frozen_orb', function()
local unit = Bastion.UnitManager:GetEnemyWithMostEnemies(11)
local unit = Bastion.UnitManager:GetEnemyWithMostEnemies(40, 10)
if not unit then
if Target:Exists() and Target:GetDistance(Player) <= 40 then
@ -97,31 +97,66 @@ local FrozenOrbTarget = Bastion.UnitManager:CreateCustomUnit('frozen_orb', funct
return unit
end)
local HasRotatedForOrb = false
FrozenOrb:OnCast(function()
HasRotatedForOrb = false
end)
---@return boolean
local function CombatRotation()
local targetCount = GetRangedTargetCount(40)
if GetFrostOption("CdsEnabled") and IcyVeins:IsKnown() and not Player:IsCastingOrChanneling() and not Player:IsMoving() then
IcyVeins:Cast(Player)
if GetFrostOption("CdsEnabled") and IcyVeins:IsKnownAndUsable() and not Player:IsMoving() and Target:Exists() then
return IcyVeins:Cast(Player)
end
if GetFrostOption("CdsEnabled") and RuneOfPower:IsKnownAndUsable() and not Player:GetAuras():FindMy(RuneOfPower):IsUp() and not Player:IsMoving() then
if GetFrostOption("CdsEnabled") and RuneOfPower:IsKnownAndUsable() and not Player:GetAuras():FindMy(RuneOfPower):IsUp() and not Player:IsMoving() and Target:Exists() and IcyVeins:GetLastCastTime() ~= false and GetTime() - IcyVeins:GetLastCastTime() > 5 then
return RuneOfPower:Cast(Player)
end
if FrozenOrb:IsKnownAndUsable() and GetFrostOption("FrozenOrbEnabled") and FrozenOrbTarget:Exists() then
if not HasRotatedForOrb then
print("TURNING TO ORB TARGET")
FaceObject(FrozenOrbTarget:GetGUID())
SendMovementHeartbeat()
HasRotatedForOrb = true
else
return FrozenOrb:Cast(Player)
end
end
if IceLance:IsKnownAndUsable() and IceLanceTarget:Exists() then
if IceLanceTarget:Exists() then
return IceLance:Cast(IceLanceTarget)
end
if Target:Exists() and Player:CanSee(Target) and IceLance:IsKnownAndUsable() and IceLance:IsInRange(Target) and (isUnitFrozen(Target) or Player:GetAuras():FindMy(FingersOfFrost):IsUp()) then
if Target:Exists() and Player:CanSee(Target) and IceLance:IsKnownAndUsable() and IceLance:IsInRange(Target) then
-- Winters Chill
if Target:GetAuras():FindMy(WintersChill):IsUp() then
local winters_chill_stacks = Target:GetAuras():FindMy(WintersChill):GetCount()
print("WC STACKS: ", winters_chill_stacks)
if winters_chill_stacks == 1 and not IceLance:IsInFlightToUnit(Target) then
return IceLance:Cast(Target)
end
if winters_chill_stacks > 1 then
return IceLance:Cast(Target)
end
end
-- Fingers of Frost
if Player:GetAuras():FindMy(FingersOfFrost):IsUp() then
local fof_stacks = Player:GetAuras():FindMy(FingersOfFrost):GetCount()
print("FOF STACKS: ", fof_stacks)
if fof_stacks == 1 and not IceLance:IsInFlightToUnit(Target) then
return IceLance:Cast(Target)
end
if fof_stacks > 1 then
return IceLance:Cast(Target)
end
end
end
if Target:Exists() and Player:CanSee(Target) and Flurry:IsKnownAndUsable() and Player:GetAuras():FindMy(BrainFreeze):IsUp() then
local CastingSpell = Player:GetCastingOrChannelingSpell()

@ -588,12 +588,17 @@ end
-- IsFacing
---@param unit Unit
---@param fov? number
---@return boolean
function Unit:IsFacing(unit)
function Unit:IsFacing(unit, fov)
local rot = ObjectRotation(self:GetOMToken())
local x, y, z = ObjectPosition(self:GetOMToken())
local x2, y2, z2 = ObjectPosition(unit:GetOMToken())
local fovToUse = 90
if fov then fovToUse = fov end
if not x or not x2 or not rot then
return false
end

@ -311,18 +311,19 @@ function UnitManager:FindFriendsCentroid(radius, range)
end
-- Get the enemy with the most enemies within a given radius
---@param distanceFromPlayer number
---@param radius number
---@return Unit
---@return table
function UnitManager:GetEnemyWithMostEnemies(radius)
function UnitManager:GetEnemyWithMostEnemies(distanceFromPlayer, radius)
local unit = nil
local count = 0
local enemies = {}
self:EnumEnemies(function(u)
if u:IsAlive() then
if u:IsAlive() and u:IsAffectingCombat() and u:GetDistance(self:Get("player")) <= distanceFromPlayer then
local c = 0
self:EnumEnemies(function(other)
if other:IsAlive() and u:GetDistance(other) <= radius then
if other:IsAlive() and other:IsAffectingCombat() and u:GetDistance(other) <= radius then
c = c + 1
end
end)
@ -331,7 +332,7 @@ function UnitManager:GetEnemyWithMostEnemies(radius)
count = c
enemies = {}
self:EnumEnemies(function(other)
if other:IsAlive() and u:GetDistance(other) <= radius then
if other:IsAlive() and other:IsAffectingCombat() and u:GetDistance(other) <= radius then
table.insert(enemies, other)
end
end)
@ -342,11 +343,11 @@ function UnitManager:GetEnemyWithMostEnemies(radius)
end
-- Find the centroid of the most dense area of friends (party/raid members) of a given radius within a given range
---@param distanceFromPlayer number
---@param radius number
---@param range number
---@return Vector3 | nil
function UnitManager:FindEnemiesCentroid(radius, range)
local unit, enemies = self:GetEnemyWithMostEnemies(radius)
function UnitManager:FindEnemiesCentroid(distanceFromPlayer, radius)
local unit, enemies = self:GetEnemyWithMostEnemies(distanceFromPlayer, radius)
if unit == nil then
return nil
end
@ -361,7 +362,7 @@ function UnitManager:FindEnemiesCentroid(radius, range)
centroid = centroid / #enemies
if unit:GetPosition():Distance(centroid) > range then
if unit:GetPosition():Distance(centroid) > distanceFromPlayer then
return unit:GetPosition()
end

Loading…
Cancel
Save