XIVComboPlugin
XIVComboPlugin copied to clipboard
[Enhancement]: CooldownData.cs Refining
Hello,
I've been working on optimizing some of the ways the cooldown data works in the addon, and while I'm not confident enough in it yet to open a real pull, I do want to let you know about the advancements we've discovered in some of the other forks of this project to see if you'd like to use any of them! The main reason currently that I avoid a pull is it seems to mess with other aspects of code that rely on the durations of cooldowns being set to 0 manually in CooldownData.cs
These are used in the CooldownData.cs section, and require:
using FFXIVClientStructs.FFXIV.Client.Game
The major one is it's been discovered how to get the haste/speed adjusted cooldown of a given actionID:
public float BaseCooldown => ActionManager.GetAdjustedRecastTime(ActionType.Spell, this.ActionID) / 1000f;
public float TotalBaseCooldown
{
get
{
var (cur, max) = Service.ComboCache.GetMaxCharges(this.ActionID);
// Rebase to the current charge count
var total = this.BaseCooldown / max * cur;
return total * cur;
}
}
public float TotalCooldownElapsed => this.cooldownElapsed;
public float TotalCooldownRemaining => this.TotalBaseCooldown - this.TotalCooldownElapsed;
That line alone has allowed functions such as tracking uptime for combo based rotations like Twin Snakes or Demolish, by using code like such:
double gcd = GetCooldown(MNK.Bootshine).BaseCooldown;
double remainingGCD = GetCooldown(MNK.Bootshine).CooldownRemaining;
double rotate = remainingGCD + (gcd * 3);
The rotate double can now be used to check if the Twin Snakes or Demolish duration remaining is less than it, providing an easy switch for combos to adjust to
Another set of useful data has been the easy calculation of time until a certain actionID is able to be used after the next usage:
public float ChargeCooldownRemaining
{
get
{
var (cur, _) = Service.ComboCache.GetMaxCharges(this.ActionID);
return this.TotalCooldownRemaining % (this.TotalBaseCooldown / cur);
}
}
public float RecoveryTime => this.CooldownRemaining + this.BaseCooldown;
public float ChargeRecoveryTime
{
get
{
if ((this.RemainingCharges - 1) >= 0)
{
return this.ChargeCooldownRemaining;
}
return this.ChargeCooldownRemaining + this.BaseCooldown;
}
}
public float TotalChargeCooldownRemaining => this.MaxCharges - this.RemainingCharges > 0
? this.MaxCharges - this.RemainingCharges == 1
? this.ChargeCooldownRemaining
: (this.BaseCooldown * ((this.MaxCharges - this.RemainingCharges) - 1)) + this.ChargeCooldownRemaining
: 0;
These can assist for timing/reserving charge based actionIDs for certain buff windows, allowing checks to see if the full charge recovery time would occur prior to a given cooldown.
I've uploaded the txt version of the modified CooldownData.cs which contains some commented lines for the functionality, hope you can find some useful additions!