Skip to content

Commit

Permalink
Merge pull request Nik-Potokar#1409 from Taurenkey/main
Browse files Browse the repository at this point in the history
More CD fixes
  • Loading branch information
Taurenkey authored Jul 1, 2024
2 parents 6af334f + 9ae6830 commit 0cdc97a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
17 changes: 5 additions & 12 deletions XIVSlothCombo/Data/CooldownData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FFXIVClientStructs.FFXIV.Client.Game;
using System;
using XIVSlothCombo.Services;

namespace XIVSlothCombo.Data
Expand All @@ -10,27 +11,25 @@ public bool IsCooldown
{
get
{
return RemainingCharges == MaxCharges
? false
: CooldownElapsed < CooldownTotal;
return CooldownRemaining > 0;
}
}

/// <summary> Gets the action ID on cooldown. </summary>
public uint ActionID;

/// <summary> Gets the elapsed cooldown time. </summary>
public unsafe float CooldownElapsed => ActionManager.Instance()->GetRecastGroupDetail(ActionManager.Instance()->GetRecastGroup(1, ActionID))->Elapsed;
public unsafe float CooldownElapsed => ActionManager.Instance()->GetRecastTimeElapsed(ActionType.Action, ActionID);

/// <summary> Gets the total cooldown time. </summary>
public unsafe float CooldownTotal => (ActionManager.GetAdjustedRecastTime(ActionType.Action, ActionID) / 1000f) * MaxCharges;

/// <summary> Gets the cooldown time remaining. </summary>
public unsafe float CooldownRemaining => IsCooldown ? CooldownTotal - CooldownElapsed : 0;
public unsafe float CooldownRemaining => CooldownElapsed == 0 ? 0 : Math.Max(0, CooldownTotal - CooldownElapsed);

/// <summary> Gets the maximum number of charges for an action at the current level. </summary>
/// <returns> Number of charges. </returns>
public ushort MaxCharges => Service.ComboCache.GetMaxCharges(ActionID);
public ushort MaxCharges => ActionManager.GetMaxCharges(ActionID, 0);

/// <summary> Gets a value indicating whether the action has charges, not charges available. </summary>
public bool HasCharges => MaxCharges > 1;
Expand All @@ -43,12 +42,6 @@ public float ChargeCooldownRemaining
{
get
{
if (!IsCooldown)
return 0;

var maxCharges = ActionManager.GetMaxCharges(ActionID, 100);
var timePerCharge = CooldownTotal / maxCharges;

return CooldownRemaining % (CooldownTotal / MaxCharges);
}
}
Expand Down
2 changes: 1 addition & 1 deletion XIVSlothCombo/Data/CustomComboCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ internal unsafe CooldownData GetCooldown(uint actionID)
/// <summary> Get the maximum number of charges for an action. </summary>
/// <param name="actionID"> Action ID to check. </param>
/// <returns> Max number of charges at current level. </returns>
internal unsafe ushort GetMaxCharges(uint actionID) => ActionManager.GetMaxCharges(actionID, 0);
internal unsafe ushort GetMaxCharges(uint actionID) => GetCooldown(actionID).MaxCharges;

/// <summary> Get the resource cost of an action. </summary>
/// <param name="actionID"> Action ID to check. </param>
Expand Down

0 comments on commit 0cdc97a

Please sign in to comment.