From 73e9bd04e7369e435e740d54ba395589a8f1fd76 Mon Sep 17 00:00:00 2001 From: Det Date: Fri, 29 Jul 2022 22:27:38 -0300 Subject: [PATCH] AutoHook 2.2.2.0 [PUSH] - Added an option to not cancel current mooch when using Auto Casts - Fixed an issue with "Stop Fishing After" --- AutoHook/AutoHook.csproj | 2 +- AutoHook/AutoHook.json | 2 +- AutoHook/Configurations/AutoCastsConfig.cs | 11 ++++++++++ AutoHook/HookManager.cs | 25 ++++++++++++++++------ AutoHook/SeFunctions/SeFunctionBase.cs | 2 +- AutoHook/Ui/AutoCastsTab.cs | 11 +++++++++- 6 files changed, 43 insertions(+), 10 deletions(-) diff --git a/AutoHook/AutoHook.csproj b/AutoHook/AutoHook.csproj index c98b61f..c1d085d 100644 --- a/AutoHook/AutoHook.csproj +++ b/AutoHook/AutoHook.csproj @@ -2,7 +2,7 @@ Det - 2.2.1.1 + 2.2.2.0 Auto hooks for you https://github.com/InitialDet/AutoHook Release;Debug diff --git a/AutoHook/AutoHook.json b/AutoHook/AutoHook.json index 3cf4ec5..43de065 100644 --- a/AutoHook/AutoHook.json +++ b/AutoHook/AutoHook.json @@ -9,5 +9,5 @@ "Tags": ["Gathering","Fishing"], "DalamudApiLevel": 6, "IconUrl": "https://raw.githubusercontent.com/InitialDet/AutoHook/main/AutoHook/images/icon.png", - "Changelog": "*NEW*\n- Added an option to stop fishing when X amount of fish is caught" + "Changelog": "- Added an option to not cancel current mooch when using Auto Casts\n- Fixed an issue with \"Stop Fishing After\"" } \ No newline at end of file diff --git a/AutoHook/Configurations/AutoCastsConfig.cs b/AutoHook/Configurations/AutoCastsConfig.cs index 9aa7979..cff0fb0 100644 --- a/AutoHook/Configurations/AutoCastsConfig.cs +++ b/AutoHook/Configurations/AutoCastsConfig.cs @@ -13,6 +13,8 @@ public class AutoCastsConfig public bool EnableMooch = false; public bool EnableMooch2 = false; + public bool DontCancelMooch = true; + public bool EnablePatience = false; public bool EnableMakeshiftPatience = false; public uint SelectedPatienceID = IDs.Actions.Patience2; // Default to Patience2 @@ -194,6 +196,9 @@ private bool UsePrizeCatch() if (!EnablePrizeCatch) return false; + if (IsMoochAvailable() && DontCancelMooch) + return false; + if (PlayerResources.HasStatus(IDs.Status.MakeshiftBait)) return false; @@ -208,11 +213,17 @@ private bool UsePrizeCatch() private bool UsesFishEyes() { + if (IsMoochAvailable() && DontCancelMooch) + return false; + return EnableFishEyes && PlayerResources.ActionAvailable(IDs.Actions.FishEyes); } private bool UsesChum() { + if (IsMoochAvailable() && DontCancelMooch) + return false; + return EnableChum && PlayerResources.ActionAvailable(IDs.Actions.Chum); } diff --git a/AutoHook/HookManager.cs b/AutoHook/HookManager.cs index 71b7b2d..2558641 100644 --- a/AutoHook/HookManager.cs +++ b/AutoHook/HookManager.cs @@ -13,7 +13,6 @@ namespace AutoHook.FishTimer; -// all credits to Otter (goat discord) for his gatherbuddy plugin public class HookingManager : IDisposable { private HookConfig? CurrentSetting; @@ -136,22 +135,37 @@ private void OnCatch(string fishName, uint fishId) CurrentBait = GetCurrentBait(); LastStep = CatchSteps.FishCaught; + - // Check if should stop + // Check if should stop with the current bait/mooch if (CurrentSetting != null && CurrentSetting.StopAfterCaught) { int total = FishCounter.Add(CurrentSetting.BaitName); - PluginLog.Debug($"{CurrentSetting.BaitName} caught. Total: {total} out of {CurrentSetting.StopAfterCaught}"); + PluginLog.Debug($"{CurrentSetting.BaitName} caught. Total: {total} out of {CurrentSetting.StopAfterCaughtLimit}"); if (total >= CurrentSetting.StopAfterCaughtLimit) { LastStep = CatchSteps.Quitting; } } + + // Check if should stop with another bait/mooch + HookConfig? CustomMoochCfg = HookSettings.FirstOrDefault(mooch => mooch.BaitName.Equals(LastCatch)); + if (CustomMoochCfg != null && CustomMoochCfg.StopAfterCaught) + { + int total = FishCounter.Add(CustomMoochCfg.BaitName); + + PluginLog.Debug($"{CustomMoochCfg.BaitName} caught. Total: {total} out of {CustomMoochCfg.StopAfterCaughtLimit}"); + + if (total >= CustomMoochCfg.StopAfterCaughtLimit) + { + LastStep = CatchSteps.Quitting; + } + } } private void OnFishingStop() { - + LastStep = CatchSteps.None; if (Timer.IsRunning) { Timer.Stop(); @@ -289,8 +303,7 @@ private void CheckState() if (Timerrr.ElapsedMilliseconds > debugValueLast + 500) { debugValueLast = Timerrr.ElapsedMilliseconds; - //PluginLog.Debug($"Fishing State: {Service.EventFramework.FishingState}, LastStep: {LastStep}"); - //PluginLog.Debug($"{PlayerResources.HaveItemInInventory(IDs.Item.Cordial)}"); + PluginLog.Debug($"Fishing State: {Service.EventFramework.FishingState}, LastStep: {LastStep}"); } } diff --git a/AutoHook/SeFunctions/SeFunctionBase.cs b/AutoHook/SeFunctions/SeFunctionBase.cs index 8332e7b..92a9fc7 100644 --- a/AutoHook/SeFunctions/SeFunctionBase.cs +++ b/AutoHook/SeFunctions/SeFunctionBase.cs @@ -60,7 +60,7 @@ public SeFunctionBase(SigScanner sigScanner, string signature, int offset = 0) { if (Address != IntPtr.Zero) { - var hook = new Hook(Address, detour); + var hook = Hook.FromAddress(Address, detour); hook.Enable(); return hook; } diff --git a/AutoHook/Ui/AutoCastsTab.cs b/AutoHook/Ui/AutoCastsTab.cs index 52dc184..c83b058 100644 --- a/AutoHook/Ui/AutoCastsTab.cs +++ b/AutoHook/Ui/AutoCastsTab.cs @@ -19,6 +19,15 @@ public override void DrawHeader() // Disable all casts if (DrawUtil.Checkbox("Enable Auto Casts", ref cfg.EnableAll, "You can uncheck this to not use any actions below")) { } + + + if (cfg.EnableAll) { + ImGui.SameLine(); + if (DrawUtil.Checkbox("Don't Cancel Mooch", ref cfg.DontCancelMooch, "If mooch is available, actions that cancel mooch wont be used (e.g. Chum, Fish Eyes, Prize Catch etc.)")) + { } + } + + } public override void Draw() @@ -161,7 +170,7 @@ private void DrawExtraOptionsMakeShiftBait() private void DrawPrizeCatch() { - if (DrawUtil.Checkbox("Use Prize Catch", ref cfg.EnablePrizeCatch, "Patience and Makeshift Bait will not be used when Prize Catch active")) + if (DrawUtil.Checkbox("Use Prize Catch", ref cfg.EnablePrizeCatch, "Cancels Current Mooch. Patience and Makeshift Bait will not be used when Prize Catch active")) { } }