diff --git a/BossMod/Autorotation/xan/DNC.cs b/BossMod/Autorotation/xan/DNC.cs index 91c2cc770a..6e98e36b3c 100644 --- a/BossMod/Autorotation/xan/DNC.cs +++ b/BossMod/Autorotation/xan/DNC.cs @@ -302,9 +302,9 @@ public override void Exec(StrategyValues strategy, Actor? primaryTarget) FinishingMoveLeft = StatusLeft(SID.FinishingMoveReady); DanceOfTheDawnLeft = StatusLeft(SID.DanceOfTheDawnReady); - (BestFan4Target, NumFan4Targets) = SelectTarget(targeting, primaryTarget, 15, CalcNumFan4Targets); - (BestRangedAOETarget, NumRangedAOETargets) = SelectTarget(targeting, primaryTarget, 25, NumSplashTargets); - (BestStarfallTarget, NumStarfallTargets) = SelectTarget(targeting, primaryTarget, 25, Num25yRectTargets); + (BestFan4Target, NumFan4Targets) = SelectTarget(targeting, primaryTarget, 15, IsFan4Target); + (BestRangedAOETarget, NumRangedAOETargets) = SelectTarget(targeting, primaryTarget, 25, IsSplashTarget); + (BestStarfallTarget, NumStarfallTargets) = SelectTarget(targeting, primaryTarget, 25, Is25yRectTarget); NumDanceTargets = Hints.NumPriorityTargetsInAOECircle(Player.Position, 15); NumAOETargets = strategy.Option(Track.AOE).As() switch @@ -318,14 +318,15 @@ public override void Exec(StrategyValues strategy, Actor? primaryTarget) && StatusLeft(SID.ClosedPosition) == 0 && _state.CD(AID.ClosedPosition) == 0 && !IsDancing - && FindDancePartner() is Actor partner) + && FindDancePartner() is Actor partner + && partner.IsTargetable) PushGCD(AID.ClosedPosition, partner); CalcNextBestGCD(strategy, primaryTarget); QueueOGCD((deadline, _) => CalcNextBestOGCD(strategy, primaryTarget, deadline)); } - private int CalcNumFan4Targets(Actor primary) => Hints.NumPriorityTargetsInAOECone(Player.Position, 15, (primary.Position - Player.Position).Normalized(), 60.Degrees()); + private bool IsFan4Target(Actor primary, Actor other) => Hints.TargetInAOECone(other, Player.Position, 15, (primary.Position - Player.Position).Normalized(), 60.Degrees()); private Actor? FindDancePartner() => World.Party.WithoutSlot().Exclude(Player).MaxBy(p => p.Class switch { diff --git a/BossMod/Autorotation/xan/xbase.cs b/BossMod/Autorotation/xan/xbase.cs index 567571baa6..6c5688969c 100644 --- a/BossMod/Autorotation/xan/xbase.cs +++ b/BossMod/Autorotation/xan/xbase.cs @@ -98,23 +98,41 @@ protected void SelectPrimaryTarget(OptionRef track, ref Actor? primaryTarget, fl private static bool IsEnemy(Actor? actor) => actor != null && actor.Type is ActorType.Enemy or ActorType.Part && !actor.IsAlly; - protected (Actor? Best, P Targets) SelectTarget

(OptionRef track, Actor? primaryTarget, float range, Func priorityFunc) where P : struct, IComparable => track.As() switch + protected (Actor? Best, int Priority) SelectTarget( + OptionRef track, + Actor? primaryTarget, + float range, + Func isInAOE + ) => SelectTarget(track, primaryTarget, range, isInAOE, (numTargets, _) => numTargets); + + protected (Actor? Best, P Priority) SelectTarget

( + OptionRef track, + Actor? primaryTarget, + float range, + Func isInAOE, + Func prioFunc + ) where P : struct, IComparable { - Targeting.Auto => FindBetterTargetBy(primaryTarget, range, priorityFunc), - Targeting.AutoPrimary => throw new NotImplementedException(), - _ => (primaryTarget, primaryTarget == null ? default : priorityFunc(primaryTarget)) - }; + P targetPrio(Actor a) => prioFunc(Hints.NumPriorityTargetsInAOE(enemy => isInAOE(a, enemy.Actor)), a); - protected int NumSplashTargets(Actor primary) => Hints.NumPriorityTargetsInAOECircle(primary.Position, 5); - protected (int Targets, uint HP) SplashTargetsPlusHP(Actor primary) - { - var targets = NumSplashTargets(primary); - return (targets, targets > 1 ? primary.HPMP.CurHP : 0); + return track.As() switch + { + Targeting.Auto => FindBetterTargetBy(primaryTarget, range, targetPrio), + Targeting.AutoPrimary => primaryTarget == null ? (null, default) : FindBetterTargetBy( + primaryTarget, + range, + targetPrio, + enemy => isInAOE(enemy.Actor, primaryTarget) + ), + _ => (primaryTarget, primaryTarget == null ? default : targetPrio(primaryTarget)) + }; } - protected int NumMeleeAOETargets() => NumSplashTargets(Player); + protected bool IsSplashTarget(Actor primary, Actor other) => Hints.TargetInAOECircle(other, primary.Position, 5); + + protected int NumMeleeAOETargets() => Hints.NumPriorityTargetsInAOECircle(Player.Position, 5); - protected int Num25yRectTargets(Actor primary) => Hints.NumPriorityTargetsInAOERect(Player.Position, (primary.Position - Player.Position).Normalized(), 25, 4); + protected bool Is25yRectTarget(Actor primary, Actor other) => Hints.TargetInAOERect(other, Player.Position, (primary.Position - Player.Position).Normalized(), 25, 4); public sealed override void Execute(StrategyValues strategy, Actor? primaryTarget) {