Skip to content

Commit

Permalink
added condition
Browse files Browse the repository at this point in the history
also changed GetStatusTime to be generic so as to not clog player resources with a method for each
  • Loading branch information
Jaksuhn committed Feb 7, 2024
1 parent 371979c commit b018859
Show file tree
Hide file tree
Showing 4 changed files with 7 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
2 changes: 1 addition & 1 deletion AutoHook/Classes/AutoCasts/AutoPatience.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,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
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 b018859

Please sign in to comment.