Skip to content

Commit

Permalink
AutoHook 2.2.2.0 [PUSH]
Browse files Browse the repository at this point in the history
- Added an option to not cancel current mooch when using Auto Casts
- Fixed an issue with "Stop Fishing After"
  • Loading branch information
InitialDet committed Jul 30, 2022
1 parent bf8be74 commit 73e9bd0
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion AutoHook/AutoHook.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Det</Authors>
<Version>2.2.1.1</Version>
<Version>2.2.2.0</Version>
<Description>Auto hooks for you</Description>
<PackageProjectUrl>https://github.com/InitialDet/AutoHook</PackageProjectUrl>
<Configurations>Release;Debug</Configurations>
Expand Down
2 changes: 1 addition & 1 deletion AutoHook/AutoHook.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
}
11 changes: 11 additions & 0 deletions AutoHook/Configurations/AutoCastsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -194,6 +196,9 @@ private bool UsePrizeCatch()
if (!EnablePrizeCatch)
return false;

if (IsMoochAvailable() && DontCancelMooch)
return false;

if (PlayerResources.HasStatus(IDs.Status.MakeshiftBait))
return false;

Expand All @@ -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);
}

Expand Down
25 changes: 19 additions & 6 deletions AutoHook/HookManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace AutoHook.FishTimer;

// all credits to Otter (goat discord) for his gatherbuddy plugin
public class HookingManager : IDisposable
{
private HookConfig? CurrentSetting;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion AutoHook/SeFunctions/SeFunctionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public SeFunctionBase(SigScanner sigScanner, string signature, int offset = 0)
{
if (Address != IntPtr.Zero)
{
var hook = new Hook<T>(Address, detour);
var hook = Hook<T>.FromAddress(Address, detour);
hook.Enable();
return hook;
}
Expand Down
11 changes: 10 additions & 1 deletion AutoHook/Ui/AutoCastsTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"))
{ }
}

Expand Down

0 comments on commit 73e9bd0

Please sign in to comment.