Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI update #589

Merged
merged 41 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
767aef2
Fix BTL queueing
xanunderscore Jan 26, 2025
d9e1d90
Utility: dash fixes
Akechi-kun Jan 27, 2025
a70e8de
Utility: status & targeting fixes
Akechi-kun Jan 27, 2025
71391f1
Utility: ClassShared healers & casters
Akechi-kun Jan 27, 2025
c21e5ab
Utility: more cleanup on shit before next TODO
Akechi-kun Jan 27, 2025
dd98deb
8uh
Akechi-kun Jan 27, 2025
9277b1d
Zombie knockback handling.
awgil Jan 27, 2025
cd4e5ee
.
Akechi-kun Jan 27, 2025
db3d35a
Movement module to replace AI
awgil Jan 27, 2025
9c9db7f
PCT
Akechi-kun Jan 28, 2025
60cdd89
lol
Akechi-kun Jan 28, 2025
62b8ee2
AI caster things.
awgil Jan 28, 2025
2258ec4
Better autopeloton.
awgil Jan 28, 2025
0401d17
Moved all standard rotation modules into Standard directory.
awgil Jan 28, 2025
e6cff12
Merge branch 'master' into _-
Akechi-kun Jan 28, 2025
24c2d18
Explicit rotation module order groups.
awgil Jan 29, 2025
37f916d
7.16 Chaotic change
NightXIV Jan 29, 2025
41a0855
Misdirection support for new AI
awgil Jan 29, 2025
8b5d398
Only check pathfinding map if we use pathfinding.
awgil Jan 29, 2025
779c8ff
Autofarm retargeting.
awgil Jan 29, 2025
d6c64c2
AI deprecation.
awgil Jan 29, 2025
52205cf
Add waymark-relative targeting option.
awgil Jan 29, 2025
5e0b4be
Merge branch 'awgil:master' into _-
Akechi-kun Jan 30, 2025
0f8f9d2
fix errors
Akechi-kun Jan 30, 2025
a6a749d
fix errors.. again
Akechi-kun Jan 30, 2025
5a34d20
Shukuchi oopy
Akechi-kun Jan 30, 2025
1f39fd4
Show transient strategies.
awgil Jan 30, 2025
ff11630
Transient strategy improvements.
awgil Jan 30, 2025
7975cb0
Merge pull request #577 from xanunderscore/patch-18
awgil Feb 2, 2025
19c8047
Merge pull request #581 from NightXIV/master
awgil Feb 2, 2025
f54bf40
Fix formatting.
awgil Feb 2, 2025
5b14dbf
Merge branch 'awgil:master' into _-
Akechi-kun Feb 2, 2025
d6d3b3d
Requested Changes
Akechi-kun Feb 2, 2025
434efa0
Merge branch '_-' of https://github.com/Akechi-kun/ffxiv_bossmod into _-
Akechi-kun Feb 2, 2025
8e6cb7a
Simple plan/preset converter + renamed WAR module.
awgil Feb 2, 2025
c6a8eef
Merge pull request #578 from Akechi-kun/_-
awgil Feb 2, 2025
177a2a1
AI WIP
CarnifexOptimus Feb 6, 2025
32058ad
Merge branch 'merge' into mergeWIP
CarnifexOptimus Feb 6, 2025
c5501f0
WIP
CarnifexOptimus Feb 6, 2025
10b338a
screw this
CarnifexOptimus Feb 6, 2025
f5baf90
cosmetic change
CarnifexOptimus Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
233 changes: 112 additions & 121 deletions BossMod/AI/AIBehaviour.cs

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions BossMod/AI/AIConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sealed class AIConfig : ConfigNode
public bool DrawUI = false;

[PropertyDisplay("Focus target master")]
public bool FocusTargetLeader = false;
public bool FocusTargetMaster = false;

[PropertyDisplay("Broadcast keypresses to other windows")]
public bool BroadcastToSlaves = false;
Expand Down Expand Up @@ -49,9 +49,6 @@ sealed class AIConfig : ConfigNode
[PropertyDisplay("Max distance to target")]
public float MaxDistanceToTarget = 2.6f;

[PropertyDisplay("Override autorotation values", tooltip: "Uses your custom positional and distance settings instead of autorotation specific values")]
public bool OverrideAutorotation = true;

[PropertyDisplay("Enable auto AFK", tooltip: "Enables auto AFK if out of combat. While AFK AI will not use autorotation or target anything")]
public bool AutoAFK = false;

