Skip to content

Commit

Permalink
Merge pull request #764 from erdelf/master
Browse files Browse the repository at this point in the history
Various Run stability improvements
  • Loading branch information
erdelf authored Jan 20, 2025
2 parents e082cce + e5e7b1b commit 7ca3453
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 20 deletions.
25 changes: 24 additions & 1 deletion AutoDuty/AutoDuty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ internal LevelingMode LevelingModeEnum
private SettingsActive _bareModeSettingsActive = SettingsActive.None;
public readonly bool isDev;

public HashSet<uint> loadedDungeonsForRebuild = [];

public AutoDuty()

Check warning on line 202 in AutoDuty/AutoDuty.cs

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field 'PathsDirectory' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 202 in AutoDuty/AutoDuty.cs

View workflow job for this annotation

GitHub Actions / Build

Non-nullable field 'AssemblyFileInfo' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
try
Expand Down Expand Up @@ -577,8 +579,19 @@ public void Run(uint territoryType = 0, int loops = 0, bool startFromZero = true
Queue(CurrentTerritoryContent);
}
TaskManager.Enqueue(() => Svc.Log.Debug($"Done Queueing-WaitDutyStarted, NavIsReady"));
TaskManager.Enqueue(() => Svc.DutyState.IsDutyStarted, "Run-WaitDutyStarted");
TaskManager.Enqueue(() => Svc.DutyState.IsDutyStarted, "Run-WaitDutyStarted");
TaskManager.Enqueue(() => VNavmesh_IPCSubscriber.Nav_IsReady(), int.MaxValue, "Run-WaitNavIsReady");
TaskManager.Enqueue(() =>
{
if (this.Configuration.RebuildNavmeshOnFirstEntry && !Plugin.loadedDungeonsForRebuild.Contains(this.CurrentTerritoryContent.Id))
{
//this.Chat.ExecuteCommand("/vnav rebuild");
VNavmesh_IPCSubscriber.Nav_Rebuild();
Plugin.loadedDungeonsForRebuild.Add(this.CurrentTerritoryContent.Id);
}
}, int.MaxValue, "Run-NavRebuild");
TaskManager.DelayNext("Run-WaitNavRebuild100", 100);
TaskManager.Enqueue(() => VNavmesh_IPCSubscriber.Nav_IsReady(), int.MaxValue, "Run-WaitNavIsReady2");
TaskManager.Enqueue(() => Svc.Log.Debug($"Start Navigation"));
TaskManager.Enqueue(() => StartNavigation(startFromZero), "Run-StartNavigation");
if (CurrentLoop == 0)
Expand Down Expand Up @@ -893,9 +906,12 @@ private void StageReadingPath()

