Skip to content

Commit

Permalink
fix primary target behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
xanunderscore committed Jul 12, 2024
1 parent 66e4b34 commit e7e807f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
11 changes: 6 additions & 5 deletions BossMod/Autorotation/xan/DNC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AOEStrategy>() switch
Expand All @@ -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
{
Expand Down
42 changes: 30 additions & 12 deletions BossMod/Autorotation/xan/xbase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P>(OptionRef track, Actor? primaryTarget, float range, Func<Actor, P> priorityFunc) where P : struct, IComparable => track.As<Targeting>() switch
protected (Actor? Best, int Priority) SelectTarget(
OptionRef track,
Actor? primaryTarget,
float range,
Func<Actor, Actor, bool> isInAOE
) => SelectTarget(track, primaryTarget, range, isInAOE, (numTargets, _) => numTargets);

protected (Actor? Best, P Priority) SelectTarget<P>(
OptionRef track,
Actor? primaryTarget,
float range,
Func<Actor, Actor, bool> isInAOE,
Func<int, Actor, P> 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<Targeting>() switch
{
Targeting.Auto => FindBetterTargetBy(primaryTarget, range, targetPrio),
Targeting.AutoPrimary => primaryTarget == null ? (null, default) : FindBetterTargetBy(

Check failure on line 121 in BossMod/Autorotation/xan/xbase.cs

View workflow job for this annotation

GitHub Actions / Build

No overload for method 'FindBetterTargetBy' takes 4 arguments

Check failure on line 121 in BossMod/Autorotation/xan/xbase.cs

View workflow job for this annotation

GitHub Actions / Build

No overload for method 'FindBetterTargetBy' takes 4 arguments
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)
{
Expand Down

0 comments on commit e7e807f

Please sign in to comment.