Expand All @@ -62,7 +59,7 @@ sealed class AIConfig : ConfigNode
public bool AllowAIToBeOutsideBounds = false;

[PropertyDisplay("Movement decision delay", tooltip: "Only change this at your own risk and keep this value low! Too high and it won't move in time for some mechanics. Make sure to readjust the value for different content.")]
public float MoveDelay = 0;
public double MoveDelay = 0;

[PropertyDisplay("Idle while mounted")]
public bool ForbidAIMovementMounted = false;
Expand Down
17 changes: 1 addition & 16 deletions BossMod/AI/AIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ sealed class AIController(WorldState ws, ActionManagerEx amex, MovementOverride

private readonly ActionManagerEx _amex = amex;
private readonly MovementOverride _movement = movement;
private DateTime _nextInteract;

public bool IsVerticalAllowed => Service.Condition[ConditionFlag.InFlight];
public Angle CameraFacing => (Camera.Instance?.CameraAzimuth ?? 0).Radians() + 180.Degrees();
Expand Down Expand Up @@ -55,24 +54,10 @@ public void Update(Actor? player, AIHints hints, DateTime now)
}
else
{
_amex.ForceCancelCastNextFrame |= ForceCancelCast && castInProgress;
hints.ForceCancelCast |= ForceCancelCast && castInProgress;
}

if (hints.ForcedMovement == null && desiredPosition != null)
hints.ForcedMovement = desiredPosition.Value - player.PosRot.XYZ();

if (hints.InteractWithTarget is Actor tar && player.DistanceToHitbox(tar) <= 3)
ExecuteInteract(now, tar);
}

private unsafe void ExecuteInteract(DateTime now, Actor target)
{
if (AIManager.Instance?.Beh == null || _amex.EffectiveAnimationLock > 0 || now < _nextInteract)
return;
var obj = GameObjectManager.Instance()->Objects.IndexSorted[target.SpawnIndex].Value;
if (obj == null || obj->GetGameObjectId() != target.InstanceID)
return;
TargetSystem.Instance()->OpenObjectInteraction(obj);
_nextInteract = now.AddMilliseconds(100);
}
}
5 changes: 1 addition & 4 deletions BossMod/AI/AIManagementWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public override void Draw()
var configModified = false;

ImGui.TextUnformatted($"Navi={_manager.Controller.NaviTargetPos}");
_manager.Beh?.DrawDebug();

configModified |= ImGui.Checkbox("Forbid actions", ref _config.ForbidActions);
ImGui.SameLine();
Expand All @@ -61,8 +60,6 @@ public override void Draw()
ImGui.Spacing();
configModified |= ImGui.Checkbox("Manual targeting", ref _config.ManualTarget);
ImGui.SameLine();
configModified |= ImGui.Checkbox("Override autorotation values", ref _config.OverrideAutorotation);
ImGui.SameLine();
configModified |= ImGui.Checkbox("Allow outside bounds", ref _config.AllowAIToBeOutsideBounds);

ImGui.Text("Follow party slot");
Expand Down Expand Up @@ -90,7 +87,7 @@ public override void Draw()
ImGui.SetNextItemWidth(100);
var positionalOptions = Enum.GetNames(typeof(Positional));
var positionalIndex = (int)_config.DesiredPositional;
if (ImGui.Combo("##DesiredPositional", ref positionalIndex, positionalOptions, positionalOptions.Length))
if (ImGui.Combo("##DesiredPositional", ref positionalIndex, positionalOptions, 4))
{
_config.DesiredPositional = (Positional)positionalIndex;
configModified = true;
Expand Down
34 changes: 4 additions & 30 deletions BossMod/AI/AIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void OnCommand(string cmd, string message)
ToggleConfig();
break;
case "TARGETMASTER":
configModified = ToggleFocusTargetLeader();
configModified = ToggleFocusTargetMaster();
break;
case "FOLLOW":
var cfgFollowSlot = _config.FollowSlot;
Expand Down Expand Up @@ -164,11 +164,7 @@ private void OnCommand(string cmd, string message)
ToggleOutOfBounds(messageData);
configModified = cfgOOB != _config.AllowAIToBeOutsideBounds;
break;
case "OVERRIDEAUTOROTATION":
var cfgARO = _config.OverrideAutorotation;
ToggleAutorotationOverride(messageData);
configModified = cfgARO != _config.OverrideAutorotation;
break;

case "POSITIONAL":
var cfgPositional = _config.DesiredPositional;
HandlePositionalCommand(messageData);
Expand Down Expand Up @@ -227,34 +223,12 @@ private void ToggleConfig()
SwitchToIdle();
}

