Skip to content

Commit

Permalink
Merge pull request #157 from Jaksuhn/refresh-patience
Browse files Browse the repository at this point in the history
option to refresh patience early
  • Loading branch information
InitialDet authored Feb 7, 2024
2 parents be5536d + b018859 commit 3bf057b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
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();
}
};
}
9 changes: 9 additions & 0 deletions AutoHook/Resources/Localization/UIStrings.Designer.cs

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

3 changes: 3 additions & 0 deletions AutoHook/Resources/Localization/UIStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -892,4 +892,7 @@ Check the Guide Tab for Guides.</value>
<data name="OnlyUseWhenNOTActiveSurfaceSlap" xml:space="preserve">
<value>Only use when Surface Slap is not active</value>
</data>
<data name="RefreshWhenTimeIsLessThanOrEqual" xml:space="preserve">
<value>Refresh when buff timer is less than or equal to</value>
</data>
</root>
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 3bf057b

Please sign in to comment.