Skip to content

Commit

Permalink
Merge branch 'main' into auto-collector's-glove
Browse files Browse the repository at this point in the history
  • Loading branch information
InitialDet authored Feb 7, 2024
2 parents 59aacf2 + 3bf057b commit db1737b
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 83 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>3.0.2.0</Version>
<Version>3.0.3.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/Classes/AutoCasts/AutoChum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override bool CastCondition()
if (!hasIntuition && _onlyUseWithIntuition)
return false;

if (hasIntuition && _onlyUseWithIntuition && PlayerResources.GetIntuitionTimeRemaining() <= _useWhenIntuitionExceeds)
if (hasIntuition && _onlyUseWithIntuition && PlayerResources.GetStatusTime(IDs.Status.FishersIntuition) <= _useWhenIntuitionExceeds)
return false;

return true;
Expand Down
5 changes: 3 additions & 2 deletions AutoHook/Classes/AutoCasts/AutoFood.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AutoHook.Resources.Localization;
using AutoHook.Data;
using AutoHook.Resources.Localization;
using AutoHook.Utils;
using FFXIVClientStructs.FFXIV.Client.Game;

Expand All @@ -17,7 +18,7 @@ public override string GetName()

public override bool CastCondition()
{
if (PlayerResources.GetStatusTime() > SecondsRemaining)
if (PlayerResources.GetStatusTime(IDs.Status.FoodBuff) > SecondsRemaining)
{
return false;
}
Expand Down
11 changes: 10 additions & 1 deletion AutoHook/Classes/AutoCasts/AutoPatience.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
using AutoHook.Utils;
using FFXIVClientStructs.FFXIV.Client.Game;
using ImGuiNET;
using System;

namespace AutoHook.Classes.AutoCasts;

public class AutoPatience : BaseActionCast
{
public bool EnableMakeshiftPatience;
public int RefreshEarlyTime = 0;

public AutoPatience() : base(UIStrings.AutoPatience_Patience, Data.IDs.Actions.Patience2, ActionType.Action)
{
Expand All @@ -21,7 +23,7 @@ public override string GetName()

public override bool CastCondition()
{
if (PlayerResources.HasStatus(IDs.Status.AnglersFortune))
if (PlayerResources.HasStatus(IDs.Status.AnglersFortune) && PlayerResources.GetStatusTime(IDs.Status.AnglersFortune) > RefreshEarlyTime)
return false;

if (PlayerResources.HasStatus(IDs.Status.PrizeCatch))
Expand Down Expand Up @@ -51,5 +53,12 @@ public override bool CastCondition()
Id = IDs.Actions.Patience2;
Service.Save();
}
var time = RefreshEarlyTime;
if (DrawUtil.EditNumberField(UIStrings.RefreshWhenTimeIsLessThanOrEqual, ref time))
{
RefreshEarlyTime = Math.Max(0, Math.Min(time, 999));
Service.Save();
}
};
}
2 changes: 1 addition & 1 deletion AutoHook/IPC/AutoHookIPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ private static void SetPreset(string preset)

private static void CreateAndSelectAnonymousPreset(string preset)
{
var name = $"anon_{preset}";
var _import = Configuration.ImportActionStack(preset);
if (_import == null) return;
var name = $"anon_{_import.PresetName}";
_import.RenamePreset(name);
Service.Configuration.HookPresets.AddPreset(_import);
Service.Configuration.HookPresets.SelectedPreset = Service.Configuration.HookPresets.CustomPresets.FirstOrDefault(x => x.PresetName == name);
Expand Down
14 changes: 14 additions & 0 deletions AutoHook/PluginUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ public static class PluginChangeLog
{
public static readonly List<Version> Versions = new()
{
new Version("3.0.3.0")
{
MainChanges =
{
"(by Jaksuhn) Added swap preset/bait on Spectral Currents",
"(by Jaksuhn) Added more Surface Slap options",
"(by Jaksuhn) Added option to chum only when intution duration is greater than x seconds",
},
MinorChanges =
{
"Fixed an issue with swapping both preset and bait at the same time",
"More IPC options"
}
},
new Version("3.0.2.0")
{
MainChanges =
Expand Down
19 changes: 18 additions & 1 deletion AutoHook/Resources/Localization/UIStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions AutoHook/Resources/Localization/UIStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ This could save you 100gp if going only for mooches</value>
<data name="Surface_Slap" xml:space="preserve">
<value>Surface Slap</value>
</data>
<data name="Surface_Slap_Options" xml:space="preserve">
<value>Surface Slap Options</value>
</data>
<data name="Identical_Cast" xml:space="preserve">
<value>Identical Cast</value>
</data>
Expand Down Expand Up @@ -892,4 +895,7 @@ Check the Guide Tab for Guides.</value>
<data name="Collect" xml:space="preserve">
<value>Collect</value>
</data>
<data name="RefreshWhenTimeIsLessThanOrEqual" xml:space="preserve">
<value>Refresh when buff timer is less than or equal to</value>
</data>
</root>
112 changes: 52 additions & 60 deletions AutoHook/Ui/SubTabBaitMooch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,24 @@ private void DrawSelectTugs(string hook, ref bool enabled, ref HookType type, re
}

ImGui.Spacing();

if (DrawUtil.Checkbox(UIStrings.OnlyUseWhenActiveSurfaceSlap, ref hookOnlyWhenActiveSlap))
if (ImGui.TreeNodeEx(UIStrings.Surface_Slap_Options, ImGuiTreeNodeFlags.FramePadding))
{
hookOnlyWhenNOTActiveSlap = false;
Service.Save();
}
if (DrawUtil.Checkbox(UIStrings.OnlyUseWhenActiveSurfaceSlap, ref hookOnlyWhenActiveSlap))
{
hookOnlyWhenNOTActiveSlap = false;
Service.Save();
}

if (DrawUtil.Checkbox(UIStrings.OnlyUseWhenNOTActiveSurfaceSlap, ref hookOnlyWhenNOTActiveSlap))
{
hookOnlyWhenActiveSlap = false;
Service.Save();
if (DrawUtil.Checkbox(UIStrings.OnlyUseWhenNOTActiveSurfaceSlap, ref hookOnlyWhenNOTActiveSlap))
{
hookOnlyWhenActiveSlap = false;
Service.Save();
}

ImGui.TreePop();
}

ImGui.TreePop();
}

Expand Down Expand Up @@ -238,65 +243,52 @@ private void DrawInputDoubleMinTime(HookConfig hookConfig)

private void DrawChumMinMaxTime(HookConfig hookConfig)
{
if (ImGui.Button(UIStrings.ChumTimer))
{
ImGui.OpenPopup(str_id: "chum_timer");
}

if (ImGui.BeginPopup("chum_timer"))
{
ImGui.Spacing();
if (DrawUtil.Checkbox(UIStrings.EnableChumTimers, ref hookConfig.UseChumTimer,
UIStrings.EnableChumTimersHelpMarker))
DrawUtil.DrawCheckboxTree(UIStrings.EnableChumTimers, ref hookConfig.UseChumTimer,
() =>
{
Service.Save();
}

ImGui.Separator();

ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
if (ImGui.InputDouble(UIStrings.MinWait, ref hookConfig.MinChumTimeDelay, .1, 1, "%.1f%"))
{
switch (hookConfig.MinChumTimeDelay)
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
if (ImGui.InputDouble(UIStrings.MinWait, ref hookConfig.MinChumTimeDelay, .1, 1, "%.1f%"))
{
case <= 0:
hookConfig.MinChumTimeDelay = 0;
break;
case > 99:
hookConfig.MinChumTimeDelay = 99;
break;
switch (hookConfig.MinChumTimeDelay)
{
case <= 0:
hookConfig.MinChumTimeDelay = 0;
break;
case > 99:
hookConfig.MinChumTimeDelay = 99;
break;
}
Service.Save();
}
Service.Save();
}
ImGui.SameLine();
ImGuiComponents.HelpMarker(UIStrings.HelpMarkerMinWaitTimer);
ImGui.SameLine();
ImGuiComponents.HelpMarker(UIStrings.HelpMarkerMinWaitTimer);
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
if (ImGui.InputDouble(UIStrings.MaxWait, ref hookConfig.MaxChumTimeDelay, .1, 1, "%.1f%"))
{
switch (hookConfig.MaxChumTimeDelay)
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
if (ImGui.InputDouble(UIStrings.MaxWait, ref hookConfig.MaxChumTimeDelay, .1, 1, "%.1f%"))
{
case 0.1:
hookConfig.MaxChumTimeDelay = 2;
break;
case <= 0:
case <= 1.9: //This makes the option turn off if delay = 2 seconds when clicking the minus.
hookConfig.MaxChumTimeDelay = 0;
break;
case > 99:
hookConfig.MaxChumTimeDelay = 99;
break;
switch (hookConfig.MaxChumTimeDelay)
{
case 0.1:
hookConfig.MaxChumTimeDelay = 2;
break;
case <= 0:
case <= 1.9: //This makes the option turn off if delay = 2 seconds when clicking the minus.
hookConfig.MaxChumTimeDelay = 0;
break;
case > 99:
hookConfig.MaxChumTimeDelay = 99;
break;
}
Service.Save();
}
Service.Save();
}

ImGui.SameLine();
ImGuiComponents.HelpMarker(UIStrings.HelpMarkerMaxWaitTimer);
ImGui.SameLine();
ImGui.EndPopup();
}
ImGuiComponents.HelpMarker(UIStrings.HelpMarkerMaxWaitTimer);
}
, UIStrings.EnableChumTimersHelpMarker);

}

private void DrawEnabledButtonCustomBait(HookConfig hookConfig)
Expand Down
18 changes: 2 additions & 16 deletions AutoHook/Utils/PlayerResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,28 +98,14 @@ public static bool HasAnglersArtStacks(int amount)
return false;
}

public static float GetStatusTime()
public static float GetStatusTime(uint statusId)
{
if (Service.ClientState.LocalPlayer?.StatusList == null)
return 0;

foreach (var buff in Service.ClientState.LocalPlayer.StatusList)
{
if (buff.StatusId == IDs.Status.FoodBuff)
return buff.RemainingTime;
}

return 0;
}

public static float GetIntuitionTimeRemaining()
{
if (Service.ClientState.LocalPlayer?.StatusList == null)
return 0;

foreach (var buff in Service.ClientState.LocalPlayer.StatusList)
{
if (buff.StatusId == IDs.Status.FishersIntuition)
if (buff.StatusId == statusId)
return buff.RemainingTime;
}

Expand Down

0 comments on commit db1737b

Please sign in to comment.