From 179a64568aeb9e585e1e2ce13ae47431db31dd4a Mon Sep 17 00:00:00 2001 From: ace Date: Fri, 18 Oct 2024 05:30:26 -0700 Subject: [PATCH] Optimal target for Spear skills --- BossMod/Autorotation/Standard/AkechiDRG.cs | 10 +++++---- BossMod/BossModule/AIHints.cs | 25 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/BossMod/Autorotation/Standard/AkechiDRG.cs b/BossMod/Autorotation/Standard/AkechiDRG.cs index da4ac362c..b21907d83 100644 --- a/BossMod/Autorotation/Standard/AkechiDRG.cs +++ b/BossMod/Autorotation/Standard/AkechiDRG.cs @@ -322,6 +322,8 @@ public static RotationModuleDefinition Definition() public DRG.AID NextGCD; //Next global cooldown action to be used private GCDPriority NextGCDPrio; //Priority of the next GCD, used for decision making on cooldowns + private Actor? FarthestTarget; + //Check if the desired ability is unlocked private bool Unlocked(DRG.AID aid) => ActionUnlocked(ActionID.MakeSpell(aid)); @@ -393,9 +395,9 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa ); //Get remaining time for Chaos Thrust and Chaotic Spring PotionLeft = PotionStatusLeft(); //Get remaining potion status (RaidBuffsLeft, RaidBuffsIn) = EstimateRaidBuffTimings(primaryTarget); //Estimate remaining raid buffs - NextGCD = DRG.AID.None; //Set next GCD ability NextGCDPrio = GCDPriority.None; //Set next GCD priority + FarthestTarget = Hints.FarthestTargetWithinRadius(Player.Position, 15); //Get farthest target within 5-yalm radius var AOEStrategy = strategy.Option(Track.AoE).As(); //Get AoE strategy var AoETargets = AOEStrategy switch //Determine AoE target count @@ -463,7 +465,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa //Execute Geirskogul if available var geirskogul = strategy.Option(Track.Geirskogul).As(); if (!hold && ShouldUseGeirskogul(geirskogul, primaryTarget)) - QueueOGCD(DRG.AID.Geirskogul, primaryTarget, geirskogul == GeirskogulStrategy.Force ? OGCDPriority.ForcedOGCD : OGCDPriority.Geirskogul); + QueueOGCD(DRG.AID.Geirskogul, FarthestTarget, geirskogul == GeirskogulStrategy.Force ? OGCDPriority.ForcedOGCD : OGCDPriority.Geirskogul); //Execute Mirage Dive if available var mirageStrat = strategy.Option(Track.MirageDive).As(); @@ -473,7 +475,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa //Execute Nastrond if available var nastrondStrat = strategy.Option(Track.Nastrond).As(); if (!hold && ShouldUseNastrond(nastrondStrat, primaryTarget)) - QueueOGCD(DRG.AID.Nastrond, primaryTarget, nastrondStrat == OffensiveStrategy.Force ? OGCDPriority.ForcedOGCD : OGCDPriority.Nastrond); + QueueOGCD(DRG.AID.Nastrond, FarthestTarget, nastrondStrat == OffensiveStrategy.Force ? OGCDPriority.ForcedOGCD : OGCDPriority.Nastrond); //Execute Stardiver if available var sdStrat = strategy.Option(Track.Stardiver).As(); @@ -483,7 +485,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa //Execute Wyrmwind Thrust if available var wtStrat = strategy.Option(Track.WyrmwindThrust).As(); if (!hold && ShouldUseWyrmwindThrust(wtStrat, primaryTarget)) - QueueOGCD(DRG.AID.WyrmwindThrust, primaryTarget, wtStrat == OffensiveStrategy.Force ? OGCDPriority.ForcedOGCD : OGCDPriority.WyrmwindThrust); + QueueOGCD(DRG.AID.WyrmwindThrust, FarthestTarget, wtStrat == OffensiveStrategy.Force ? OGCDPriority.ForcedOGCD : OGCDPriority.WyrmwindThrust); //Execute Rise of the Dragon if available var riseStrat = strategy.Option(Track.RiseOfTheDragon).As(); diff --git a/BossMod/BossModule/AIHints.cs b/BossMod/BossModule/AIHints.cs index 9120e6e7c..482629d18 100644 --- a/BossMod/BossModule/AIHints.cs +++ b/BossMod/BossModule/AIHints.cs @@ -277,4 +277,29 @@ public Func GoalCombined(Func singleTarget, Func= 0 ? 3 + aoeTargets : singleTarget(p); }; } + + public Actor? FarthestTargetWithinRadius(WPos origin, float radius = 15f) + { + Actor? farthestTarget = null; + float maxDistanceSquared = 0f; + + // Iterate through all potential targets + foreach (var target in PotentialTargets) + { + var distanceSquared = (target.Actor.Position - origin).LengthSq(); + + // Check if the target is within the given radius + if (distanceSquared <= radius * radius) + { + // If this target is farther than the current farthest, update it + if (distanceSquared > maxDistanceSquared) + { + maxDistanceSquared = distanceSquared; + farthestTarget = target.Actor; + } + } + } + + return farthestTarget; + } }