if (!VNavmesh_IPCSubscriber.SimpleMove_PathfindInProgress() && !VNavmesh_IPCSubscriber.Path_IsRunning())
{
Chat.Instance.ExecuteCommand("/automove off");
VNavmesh_IPCSubscriber.Path_SetTolerance(0.25f);
if (PathAction.Name == "MoveTo" && PathAction.Arguments.Count > 0 && bool.TryParse(PathAction.Arguments[0], out bool useMesh) && !useMesh)
{
VNavmesh_IPCSubscriber.Path_MoveTo([PathAction.Position], false);
}
else
VNavmesh_IPCSubscriber.SimpleMove_PathfindAndMoveTo(PathAction.Position, false);
Stage = Stage.Moving;
Expand Down Expand Up @@ -1196,7 +1212,14 @@ internal void SetRotationPluginSettings(bool on, bool ignoreConfig = false)
if (on)
if (!Wrath_IPCSubscriber.IsCurrentJobAutoRotationReady())
if (this.Configuration.Wrath_AutoSetupJobs)
{
Wrath_IPCSubscriber.SetJobAutoReady();
if (!Wrath_IPCSubscriber.IsCurrentJobAutoRotationReady())
{
Wrath_IPCSubscriber.Release();
wrathRotationReady = false;
}
}
else
wrathRotationReady = false;

Expand Down
6 changes: 6 additions & 0 deletions AutoDuty/Helpers/MovementHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace AutoDuty.Helpers
{
using ECommons.Automation;
using Lumina.Excel.Sheets;

internal static class MovementHelper
Expand Down Expand Up @@ -73,7 +74,11 @@ internal unsafe static bool Move(Vector3 position, float tollerance = 0.25f, flo
if (!useMesh)
{
if (!VNavmesh_IPCSubscriber.Path_IsRunning())
{
Chat.Instance.ExecuteCommand("/automove off");
VNavmesh_IPCSubscriber.Path_MoveTo([position], fly);
}

return false;
}

Expand All @@ -82,6 +87,7 @@ internal unsafe static bool Move(Vector3 position, float tollerance = 0.25f, flo

if (!VNavmesh_IPCSubscriber.SimpleMove_PathfindInProgress() || VNavmesh_IPCSubscriber.Path_NumWaypoints() == 0)
{
Chat.Instance.ExecuteCommand("/automove off");
VNavmesh_IPCSubscriber.Path_SetTolerance(tollerance);
VNavmesh_IPCSubscriber.SimpleMove_PathfindAndMoveTo(position, fly);
}
Expand Down
20 changes: 10 additions & 10 deletions AutoDuty/IPC/IPCSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,17 @@ internal static class VNavmesh_IPCSubscriber

internal static bool IsEnabled => IPCSubscriber_Common.IsReady("vnavmesh");

[EzIPC("Nav.IsReady", true)] internal static readonly Func<bool> Nav_IsReady;
[EzIPC("Nav.BuildProgress", true)] internal static readonly Func<float> Nav_BuildProgress;
[EzIPC("Nav.Reload", true)] internal static readonly Action Nav_Reload;
[EzIPC("Nav.Rebuild", true)] internal static readonly Action Nav_Rebuild;
[EzIPC("Nav.Pathfind", true)] internal static readonly Func<Vector3, Vector3, bool, Task<List<Vector3>>> Nav_Pathfind;
[EzIPC("Nav.IsReady", true)] internal static readonly Func<bool> Nav_IsReady;
[EzIPC("Nav.BuildProgress", true)] internal static readonly Func<float> Nav_BuildProgress;
[EzIPC("Nav.Reload", true)] internal static readonly Func<bool> Nav_Reload;
[EzIPC("Nav.Rebuild", true)] internal static readonly Func<bool> Nav_Rebuild;
[EzIPC("Nav.Pathfind", true)] internal static readonly Func<Vector3, Vector3, bool, Task<List<Vector3>>> Nav_Pathfind;
[EzIPC("Nav.PathfindCancelable", true)] internal static readonly Func<Vector3, Vector3, bool, CancellationToken, Task<List<Vector3>>> Nav_PathfindCancelable;
[EzIPC("Nav.PathfindCancelAll", true)] internal static readonly Action Nav_PathfindCancelAll;
[EzIPC("Nav.PathfindInProgress", true)] internal static readonly Func<bool> Nav_PathfindInProgress;
[EzIPC("Nav.PathfindNumQueued", true)] internal static readonly Func<int> Nav_PathfindNumQueued;
[EzIPC("Nav.IsAutoLoad", true)] internal static readonly Func<bool> Nav_IsAutoLoad;
[EzIPC("Nav.SetAutoLoad", true)] internal static readonly Action<bool> Nav_SetAutoLoad;
[EzIPC("Nav.PathfindCancelAll", true)] internal static readonly Action Nav_PathfindCancelAll;
[EzIPC("Nav.PathfindInProgress", true)] internal static readonly Func<bool> Nav_PathfindInProgress;
[EzIPC("Nav.PathfindNumQueued", true)] internal static readonly Func<int> Nav_PathfindNumQueued;
[EzIPC("Nav.IsAutoLoad", true)] internal static readonly Func<bool> Nav_IsAutoLoad;
[EzIPC("Nav.SetAutoLoad", true)] internal static readonly Action<bool> Nav_SetAutoLoad;

[EzIPC("Query.Mesh.NearestPoint", true)] internal static readonly Func<Vector3, float, float, Vector3> Query_Mesh_NearestPoint;
[EzIPC("Query.Mesh.PointOnFloor", true)] internal static readonly Func<Vector3, bool, float, Vector3> Query_Mesh_PointOnFloor;
Expand Down
28 changes: 19 additions & 9 deletions AutoDuty/Windows/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ public bool AutoManageBossModAISettings
HideBossModAIConfig = !value;
}
}
public bool AutoManageVnavAlignCamera = true;
public bool LootTreasure = true;
public LootMethod LootMethodEnum = LootMethod.AutoDuty;
public bool LootBossTreasureOnly = false;
public int TreasureCofferScanDistance = 25;
public bool OverridePartyValidation = false;
public bool UsingAlternativeRotationPlugin = false;
public bool UsingAlternativeMovementPlugin = false;
public bool UsingAlternativeBossPlugin = false;
public bool AutoManageVnavAlignCamera = true;
public bool LootTreasure = true;
public LootMethod LootMethodEnum = LootMethod.AutoDuty;
public bool LootBossTreasureOnly = false;
public int TreasureCofferScanDistance = 25;
public bool RebuildNavmeshOnFirstEntry = true;
public bool OverridePartyValidation = false;
public bool UsingAlternativeRotationPlugin = false;
public bool UsingAlternativeMovementPlugin = false;
public bool UsingAlternativeBossPlugin = false;

//PreLoop Config Options
public bool EnablePreLoopActions = true;
Expand Down Expand Up @@ -748,6 +749,15 @@ public static void Draw()
}
ImGuiComponents.HelpMarker("AutoDuty will ignore all non-boss chests, and only loot boss chests. (Only works with AD Looting)");

if (ImGui.Checkbox("Rebuild Navmesh on first dungeon load this session", ref Configuration.RebuildNavmeshOnFirstEntry))
Configuration.Save();
if (Configuration.RebuildNavmeshOnFirstEntry && Plugin.loadedDungeonsForRebuild.Count > 0)
{
ImGui.SameLine();
if (ImGui.Button("Clear cache of already visited dungeons"))
Plugin.loadedDungeonsForRebuild.Clear();
}

if (ImGui.Checkbox("Override Party Validation", ref Configuration.OverridePartyValidation))
Configuration.Save();
ImGuiComponents.HelpMarker("AutoDuty will ignore your party makeup when queueing for duties\nThis is for Multi-Boxing Only\n*AutoDuty is not recommended to be used with other players*");
Expand Down

0 comments on commit 7ca3453

Please sign in to comment.