Skip to content

Commit

Permalink
Merge pull request #589 from xanunderscore/autopull
Browse files Browse the repository at this point in the history
Misc AI auto-pull preset
  • Loading branch information
xanunderscore authored Feb 7, 2025
2 parents daa42e9 + 64d05f9 commit 204499e
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions BossMod/Autorotation/MiscAI/AutoPull.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using BossMod.Autorotation.xan;

namespace BossMod.Autorotation.MiscAI;

public sealed class AutoPull(RotationModuleManager manager, Actor player) : RotationModule(manager, player)
{
public enum Track { QuestBattle, DeepDungeon, EpicEcho, Hunt }

public static RotationModuleDefinition Definition()
{
var def = new RotationModuleDefinition("Misc AI: Auto-pull", "Automatically attack passive mobs in certain circumstances", "Misc", "xan", RotationModuleQuality.Basic, new(~0ul), 1000, Order: RotationModuleOrder.HighLevel, CanUseWhileRoleplaying: true);

def.AbilityTrack(Track.QuestBattle, "Automatically attack solo duty bosses");
def.AbilityTrack(Track.DeepDungeon, "Automatically attack deep dungeon bosses when solo");
def.AbilityTrack(Track.EpicEcho, "Automatically attack all targets if the Epic Echo status is present (i.e. when unsynced)");
def.AbilityTrack(Track.Hunt, "Automatically attack hunt marks once they have already been pulled");

return def;
}

public override void Execute(StrategyValues strategy, ref Actor? primaryTarget, float estimatedAnimLockDelay, bool isMoving)
{
if (Player.InCombat || primaryTarget != null || World.Client.CountdownRemaining != null)
return;

var enabled = false;

if (strategy.Enabled(Track.QuestBattle))
enabled |= Bossmods.ActiveModule?.Info?.Category == BossModuleInfo.Category.Quest;

if (strategy.Enabled(Track.DeepDungeon))
enabled |= Bossmods.ActiveModule?.Info?.Category == BossModuleInfo.Category.DeepDungeon && World.Party.WithoutSlot().Count() == 1;

if (strategy.Enabled(Track.EpicEcho))
enabled |= Player.Statuses.Any(s => s.ID == 2734);

// TODO set HP threshold lower, or remove entirely? want to avoid getting one guy'd by an early puller
if (strategy.Enabled(Track.Hunt) && Bossmods.ActiveModule?.Info?.Category == BossModuleInfo.Category.Hunt && Bossmods.ActiveModule?.PrimaryActor is Actor p && p.InCombat && p.HPRatio < 0.95f)
{
Hints.SetPriority(p, 0);
primaryTarget = p;
return;
}

if (enabled)
{
var bestEnemy = Hints.PotentialTargets.Where(t => t.Priority == AIHints.Enemy.PriorityUndesirable).MinBy(p => Player.DistanceToHitbox(p.Actor));
if (bestEnemy != null)
{
bestEnemy.Priority = 0;
primaryTarget = bestEnemy.Actor;
}
}
}
}

0 comments on commit 204499e

Please sign in to comment.