Skip to content

Commit

Permalink
AutoHook 2.2.2.4 [PUSH]
Browse files Browse the repository at this point in the history
Added #24
  • Loading branch information
InitialDet committed Aug 15, 2022
1 parent 4383096 commit 2feb915
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 21 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.2.3</Version>
<Version>2.2.2.4</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": "- Trying to add support for CN server \n- Fixing problems with collectable fish"
"Changelog": "- Trying to add support for CN server \n- Fixing problems with collectable fish\n- Added a new option to use Double/Triple Hooks only when Identical Cast is Enabled"
}
46 changes: 40 additions & 6 deletions AutoHook/Configurations/HookConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using AutoHook.Data;
using AutoHook.Enums;
using AutoHook.Utils;
using Dalamud.Logging;

namespace AutoHook.Configurations;

Expand Down Expand Up @@ -37,6 +38,9 @@ public class HookConfig
public bool UseDoubleHook = false;
public bool UseTripleHook = false;
public bool UseDHTHPatience = false;
public bool UseDHTHOnlySurfaceSlap = false;
public bool OnlyUseDHTH = false;


public double MaxTimeDelay = 0;
public double MinTimeDelay = 0;
Expand All @@ -49,7 +53,7 @@ public HookConfig(string bait)
BaitName = bait;
}

public HookType GetHook(BiteType bite)
public HookType? GetHook(BiteType bite)
{
bool hasIntuition = PlayerResources.HasStatus(IDs.Status.FishersIntuition);

Expand All @@ -72,6 +76,21 @@ public HookType GetHook(BiteType bite)
return GetPatienceHook(bite);
}

public HookType? GetHookIgnoreEnable(BiteType bite)
{
bool hasIntuition = PlayerResources.HasStatus(IDs.Status.FishersIntuition);

var hook = GetDoubleTripleHook(bite);

if (hook == null || hook != HookType.None)
return hook;

if (hasIntuition)
return GetIntuitionHook(bite);
else
return GetPatienceHook(bite);
}

public bool CheckHookEnabled(BiteType bite) =>
bite == BiteType.Weak ? HookWeakEnabled :
bite == BiteType.Strong ? HookStrongEnabled :
Expand Down Expand Up @@ -101,18 +120,33 @@ public bool CheckHookIntuitionEnabled(BiteType bite) =>
_ => HookType.None,
};

private HookType GetDoubleTripleHook(BiteType bite)
private HookType? GetDoubleTripleHook(BiteType bite)
{
HookType hook = HookType.None;

if (PlayerResources.HasStatus(IDs.Status.AnglersFortune) && !UseDHTHPatience)
return hook;

if (UseDoubleHook && PlayerResources.GetCurrentGP() >= 400)
hook = HookType.Double;
else if (UseTripleHook && PlayerResources.GetCurrentGP() >= 700)
hook = HookType.Triple;
if (UseDHTHOnlySurfaceSlap && !PlayerResources.HasStatus(IDs.Status.IdenticalCast))
return hook;


if (UseDoubleHook)
{
if (PlayerResources.GetCurrentGP() >= 400)
hook = HookType.Double;
else if (OnlyUseDHTH)
return null;
}

else if (UseTripleHook)
{
if (PlayerResources.GetCurrentGP() >= 700)
hook = HookType.Triple;
else if (OnlyUseDHTH)
return null;
}

return hook;
}

