Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
JustUsed working for charges
Browse files Browse the repository at this point in the history
  • Loading branch information
Taurenkey committed Aug 10, 2024
1 parent 9412759 commit ac2e6b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion XIVSlothCombo/CustomCombo/Functions/Cooldown.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using System;
using XIVSlothCombo.Data;
using XIVSlothCombo.Services;

Expand Down Expand Up @@ -40,7 +41,7 @@ internal abstract partial class CustomComboFunctions
/// <param name="actionID"> Action ID to check. </param>
/// <param name="variance"> Variance of how long to check the elapsed cooldown</param>
/// <returns> True or false. </returns>
public static bool JustUsed(uint actionID, float variance = 3f) => IsOnCooldown(actionID) && GetCooldownElapsed(actionID) <= variance;
public static bool JustUsed(uint actionID, float variance = 3f) => GetMaxCharges(actionID) == 0 ? IsOnCooldown(actionID) && GetCooldownElapsed(actionID) <= variance : ActionWatching.ChargeTimestamps.ContainsKey(actionID) ? (Environment.TickCount64 - ActionWatching.ChargeTimestamps[actionID]) / 1000f <= variance : false;

/// <summary> Gets a value indicating whether an action has any available charges. </summary>
/// <param name="actionID"> Action ID to check. </param>
Expand Down
7 changes: 6 additions & 1 deletion XIVSlothCombo/Data/ActionWatching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public static class ActionWatching

private static readonly Dictionary<string, List<uint>> statusCache = [];

internal static readonly Dictionary<uint, long> ChargeTimestamps = [];

internal readonly static List<uint> CombatActions = [];

private delegate void ReceiveActionEffectDelegate(ulong sourceObjectId, IntPtr sourceActor, IntPtr position, IntPtr effectHeader, IntPtr effectArray, IntPtr effectTrail);
Expand All @@ -42,7 +44,7 @@ private static void ReceiveActionEffectDetour(ulong sourceObjectId, IntPtr sourc
if (!CustomComboFunctions.InCombat()) CombatActions.Clear();
ReceiveActionEffectHook!.Original(sourceObjectId, sourceActor, position, effectHeader, effectArray, effectTrail);
ActionEffectHeader header = Marshal.PtrToStructure<ActionEffectHeader>(effectHeader);

if (ActionType is 13 or 2) return;
if (header.ActionId != 7 &&
header.ActionId != 8 &&
Expand Down Expand Up @@ -87,6 +89,9 @@ private unsafe static void SendActionDetour(ulong targetObjectId, byte actionTyp
{
try
{
if (CustomComboFunctions.GetMaxCharges(actionId) > 0)
ChargeTimestamps[actionId] = Environment.TickCount64;

CheckForChangedTarget(actionId, ref targetObjectId);
SendActionHook!.Original(targetObjectId, actionType, actionId, sequence, a5, a6, a7, a8, a9);
TimeLastActionUsed = DateTime.Now;
Expand Down

0 comments on commit ac2e6b6

Please sign in to comment.