From 129fc6d371b9bc6d75c5a892b41d693557fad9de Mon Sep 17 00:00:00 2001 From: Simon Latusek Date: Sun, 27 Apr 2025 04:05:46 +0200 Subject: [PATCH] adjusted AutoRetainer and GC turnin stop procedures --- AutoDuty/AutoDuty.cs | 2 +- AutoDuty/Helpers/AMHelper.cs | 114 ------------------------- AutoDuty/Helpers/AutoRetainerHelper.cs | 9 +- AutoDuty/Helpers/GCTurninHelper.cs | 8 +- AutoDuty/Windows/Config.cs | 4 +- 5 files changed, 15 insertions(+), 122 deletions(-) delete mode 100644 AutoDuty/Helpers/AMHelper.cs diff --git a/AutoDuty/AutoDuty.cs b/AutoDuty/AutoDuty.cs index 7cf0de7f..9b949a08 100644 --- a/AutoDuty/AutoDuty.cs +++ b/AutoDuty/AutoDuty.cs @@ -1434,7 +1434,7 @@ private void GetJobAndLevelingCheck() private void CheckRetainerWindow() { - if (AutoRetainerHelper.State == ActionState.Running || AMHelper.State == ActionState.Running || AutoRetainer_IPCSubscriber.IsBusy() || AM_IPCSubscriber.IsRunning() || Stage == Stage.Paused) + if (AutoRetainerHelper.State == ActionState.Running || AutoRetainer_IPCSubscriber.IsBusy() || AM_IPCSubscriber.IsRunning() || Stage == Stage.Paused) return; if (Svc.Condition[ConditionFlag.OccupiedSummoningBell]) diff --git a/AutoDuty/Helpers/AMHelper.cs b/AutoDuty/Helpers/AMHelper.cs deleted file mode 100644 index b923fda4..00000000 --- a/AutoDuty/Helpers/AMHelper.cs +++ /dev/null @@ -1,114 +0,0 @@ -using AutoDuty.IPC; -using Dalamud.Game.ClientState.Conditions; -using Dalamud.Game.ClientState.Objects.Types; -using Dalamud.Plugin.Services; -using ECommons; -using ECommons.DalamudServices; -using ECommons.Throttlers; -using FFXIVClientStructs.FFXIV.Component.GUI; -using System.Linq; - -namespace AutoDuty.Helpers -{ - internal class AMHelper : ActiveHelperBase - { - protected override string Name { get; } = nameof(AMHelper); - protected override string DisplayName { get; } = "AM"; - protected override int TimeOut { get; set; } = 600_000; - protected override string[] AddonsToClose { get; } = - ["SelectYesno", "SelectString", "Talk", "RetainerList", "RetainerSellList", "RetainerSell", "ItemSearchResult"]; - - internal override void Start() - { - if (!AM_IPCSubscriber.IsEnabled) - { - Svc.Log.Info("AM requires a plugin, visit https://discord.gg/JzSxThjKnd for more info"); - Svc.Log.Info("DO NOT ask in Puni.sh discord about this option"); - } - else if (State != ActionState.Running) - { - base.Start(); - } - } - - internal override void Stop() - { - base.Stop(); - - _aMStarted = false; - if (AM_IPCSubscriber.IsRunning()) - AM_IPCSubscriber.Stop(); - } - private static bool _aMStarted = false; - private static IGameObject? SummoningBellGameObject => Svc.Objects.FirstOrDefault(x => x.DataId == SummoningBellHelper.SummoningBellDataIds((uint)Plugin.Configuration.PreferredSummoningBellEnum)); - - protected override unsafe void HelperStopUpdate(IFramework framework) - { - if (!Svc.Condition[ConditionFlag.OccupiedSummoningBell]) - { - base.HelperStopUpdate(framework); - } - else if (Svc.Targets.Target != null) - Svc.Targets.Target = null; - else - this.CloseAddons(); - } - - protected override unsafe void HelperUpdate(IFramework framework) - { - if (Plugin.States.HasFlag(PluginState.Paused)) - return; - - if (Plugin.States.HasFlag(PluginState.Navigating)) - { - Svc.Log.Debug("AutoDuty is Started, Stopping AMHelper"); - Stop(); - } - if (!_aMStarted && AM_IPCSubscriber.IsRunning()) - { - Svc.Log.Info("AM has Started"); - _aMStarted = true; - return; - } - else if (_aMStarted && !AM_IPCSubscriber.IsRunning()) - { - Svc.Log.Debug("AM is Complete"); - Stop(); - return; - } - - if (!EzThrottler.Throttle("AM", 250)) - return; - - if (!PlayerHelper.IsValid) return; - - if (GotoHelper.State == ActionState.Running) - { - Svc.Log.Debug("Goto Running"); - return; - } - Plugin.Action = "AM Running"; - - if (SummoningBellGameObject != null && !SummoningBellHelper.HousingZones.Contains(Player.Territory) && ObjectHelper.GetDistanceToPlayer(SummoningBellGameObject) > 4) - { - Svc.Log.Debug("Moving Closer to Summoning Bell"); - MovementHelper.Move(SummoningBellGameObject, 0.25f, 4); - } - else if ((SummoningBellGameObject == null || SummoningBellHelper.HousingZones.Contains(Player.Territory)) && GotoHelper.State != ActionState.Running) - { - Svc.Log.Debug("Moving to Summoning Bell Location"); - SummoningBellHelper.Invoke(Plugin.Configuration.PreferredSummoningBellEnum); - } - else if (SummoningBellGameObject != null && ObjectHelper.GetDistanceToPlayer(SummoningBellGameObject) <= 4 && !_aMStarted && !GenericHelpers.TryGetAddonByName("RetainerList", out AtkUnitBase* addonRetainerList) && (ObjectHelper.InteractWithObjectUntilAddon(SummoningBellGameObject, "RetainerList") == null)) - { - if (Svc.Condition[ConditionFlag.OccupiedSummoningBell]) - { - Svc.Log.Debug("Starting AM"); - AM_IPCSubscriber.Start(); - } - else - Svc.Log.Debug("Interacting with SummoningBell"); - } - } - } -} diff --git a/AutoDuty/Helpers/AutoRetainerHelper.cs b/AutoDuty/Helpers/AutoRetainerHelper.cs index b9d6d483..61bb8518 100644 --- a/AutoDuty/Helpers/AutoRetainerHelper.cs +++ b/AutoDuty/Helpers/AutoRetainerHelper.cs @@ -50,12 +50,17 @@ internal override void Stop() protected override unsafe void HelperStopUpdate(IFramework framework) { if (!Svc.Condition[ConditionFlag.OccupiedSummoningBell]) + { base.HelperStopUpdate(framework); - else if (Svc.Targets.Target != null) - Svc.Targets.Target = null; + } else + { + if (Svc.Targets.Target != null) + Svc.Targets.Target = null; this.CloseAddons(); + } } + protected override unsafe void HelperUpdate(IFramework framework) { diff --git a/AutoDuty/Helpers/GCTurninHelper.cs b/AutoDuty/Helpers/GCTurninHelper.cs index cb878d70..ce568cb7 100644 --- a/AutoDuty/Helpers/GCTurninHelper.cs +++ b/AutoDuty/Helpers/GCTurninHelper.cs @@ -45,11 +45,15 @@ internal override void Stop() protected override unsafe void HelperStopUpdate(IFramework framework) { if (!Svc.Condition[Dalamud.Game.ClientState.Conditions.ConditionFlag.OccupiedInQuestEvent]) + { base.HelperStopUpdate(framework); - else if (Svc.Targets.Target != null) - Svc.Targets.Target = null; + } else + { + if (Svc.Targets.Target != null) + Svc.Targets.Target = null; this.CloseAddons(); + } } protected override unsafe void HelperUpdate(IFramework framework) diff --git a/AutoDuty/Windows/Config.cs b/AutoDuty/Windows/Config.cs index 479ec76f..6d0d41a5 100644 --- a/AutoDuty/Windows/Config.cs +++ b/AutoDuty/Windows/Config.cs @@ -21,8 +21,6 @@ namespace AutoDuty.Windows; -using System.Numerics; -using System.Text.Json.Serialization; using Dalamud.Utility.Numerics; using Data; using ECommons.ExcelServices; @@ -33,7 +31,7 @@ namespace AutoDuty.Windows; using ECommons.UIHelpers.AtkReaderImplementations; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using FFXIVClientStructs.FFXIV.Component.GUI; -using ImPlotNET; +using ReflectionHelper = Helpers.ReflectionHelper; [Serializable] public class Configuration : IPluginConfiguration