Skip to content

Commit

Permalink
Optimal target for Spear skills
Browse files Browse the repository at this point in the history
  • Loading branch information
Akechi-kun committed Oct 18, 2024
1 parent 3b6a92f commit 179a645
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
10 changes: 6 additions & 4 deletions BossMod/Autorotation/Standard/AkechiDRG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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<AOEStrategy>(); //Get AoE strategy
var AoETargets = AOEStrategy switch //Determine AoE target count
Expand Down Expand Up @@ -463,7 +465,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa
//Execute Geirskogul if available
var geirskogul = strategy.Option(Track.Geirskogul).As<GeirskogulStrategy>();
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<OffensiveStrategy>();
Expand All @@ -473,7 +475,7 @@ public override void Execute(StrategyValues strategy, Actor? primaryTarget, floa
//Execute Nastrond if available
var nastrondStrat = strategy.Option(Track.Nastrond).As<OffensiveStrategy>();
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<StardiverStrategy>();
Expand All @@ -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<OffensiveStrategy>();
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<OffensiveStrategy>();
Expand Down
25 changes: 25 additions & 0 deletions BossMod/BossModule/AIHints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,29 @@ public Func<WPos, float> GoalCombined(Func<WPos, float> singleTarget, Func<WPos,
return aoeTargets >= 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;
}
}

0 comments on commit 179a645

Please sign in to comment.