/// <summary>
/// Walk towards a location with positional bonuses e.g. occulus damage bonus / serenity defensive bonus.
/// </summary>
/// <param name="power">Trinity power configured to move player towards a buffed position</param>
/// <param name="maxDistance">maximum distance spot can be from player's current position</param>
/// <param name="arriveDistance">how close to get to the middle of the spot before stopping walking</param>
/// <returns>if a location was found and should be moved to</returns>
public static bool TryMoveToBuffedSpot(out TrinityPower power, float maxDistance, float arriveDistance = 20f)
{
if (IsInCombat && !IsCurrentlyKiting && !IsCurrentlyAvoiding)
{
Vector3 buffedLocation;
if (PhelonUtils.BestBuffPosition(maxDistance, Player.Position, true, out buffedLocation))
{
var lastPower = SpellHistory.LastPower;
var distance = buffedLocation.Distance(Player.Position);
Logger.LogVerbose(LogCategory.Routine, $"Buffed location found Dist={distance}");
if (buffedLocation.Distance(Player.Position) < arriveDistance)
{
Logger.Log(LogCategory.Routine, $"Standing in Buffed Position {buffedLocation} Dist={distance}");
}
else if (!Core.Avoidance.Grid.CanRayWalk(Player.Position, buffedLocation))
{
Logger.Log(LogCategory.Routine, $"Unable to straight-line path to Buffed Position {buffedLocation} Dist={distance}");
}
else if (!Core.Avoidance.Grid.CanRayWalk(CurrentTarget.Position, buffedLocation))
{
Logger.Log(LogCategory.Routine, $"Can't see target from buffed position {buffedLocation} Dist={distance}");
}
else if (Core.Avoidance.Avoider.IsKiteOnCooldown)
{
Logger.Log(LogCategory.Routine, $"Not moving to buffed location while on kite cooldown");
}
else if (lastPower != null && buffedLocation.Distance(CurrentTarget.Position) > lastPower.MinimumRange + CurrentTarget.CollisionRadius + Player.Radius)
{
Logger.LogVerbose(LogCategory.Routine, $"Buffed spot outside attack range for power {lastPower.SNOPower} Range={lastPower.MinimumRange} TimeSinceUse={lastPower.TimeSinceUse} Dist={distance}");
}
else if (KiteDistance <= 0 || !TargetUtil.AnyMobsInRangeOfPosition(buffedLocation, KiteDistance))
{
Logger.LogVerbose(LogCategory.Routine, $"Moving to Buffed Position {buffedLocation} Dist={distance}");
power = new TrinityPower(SNOPower.Walk, maxDistance, buffedLocation);
return true;
}
}
}
power = null;
return false;
}