From b309d87e479c826b343164da7bc08aef884ee038 Mon Sep 17 00:00:00 2001 From: Taurenkey Date: Mon, 1 Jul 2024 21:24:47 +0100 Subject: [PATCH 1/2] Fix more CD data issues --- XIVSlothCombo/Data/CooldownData.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/XIVSlothCombo/Data/CooldownData.cs b/XIVSlothCombo/Data/CooldownData.cs index 3a370d8e1..391fc75f5 100644 --- a/XIVSlothCombo/Data/CooldownData.cs +++ b/XIVSlothCombo/Data/CooldownData.cs @@ -1,4 +1,5 @@ using FFXIVClientStructs.FFXIV.Client.Game; +using System; using XIVSlothCombo.Services; namespace XIVSlothCombo.Data @@ -10,9 +11,7 @@ public bool IsCooldown { get { - return RemainingCharges == MaxCharges - ? false - : CooldownElapsed < CooldownTotal; + return CooldownRemaining > 0; } } @@ -20,13 +19,13 @@ public bool IsCooldown public uint ActionID; /// Gets the elapsed cooldown time. - public unsafe float CooldownElapsed => ActionManager.Instance()->GetRecastGroupDetail(ActionManager.Instance()->GetRecastGroup(1, ActionID))->Elapsed; + public unsafe float CooldownElapsed => ActionManager.Instance()->GetRecastTimeElapsed(ActionType.Action, ActionID); /// Gets the total cooldown time. public unsafe float CooldownTotal => (ActionManager.GetAdjustedRecastTime(ActionType.Action, ActionID) / 1000f) * MaxCharges; /// Gets the cooldown time remaining. - public unsafe float CooldownRemaining => IsCooldown ? CooldownTotal - CooldownElapsed : 0; + public unsafe float CooldownRemaining => CooldownElapsed == 0 ? 0 : Math.Max(0, CooldownTotal - CooldownElapsed); /// Gets the maximum number of charges for an action at the current level. /// Number of charges. @@ -43,10 +42,7 @@ public float ChargeCooldownRemaining { get { - if (!IsCooldown) - return 0; - - var maxCharges = ActionManager.GetMaxCharges(ActionID, 100); + var maxCharges = ActionManager.GetMaxCharges(ActionID, 0); var timePerCharge = CooldownTotal / maxCharges; return CooldownRemaining % (CooldownTotal / MaxCharges); From 039b6133814c9d4f3bab6c21ce491e4fe6eb53b1 Mon Sep 17 00:00:00 2001 From: Taurenkey Date: Mon, 1 Jul 2024 21:28:27 +0100 Subject: [PATCH 2/2] Tidy up --- XIVSlothCombo/Data/CooldownData.cs | 5 +---- XIVSlothCombo/Data/CustomComboCache.cs | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/XIVSlothCombo/Data/CooldownData.cs b/XIVSlothCombo/Data/CooldownData.cs index 391fc75f5..8e2387462 100644 --- a/XIVSlothCombo/Data/CooldownData.cs +++ b/XIVSlothCombo/Data/CooldownData.cs @@ -29,7 +29,7 @@ public bool IsCooldown /// Gets the maximum number of charges for an action at the current level. /// Number of charges. - public ushort MaxCharges => Service.ComboCache.GetMaxCharges(ActionID); + public ushort MaxCharges => ActionManager.GetMaxCharges(ActionID, 0); /// Gets a value indicating whether the action has charges, not charges available. public bool HasCharges => MaxCharges > 1; @@ -42,9 +42,6 @@ public float ChargeCooldownRemaining { get { - var maxCharges = ActionManager.GetMaxCharges(ActionID, 0); - var timePerCharge = CooldownTotal / maxCharges; - return CooldownRemaining % (CooldownTotal / MaxCharges); } } diff --git a/XIVSlothCombo/Data/CustomComboCache.cs b/XIVSlothCombo/Data/CustomComboCache.cs index c49e564d4..33fdbdef0 100644 --- a/XIVSlothCombo/Data/CustomComboCache.cs +++ b/XIVSlothCombo/Data/CustomComboCache.cs @@ -92,7 +92,7 @@ internal unsafe CooldownData GetCooldown(uint actionID) /// Get the maximum number of charges for an action. /// Action ID to check. /// Max number of charges at current level. - internal unsafe ushort GetMaxCharges(uint actionID) => ActionManager.GetMaxCharges(actionID, 0); + internal unsafe ushort GetMaxCharges(uint actionID) => GetCooldown(actionID).MaxCharges; /// Get the resource cost of an action. /// Action ID to check.