From cdb94c3c75d711aa551f1729594620edd946e004 Mon Sep 17 00:00:00 2001 From: Det Date: Wed, 6 Dec 2023 00:24:50 -0300 Subject: [PATCH] AutoHook 3.0.1.0 [PUSH] Fixes and changes #140, #138, #137, #136, #132, #127, #121 --- AutoHook/AutoHook.cs | 9 +- AutoHook/AutoHook.csproj | 2 +- AutoHook/Classes/AutoCasts/AutoCastLine.cs | 2 +- AutoHook/Classes/AutoCasts/AutoCordial.cs | 6 +- AutoHook/Classes/AutoCasts/AutoMooch.cs | 4 +- AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs | 2 +- AutoHook/Classes/AutoCasts/AutoReleaseFish.cs | 20 + AutoHook/Classes/BaseActionCast.cs | 8 +- AutoHook/Configurations/AutoCastsConfig.cs | 6 +- AutoHook/Configurations/Configuration.cs | 4 +- AutoHook/Configurations/ExtraConfig.cs | 20 + AutoHook/Configurations/FishConfig.cs | 18 +- AutoHook/Configurations/HookConfig.cs | 22 +- AutoHook/Configurations/PresetConfig.cs | 2 + AutoHook/Data/IDs.cs | 1 + .../Enums/{CatchSteps.cs => FishingSteps.cs} | 7 +- AutoHook/Enums/IntuitionStatus.cs | 9 + AutoHook/HookManager.cs | 468 ++++++++++++------ AutoHook/PluginUI.cs | 26 +- .../Localization/UIStrings.Designer.cs | 126 +++++ .../Resources/Localization/UIStrings.de.resx | 177 ++++++- .../Resources/Localization/UIStrings.es.resx | 173 ++++++- .../Resources/Localization/UIStrings.fr.resx | 178 ++++++- .../Resources/Localization/UIStrings.ko.resx | 180 ++++++- .../Resources/Localization/UIStrings.resx | 42 ++ .../Resources/Localization/UIStrings.zh.resx | 174 ++++++- AutoHook/SeFunctions/CurrentBait.cs | 26 +- AutoHook/Service.cs | 5 +- AutoHook/Ui/SubTabAutoCast.cs | 1 + AutoHook/Ui/SubTabBaitMooch.cs | 10 +- AutoHook/Ui/SubTabExtra.cs | 143 ++++++ AutoHook/Ui/SubTabFish.cs | 55 +- AutoHook/Ui/TabConfigGuides.cs | 81 ++- AutoHook/Ui/TabCustomPresets.cs | 9 +- AutoHook/Ui/TabDefaultPreset.cs | 8 + AutoHook/Utils/DrawUtil.cs | 25 +- AutoHook/Utils/PlayerResources.cs | 29 +- 37 files changed, 1780 insertions(+), 298 deletions(-) create mode 100644 AutoHook/Classes/AutoCasts/AutoReleaseFish.cs create mode 100644 AutoHook/Configurations/ExtraConfig.cs rename AutoHook/Enums/{CatchSteps.cs => FishingSteps.cs} (80%) create mode 100644 AutoHook/Enums/IntuitionStatus.cs create mode 100644 AutoHook/Ui/SubTabExtra.cs diff --git a/AutoHook/AutoHook.cs b/AutoHook/AutoHook.cs index 138eee2..942775d 100644 --- a/AutoHook/AutoHook.cs +++ b/AutoHook/AutoHook.cs @@ -19,7 +19,7 @@ public class AutoHook : IDalamudPlugin public string Name => UIStrings.AutoHook; private const string CmdAhCfg = "/ahcfg"; - private const string CmdAh = "/ah"; + private const string CmdAh = "/autohook"; private const string CmdAhOn = "/ahon"; private const string CmdAhOff = "/ahoff"; private const string CmdAhtg = "/ahtg"; @@ -63,6 +63,11 @@ public AutoHook(DalamudPluginInterface pluginInterface) { HelpMessage = UIStrings.Opens_Config_Window }); + + Service.Commands.AddHandler(CmdAh, new CommandInfo(OnCommand) + { + HelpMessage = UIStrings.Opens_Config_Window + }); /*Service.Commands.AddHandler(CmdAh, new CommandInfo(OnCommand) { @@ -117,8 +122,8 @@ public void Dispose() Service.Save(); Service.PluginInterface.UiBuilder.Draw -= Service.WindowSystem.Draw; Service.PluginInterface.UiBuilder.OpenConfigUi -= OnOpenConfigUi; + Service.Commands.RemoveHandler(CmdAh); Service.Commands.RemoveHandler(CmdAhCfg); - //Service.Commands.RemoveHandler(CmdAh); Service.Commands.RemoveHandler(CmdAhOn); Service.Commands.RemoveHandler(CmdAhOff); Service.Commands.RemoveHandler(CmdAhtg); diff --git a/AutoHook/AutoHook.csproj b/AutoHook/AutoHook.csproj index 62cd453..20d1693 100644 --- a/AutoHook/AutoHook.csproj +++ b/AutoHook/AutoHook.csproj @@ -2,7 +2,7 @@ Det - 3.0.0.7 + 3.0.1.0 Auto hooks for you https://github.com/InitialDet/AutoHook Release;Debug diff --git a/AutoHook/Classes/AutoCasts/AutoCastLine.cs b/AutoHook/Classes/AutoCasts/AutoCastLine.cs index 17ade37..41c2059 100644 --- a/AutoHook/Classes/AutoCasts/AutoCastLine.cs +++ b/AutoHook/Classes/AutoCasts/AutoCastLine.cs @@ -6,7 +6,7 @@ public class AutoCastLine : BaseActionCast { public AutoCastLine() : base(UIStrings.AutoCastLine_Auto_Cast_Line, Data.IDs.Actions.Cast) { - GpThreshold = 1; + } public override bool CastCondition() diff --git a/AutoHook/Classes/AutoCasts/AutoCordial.cs b/AutoHook/Classes/AutoCasts/AutoCordial.cs index e82b49f..afa38fd 100644 --- a/AutoHook/Classes/AutoCasts/AutoCordial.cs +++ b/AutoHook/Classes/AutoCasts/AutoCordial.cs @@ -36,7 +36,7 @@ public class AutoCordial : BaseActionCast public AutoCordial() : base(UIStrings.Cordial, IDs.Item.Cordial, ActionType.Item) { - GpThreshold = 1; + } public override string GetName() @@ -65,8 +65,8 @@ public override bool CastCondition() public override void SetThreshold(int newCost) { - if (newCost <= 1) - GpThreshold = 1; + if (newCost <= 0) + GpThreshold = 0; else GpThreshold = newCost; } diff --git a/AutoHook/Classes/AutoCasts/AutoMooch.cs b/AutoHook/Classes/AutoCasts/AutoMooch.cs index 5822cd5..5ecb6aa 100644 --- a/AutoHook/Classes/AutoCasts/AutoMooch.cs +++ b/AutoHook/Classes/AutoCasts/AutoMooch.cs @@ -21,7 +21,7 @@ public override string GetName() public override bool CastCondition() { - if (OnlyMoochIntuition && !PlayerResources.HasStatus(IDs.Status.IdenticalCast)) + if (OnlyMoochIntuition && !PlayerResources.HasStatus(IDs.Status.FishersIntuition)) return false; if (Mooch2.IsAvailableToCast()) @@ -38,7 +38,7 @@ public override bool CastCondition() return true; } - return true; + return false; } protected override DrawOptionsDelegate DrawOptions => () => diff --git a/AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs b/AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs index 2a9e173..d621b14 100644 --- a/AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs +++ b/AutoHook/Classes/AutoCasts/AutoPrizeCatch.cs @@ -25,7 +25,7 @@ public override bool CastCondition() if (!Enabled) return false; - if (UseWhenMoochIIOnCD && PlayerResources.ActionTypeAvailable(IDs.Actions.Mooch2)) + if (UseWhenMoochIIOnCD && !PlayerResources.ActionOnCoolDown(IDs.Actions.Mooch2)) return false; if (UseOnlyWithIdenticalCast && !PlayerResources.HasStatus(IDs.Status.IdenticalCast)) diff --git a/AutoHook/Classes/AutoCasts/AutoReleaseFish.cs b/AutoHook/Classes/AutoCasts/AutoReleaseFish.cs new file mode 100644 index 0000000..dc884e5 --- /dev/null +++ b/AutoHook/Classes/AutoCasts/AutoReleaseFish.cs @@ -0,0 +1,20 @@ +using AutoHook.Resources.Localization; + +namespace AutoHook.Classes.AutoCasts; + +public class AutoReleaseFish : BaseActionCast +{ + public AutoReleaseFish() : base(UIStrings.ReleaseAllFish, Data.IDs.Actions.Release) + { + HelpText = UIStrings.ReleaseAllFishHelpText; + DoesCancelMooch = false; + } + + public override bool CastCondition() + { + return true; + } + + public override string GetName() + => Name = UIStrings.ReleaseAllFish; +} \ No newline at end of file diff --git a/AutoHook/Classes/BaseActionCast.cs b/AutoHook/Classes/BaseActionCast.cs index 8020c24..c1f7534 100644 --- a/AutoHook/Classes/BaseActionCast.cs +++ b/AutoHook/Classes/BaseActionCast.cs @@ -29,11 +29,11 @@ protected BaseActionCast(string name, uint id, ActionType actionType = ActionTyp public uint Id { get; set; } - public int GpThreshold = 1; + public int GpThreshold = 0; public bool GpThresholdAbove { get; set; } = true; - public bool DoesCancelMooch { get; init; } + public bool DoesCancelMooch { get; set; } public bool DontCancelMooch = true; @@ -45,7 +45,7 @@ public virtual void SetThreshold(int newCost) { var actionCost = (int) PlayerResources.CastActionCost(Id, ActionType); - GpThreshold = (newCost < 1) ? 1 : Math.Max(newCost, actionCost); + GpThreshold = (newCost < 0) ? 0 : Math.Max(newCost, actionCost); Service.Save(); } @@ -159,7 +159,7 @@ public virtual void DrawGpThreshold() ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale); if (ImGui.InputInt(UIStrings.GP, ref GpThreshold, 1, 1)) { - GpThreshold = Math.Max(GpThreshold, 1); + GpThreshold = Math.Max(GpThreshold, 0); SetThreshold(GpThreshold); Service.Save(); } diff --git a/AutoHook/Configurations/AutoCastsConfig.cs b/AutoHook/Configurations/AutoCastsConfig.cs index 3e2fe29..23dc2f7 100644 --- a/AutoHook/Configurations/AutoCastsConfig.cs +++ b/AutoHook/Configurations/AutoCastsConfig.cs @@ -22,14 +22,16 @@ public class AutoCastsConfig //public AutoSurfaceSlap CastSurfaceSlap = new(); public AutoThaliaksFavor CastThaliaksFavor = new(); + //public AutoReleaseFish CastReleaseFish = new(); + public List GetAutoActions() - { + { return new List { CastThaliaksFavor, - CastMakeShiftBait, CastCordial, CastPatience, + CastMakeShiftBait, CastChum, CastFishEyes, CastPrizeCatch, diff --git a/AutoHook/Configurations/Configuration.cs b/AutoHook/Configurations/Configuration.cs index 76bfd3d..d8cffd2 100644 --- a/AutoHook/Configurations/Configuration.cs +++ b/AutoHook/Configurations/Configuration.cs @@ -40,8 +40,10 @@ public class Configuration : IPluginConfiguration public bool ShowChatLogs = true; public int DelayBetweenCastsMin = 600; - public int DelayBetweenCastsMax = 1000; + + public int DelayBetweenHookMin = 0; + public int DelayBetweenHookMax = 0; public bool ShowStatusHeader = true; diff --git a/AutoHook/Configurations/ExtraConfig.cs b/AutoHook/Configurations/ExtraConfig.cs new file mode 100644 index 0000000..8666ead --- /dev/null +++ b/AutoHook/Configurations/ExtraConfig.cs @@ -0,0 +1,20 @@ +using AutoHook.Classes; + +namespace AutoHook.Configurations; + +public class ExtraConfig +{ + public bool Enabled = false; + + public bool SwapBaitIntuitionGain = false; + public BaitFishClass BaitToSwapIntuitionGain = new(); + + public bool SwapBaitIntuitionLost = false; + public BaitFishClass BaitToSwapIntuitionLost = new(); + + public bool SwapPresetIntuitionGain = false; + public string PresetToSwapIntuitionGain = "-"; + + public bool SwapPresetIntuitionLost = false; + public string PresetToSwapIntuitionLost = "-"; +} \ No newline at end of file diff --git a/AutoHook/Configurations/FishConfig.cs b/AutoHook/Configurations/FishConfig.cs index 07e68d2..3b78a77 100644 --- a/AutoHook/Configurations/FishConfig.cs +++ b/AutoHook/Configurations/FishConfig.cs @@ -1,4 +1,5 @@ -using AutoHook.Classes; +using System; +using AutoHook.Classes; using AutoHook.Classes.AutoCasts; using AutoHook.Enums; using AutoHook.Resources.Localization; @@ -7,6 +8,7 @@ namespace AutoHook.Configurations; public class FishConfig { + private Guid _uniqueId; public bool Enabled = true; public BaitFishClass Fish; @@ -28,12 +30,24 @@ public class FishConfig public bool NeverMooch = false; - public CatchSteps StopFishingStep = CatchSteps.None; + public bool NeverRelease = false; + + public FishingSteps StopFishingStep = FishingSteps.None; public FishConfig(BaitFishClass fish) { Fish = fish; // ok this is not the best way, but im tired and it works for now so be nice to me Mooch.Name = UIStrings.Always_Mooch; + + _uniqueId = Guid.NewGuid(); + } + + public Guid GetUniqueId() + { + if (_uniqueId == Guid.Empty) + _uniqueId = Guid.NewGuid(); + + return _uniqueId; } } \ No newline at end of file diff --git a/AutoHook/Configurations/HookConfig.cs b/AutoHook/Configurations/HookConfig.cs index 37faaa4..0bd4b2e 100644 --- a/AutoHook/Configurations/HookConfig.cs +++ b/AutoHook/Configurations/HookConfig.cs @@ -1,4 +1,5 @@ using System; +using System.Xml; using AutoHook.Classes; using AutoHook.Data; using AutoHook.Enums; @@ -10,8 +11,8 @@ public class HookConfig { public bool Enabled = true; - //public string BaitName = UIStrings.BaitName_Default; - + private Guid _uniqueId; + public BaitFishClass BaitFish = new(); public bool HookWeakEnabled = true; @@ -57,7 +58,7 @@ public class HookConfig public bool StopAfterCaught = false; public int StopAfterCaughtLimit = 1; - public CatchSteps StopFishingStep = CatchSteps.None; + public FishingSteps StopFishingStep = FishingSteps.None; /*public HookConfig(string bait) { @@ -67,6 +68,7 @@ public class HookConfig public HookConfig(BaitFishClass baitFish) { BaitFish = baitFish; + _uniqueId = Guid.NewGuid(); } public HookType? GetHook(BiteType bite) @@ -121,8 +123,7 @@ public bool CheckHookDHTHEnabled(BiteType bite) => bite == BiteType.Weak ? HookWeakDHTHEnabled : bite == BiteType.Strong ? HookStrongDHTHEnabled : bite == BiteType.Legendary ? HookLegendaryDHTHEnabled : false; - - + private HookType GetPatienceHook(BiteType bite) => bite switch { BiteType.Weak => HookTypeWeak, @@ -161,7 +162,16 @@ public bool CheckHookDHTHEnabled(BiteType bite) => return HookType.None; } - + + + public Guid GetUniqueId() + { + if (_uniqueId == Guid.Empty) + _uniqueId = Guid.NewGuid(); + + return _uniqueId; + } + public override bool Equals(object? obj) { return obj is HookConfig settings && diff --git a/AutoHook/Configurations/PresetConfig.cs b/AutoHook/Configurations/PresetConfig.cs index d49fbcc..d74f775 100644 --- a/AutoHook/Configurations/PresetConfig.cs +++ b/AutoHook/Configurations/PresetConfig.cs @@ -15,6 +15,8 @@ public class PresetConfig public List ListOfFish { get; set; } = new(); public AutoCastsConfig AutoCastsCfg = new(); + + public ExtraConfig ExtraCfg = new(); public PresetConfig(string presetName) { diff --git a/AutoHook/Data/IDs.cs b/AutoHook/Data/IDs.cs index 7726437..0d1b526 100644 --- a/AutoHook/Data/IDs.cs +++ b/AutoHook/Data/IDs.cs @@ -7,6 +7,7 @@ public static class Actions public const uint Cast = 289, Quit = 299, + Release = 300, Gig = 7632, NaturesBounty = 7909, Mooch = 297, diff --git a/AutoHook/Enums/CatchSteps.cs b/AutoHook/Enums/FishingSteps.cs similarity index 80% rename from AutoHook/Enums/CatchSteps.cs rename to AutoHook/Enums/FishingSteps.cs index 94c61bd..c7595ab 100644 --- a/AutoHook/Enums/CatchSteps.cs +++ b/AutoHook/Enums/FishingSteps.cs @@ -1,6 +1,9 @@ +using System; + namespace AutoHook.Enums; -public enum CatchSteps +[Flags] +public enum FishingSteps { None, BeganFishing, @@ -13,4 +16,4 @@ public enum CatchSteps FishReeled, TimeOut, Quitting -} +} \ No newline at end of file diff --git a/AutoHook/Enums/IntuitionStatus.cs b/AutoHook/Enums/IntuitionStatus.cs new file mode 100644 index 0000000..8c7d95b --- /dev/null +++ b/AutoHook/Enums/IntuitionStatus.cs @@ -0,0 +1,9 @@ +namespace AutoHook.Enums; + +public enum IntuitionStatus +{ + NotActive, + Gained, + Active, + Lost, +} \ No newline at end of file diff --git a/AutoHook/HookManager.cs b/AutoHook/HookManager.cs index de0a80d..9f14d1b 100644 --- a/AutoHook/HookManager.cs +++ b/AutoHook/HookManager.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Threading.Tasks; using AutoHook.Classes; +using AutoHook.Classes.AutoCasts; using AutoHook.Configurations; using AutoHook.Data; using AutoHook.Enums; @@ -31,13 +33,22 @@ public class HookingManager : IDisposable private readonly Stopwatch _timerState = new(); private Hook? _catchHook; - private Hook? _hookHook; private FishingState _lastState = FishingState.None; - private CatchSteps _lastStep = 0; + private FishingSteps _lastStep = 0; - //create a dictionary to receive a PresetConfig and HookConfig - private (HookConfig? hook, string presetName) _currentHook = new(); + private HookConfig? _currentHook; + + //private FishConfig? _lastFishCatchCfg; + private BaitFishClass? _lastCatch; + + private IntuitionStatus _intuitionStatus = IntuitionStatus.NotActive; + + private delegate bool UseActionDelegate(IntPtr manager, ActionType actionType, uint actionId, GameObjectID targetId, + uint a4, uint a5, + uint a6, IntPtr a7); + + private Hook? _useActionHook; public HookingManager() { @@ -45,7 +56,7 @@ public HookingManager() Enable(); } - public static BaitFishClass LastCatch { get; private set; } = new(@"-", -1); + //public static BaitFishClass LastCatch { get; private set; } = new(@"-", -1); public static string CurrentBaitMooch { get; private set; } = @"-"; @@ -54,27 +65,27 @@ public void Dispose() Disable(); _catchHook?.Dispose(); - _hookHook?.Dispose(); + _useActionHook?.Dispose(); } private unsafe void CreateDalamudHooks() { _catchHook = new UpdateFishCatch(Service.SigScanner).CreateHook(OnCatchUpdate); var hookPtr = (IntPtr)ActionManager.MemberFunctionPointers.UseAction; - _hookHook = Service.GameInteropProvider.HookFromAddress(hookPtr, OnUseAction); + _useActionHook = Service.GameInteropProvider.HookFromAddress(hookPtr, OnUseAction); } private void Enable() { Service.Framework.Update += OnFrameworkUpdate; _catchHook?.Enable(); - _hookHook?.Enable(); + _useActionHook?.Enable(); } private void Disable() { Service.Framework.Update -= OnFrameworkUpdate; - _hookHook?.Disable(); + _useActionHook?.Disable(); _catchHook?.Disable(); } @@ -91,32 +102,39 @@ private void UpdateCurrentPreset() ResetAfkTimer(); // check if SelectedPreset has hook for the current bait - var customHook = _lastStep == CatchSteps.BeganMooching + var customHook = _lastStep == FishingSteps.BeganMooching ? Presets.SelectedPreset?.GetMoochByName(CurrentBaitMooch) : Presets.SelectedPreset?.GetBaitByName(CurrentBaitMooch); - var defaultHook = _lastStep == CatchSteps.BeganMooching + var defaultHook = _lastStep == FishingSteps.BeganMooching ? Presets.DefaultPreset.ListOfMooch.FirstOrDefault() : Presets.DefaultPreset.ListOfBaits.FirstOrDefault(); - _currentHook.hook = customHook?.Enabled ?? false ? customHook + _currentHook = customHook?.Enabled ?? false ? customHook : defaultHook?.Enabled ?? false ? defaultHook : null; - _currentHook.presetName = customHook?.Enabled ?? false ? Presets.SelectedPreset?.PresetName ?? @"Custom" + var presetName = customHook?.Enabled ?? false ? Presets.SelectedPreset?.PresetName ?? @"Custom" : defaultHook?.Enabled ?? false ? Presets.DefaultPreset.PresetName : @""; - - Service.Status = _currentHook.hook == null + + var autoCastName = Presets.SelectedPreset?.AutoCastsCfg.EnableAll ?? false ? Presets.SelectedPreset.PresetName + : Presets.DefaultPreset?.AutoCastsCfg.EnableAll ?? false ? Presets.DefaultPreset.PresetName + : "-"; + + var extraCfg = Presets.SelectedPreset?.ExtraCfg.Enabled ?? false ? Presets.SelectedPreset.PresetName + : Presets.DefaultPreset?.ExtraCfg.Enabled ?? false ? Presets.DefaultPreset.PresetName + : "-"; + + Service.Status = _currentHook == null ? @"-" - : @$"Preset: {_currentHook.presetName} | Hook Config: {_currentHook.hook.BaitFish.Name}"; - - Service.PrintDebug(_currentHook.hook == null + : @$"Hook Config: {_currentHook.BaitFish.Name}({presetName}) | AutoCast: {autoCastName} | Extra: {extraCfg}"; + + Service.PrintDebug(_currentHook == null ? @$"[HookManager] No config found. Not hooking" - : @$"[HookManager] Config Found: {_currentHook.hook.BaitFish.Name}, Preset: {_currentHook.presetName}"); + : @$"[HookManager] Config Found: {_currentHook.BaitFish.Name}, Preset: {presetName}"); } - private AutoCastsConfig GetAutoCastCfg() { return Presets.SelectedPreset?.AutoCastsCfg.EnableAll ?? false @@ -124,15 +142,19 @@ private AutoCastsConfig GetAutoCastCfg() : Presets.DefaultPreset.AutoCastsCfg; } - private (FishConfig, string)? GetFishConfig() + private ExtraConfig GetExtraCfg() { - if (LastCatch == null) - return null; + return Presets.SelectedPreset?.ExtraCfg.Enabled ?? false + ? Presets.SelectedPreset.ExtraCfg + : Presets.DefaultPreset.ExtraCfg; + } - var fish = Presets.SelectedPreset?.GetFishAndPresetById(LastCatch.Id) ?? - Presets.DefaultPreset.GetFishAndPresetById(LastCatch.Id); + private FishConfig? GetLastCatchConfig() + { + if (_lastCatch == null) + return null; - return fish; + return Presets.SelectedPreset?.GetFishById(_lastCatch.Id) ?? Presets.DefaultPreset.GetFishById(_lastCatch.Id); } private void OnFrameworkUpdate(IFramework _) @@ -142,7 +164,7 @@ private void OnFrameworkUpdate(IFramework _) if (!Service.Configuration.PluginEnabled || currentState == FishingState.None) return; - if (currentState != FishingState.Quit && _lastStep == CatchSteps.Quitting) + if (currentState != FishingState.Quit && _lastStep == FishingSteps.Quitting) { if (PlayerResources.IsCastAvailable()) { @@ -153,7 +175,11 @@ private void OnFrameworkUpdate(IFramework _) //CheckState(); - if (_lastStep != CatchSteps.Quitting && currentState == FishingState.PoleReady) + if (_lastStep != FishingSteps.Quitting && currentState == FishingState.PoleReady && + _lastStep == FishingSteps.FishCaught) + CheckStopCondition(); + + if (_lastStep != FishingSteps.Quitting && currentState == FishingState.PoleReady) UseAutoCasts(); if (currentState == FishingState.Waiting2) @@ -161,17 +187,20 @@ private void OnFrameworkUpdate(IFramework _) if (_lastState == currentState) return; - + + if (currentState == FishingState.PoleReady) + Service.Status = "-"; + _lastState = currentState; switch (currentState) { case FishingState.PullPoleIn: // If a hook is manually used before a bite, dont use auto cast - if (_lastStep is CatchSteps.BeganFishing or CatchSteps.BeganMooching) - _lastStep = CatchSteps.None; + if (_lastStep is FishingSteps.BeganFishing or FishingSteps.BeganMooching) + _lastStep = FishingSteps.None; break; case FishingState.Bite: - if (_lastStep != CatchSteps.FishBit) OnBite(); + if (_lastStep != FishingSteps.FishBit) OnBite(); break; case FishingState.Quit: OnFishingStop(); @@ -182,7 +211,7 @@ private void OnFrameworkUpdate(IFramework _) private void UseAutoCasts() { // if _lastStep is FishBit but currentState is FishingState.PoleReady, it case means that the fish was hooked, but it escaped. - if (_lastStep is CatchSteps.None or CatchSteps.BeganFishing or CatchSteps.BeganMooching) + if (_lastStep is FishingSteps.None or FishingSteps.BeganFishing or FishingSteps.BeganMooching) return; if (!_recastTimer.IsRunning) @@ -197,61 +226,66 @@ private void UseAutoCasts() if (!PlayerResources.IsCastAvailable()) return; - var fishCfg = GetFishConfig(); + CheckExtraActions(); + var acCfg = GetAutoCastCfg(); - var cast = FishCaughtActions(fishCfg) ?? GetNextAutoCast(acCfg); + var cast = GetFishCaughActions() ?? GetNextAutoCast(acCfg); if (cast != null) PlayerResources.CastActionDelayed(cast.Id, cast.ActionType, cast.Name); else - CastLineOrMooch(fishCfg?.Item1, acCfg); + CastLineMoochOrRelease(acCfg); } - private BaseActionCast? FishCaughtActions((FishConfig, string)? fishAndPreset) + private BaseActionCast? GetFishCaughActions() { - var fishCfg = fishAndPreset?.Item1; + var lastFishCatchCfg = GetLastCatchConfig(); - if (fishCfg == null || !fishCfg.Enabled) return null; - - if (!PlayerResources.IsCastAvailable()) return null; + if (lastFishCatchCfg == null || !lastFishCatchCfg.Enabled) + return null; - if (fishCfg.IdenticalCast.IsAvailableToCast()) - return fishCfg.IdenticalCast; + if (lastFishCatchCfg.IdenticalCast.IsAvailableToCast()) + return lastFishCatchCfg.IdenticalCast; - if (fishCfg.SurfaceSlap.IsAvailableToCast()) - return fishCfg.SurfaceSlap; + if (lastFishCatchCfg.SurfaceSlap.IsAvailableToCast()) + return lastFishCatchCfg.SurfaceSlap; - var count = FishingCounter.GetCount($"{fishCfg.Fish.Name} {fishAndPreset?.Item2}"); - if (fishCfg.SwapBait && fishCfg.BaitToSwap.Id != Service.EquipedBait.Current) + var count = FishingCounter.GetCount(lastFishCatchCfg.GetUniqueId()); + if (_lastStep != FishingSteps.BaitSwapped && lastFishCatchCfg.SwapBait) { - Service.PrintDebug($"{fishCfg.Fish.Name} {fishAndPreset?.Item2} {count}/{fishCfg.SwapBaitCount}"); - if (count >= fishCfg.SwapBaitCount) + if (count == lastFishCatchCfg.SwapBaitCount && + lastFishCatchCfg.BaitToSwap.Id != Service.EquipedBait.Current) { - var result = Service.EquipedBait.ChangeBait((uint)fishCfg.BaitToSwap.Id); + var result = Service.EquipedBait.ChangeBait(lastFishCatchCfg.BaitToSwap); + + _lastStep |= FishingSteps.BaitSwapped; // one try per catch if (result == CurrentBait.ChangeBaitReturn.Success) { - Service.PrintChat(@$"Swapping bait to {fishCfg.BaitToSwap.Name}"); + Service.PrintChat(@$"[Fish] Swapping bait to {lastFishCatchCfg.BaitToSwap.Name}"); Service.Save(); } } } - if (fishCfg.SwapPresets && fishCfg.PresetToSwap != Presets.SelectedPreset?.PresetName) + if (_lastStep != FishingSteps.PresetSwapped && lastFishCatchCfg.SwapPresets) { - Service.PrintDebug($"{fishCfg.Fish.Name} {fishAndPreset?.Item2} {count}/{fishCfg.SwapPresetCount}"); - - if (count >= fishCfg.SwapPresetCount) + if (count == lastFishCatchCfg.SwapPresetCount && + lastFishCatchCfg.PresetToSwap != Presets.SelectedPreset?.PresetName) { - var preset = Presets.CustomPresets.FirstOrDefault(preset => preset.PresetName == fishCfg.PresetToSwap); + var preset = + Presets.CustomPresets.FirstOrDefault(preset => preset.PresetName == lastFishCatchCfg.PresetToSwap); + _lastStep |= FishingSteps.PresetSwapped; // one try per catch if (preset != null) { Presets.SelectedPreset = preset; - Service.PrintChat(@$"Swapping current preset to {fishCfg.PresetToSwap}"); + Service.PrintChat(@$"[Fish] Swapping current preset to {lastFishCatchCfg.PresetToSwap}"); Service.Save(); } + else + Service.PrintChat(@$"Preset {lastFishCatchCfg.PresetToSwap} not found."); } } @@ -273,16 +307,100 @@ private void UseAutoCasts() return null; } - private void CastLineOrMooch(FishConfig? fishConfig, AutoCastsConfig acCfg) + private void CheckExtraActions() { - var blockMooch = fishConfig is { Enabled: true, NeverMooch: true }; + if (_intuitionStatus == IntuitionStatus.NotActive) + { + if (!PlayerResources.HasStatus(IDs.Status.FishersIntuition)) + return; + + _intuitionStatus = IntuitionStatus.Active; // only one try + + var extraCfg = GetExtraCfg(); + + if (extraCfg.SwapPresetIntuitionGain) + { + var preset = + Presets.CustomPresets.FirstOrDefault(preset => + preset.PresetName == extraCfg.PresetToSwapIntuitionGain); + + if (preset != null) + { + Presets.SelectedPreset = preset; + Service.PrintChat(@$"[Extra] Swapping current preset to {extraCfg.PresetToSwapIntuitionGain}"); + Service.Save(); + } + else + Service.PrintChat(@$"Preset {extraCfg.PresetToSwapIntuitionGain} not found."); + } + + if (extraCfg.SwapBaitIntuitionGain) + { + var result = Service.EquipedBait.ChangeBait(extraCfg.BaitToSwapIntuitionGain); + + if (result == CurrentBait.ChangeBaitReturn.Success) + { + Service.PrintChat(@$"[Extra] Swapping bait to {extraCfg.BaitToSwapIntuitionGain.Name}"); + _lastStep |= FishingSteps.BaitSwapped; // one try per catch + Service.Save(); + } + } + } + + if (_intuitionStatus == IntuitionStatus.Active) + { + if (PlayerResources.HasStatus(IDs.Status.FishersIntuition)) + return; + + _intuitionStatus = IntuitionStatus.NotActive; // only one try + + var extraCfg = GetExtraCfg(); + + if (extraCfg.SwapPresetIntuitionLost) + { + var preset = + Presets.CustomPresets.FirstOrDefault(preset => + preset.PresetName == extraCfg.PresetToSwapIntuitionLost); + + if (preset != null) + { + // one try per catch + _lastStep |= FishingSteps.PresetSwapped; + Presets.SelectedPreset = preset; + Service.PrintChat(@$"[Extra] Swapping current preset to {extraCfg.PresetToSwapIntuitionLost}"); + Service.Save(); + } + else + Service.PrintChat(@$"Preset {extraCfg.PresetToSwapIntuitionLost} not found."); + } + + if (extraCfg.SwapBaitIntuitionLost) + { + var result = Service.EquipedBait.ChangeBait(extraCfg.BaitToSwapIntuitionLost); + + // one try per catch + _lastStep |= FishingSteps.BaitSwapped; + if (result == CurrentBait.ChangeBaitReturn.Success) + { + Service.PrintChat(@$"[Extra] Swapping bait to {extraCfg.BaitToSwapIntuitionLost.Name}"); + Service.Save(); + } + } + } + } + private void CastLineMoochOrRelease(AutoCastsConfig acCfg) + { + var lastFishCatchCfg = GetLastCatchConfig(); + + var blockMooch = lastFishCatchCfg is { Enabled: true, NeverMooch: true }; if (!blockMooch) { - if (fishConfig is { Enabled: true } && fishConfig.Mooch.IsAvailableToCast()) + if (lastFishCatchCfg is { Enabled: true } && lastFishCatchCfg.Mooch.IsAvailableToCast()) { - PlayerResources.CastActionDelayed(fishConfig.Mooch.Id, fishConfig.Mooch.ActionType, UIStrings.Mooch); + PlayerResources.CastActionDelayed(lastFishCatchCfg.Mooch.Id, lastFishCatchCfg.Mooch.ActionType, + UIStrings.Mooch); return; } @@ -300,86 +418,135 @@ private void CastLineOrMooch(FishConfig? fishConfig, AutoCastsConfig acCfg) } } + private void CheckStopCondition() + { + var lastFishCatchCfg = GetLastCatchConfig(); + + if (lastFishCatchCfg?.StopAfterCaught ?? false) + { + var guid = lastFishCatchCfg.GetUniqueId(); + var total = FishingCounter.GetCount(guid); + + if (total >= lastFishCatchCfg.StopAfterCaughtLimit) + { + Service.PrintChat(string.Format(UIStrings.Caught_Limited_Reached_Chat_Message, + @$"{lastFishCatchCfg.Fish.Name}: {lastFishCatchCfg.StopAfterCaughtLimit}")); + + _lastStep = lastFishCatchCfg.StopFishingStep; + FishingCounter.Remove(guid); + } + } + + if (_currentHook?.StopAfterCaught ?? false) + { + var guid = _currentHook.GetUniqueId(); + var total = FishingCounter.GetCount(guid); + + if (total >= _currentHook.StopAfterCaughtLimit) + { + Service.PrintChat(string.Format(UIStrings.Hooking_Limited_Reached_Chat_Message, + @$"{_currentHook.BaitFish.Name}: {_currentHook.StopAfterCaughtLimit}")); + + _lastStep = _currentHook.StopFishingStep; + FishingCounter.Remove(guid); + } + } + } + private void OnBeganFishing() { - if (_lastStep == CatchSteps.BeganFishing && _lastState != FishingState.PoleReady) + if (_lastStep == FishingSteps.BeganFishing && _lastState != FishingState.PoleReady) return; CurrentBaitMooch = GetCurrentBait(); _timer.Reset(); _timer.Start(); - _lastStep = CatchSteps.BeganFishing; + _lastStep = FishingSteps.BeganFishing; UpdateCurrentPreset(); } private void OnBeganMooch() { - if (_lastStep == CatchSteps.BeganMooching && _lastState != FishingState.PoleReady) + if (_lastStep == FishingSteps.BeganMooching && _lastState != FishingState.PoleReady) return; - CurrentBaitMooch = new string(LastCatch.Name); + CurrentBaitMooch = new string(Service.LastCatch.Name); _timer.Reset(); _timer.Start(); //LastCatch = null; - _lastStep = CatchSteps.BeganMooching; + _lastStep = FishingSteps.BeganMooching; UpdateCurrentPreset(); } private void OnBite() { UpdateCurrentPreset(); - _lastStep = CatchSteps.FishBit; + _lastStep = FishingSteps.FishBit; _timer.Stop(); HookFish(Service.TugType?.Bite ?? BiteType.Unknown); } - private void OnCatch(uint fishId) + private async void HookFish(BiteType bite) { - LastCatch = PlayerResources.Fishes.FirstOrDefault(fish => fish.Id == fishId) ?? new BaitFishClass(@"-", -1); + var delay = new Random().Next(Service.Configuration.DelayBetweenHookMin, + Service.Configuration.DelayBetweenHookMax); + await Task.Delay(delay); - CurrentBaitMooch = GetCurrentBait(); + if (_currentHook == null) + return; - Service.PrintDebug(@$"[HookManager] Caught {LastCatch.Name} (id {fishId})"); + // Check if the minimum time has passed + if (!CheckMinTimeLimit()) + return; - _lastStep = CatchSteps.FishCaught; + var hook = _currentHook.GetHook(bite); - // check if should stop fishing - var fishCfg = Presets.SelectedPreset?.GetFishAndPresetById(LastCatch.Id) ?? Presets.DefaultPreset.GetFishAndPresetById(LastCatch.Id); + if (hook is null or HookType.None) + return; - if (fishCfg != null) + if (PlayerResources.ActionTypeAvailable((uint)hook)) // Check if Powerful/Precision is available { - var name = @$"{fishCfg.Value.Item1.Fish.Name} {fishCfg.Value.Item2}"; - var total = FishingCounter.Add(name); - - if (total >= fishCfg.Value.Item1.StopAfterCaughtLimit && fishCfg.Value.Item1.StopAfterCaught) - { - Service.PrintChat(string.Format(UIStrings.Caught_Limited_Reached_Chat_Message, - @$"{fishCfg.Value.Item1.Fish.Name}: {fishCfg.Value.Item1.StopAfterCaughtLimit}")); - _lastStep = fishCfg.Value.Item1.StopFishingStep; - FishingCounter.Remove(name); - } + Service.PrintDebug(@$"[HookManager] Using {hook.ToString()} hook."); + PlayerResources.CastActionDelayed((uint)hook, ActionType.Action, @$"{hook.ToString()}"); + } + else + { + Service.PrintDebug(@"[HookManager] Powerful/Precision not available. Using normal hook."); + PlayerResources.CastActionDelayed((uint)HookType.Normal, ActionType.Action, + @$"{HookType.Normal.ToString()}"); } + } + + private void OnCatch(uint fishId, uint amount) + { + _lastCatch = PlayerResources.Fishes.FirstOrDefault(fish => fish.Id == fishId) ?? new BaitFishClass(@"-", -1); + var lastFishCatchCfg = GetLastCatchConfig(); + + Service.LastCatch = _lastCatch; + + // Set the equipped bait back + CurrentBaitMooch = GetCurrentBait(); + + Service.PrintDebug(@$"[HookManager] Caught {_lastCatch.Name} (id {_lastCatch.Id})"); + + _lastStep = FishingSteps.FishCaught; - if (_currentHook.hook?.StopAfterCaught ?? false) + if (lastFishCatchCfg != null) { - var name = @$"{_currentHook.hook.BaitFish.Name} {_currentHook.presetName}"; - var total = FishingCounter.Add(name); - if (total >= _currentHook.hook.StopAfterCaughtLimit && _currentHook.hook.StopAfterCaught) + for (var i = 0; i < amount; i++) { - Service.PrintChat(string.Format(UIStrings.Hooking_Limited_Reached_Chat_Message, - @$"{_currentHook.hook.BaitFish.Name}: {_currentHook.hook.StopAfterCaughtLimit}")); - - _lastStep = _currentHook.hook.StopFishingStep; - - FishingCounter.Remove(name); + FishingCounter.Add(lastFishCatchCfg.GetUniqueId()); } } + + if (_currentHook != null) + FishingCounter.Add(_currentHook.GetUniqueId()); } private void OnFishingStop() { - _lastStep = CatchSteps.None; + _lastStep = FishingSteps.None; if (_timer.IsRunning) _timer.Stop(); @@ -397,78 +564,49 @@ private void OnFishingStop() PlayerResources.CastActionNoDelay(IDs.Actions.Quit); PlayerResources.DelayNextCast(0); - - - } - - private void HookFish(BiteType bite) - { - if (_currentHook.hook == null) - return; - - // Check if the minimum time has passed - if (!CheckMinTimeLimit()) - return; - - var hook = _currentHook.hook.GetHook(bite); - - if (hook is null or HookType.None) - return; - - if (PlayerResources.ActionTypeAvailable((uint)hook)) // Check if Powerful/Precision is available - { - Service.PrintDebug(@$"[HookManager] Using {hook.ToString()} hook."); - PlayerResources.CastActionDelayed((uint)hook, ActionType.Action, @$"{hook.ToString()}"); - } - else - { - Service.PrintDebug(@"[HookManager] Powerful/Precision not available. Using normal hook."); - PlayerResources.CastActionDelayed((uint)HookType.Normal, ActionType.Action, - @$"{HookType.Normal.ToString()}"); - } } private bool CheckMinTimeLimit() { - if (_currentHook.hook == null) + if (_currentHook == null) return true; double minTime; - if (_currentHook.hook.UseChumTimer && PlayerResources.HasStatus(IDs.Status.Chum)) - minTime = Math.Truncate(_currentHook.hook.MinChumTimeDelay * 100) / 100; + if (_currentHook.UseChumTimer && PlayerResources.HasStatus(IDs.Status.Chum)) + minTime = Math.Truncate(_currentHook.MinChumTimeDelay * 100) / 100; else - minTime = Math.Truncate(_currentHook.hook.MinTimeDelay * 100) / 100; + minTime = Math.Truncate(_currentHook.MinTimeDelay * 100) / 100; var timeElapsed = Math.Truncate(_timer.ElapsedMilliseconds / 1000.0 * 100) / 100; if (!(minTime > 0) || !(timeElapsed < minTime)) return true; - _lastStep = CatchSteps.TimeOut; + _lastStep = FishingSteps.TimeOut; return false; } private void CheckMaxTimeLimit() { - if (_currentHook.hook == null) + if (_currentHook == null) return; double maxTime; - if (_currentHook.hook.UseChumTimer && PlayerResources.HasStatus(IDs.Status.Chum)) - maxTime = Math.Truncate(_currentHook.hook.MaxChumTimeDelay * 100) / 100; + if (_currentHook.UseChumTimer && PlayerResources.HasStatus(IDs.Status.Chum)) + maxTime = Math.Truncate(_currentHook.MaxChumTimeDelay * 100) / 100; else - maxTime = Math.Truncate(_currentHook.hook.MaxTimeDelay * 100) / 100; + maxTime = Math.Truncate(_currentHook.MaxTimeDelay * 100) / 100; var currentTime = Math.Truncate(_timer.ElapsedMilliseconds / 1000.0 * 100) / 100; - if (!(maxTime > 0) || !(currentTime > maxTime) || _lastStep == CatchSteps.TimeOut) + if (!(maxTime > 0) || !(currentTime > maxTime) || _lastStep == FishingSteps.TimeOut) return; Service.PrintDebug(@"[HookManager] Timeout. Hooking fish."); - _lastStep = CatchSteps.TimeOut; + _lastStep = FishingSteps.TimeOut; PlayerResources.CastActionDelayed(IDs.Actions.Hook, ActionType.Action, @"Hook"); } @@ -494,26 +632,31 @@ private void CheckState() @$"[HookManager] Fishing State: {Service.EventFramework.FishingState}, LastStep: {_lastStep}"); } - private delegate bool UseActionDelegate(IntPtr manager, ActionType actionType, uint actionId, GameObjectID targetId, - uint a4, uint a5, - uint a6, IntPtr a7); - private bool OnUseAction(IntPtr manager, ActionType actionType, uint actionId, GameObjectID targetId, uint a4, uint a5, uint a6, IntPtr a7) { - if (actionType == ActionType.Action && PlayerResources.ActionTypeAvailable(actionId)) - switch (actionId) + try + { + if (actionType == ActionType.Action) { - case IDs.Actions.Cast: - OnBeganFishing(); - break; - case IDs.Actions.Mooch: - case IDs.Actions.Mooch2: - OnBeganMooch(); - break; + switch (actionId) + { + case IDs.Actions.Cast: + if (PlayerResources.ActionTypeAvailable(actionId)) OnBeganFishing(); + break; + case IDs.Actions.Mooch: + case IDs.Actions.Mooch2: + if (PlayerResources.ActionTypeAvailable(actionId)) OnBeganMooch(); + break; + } } + } + catch (Exception e) + { + Service.PrintDebug(@$"[HookManager] Error: {e.Message}"); + } - return _hookHook!.Original(manager, actionType, actionId, targetId, a4, a5, a6, a7); + return _useActionHook!.Original(manager, actionType, actionId, targetId, a4, a5, a6, a7); } private void OnCatchUpdate(IntPtr module, uint fishId, bool large, ushort size, byte amount, byte level, byte unk7, @@ -525,32 +668,27 @@ private void OnCatchUpdate(IntPtr module, uint fishId, bool large, ushort size, if (fishId > 500000) fishId -= 500000; - OnCatch(fishId); + OnCatch(fishId, amount); } public static class FishingCounter { - private static Dictionary _fishCount = new(); + private static Dictionary _fishCount = new(); - public static int Add(string fishName) + public static int Add(Guid guid) { - _fishCount.TryAdd(fishName, 0); - _fishCount[fishName]++; + _fishCount.TryAdd(guid, 0); + _fishCount[guid]++; - foreach (var (key, value) in _fishCount) - { - Service.PrintDebug(@$"-----------[HookManager] {key}: {value}"); - } - - return GetCount(fishName); + return GetCount(guid); } - public static int GetCount(string fishName) + public static int GetCount(Guid fishName) { return !_fishCount.ContainsKey(fishName) ? 0 : _fishCount[fishName]; } - - public static void Remove(string fishName) + + public static void Remove(Guid fishName) { if (_fishCount.ContainsKey(fishName)) _fishCount.Remove(fishName); @@ -558,7 +696,7 @@ public static void Remove(string fishName) public static void Reset() { - _fishCount = new Dictionary(); + _fishCount = new Dictionary(); } } } \ No newline at end of file diff --git a/AutoHook/PluginUI.cs b/AutoHook/PluginUI.cs index 0d2f483..1ed6059 100644 --- a/AutoHook/PluginUI.cs +++ b/AutoHook/PluginUI.cs @@ -52,7 +52,7 @@ public override void Draw() if (!IsOpen) return; - ImGui.TextColored(ImGuiColors.DalamudYellow, "Major plugin rework!!! Please, recheck all of your presets"); + //ImGui.TextColored(ImGuiColors.DalamudYellow, "Major plugin rework!!! Please, recheck all of your presets"); ImGui.Spacing(); DrawUtil.Checkbox(UIStrings.Enable_AutoHook, ref Service.Configuration.PluginEnabled, UIStrings.PluginUi_Draw_Enables_Disables); @@ -133,12 +133,7 @@ private void Debug() private static unsafe void TestButtons() { if (ImGui.Button(@"Check")) - { - Service.PrintChat("-----------------"); - Service.PrintChat("Watered Available: " + InventoryManager.Instance()->GetInventoryItemCount(IDs.Item.WateredCordial)); - Service.PrintChat("HQ Watered Available: " + InventoryManager.Instance()->GetInventoryItemCount(IDs.Item.HQWateredCordial)); - - + { } } @@ -293,7 +288,7 @@ private void DrawChangelog() if (changes[i].MinorChanges.Count > 0) { ImGui.Spacing(); - ImGui.TextWrapped("Bug Fixes"); + ImGui.TextWrapped("Minor Changes"); foreach (var minorChange in changes[i].MinorChanges) ImGui.TextWrapped($"- {minorChange}"); @@ -315,6 +310,21 @@ public static class PluginChangeLog { public static readonly List Versions = new() { + new Version("3.0.1.0") + { + MainChanges = + { + "Added new subtab 'Extra' for extra options", + "Added options to change bait/presets when gaining/losing intuition", + "(Config) Added optional delay for hooking or auto casting", + }, + MinorChanges = + { + "Pantience I/II has priority over MakeShift Bait if both options are enabled", + "Added a new command to open the plugin menu", + "Minor text changes" + } + }, new Version("3.0.0.0") { MainChanges = diff --git a/AutoHook/Resources/Localization/UIStrings.Designer.cs b/AutoHook/Resources/Localization/UIStrings.Designer.cs index 023b581..669570e 100644 --- a/AutoHook/Resources/Localization/UIStrings.Designer.cs +++ b/AutoHook/Resources/Localization/UIStrings.Designer.cs @@ -521,6 +521,15 @@ internal static string Custom_AutoCast_Being_Used { } } + /// + /// Looks up a localized string similar to Custom preset [{0}] Extra config is being used instead. + /// + internal static string Custom_Extra_Being_Used { + get { + return ResourceManager.GetString("Custom_Extra_Being_Used", resourceCulture); + } + } + /// /// Looks up a localized string similar to This is not a valid import.. /// @@ -539,6 +548,15 @@ internal static string Default_AutoCast_Being_Used { } } + /// + /// Looks up a localized string similar to [Default] Extra config is being used instead. + /// + internal static string Default_Extra_Being_Used { + get { + return ResourceManager.GetString("Default_Extra_Being_Used", resourceCulture); + } + } + /// /// Looks up a localized string similar to Default Cast. /// @@ -584,6 +602,15 @@ internal static string Delay_Between_Casts { } } + /// + /// Looks up a localized string similar to Delay when hooking. + /// + internal static string Delay_when_hooking { + get { + return ResourceManager.GetString("Delay_when_hooking", resourceCulture); + } + } + /// /// Looks up a localized string similar to Important!!! /// @@ -631,6 +658,24 @@ internal static string DoubleTripleHookSettings { } } + /// + /// Looks up a localized string similar to Configs. + /// + internal static string Draw_Configs { + get { + return ResourceManager.GetString("Draw_Configs", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Guides. + /// + internal static string Draw_Guides { + get { + return ResourceManager.GetString("Draw_Guides", resourceCulture); + } + } + /// /// Looks up a localized string similar to Max.. /// @@ -766,6 +811,15 @@ internal static string Enable_AutoHook { } } + /// + /// Looks up a localized string similar to Enable Extra Configs. + /// + internal static string Enable_Extra_Configs { + get { + return ResourceManager.GetString("Enable_Extra_Configs", resourceCulture); + } + } + /// /// Looks up a localized string similar to Enable AutoGig. /// @@ -841,6 +895,15 @@ internal static string ExportPresetToClipboard { } } + /// + /// Looks up a localized string similar to Extra. + /// + internal static string Extra { + get { + return ResourceManager.GetString("Extra", resourceCulture); + } + } + /// /// Looks up a localized string similar to >Make sure 'Use Mooch II' is enabled or else it wont work< ///This could save you 100gp if going only for mooches. @@ -1209,6 +1272,24 @@ internal static string Never_Mooch { } } + /// + /// Looks up a localized string similar to Never Release. + /// + internal static string NeverRelease { + get { + return ResourceManager.GetString("NeverRelease", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This fish won't be released if 'Release All Fish' is enabled in the Auto Cast tab. + /// + internal static string NeverReleaseHelptext { + get { + return ResourceManager.GetString("NeverReleaseHelptext", resourceCulture); + } + } + /// /// Looks up a localized string similar to New Preset. /// @@ -1470,6 +1551,24 @@ internal static string Quit_Fishing { } } + /// + /// Looks up a localized string similar to Release All Fish. + /// + internal static string ReleaseAllFish { + get { + return ResourceManager.GetString("ReleaseAllFish", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to If you dont want to release a specific fish, add it to a preset and select "Never Release". + /// + internal static string ReleaseAllFishHelpText { + get { + return ResourceManager.GetString("ReleaseAllFishHelpText", resourceCulture); + } + } + /// /// Looks up a localized string similar to Right-click to rename. /// @@ -1605,6 +1704,15 @@ internal static string SubAuto_Disabled { } } + /// + /// Looks up a localized string similar to Extra options disabled. + /// + internal static string SubExtra_Disabled { + get { + return ResourceManager.GetString("SubExtra_Disabled", resourceCulture); + } + } + /// /// Looks up a localized string similar to Support me on Ko-fi. /// @@ -2099,6 +2207,24 @@ internal static string Watered_Cordial { } } + /// + /// Looks up a localized string similar to When gaining fisher's intuition.... + /// + internal static string When_gaining_fishers_intuition { + get { + return ResourceManager.GetString("When_gaining_fishers_intuition", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to When losing fisher's intuition.... + /// + internal static string When_losing_fishers_intuition { + get { + return ResourceManager.GetString("When_losing_fishers_intuition", resourceCulture); + } + } + /// /// Looks up a localized string similar to will be used when your GP is Equal or. /// diff --git a/AutoHook/Resources/Localization/UIStrings.de.resx b/AutoHook/Resources/Localization/UIStrings.de.resx index e3a8bb4..f39d0c8 100644 --- a/AutoHook/Resources/Localization/UIStrings.de.resx +++ b/AutoHook/Resources/Localization/UIStrings.de.resx @@ -119,8 +119,6 @@ Test - Just a test field - Not being used - Standard @@ -175,7 +173,6 @@ EditMe - Context: Temporary name displayed to the user telling them to edit the field with the wanted Bait or Fish name Hinzufügen @@ -199,7 +196,12 @@ Neues Preset hinzufügen - Hier kannst du einstellen, welcher Angelschlag für den aktuellen Köder oder Naturköder verwendet werden soll. Wenn kein Köder/Naturköder angegeben ist, wir die Standardeinstellung (General Tab) verwendet. + Here you can customize which hook to use based on the current bait or mooch. +If a bait/mooch is not specified, the Default Preset will be used instead. + + + Here you can customize which hook to use based on the current bait or mooch. +If a bait/mooch is not specified, the Default Preset will be used instead. Neues Preset @@ -654,4 +656,171 @@ Möchtest du Auto-Naturköder für einen spezifischen Fisch verwenden, und ander AutoHook + + Language + + + Help with the plugin localization (Crowdin) + + + Add new bait + + + Add new mooch + + + Hook + + + Mooch + + + Auto Cast Line + + + This option have priority over Auto Cast Line + + + Normal Hook + + + Default Preset + + + Bait + + + All Baits + + + All Mooches + + + Patience + + + Fish + + + Add new fish + + + Cast Line + Cast (fisher action) + + + Mooch II + + + Never Mooch + + + Mooch Setting + + + Swap Preset + + + Swap Bait + + + If disabled, mooching opportunity will be lost + + + Always Mooch + + + Caught: + It'll shows how many times the fish was caught. Example: Caught: 5x + + + Hooked: + It'll shows how many times the fish was caught. Example: Hooked: 5x + + + Enabled + + + After hooking... + + + Hooking limit reached ({0}). Stopping fishing. + + + Caught limit reached ({0}). Stopping fishing. + + + Stop Casting + + + Auto casting will be stopped, but won't quit fishing + + + Quit Fishing + + + Quit action will be used and completely stop fishing + + + Description + + + The default preset is used when no custom bait/mooch/fish/autocast is detected. Here you can set the hooking behavior that will be used for all baits and mooches unless a custom preset is created. +Check the Guide Tab for Guides. + + + This is an old import, some settings might be missing. + + + Show Chat Logs + + + Show Current Status Header + + + Max. + + + Min. + + + Delay Between Casts (in ms): + + + Show Debug Console + + + Show messages like "Preset Swapped" in chat + + + Config / Guides + + + Open Console + + + Auto cast is disabled + + + [Default] auto cast is being used instead + + + Custom preset [{0}] Auto cast is being used instead + + + Important! Auto Casts wont be used if you hook manually. + + + Food Buff + + + Only use when patience is active + + + Stop After Caught + + + Search... + Hint Text for search bar + \ No newline at end of file diff --git a/AutoHook/Resources/Localization/UIStrings.es.resx b/AutoHook/Resources/Localization/UIStrings.es.resx index 30c8ec6..3f588da 100644 --- a/AutoHook/Resources/Localization/UIStrings.es.resx +++ b/AutoHook/Resources/Localization/UIStrings.es.resx @@ -197,7 +197,11 @@ Here you can customize which hook to use based on the current bait or mooch. -If a bait/mooch is not specified, the default behavior (General Tab) will be used instead. +If a bait/mooch is not specified, the Default Preset will be used instead. + + + Here you can customize which hook to use based on the current bait or mooch. +If a bait/mooch is not specified, the Default Preset will be used instead. New Preset @@ -652,4 +656,171 @@ If you want to Auto Mooch only a specific fish and ignore others, disable this o AutoHook + + Language + + + Help with the plugin localization (Crowdin) + + + Add new bait + + + Add new mooch + + + Hook + + + Mooch + + + Auto Cast Line + + + This option have priority over Auto Cast Line + + + Normal Hook + + + Default Preset + + + Bait + + + All Baits + + + All Mooches + + + Patience + + + Fish + + + Add new fish + + + Cast Line + Cast (fisher action) + + + Mooch II + + + Never Mooch + + + Mooch Setting + + + Swap Preset + + + Swap Bait + + + If disabled, mooching opportunity will be lost + + + Always Mooch + + + Caught: + It'll shows how many times the fish was caught. Example: Caught: 5x + + + Hooked: + It'll shows how many times the fish was caught. Example: Hooked: 5x + + + Enabled + + + After hooking... + + + Hooking limit reached ({0}). Stopping fishing. + + + Caught limit reached ({0}). Stopping fishing. + + + Stop Casting + + + Auto casting will be stopped, but won't quit fishing + + + Quit Fishing + + + Quit action will be used and completely stop fishing + + + Description + + + The default preset is used when no custom bait/mooch/fish/autocast is detected. Here you can set the hooking behavior that will be used for all baits and mooches unless a custom preset is created. +Check the Guide Tab for Guides. + + + This is an old import, some settings might be missing. + + + Show Chat Logs + + + Show Current Status Header + + + Max. + + + Min. + + + Delay Between Casts (in ms): + + + Show Debug Console + + + Show messages like "Preset Swapped" in chat + + + Config / Guides + + + Open Console + + + Auto cast is disabled + + + [Default] auto cast is being used instead + + + Custom preset [{0}] Auto cast is being used instead + + + Important! Auto Casts wont be used if you hook manually. + + + Food Buff + + + Only use when patience is active + + + Stop After Caught + + + Search... + Hint Text for search bar + \ No newline at end of file diff --git a/AutoHook/Resources/Localization/UIStrings.fr.resx b/AutoHook/Resources/Localization/UIStrings.fr.resx index 981b0b9..d33deaf 100644 --- a/AutoHook/Resources/Localization/UIStrings.fr.resx +++ b/AutoHook/Resources/Localization/UIStrings.fr.resx @@ -119,8 +119,6 @@ Tests en cours - Just a test field - Not being used - Défaut @@ -175,7 +173,6 @@ EditMe - Context: Temporary name displayed to the user telling them to edit the field with the wanted Bait or Fish name Ajouter @@ -199,8 +196,12 @@ Ajouter un nouveau préréglage - Ici, vous pouvez personnaliser l’appât à utiliser en fonction de l’appât actuel ou pêche au vif. -Si un appât/pêche au vif n’est pas spécifié, le comportement par défaut (onglet général) sera utilisé à la place. + Ici, vous pouvez personnaliser l'hameçon à utiliser en fonction de l’appât actuel ou pêche au vif. +Si aucun appât/pêche au vif n'est spécifié, le préréglage par défaut sera utilisé à la place. + + + Ici, vous pouvez personnaliser l'hameçon à utiliser en fonction de l’appât actuel ou pêche au vif. +Si aucun appât/pêche au vif n'est spécifié, le préréglage par défaut sera utilisé à la place. Nouveau Préréglage @@ -654,4 +655,171 @@ Si vous voulez lancer Pêche Au vif automatiquement seulement sur un poisson sp AutoHook + + Langue + + + Aide à la localisation du plugin (Crowdin) + + + Ajouter un nouvel appât + + + Ajouter une nouvelle pêche au vif + + + Hameçon + + + Pêche au vif + + + Lancé automatiquement + + + Cette option prend priorité sur le lancer de ligne automatique + + + Hameçon normal + + + Préréglages par défaut + + + Appât + + + Tous les appâts + + + Toutes les pêches au vif + + + Patience + + + Poisson + + + Ajouter un nouveau poisson + + + Lancer de ligne + Cast (fisher action) + + + Pêche au vif II + + + Ne jamais faire de pêche au vif + + + Réglage de la pêche au vif + + + Changer de préréglage + + + Changer d'appât + + + Si désactivé, l'opportunité de pêche au vif sera perdue + + + Toujours faire de la pêche au vif + + + Attrapés: + It'll shows how many times the fish was caught. Example: Caught: 5x + + + Ferrés: + It'll shows how many times the fish was caught. Example: Hooked: 5x + + + Activé + + + Après l'hameçonnage... + + + Limite d'hameçonnage atteint ({0}). Arrêt de la pêche. + + + Limite de capture atteinte ({0}). Arrêt de la pêche. + + + Arrêter le lancé + + + Le lancé automatique sera arrêté, mais ne quittera pas la pêche + + + Quitter la pêche + + + L'action de fermeture sera utilisée et arrêtera complètement la pêche + + + Description + + + Le préréglage par défaut est utilisé quand aucun appât/pêche au vif/poisson/ferrage automatique personnalisé n'est détecté. Ici, vous pouvez définir le comportement d'hameçonnage qui sera utilisé pour tous les appâts et pêches au vif à moins qu'un préréglage personnalisé ne soit créé. +Consultez l’onglet Guide pour trouver des guides. + + + Il s'agit d'une ancienne importation, certains paramètres peuvent être manquants. + + + Afficher les journaux de discussion + + + Afficher l'en-tête de statut actuel + + + Max. + + + Min. + + + Délai entre les lancés (en ms) : + + + Afficher la console de débogage + + + Afficher les messages comme "Préréglage Changé" dans le chat + + + Configuration / Tutoriels + + + Ouvrir la console + + + Le lancé auto est désactivé + + + [Default] lancé auto est utilisé à la place + + + Préréglage personnalisé [{0}] Le lancer auto est utilisé à la place + + + Important ! Les lancés automatiques ne seront pas utilisés si vous hameçonnez manuellement. + + + Buff de repas + + + Utiliser uniquement lorsque patience est actif + + + Arrêter après une prise + + + Rechercher... + Hint Text for search bar + \ No newline at end of file diff --git a/AutoHook/Resources/Localization/UIStrings.ko.resx b/AutoHook/Resources/Localization/UIStrings.ko.resx index 9212522..17ac7ee 100644 --- a/AutoHook/Resources/Localization/UIStrings.ko.resx +++ b/AutoHook/Resources/Localization/UIStrings.ko.resx @@ -119,8 +119,6 @@ 테스트 - Just a test field - Not being used - 기본값 @@ -175,7 +173,6 @@ 이름을 입력하세요 - Context: Temporary name displayed to the user telling them to edit the field with the wanted Bait or Fish name 추가 @@ -199,8 +196,12 @@ 새로운 사전 설정 추가 - 여기서 현재 미끼를 바탕으로 사용 할 낚아채기를 지정 할 수 있습니다. -먹이/생미끼가 지정되지 않은 경우 대신 기본 설정 (일반 탭) 이 사용됩니다. + Here you can customize which hook to use based on the current bait or mooch. +If a bait/mooch is not specified, the Default Preset will be used instead. + + + Here you can customize which hook to use based on the current bait or mooch. +If a bait/mooch is not specified, the Default Preset will be used instead. 새로운 사전 설정 @@ -427,7 +428,7 @@ 선택한 크기와 속도의 물고기에만 히트박스가 적용됩니다. - 물고기 히트박스 보이기 + 작살질 히트박스 보이기 물고기의 크기와 속도를 선택하세요. (Gatherbuddy의 작살질 오버레이가 많은 도움이 됩니다.) @@ -655,4 +656,171 @@ 자동 낚아채기 + + 언어 설정 + + + Help with the plugin localization (Crowdin) + + + Add new bait + + + Add new mooch + + + 낚아채기 + + + Mooch + + + Auto Cast Line + + + This option have priority over Auto Cast Line + + + Normal Hook + + + Default Preset + + + 미끼 + + + All Baits + + + All Mooches + + + 인내 + + + 물고기 + + + Add new fish + + + Cast Line + Cast (fisher action) + + + 생미끼 낚시 2 + + + Never Mooch + + + 생미끼 낚시 설정 + + + Swap Preset + + + Swap Bait + + + If disabled, mooching opportunity will be lost + + + Always Mooch + + + Caught: + It'll shows how many times the fish was caught. Example: Caught: 5x + + + Hooked: + It'll shows how many times the fish was caught. Example: Hooked: 5x + + + 활성화됨 + + + After hooking... + + + Hooking limit reached ({0}). Stopping fishing. + + + Caught limit reached ({0}). Stopping fishing. + + + Stop Casting + + + Auto casting will be stopped, but won't quit fishing + + + Quit Fishing + + + Quit action will be used and completely stop fishing + + + Description + + + The default preset is used when no custom bait/mooch/fish/autocast is detected. Here you can set the hooking behavior that will be used for all baits and mooches unless a custom preset is created. +Check the Guide Tab for Guides. + + + This is an old import, some settings might be missing. + + + Show Chat Logs + + + Show Current Status Header + + + 최대 + + + 최소 + + + Delay Between Casts (in ms): + + + Show Debug Console + + + Show messages like "Preset Swapped" in chat + + + Config / Guides + + + Open Console + + + Auto cast is disabled + + + [Default] auto cast is being used instead + + + Custom preset [{0}] Auto cast is being used instead + + + Important! Auto Casts wont be used if you hook manually. + + + Food Buff + + + Only use when patience is active + + + Stop After Caught + + + Search... + Hint Text for search bar + \ No newline at end of file diff --git a/AutoHook/Resources/Localization/UIStrings.resx b/AutoHook/Resources/Localization/UIStrings.resx index 7ee46f9..3586edb 100644 --- a/AutoHook/Resources/Localization/UIStrings.resx +++ b/AutoHook/Resources/Localization/UIStrings.resx @@ -801,12 +801,21 @@ Check the Guide Tab for Guides. Auto cast is disabled + + Extra options disabled + [Default] auto cast is being used instead Custom preset [{0}] Auto cast is being used instead + + [Default] Extra config is being used instead + + + Custom preset [{0}] Extra config is being used instead + Important! Auto Casts wont be used if you hook manually. @@ -823,4 +832,37 @@ Check the Guide Tab for Guides. Search... Hint Text for search bar + + Extra + + + This fish won't be released if 'Release All Fish' is enabled in the Auto Cast tab + + + Never Release + + + Release All Fish + + + If you dont want to release a specific fish, add it to a preset and select "Never Release" + + + Enable Extra Configs + + + When gaining fisher's intuition... + + + When losing fisher's intuition... + + + Configs + + + Guides + + + Delay when hooking + \ No newline at end of file diff --git a/AutoHook/Resources/Localization/UIStrings.zh.resx b/AutoHook/Resources/Localization/UIStrings.zh.resx index b3578e1..0386252 100644 --- a/AutoHook/Resources/Localization/UIStrings.zh.resx +++ b/AutoHook/Resources/Localization/UIStrings.zh.resx @@ -119,8 +119,6 @@ 测试 - Just a test field - Not being used - 默认 @@ -175,7 +173,6 @@ 修改 - Context: Temporary name displayed to the user telling them to edit the field with the wanted Bait or Fish name 添加 @@ -200,6 +197,10 @@ 您可以在这里自定义当前的鱼饵或以小钓大鱼使用什么提钩技能。 +如果未指定鱼饵/以小钓大鱼,那么将会使用通用标签页中的默认行为。 + + + 您可以在这里自定义当前的鱼饵或以小钓大鱼使用什么提钩技能。 如果未指定鱼饵/以小钓大鱼,那么将会使用通用标签页中的默认行为。 @@ -654,4 +655,171 @@ 自动提钩 + + 语言 + + + 帮助插件本地化 (Crowdin) + + + 添加新鱼饵 + + + 添加新的以小钓大 + + + 提钩 + + + 以小钓大 + + + 自动抛竿 + + + 此选项优先于自动抛竿 + + + 普通提钩 + + + 默认预设 + + + 鱼饵 + + + 所有鱼饵 + + + 所有以小钓大 + + + 耐心 + + + + + + 添加新鱼 + + + 抛竿 + Cast (fisher action) + + + 以小钓大II + + + 从不以小钓大 + + + 以小钓大设置 + + + 交换预设 + + + 交换鱼饵 + + + 如果禁用,将会失去以小钓大机会 + + + 总是以小钓大 + + + 捕获: + It'll shows how many times the fish was caught. Example: Caught: 5x + + + 提钩: + It'll shows how many times the fish was caught. Example: Hooked: 5x + + + 启用 + + + 提钩后... + + + 提钩达到({0})。停止钓鱼。 + + + 捕获达到({0})。停止钓鱼。 + + + 停止抛竿 + + + 自动垂钓将停止,但不会退出钓鱼状态 + + + 退出钓鱼 + + + 退出并停止钓鱼 + + + 描述 + + + 当未检测到自定义的鱼饵/以小到大/鱼/自动抛竿时,将使用默认预设。 在这里您可以设置用于所有鱼饵和以小钓大的挂钩行为,除非创建了自定义预设。 +请检查指南选项卡。 + + + 这是一个旧的配置,可能缺少一些设置。 + + + 显示聊天日志 + + + 显示当前状态标题 + + + 最大值 + + + 最小. + + + 延迟抛竿(毫秒): + + + 显示调试控制台 + + + 在聊天中显示像“预设交换”这样的消息 + + + 配置 / 指南 + + + 打开控制台 + + + 自动抛竿已关闭 + + + [默认] 正在使用自动抛竿 + + + 正在使用自定义预设 [{0}] 进行自动抛竿。 + + + 重要!如果您手动提钩,将不会使用自动抛竿。 + + + 食物增益 + + + 仅在耐心激活时使用 + + + 捕获后停止 + + + 搜索... + Hint Text for search bar + \ No newline at end of file diff --git a/AutoHook/SeFunctions/CurrentBait.cs b/AutoHook/SeFunctions/CurrentBait.cs index 64c9064..e94f706 100644 --- a/AutoHook/SeFunctions/CurrentBait.cs +++ b/AutoHook/SeFunctions/CurrentBait.cs @@ -1,4 +1,5 @@ using System.Linq; +using AutoHook.Classes; using AutoHook.Utils; using Dalamud.Game; using Dalamud.Utility.Signatures; @@ -44,16 +45,29 @@ public ChangeBaitReturn ChangeBait(uint baitId) { if (HasItem(baitId) <= 0) return ChangeBaitReturn.NotInInventory; - return _executeCommand(701, 4, baitId, 0, 0) == 1 ? ChangeBaitReturn.Success : ChangeBaitReturn.UnknownError; } - public ChangeBaitReturn ChangeBait(string baitName) { - var result = PlayerResources.Baits.FirstOrDefault(b => b.Name == baitName); + public ChangeBaitReturn ChangeBait(BaitFishClass bait) { + + if (bait.Id == Current) + { + Service.PrintChat($"Bait \"{bait.Name}\" is already equipped."); + return ChangeBaitReturn.AlreadyEquipped; + } - if (result == null) + if (bait.Id == 0 || PlayerResources.Baits.All(b => b.Id != bait.Id)) + { + Service.PrintChat($"Bait \"{bait.Name}\" is not a valid bait."); return ChangeBaitReturn.InvalidBait; - - return ChangeBait((uint)result.Id); + } + + if (HasItem((uint)bait.Id) <= 0) + { + Service.PrintChat($"Bait \"{bait.Name}\" is not in your inventory."); + return ChangeBaitReturn.NotInInventory; + } + + return _executeCommand(701, 4, (uint)bait.Id, 0, 0) == 1 ? ChangeBaitReturn.Success : ChangeBaitReturn.UnknownError; } } diff --git a/AutoHook/Service.cs b/AutoHook/Service.cs index eadbbfd..4d95049 100644 --- a/AutoHook/Service.cs +++ b/AutoHook/Service.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using AutoHook.Classes; using Dalamud.Game; using Dalamud.IoC; using Dalamud.Plugin; @@ -35,7 +36,9 @@ public static void Initialize(DalamudPluginInterface pluginInterface) public static ClientLanguage Language { get; set; } public static string Status = @"-"; - + + public static BaitFishClass LastCatch { get; set; } = new(@"-", -1); + public static void Save() { Configuration.Save(); diff --git a/AutoHook/Ui/SubTabAutoCast.cs b/AutoHook/Ui/SubTabAutoCast.cs index a64201e..f0ec242 100644 --- a/AutoHook/Ui/SubTabAutoCast.cs +++ b/AutoHook/Ui/SubTabAutoCast.cs @@ -29,6 +29,7 @@ public void DrawAutoCastTab(AutoCastsConfig acCfg) acCfg.CastMakeShiftBait, acCfg.CastPatience, acCfg.CastPrizeCatch, + //acCfg.CastReleaseFish, //acCfg.CastSurfaceSlap, acCfg.CastThaliaksFavor, }; diff --git a/AutoHook/Ui/SubTabBaitMooch.cs b/AutoHook/Ui/SubTabBaitMooch.cs index b377f3a..d604f80 100644 --- a/AutoHook/Ui/SubTabBaitMooch.cs +++ b/AutoHook/Ui/SubTabBaitMooch.cs @@ -48,7 +48,7 @@ public void DrawHookTab(PresetConfig presetCfg) ImGui.PushID($"id###{idx}"); ImGui.Spacing(); - var count = HookingManager.FishingCounter.GetCount($"{bait.BaitFish.Name} {presetCfg.PresetName}"); + var count = HookingManager.FishingCounter.GetCount(bait.GetUniqueId()); var hookCounter = count > 0 ? $"({UIStrings.Hooked_Counter} {count})" : ""; if (ImGui.CollapsingHeader($"{bait.BaitFish.Name} {hookCounter}###{idx}")) { @@ -432,18 +432,18 @@ private void DrawStopAfter(HookConfig hookConfig) ImGui.Unindent(); } - if (ImGui.RadioButton(UIStrings.Stop_Casting, hookConfig.StopFishingStep == CatchSteps.None)) + if (ImGui.RadioButton(UIStrings.Stop_Casting, hookConfig.StopFishingStep == FishingSteps.None)) { - hookConfig.StopFishingStep = CatchSteps.None; + hookConfig.StopFishingStep = FishingSteps.None; Service.Save(); } ImGui.SameLine(); ImGuiComponents.HelpMarker(UIStrings.Auto_Cast_Stopped); - if (ImGui.RadioButton(UIStrings.Quit_Fishing, hookConfig.StopFishingStep == CatchSteps.Quitting)) + if (ImGui.RadioButton(UIStrings.Quit_Fishing, hookConfig.StopFishingStep == FishingSteps.Quitting)) { - hookConfig.StopFishingStep = CatchSteps.Quitting; + hookConfig.StopFishingStep = FishingSteps.Quitting; Service.Save(); } ImGui.SameLine(); diff --git a/AutoHook/Ui/SubTabExtra.cs b/AutoHook/Ui/SubTabExtra.cs new file mode 100644 index 0000000..8b1a3e0 --- /dev/null +++ b/AutoHook/Ui/SubTabExtra.cs @@ -0,0 +1,143 @@ +using AutoHook.Configurations; +using AutoHook.Resources.Localization; +using AutoHook.Utils; +using Dalamud.Interface.Colors; +using ImGuiNET; + +namespace AutoHook.Ui; + +public class SubTabExtra +{ + public bool IsDefaultPreset { get; set; } + + public void DrawExtraTab(ExtraConfig config) + { + DrawHeader(config); + + if (config.Enabled) + DrawBody(config); + } + + public void DrawHeader(ExtraConfig config) + { + ImGui.Spacing(); + + if (DrawUtil.Checkbox(UIStrings.Enable_Extra_Configs, ref config.Enabled)) + { + Service.Save(); + } + + if (!IsDefaultPreset) + { + if (Service.Configuration.HookPresets.DefaultPreset.ExtraCfg.Enabled && !config.Enabled) + ImGui.TextColored(ImGuiColors.DalamudViolet, UIStrings.Default_Extra_Being_Used); + else if (!config.Enabled) + ImGui.TextColored(ImGuiColors.ParsedBlue, UIStrings.SubExtra_Disabled); + } + else + { + if (Service.Configuration.HookPresets.SelectedPreset?.ExtraCfg.Enabled ?? false) + ImGui.TextColored(ImGuiColors.DalamudViolet, + string.Format(UIStrings.Custom_Extra_Being_Used, Service.Configuration.HookPresets.SelectedPreset.PresetName)); + else if (!config.Enabled) + ImGui.TextColored(ImGuiColors.ParsedBlue, UIStrings.SubExtra_Disabled); + } + } + + public void DrawBody(ExtraConfig config) + { + ImGui.BeginGroup(); + ImGui.Spacing(); + if (ImGui.TreeNodeEx(UIStrings.When_gaining_fishers_intuition, ImGuiTreeNodeFlags.FramePadding)) + { + ImGui.PushID("gaining_intuition"); + ImGui.Spacing(); + DrawSwapPresetIntuitionGain(config); + DrawSwapBaitIntuitionGain(config); + ImGui.PopID(); + ImGui.TreePop(); + } + + DrawUtil.SpacingSeparator(); + + if (ImGui.TreeNodeEx(UIStrings.When_losing_fishers_intuition, ImGuiTreeNodeFlags.FramePadding)) + { + ImGui.PushID("losing_intuition"); + ImGui.Spacing(); + DrawSwapPresetIntuitionLost(config); + DrawSwapBaitIntuitionLost(config); + ImGui.PopID(); + ImGui.TreePop(); + } + + DrawUtil.SpacingSeparator(); + + ImGui.EndGroup(); + } + + private void DrawSwapPresetIntuitionGain(ExtraConfig config) + { + ImGui.PushID("DrawSwapPresetIntuitionGain"); + DrawUtil.DrawCheckboxTree(UIStrings.Swap_Preset, ref config.SwapPresetIntuitionGain, + () => + { + DrawUtil.DrawComboSelector( + Service.Configuration.HookPresets.CustomPresets, + preset => preset.PresetName, + config.PresetToSwapIntuitionGain, + preset => config.PresetToSwapIntuitionGain = preset.PresetName); + } + ); + ImGui.PopID(); + } + + private void DrawSwapBaitIntuitionGain(ExtraConfig config) + { + ImGui.PushID("DrawSwapBaitIntuitionGain"); + DrawUtil.DrawCheckboxTree(UIStrings.Swap_Bait, ref config.SwapBaitIntuitionGain, + () => + { + DrawUtil.DrawComboSelector( + PlayerResources.Baits, + bait => bait.Name, + config.BaitToSwapIntuitionGain.Name, + bait => config.BaitToSwapIntuitionGain = bait); + } + ); + + ImGui.PopID(); + } + + private void DrawSwapPresetIntuitionLost(ExtraConfig config) + { + ImGui.PushID("DrawSwapPresetIntuitionLost"); + DrawUtil.DrawCheckboxTree(UIStrings.Swap_Preset, ref config.SwapPresetIntuitionLost, + () => + { + DrawUtil.DrawComboSelector( + Service.Configuration.HookPresets.CustomPresets, + preset => preset.PresetName, + config.PresetToSwapIntuitionLost, + preset => config.PresetToSwapIntuitionLost = preset.PresetName); + } + ); + ImGui.PopID(); + } + + private void DrawSwapBaitIntuitionLost(ExtraConfig config) + { + ImGui.PushID("DrawSwapBaitIntuitionLost"); + DrawUtil.DrawCheckboxTree(UIStrings.Swap_Bait, ref config.SwapBaitIntuitionLost, + () => + { + DrawUtil.DrawComboSelector( + PlayerResources.Baits, + bait => bait.Name, + config.BaitToSwapIntuitionLost.Name, + bait => config.BaitToSwapIntuitionLost = bait); + } + ); + + ImGui.PopID(); + } +} \ No newline at end of file diff --git a/AutoHook/Ui/SubTabFish.cs b/AutoHook/Ui/SubTabFish.cs index e97706f..e2ca7c9 100644 --- a/AutoHook/Ui/SubTabFish.cs +++ b/AutoHook/Ui/SubTabFish.cs @@ -36,7 +36,7 @@ public void DrawFishTab(PresetConfig presetCfg) var fish = _listOfFish[idx]; ImGui.PushID($"fishTab###{idx}"); - var count = HookingManager.FishingCounter.GetCount($"{fish.Fish.Name} {presetCfg.PresetName}"); + var count = HookingManager.FishingCounter.GetCount(fish.GetUniqueId()); var fishCount = count > 0 ? $"({UIStrings.Caught_Counter} {count})" : ""; if (ImGui.CollapsingHeader($"{fish.Fish.Name} {fishCount}###a{idx}")) { @@ -47,9 +47,7 @@ public void DrawFishTab(PresetConfig presetCfg) ImGui.Indent(); DrawFishSearchBar(fish); - ImGui.Spacing(); - ImGui.Separator(); - ImGui.Spacing(); + DrawUtil.SpacingSeparator(); DrawSurfaceSlapIdenticalCast(fish); ImGui.Spacing(); @@ -57,7 +55,7 @@ public void DrawFishTab(PresetConfig presetCfg) DrawMooch(fish); ImGui.Spacing(); - DrawSwapToBait(fish); + DrawSwapBait(fish); ImGui.Spacing(); DrawSwapPreset(fish); @@ -65,6 +63,9 @@ public void DrawFishTab(PresetConfig presetCfg) DrawStopAfter(fish); ImGui.Spacing(); + + /*DrawNeverRelease(fish); + ImGui.Spacing();*/ ImGui.Unindent(); } @@ -90,17 +91,18 @@ private void DrawDescription(List list) ImGui.SameLine(); ImGui.Text($"{UIStrings.Add_new_fish} ({list.Count})"); ImGui.SameLine(); - - var lastCatch = HookingManager.LastCatch; + ImGui.SameLine(); - if (ImGui.Button($"{UIStrings.AddLastCatch} {lastCatch.Name ?? "-"}")) + if (ImGui.Button($"{UIStrings.AddLastCatch} {Service.LastCatch.Name ?? "-"}")) { - if (list.All(x => x.Fish.Id != lastCatch.Id)) - { - list.Add(new FishConfig(lastCatch)); - Service.Save(); - } + if (Service.LastCatch.Id == 0 || Service.LastCatch.Id == -1) + return; + if (list.Any(x => x.Fish.Id == Service.LastCatch.Id)) + return; + + list.Add(new FishConfig(Service.LastCatch)); + Service.Save(); } } @@ -172,9 +174,9 @@ private void DrawMooch(FishConfig fishConfig) ImGui.PopID(); } - private void DrawSwapToBait(FishConfig fishConfig) + private void DrawSwapBait(FishConfig fishConfig) { - ImGui.PushID("DrawSwapToBait"); + ImGui.PushID("DrawSwapBait"); DrawUtil.DrawCheckboxTree(UIStrings.Swap_Bait, ref fishConfig.SwapBait, () => { @@ -238,7 +240,8 @@ private void DrawSwapPreset(FishConfig fishConfig) private void DrawStopAfter(FishConfig fishConfig) { ImGui.PushID("DrawStopAfter"); - DrawUtil.Checkbox("", ref fishConfig.StopAfterCaught); + if (DrawUtil.Checkbox("", ref fishConfig.StopAfterCaught)) + Service.Save(); ImGui.SameLine(); if (ImGui.TreeNodeEx(UIStrings.Stop_After_Caught, ImGuiTreeNodeFlags.FramePadding)) @@ -253,18 +256,18 @@ private void DrawStopAfter(FishConfig fishConfig) Service.Save(); } - if (ImGui.RadioButton(UIStrings.Stop_Casting, fishConfig.StopFishingStep == CatchSteps.None)) + if (ImGui.RadioButton(UIStrings.Stop_Casting, fishConfig.StopFishingStep == FishingSteps.None)) { - fishConfig.StopFishingStep = CatchSteps.None; + fishConfig.StopFishingStep = FishingSteps.None; Service.Save(); } ImGui.SameLine(); ImGuiComponents.HelpMarker(UIStrings.Auto_Cast_Stopped); - if (ImGui.RadioButton(UIStrings.Quit_Fishing, fishConfig.StopFishingStep == CatchSteps.Quitting)) + if (ImGui.RadioButton(UIStrings.Quit_Fishing, fishConfig.StopFishingStep == FishingSteps.Quitting)) { - fishConfig.StopFishingStep = CatchSteps.Quitting; + fishConfig.StopFishingStep = FishingSteps.Quitting; Service.Save(); } @@ -279,5 +282,17 @@ private void DrawStopAfter(FishConfig fishConfig) ImGui.PopID(); } + private void DrawNeverRelease(FishConfig fishConfig) + { + ImGui.PushID("DrawNeverRelease"); + + if (DrawUtil.Checkbox(UIStrings.NeverRelease, ref fishConfig.NeverRelease, UIStrings.NeverReleaseHelptext)) + { + Service.Save(); + } + + ImGui.PopID(); + } + public bool IsDefault { get; set; } } \ No newline at end of file diff --git a/AutoHook/Ui/TabConfigGuides.cs b/AutoHook/Ui/TabConfigGuides.cs index cad2592..eae0f76 100644 --- a/AutoHook/Ui/TabConfigGuides.cs +++ b/AutoHook/Ui/TabConfigGuides.cs @@ -53,14 +53,14 @@ public override void Draw() { if (ImGui.BeginTabBar(@"TabBarsConfig", ImGuiTabBarFlags.NoTooltip)) { - if (ImGui.BeginTabItem("Configs")) + if (ImGui.BeginTabItem(UIStrings.Draw_Configs)) { ImGui.Spacing(); DrawConfigs(); ImGui.EndTabItem(); } - if (ImGui.BeginTabItem("Guides")) + if (ImGui.BeginTabItem(UIStrings.Draw_Guides)) { ImGui.Spacing(); DrawGuides(); @@ -79,37 +79,96 @@ private void DrawConfigs() Service.Save(); } + ImGui.Spacing(); + ImGui.Separator(); + ImGui.Spacing(); + if (DrawUtil.Checkbox(UIStrings.Show_Chat_Logs, ref Service.Configuration.ShowChatLogs, UIStrings.Show_Chat_Logs_HelpText)) { Service.Save(); } - ImGui.TextWrapped(UIStrings.Delay_Between_Casts); - + ImGui.Spacing(); + ImGui.Separator(); + ImGui.Spacing(); + + DrawDelayHook(); + + DrawDelayCasts(); + + if (DrawUtil.Checkbox(UIStrings.Show_Current_Status_Header, ref Service.Configuration.ShowStatusHeader)) + { + Service.Save(); + } + } + + private static void DrawDelayHook() + { + ImGui.PushID("DrawDelayHook"); + ImGui.TextWrapped(UIStrings.Delay_when_hooking); ImGui.SetNextItemWidth(45 * ImGuiHelpers.GlobalScale); - if (ImGui.InputInt(UIStrings.DrawConfigs_Min_, ref Service.Configuration.DelayBetweenCastsMin, 0)) + if (ImGui.InputInt(UIStrings.DrawConfigs_Min_, ref Service.Configuration.DelayBetweenHookMin, 0)) { - if (Service.Configuration.DelayBetweenCastsMin < 1) - Service.Configuration.DelayBetweenCastsMin = 1; + if (Service.Configuration.DelayBetweenHookMin < 0) + Service.Configuration.DelayBetweenHookMin = 0; + else if (Service.Configuration.DelayBetweenHookMin > 9999) + Service.Configuration.DelayBetweenHookMin = 9999; + Service.Save(); } + ImGui.SameLine(); ImGui.SetNextItemWidth(45 * ImGuiHelpers.GlobalScale); - if (ImGui.InputInt(UIStrings.DrawConfigs_Max_, ref Service.Configuration.DelayBetweenCastsMax,0)) + if (ImGui.InputInt(UIStrings.DrawConfigs_Max_, ref Service.Configuration.DelayBetweenHookMax, 0)) { - if (Service.Configuration.DelayBetweenCastsMax < 1) - Service.Configuration.DelayBetweenCastsMax = 1; + if (Service.Configuration.DelayBetweenHookMax < 0) + Service.Configuration.DelayBetweenHookMax = 0; + else if (Service.Configuration.DelayBetweenHookMax > 9999) + Service.Configuration.DelayBetweenHookMax = 9999; Service.Save(); } + ImGui.Spacing(); + ImGui.Separator(); ImGui.Spacing(); - if (DrawUtil.Checkbox(UIStrings.Show_Current_Status_Header, ref Service.Configuration.ShowStatusHeader)) + ImGui.PopID(); + } + + private static void DrawDelayCasts() + { + ImGui.PushID("DrawDelayCasts"); + ImGui.TextWrapped(UIStrings.Delay_Between_Casts); + ImGui.SetNextItemWidth(45 * ImGuiHelpers.GlobalScale); + if (ImGui.InputInt(UIStrings.DrawConfigs_Min_, ref Service.Configuration.DelayBetweenCastsMin, 0)) { + if (Service.Configuration.DelayBetweenCastsMin < 0) + Service.Configuration.DelayBetweenCastsMin = 0; + else if (Service.Configuration.DelayBetweenCastsMin > 9999) + Service.Configuration.DelayBetweenCastsMin = 9999; + Service.Save(); } + + ImGui.SameLine(); + ImGui.SetNextItemWidth(45 * ImGuiHelpers.GlobalScale); + if (ImGui.InputInt(UIStrings.DrawConfigs_Max_, ref Service.Configuration.DelayBetweenCastsMax, 0)) + { + if (Service.Configuration.DelayBetweenCastsMax < 0) + Service.Configuration.DelayBetweenCastsMax = 0; + else if (Service.Configuration.DelayBetweenCastsMax > 9999) + Service.Configuration.DelayBetweenCastsMax = 9999; + + Service.Save(); + } + + ImGui.Spacing(); + ImGui.Separator(); + ImGui.Spacing(); + + ImGui.PopID(); } private void DrawGuides() diff --git a/AutoHook/Ui/TabCustomPresets.cs b/AutoHook/Ui/TabCustomPresets.cs index d48960e..d940e0c 100644 --- a/AutoHook/Ui/TabCustomPresets.cs +++ b/AutoHook/Ui/TabCustomPresets.cs @@ -22,6 +22,7 @@ public class TabCustomPresets : BaseTab private SubTabBaitMooch _subTabBaitMooch = new(); private SubTabAutoCast _subTabAutoCast = new(); private SubTabFish _subTabFish = new(); + private SubTabExtra _subTabExtra = new(); private bool _showDescription; @@ -87,11 +88,16 @@ public override void Draw() _subTabFish.DrawFishTab(_hookPresets.SelectedPreset); ImGui.EndTabItem(); } + + if (ImGui.BeginTabItem(UIStrings.Extra)) + { + _subTabExtra.DrawExtraTab(_hookPresets.SelectedPreset.ExtraCfg); + ImGui.EndTabItem(); + } if (ImGui.BeginTabItem(UIStrings.Auto_Casts)) { _subTabAutoCast.DrawAutoCastTab(_hookPresets.SelectedPreset.AutoCastsCfg); - ImGui.EndTabItem(); } @@ -146,6 +152,7 @@ private void DrawEditPresetName() ImGui.CloseCurrentPopup(); Service.Save(); } + ImGui.EndPopup(); } diff --git a/AutoHook/Ui/TabDefaultPreset.cs b/AutoHook/Ui/TabDefaultPreset.cs index e9a35b4..9193e83 100644 --- a/AutoHook/Ui/TabDefaultPreset.cs +++ b/AutoHook/Ui/TabDefaultPreset.cs @@ -11,6 +11,7 @@ internal class TabDefaultPreset : BaseTab private SubTabBaitMooch _subTabBaitMooch = new(); private SubTabAutoCast _subTabAutoCast = new(); private SubTabFish _subTabFish = new(); + private SubTabExtra _subTabExtra = new(); private bool _showDescription = true; @@ -68,6 +69,13 @@ public override void Draw() _subTabFish.DrawFishTab(preset); ImGui.EndTabItem(); } + + if (ImGui.BeginTabItem(UIStrings.Extra)) + { + _subTabExtra.IsDefaultPreset = true; + _subTabExtra.DrawExtraTab(preset.ExtraCfg); + ImGui.EndTabItem(); + } if (ImGui.BeginTabItem($"{UIStrings.Auto_Casts}")) { diff --git a/AutoHook/Utils/DrawUtil.cs b/AutoHook/Utils/DrawUtil.cs index 7ee3c5e..7695f8d 100644 --- a/AutoHook/Utils/DrawUtil.cs +++ b/AutoHook/Utils/DrawUtil.cs @@ -72,24 +72,6 @@ public static bool Checkbox(string label, ref bool refValue, string helpText = " return clicked; } - - public static void CompleteIncomplete(bool complete) - { - ConditionalText(complete, UIStrings.Complete, UIStrings.Incomplete); - } - - public static void ConditionalText(bool condition, string trueString, string falseString) - { - if (condition) - { - ImGui.TextColored(new Vector4(0, 255, 0, 0.8f), trueString); - } - else - { - ImGui.TextColored(new Vector4(185, 0, 0, 0.8f), falseString); - } - } - public static void DrawWordWrappedString(string message) { var words = message.Split(' '); @@ -195,4 +177,11 @@ public static void DrawCheckboxTree(string treeName, ref bool enable, Action act ImGui.TreePop(); } } + + public static void SpacingSeparator() + { + ImGui.Spacing(); + ImGui.Separator(); + ImGui.Spacing(); + } } \ No newline at end of file diff --git a/AutoHook/Utils/PlayerResources.cs b/AutoHook/Utils/PlayerResources.cs index d9e0a01..59d973e 100644 --- a/AutoHook/Utils/PlayerResources.cs +++ b/AutoHook/Utils/PlayerResources.cs @@ -13,16 +13,13 @@ namespace AutoHook.Utils; public class PlayerResources : IDisposable { - private static unsafe ActionManager* _actionManager = ActionManager.Instance(); - public static List Baits { get; set; } = new(); public static List Fishes { get; set; } = new(); public void Initialize() { - Service.GameInteropProvider.InitializeFromAttributes(this); + //Service.GameInteropProvider.InitializeFromAttributes(this); - Baits = Service.DataManager.GetExcelSheet()? .Where(i => i.ItemSearchCategory.Row == BaitFishClass.FishingTackleRow) .Select(b => new BaitFishClass(b)) @@ -48,7 +45,7 @@ public static bool IsMoochAvailable() if (ActionTypeAvailable(IDs.Actions.Mooch)) return true; - else if (ActionTypeAvailable(IDs.Actions.Mooch2)) + if (ActionTypeAvailable(IDs.Actions.Mooch2)) return true; return false; @@ -131,25 +128,26 @@ public static unsafe bool ActionOnCoolDown(uint id, ActionType actionType = Acti if (group == -1) // Im assuming -1 recast group has no CD return false; - var recastDetail = _actionManager->GetRecastGroupDetail(group); + var recastDetail = ActionManager.Instance()->GetRecastGroupDetail(group); return recastDetail->Total - recastDetail->Elapsed > 0; } public static unsafe uint ActionStatus(uint id, ActionType actionType = ActionType.Action) - => _actionManager->GetActionStatus(actionType, id); + { + return ActionManager.Instance()->GetActionStatus(actionType, id); + } public static unsafe bool CastAction(uint id, ActionType actionType = ActionType.Action) { - if (_actionManager == null) - _actionManager = ActionManager.Instance(); - - return _actionManager->UseAction(actionType, id); + return ActionManager.Instance()->UseAction(actionType, id); } public static unsafe int GetRecastGroups(uint id, ActionType actionType = ActionType.Action) - => _actionManager->GetRecastGroup((int)actionType, id); + { + return ActionManager.Instance()->GetRecastGroup((int)actionType, id); + } public static unsafe void UseItems(uint id) { @@ -159,15 +157,12 @@ public static unsafe void UseItems(uint id) // RecastGroup 68 = Cordial pots public static unsafe bool IsPotOffCooldown() { - var recast = _actionManager->GetRecastGroupDetail(68); + var recast = ActionManager.Instance()->GetRecastGroupDetail(68); return recast->Total - recast->Elapsed == 0; } public static unsafe uint CastActionCost(uint id, ActionType actionType = ActionType.Action) { - if (_actionManager == null) - _actionManager = ActionManager.Instance(); - return (uint)ActionManager.GetActionCost(actionType, id, 0, 0, 0, 0); } @@ -178,7 +173,7 @@ public static unsafe float GetCooldown(uint id, ActionType actionType) if (group == -1) // Im assuming -1 recast group has no CD return 0; - var recast = _actionManager->GetRecastGroupDetail(group); + var recast = ActionManager.Instance()->GetRecastGroupDetail(group); return recast->Total - recast->Elapsed; }