private bool ToggleFocusTargetLeader()
private bool ToggleFocusTargetMaster()
{
_config.FocusTargetLeader = !_config.FocusTargetLeader;
_config.FocusTargetMaster = !_config.FocusTargetMaster;
return true;
}

private void ToggleAutorotationOverride(string[] messageData)
{
if (messageData.Length == 1)
_config.OverrideAutorotation = !_config.OverrideAutorotation;
else
{
switch (messageData[1].ToUpperInvariant())
{
case "ON":
_config.OverrideAutorotation = true;
break;
case "OFF":
_config.OverrideAutorotation = false;
break;
default:
Service.ChatGui.Print($"[AI] Unknown follow target command: {messageData[1]}");
return;
}
}
Service.Log($"[AI] Following targets is now {(_config.OverrideAutorotation ? "enabled" : "disabled")}");
}

private void ToggleOutOfBounds(string[] messageData)
{
if (messageData.Length == 1)
Expand Down
13 changes: 8 additions & 5 deletions BossMod/AI/AIRotationModule.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using BossMod.Autorotation;
using BossMod.Pathfinding;

namespace BossMod.AI;

public abstract class AIRotationModule(RotationModuleManager manager, Actor player) : RotationModule(manager, player)
{
protected float Deadline(DateTime deadline) => Math.Max(0, (float)(deadline - World.CurrentTime).TotalSeconds);
protected float Speed() => Player.FindStatus(50) != null ? 7.8f : 6;
protected NavigationDecision.Context NavigationContext = new();

protected float Deadline(DateTime deadline) => Math.Max(0f, (float)(deadline - World.CurrentTime).TotalSeconds);
protected float Speed() => Player.FindStatus((uint)ClassShared.SID.Sprint) != null ? 7.8f : 6f;

protected bool InMeleeRange(Actor target, WPos position)
{
var maxRange = target.HitboxRadius + Player.HitboxRadius + 3;
var maxRange = target.HitboxRadius + 2.6f;
return (target.Position - position).LengthSq() < maxRange * maxRange;
}

Expand All @@ -31,7 +34,7 @@ protected WPos ClosestInRange(WPos pos, WPos target, float maxRange)
return range <= maxRange ? pos : target + maxRange * toPlayer.Normalized();
}

protected WPos ClosestInMelee(WPos pos, Actor target, float tolerance = 0.25f) => ClosestInRange(pos, target.Position, target.HitboxRadius + 3 - tolerance);
protected WPos ClosestInMelee(WPos pos, Actor target, float tolerance = 0f) => ClosestInRange(pos, target.Position, target.HitboxRadius + 2.6f - tolerance);

// return uptime position if player will be able to reach downtime position within deadline having started movement after next action, otherwise downtime position
protected WPos UptimeDowntimePos(WPos uptimePos, WPos downtimePos, float nextAction, float deadline)
Expand All @@ -41,7 +44,7 @@ protected WPos UptimeDowntimePos(WPos uptimePos, WPos downtimePos, float nextAct
}

// return position that will make the target (assumed aggro'd) move to specified position, ensuring we're back in melee range by the deadline
protected WPos MoveTarget(Actor target, WPos desired, float nextAction, float targetMeleeRange = 2)
protected WPos MoveTarget(Actor target, WPos desired, float nextAction, float targetMeleeRange = 2f)
{
var dir = desired - target.Position;
if (dir.LengthSq() < 0.01f)
Expand Down
7 changes: 5 additions & 2 deletions BossMod/ActionQueue/ActionQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// - repeat the process until no more actions can be found
public sealed class ActionQueue
{
public readonly record struct Entry(ActionID Action, Actor? Target, float Priority, float Expire = float.MaxValue, float Delay = 0, Vector3 TargetPos = default, Angle? FacingAngle = null);
public readonly record struct Entry(ActionID Action, Actor? Target, float Priority, float Expire, float Delay, float CastTime, Vector3 TargetPos, Angle? FacingAngle);

// reference priority guidelines
// values divisible by 1000 are reserved for standard cooldown planner priorities
Expand Down Expand Up @@ -38,7 +38,7 @@ public static class Priority
public readonly List<Entry> Entries = [];

public void Clear() => Entries.Clear();
public void Push(ActionID action, Actor? target, float priority, float expire = float.MaxValue, float delay = 0, Vector3 targetPos = default, Angle? facingAngle = null) => Entries.Add(new(action, target, priority, expire, delay, targetPos, facingAngle));
public void Push(ActionID action, Actor? target, float priority, float expire = float.MaxValue, float delay = 0, float castTime = 0, Vector3 targetPos = default, Angle? facingAngle = null) => Entries.Add(new(action, target, priority, expire, delay, castTime, targetPos, facingAngle));

public Entry FindBest(WorldState ws, Actor player, ReadOnlySpan<Cooldown> cooldowns, float animationLock, AIHints hints, float instantAnimLockDelay)
{
Expand All @@ -54,6 +54,9 @@ public Entry FindBest(WorldState ws, Actor player, ReadOnlySpan<Cooldown> cooldo
if (def == null || !def.IsUnlocked(ws, player))
continue; // unregistered or locked action

if (candidate.CastTime > hints.MaxCastTime)
continue; // this cast can't be finished in time, look for something else

var startDelay = Math.Max(Math.Max(candidate.Delay, animationLock), def.ReadyIn(cooldowns, ws.Client.DutyActions));

// TODO: adjusted cast time!
Expand Down
5 changes: 3 additions & 2 deletions BossMod/ActionQueue/Casters/BLM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public enum TraitID : uint
public enum SID : uint
{
None = 0,
LucidDreaming = 1204, // applied by Lucid Dreaming to self
Swiftcast = 167, // applied by Swiftcast to self
Manaward = 168, // applied by Manaward to self
Thunder = 161, // applied by Thunder to target
ThunderII = 162, // applied by Thunder II to target
Expand All @@ -101,6 +99,9 @@ public enum SID : uint

//Shared
Addle = ClassShared.SID.Addle, // applied by Addle to target
Surecast = ClassShared.SID.Surecast, // applied by Surecast to self
LucidDreaming = ClassShared.SID.LucidDreaming, // applied by Lucid Dreaming to self
Swiftcast = ClassShared.SID.Swiftcast, // applied by Swiftcast to self
}

public sealed class Definitions : IDisposable
Expand Down
5 changes: 4 additions & 1 deletion BossMod/ActionQueue/Casters/PCT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public enum SID : uint
Aetherhues = 3675, // applied by Fire in Red, Fire II in Red, Blizzard II in Cyan, Blizzard in Cyan to self
AetherhuesII = 3676, // applied by Aero in Green, Aero II in Green, Stone in Yellow to self
TemperaCoat = 3686, // applied by Tempera Coat to self
Swiftcast = 167, // applied by Swiftcast to self
TemperaGrassa = 3687, // applied by Tempera Grassa to self
Smudge = 3684, // applied by Smudge to self
HammerTime = 3680, // applied by Striking Muse to self
SubtractivePalette = 3674, // applied by Subtractive Palette to self
Expand All @@ -103,6 +103,9 @@ public enum SID : uint

//Shared
Addle = ClassShared.SID.Addle, // applied by Addle to target
Surecast = ClassShared.SID.Surecast, // applied by Surecast to self
LucidDreaming = ClassShared.SID.LucidDreaming, // applied by Lucid Dreaming to self
Swiftcast = ClassShared.SID.Swiftcast, // applied by Swiftcast to self
}

public sealed class Definitions : IDisposable
Expand Down
5 changes: 3 additions & 2 deletions BossMod/ActionQueue/Casters/RDM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ public enum TraitID : uint
public enum SID : uint
{
None = 0,
LucidDreaming = 1204, // applied by Lucid Dreaming to self
Swiftcast = 167, // applied by Swiftcast to self
VerfireReady = 1234,
VerstoneReady = 1235,
Acceleration = 1238,
Expand All @@ -101,6 +99,9 @@ public enum SID : uint

//Shared
Addle = ClassShared.SID.Addle, // applied by Addle to target
Surecast = ClassShared.SID.Surecast, // applied by Surecast to self
LucidDreaming = ClassShared.SID.LucidDreaming, // applied by Lucid Dreaming to self
Swiftcast = ClassShared.SID.Swiftcast, // applied by Swiftcast to self
}

public sealed class Definitions : IDisposable
Expand Down
4 changes: 2 additions & 2 deletions BossMod/ActionQueue/Casters/SMN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public enum SID : uint
None = 0,
Sleep = 3, // applied by Sleep to target
FurtherRuin = 2701, // applied by Energy Drain, Energy Siphon to self
LucidDreaming = 1204, // applied by Lucid Dreaming to self
SearingLight = 2703, // applied by Searing Light to self/target
TitansFavor = 2853, // applied by Topaz Rite, Topaz Catastrophe to self
Rekindle = 2704, // applied by Rekindle to self
Expand All @@ -140,8 +139,9 @@ public enum SID : uint

//Shared
Addle = ClassShared.SID.Addle, // applied by Addle to target
Surecast = ClassShared.SID.Surecast, // applied by Surecast to self
LucidDreaming = ClassShared.SID.LucidDreaming, // applied by Lucid Dreaming to self
Swiftcast = ClassShared.SID.Swiftcast, // applied by Swiftcast to self

}

public sealed class Definitions : IDisposable
Expand Down
8 changes: 7 additions & 1 deletion BossMod/ActionQueue/ClassShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public enum SID : uint
#region PvE
None = 0,

Sprint = 50, // applied by Sprint to self

// Tank
Reprisal = 1193, // applied by Reprisal to target

Expand All @@ -89,8 +91,12 @@ public enum SID : uint
// PhysRanged
Peloton = 1199, // applied by Peloton to self/party

// Caster/Healer
// Caster
Addle = 1203, // applied by Addle to target

// Magical
LucidDreaming = 1204, // applied by Lucid Dreaming to self
Surecast = 160, // applied by Surecast to self
Swiftcast = 167, // applied by Swiftcast to self
Raise = 148, // applied by Raise to target

Expand Down
39 changes: 32 additions & 7 deletions BossMod/ActionQueue/Healers/AST.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,46 @@ public enum TraitID : uint
public enum SID : uint
{
None = 0,
LucidDreaming = 1204, // applied by Lucid Dreaming to self
Surecast = 160, // applied by Surecast to self
Combust = 838,
AspectedHelios = 836,
AspectedBenefic = 835,
HeliosConjunction = 3894,
Lightspeed = 841,
CombustII = 843,
CombustIII = 1881,
AspectedBenefic = 835,
AspectedHelios = 836,
HeliosConjunction = 3894,
Horoscope = 1890,
HoroscopeHelios = 1891,
NeutralSect = 1892,
NeutralSectShield = 1921,
Divination = 1878,
GiantDominance = 1248,
ClarifyingDraw = 2713,
Macrocosmos = 2718,
Lightspeed = 841,
SelfSynastry = 845,
TargetSynastry = 846,
Divining = 3893,

//Cards
TheBalance = 3887,
TheSpear = 3889,
Divining = 3893,
LordOfCrownsDrawn = 2054,
LadyOfCrownsDrawn = 2055,
BalanceDrawn = 913,
BoleDrawn = 914,
ArrowDrawn = 915,
SpearDrawn = 916,
EwerDrawn = 917,
SpireDrawn = 918,
BalanceBuff = 3887,
BoleBuff = 3890,
ArrowBuff = 3888,
SpearBuff = 3889,
EwerBuff = 3891,
SpireBuff = 3892,

//Shared
Surecast = ClassShared.SID.Surecast, // applied by Surecast to self
LucidDreaming = ClassShared.SID.LucidDreaming, // applied by Lucid Dreaming to self
Swiftcast = ClassShared.SID.Swiftcast, // applied by Swiftcast to self
}

Expand Down
5 changes: 3 additions & 2 deletions BossMod/ActionQueue/Healers/SCH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ public enum SID : uint
Bio2 = 189, // applied by Bio2 to target, dot
Biolysis = 1895,
Galvanize = 297, // applied by Adloquium to target, shield
LucidDreaming = 1204, // applied by Lucid Dreaming to self
Sleep = 3, // applied by Repose to target
BanefulImpaction = 3883, // applied by Baneful Impaction to target
ImpactImminent = 3882, // applied by Chain Stratagem to self
ChainStratagem = 1221, // applied by Chain Stratagem to target
FeyUnion = 1222, // applied by Aetherpact to target
FeyUnion = 1223, // applied by Aetherpact to target
Seraphism = 3884, // applied by Seraphism to self

//Shared
Surecast = ClassShared.SID.Surecast, // applied by Surecast to self
LucidDreaming = ClassShared.SID.LucidDreaming, // applied by Lucid Dreaming to self
Swiftcast = ClassShared.SID.Swiftcast, // applied by Swiftcast to self
}

Expand Down
Loading