Expand Down
1 change: 1 addition & 0 deletions AutoHook/Data/IDs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static class Status
{
public const uint
FishersIntuition = 568,
IdenticalCast = 1804,

AnglersFortune = 850,

Expand Down
21 changes: 15 additions & 6 deletions AutoHook/HookManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private void UnSubscribeToParser()
// The current config is updates two times: When we began fishing (to get the config based on the mooch/bait) and when we hooked the fish (in case the user updated their configs).
private void UpdateCurrentSetting()
{
CurrentSetting = HookSettings.FirstOrDefault(mooch => mooch.BaitName.Equals(CurrentBait));
if (CurrentSetting == null)
CurrentSetting = HookSettings.FirstOrDefault(mooch => mooch.BaitName.Equals(CurrentBait));

if (CurrentSetting == null)
{
Expand Down Expand Up @@ -136,7 +137,6 @@ private void OnCatch(string fishName, uint fishId)

LastStep = CatchSteps.FishCaught;


// Check if should stop with the current bait/mooch
if (CurrentSetting != null && CurrentSetting.StopAfterCaught) {
int total = FishCounter.Add(CurrentSetting.BaitName);
Expand Down Expand Up @@ -183,7 +183,6 @@ private void OnFrameworkUpdate(Framework _)
if (!cfg.PluginEnabled || state == FishingState.None)
return;


if (state != FishingState.Quit && LastStep == CatchSteps.Quitting) {
PlayerResources.CastActionDelayed(IDs.Actions.Quit);
state = FishingState.Quit;
Expand All @@ -196,7 +195,6 @@ private void OnFrameworkUpdate(Framework _)
}

//CheckState();

if (state == FishingState.Waiting2)
CheckMaxTimeLimit();

Expand Down Expand Up @@ -228,9 +226,20 @@ private unsafe void HookFish(BiteType bite)
if (!CheckMinTimeLimit())
return;

HookType hook = CurrentSetting.GetHook(bite);
HookType? hook = null;

if (PlayerResources.HasStatus(IDs.Status.IdenticalCast))
{
var IdenticalCast = HookSettings.FirstOrDefault(mooch => mooch.BaitName.Equals(LastCatch));
if (IdenticalCast != null)
hook = IdenticalCast.GetHookIgnoreEnable(bite);
else
hook = CurrentSetting.GetHook(bite);
}
else
hook = CurrentSetting.GetHook(bite);

if (hook == HookType.None)
if (hook == null || hook == HookType.None)
return;

if (PlayerResources.ActionAvailable((uint)hook)) // Check if Powerful/Precision is available
Expand Down
9 changes: 3 additions & 6 deletions AutoHook/Ui/GeneralTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,24 @@ internal class GeneralTab : TabConfig
public override bool Enabled => true;
public override string TabName => "General";


public override void DrawHeader()
{
ImGui.Text("General settings");

ImGui.Separator();
ImGui.Spacing();
if (ImGui.Button("Please report any issue you encounter."))
if (ImGui.Button("Click here to report an issue or make an suggestion"))
{
Process.Start(new ProcessStartInfo { FileName = "https://github.com/InitialDet/AutoHook/issues", UseShellExecute = true });
}
ImGui.Spacing();


#if DEBUG

if (ImGui.Button("Testing"))
{
PluginLog.Debug($"Pot CD = {PlayerResources.GetPotCooldown()}, is it out of cd? {PlayerResources.IsPotOffCooldown()}");
PluginLog.Debug($"RecastGorup: {PlayerResources.GetRecastGroups(6141, ActionType.Item)}");

PluginLog.Debug($"IdenticalCast = {PlayerResources.HasStatus(IDs.Status.IdenticalCast)}");

}
#endif
}
Expand Down
9 changes: 8 additions & 1 deletion AutoHook/Ui/TabConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ public void DrawCheckBoxDoubleTripleHook(HookConfig cfg)

ImGui.TextColored(ImGuiColors.DalamudYellow, "Double/Triple Hook Settings");
ImGui.Spacing();

ImGui.Checkbox("Only use when Identical Cast is active", ref cfg.UseDHTHOnlySurfaceSlap);
ImGui.Spacing();
ImGui.Separator();
ImGui.Spacing();

if (ImGui.Checkbox("Use Double Hook (If gp > 400)", ref cfg.UseDoubleHook))
{
if (cfg.UseDoubleHook) cfg.UseTripleHook = false;
Expand All @@ -166,8 +172,9 @@ public void DrawCheckBoxDoubleTripleHook(HookConfig cfg)
ImGui.Indent();


ImGui.Checkbox("Also use when Patience is active (not recommended)", ref cfg.UseDHTHPatience);
ImGui.Checkbox("Use when Patience is active (not recommended)", ref cfg.UseDHTHPatience);
ImGuiComponents.HelpMarker("Important!!!\n\nIf disabled, Precision/Powerful hook will be used instead when Patience is up.");
ImGui.Checkbox("Let the fish escape if GP is below the required", ref cfg.OnlyUseDHTH);
ImGui.Unindent();
}

Expand Down

0 comments on commit 2feb915

Please sign in to comment.