Skip to content

Commit

Permalink
Merge pull request #344 from FFXIV-CombatReborn/Descriptions
Browse files Browse the repository at this point in the history
PCT sub 86 level hammer use fix
  • Loading branch information
LTS-FFXIV authored Sep 12, 2024
2 parents 29a013d + e6b0c61 commit c0f46ea
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 41 deletions.
104 changes: 64 additions & 40 deletions RotationSolver.Basic/Actions/ActionCooldownInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,136 +11,160 @@ namespace RotationSolver.Basic.Actions;
private readonly IBaseAction _action;

/// <summary>
/// The cd group.
/// The cooldown group.
/// </summary>
public byte CoolDownGroup { get; }

unsafe RecastDetail* CoolDownDetail => ActionIdHelper.GetCoolDownDetail(CoolDownGroup);
/// <summary>
/// Gets the cooldown detail.
/// </summary>
private unsafe RecastDetail* CoolDownDetail => ActionIdHelper.GetCoolDownDetail(CoolDownGroup);

/// <summary>
/// Gets the total recast time.
/// </summary>
private unsafe float RecastTime => CoolDownDetail == null ? 0 : CoolDownDetail->Total;

/// <summary>
///
/// Gets the elapsed recast time minus the default GCD remain.
/// </summary>
public float RecastTimeElapsed => RecastTimeElapsedRaw - DataCenter.DefaultGCDRemain;

/// <summary>
///
/// Gets the raw elapsed recast time.
/// </summary>
internal unsafe float RecastTimeElapsedRaw => CoolDownDetail == null ? 0 : CoolDownDetail->Elapsed;
float ICooldown.RecastTimeElapsedRaw => RecastTimeElapsedRaw;

/// <summary>
///
/// Gets a value indicating whether the action is cooling down.
/// </summary>
public unsafe bool IsCoolingDown => ActionIdHelper.IsCoolingDown(CoolDownGroup);

/// <summary>
/// Gets the remaining recast time.
/// </summary>
private float RecastTimeRemain => RecastTime - RecastTimeElapsedRaw;

/// <summary>
///
/// Gets a value indicating whether the action has at least one charge.
/// </summary>
public bool HasOneCharge => !IsCoolingDown || RecastTimeElapsedRaw >= RecastTimeOneChargeRaw;

/// <summary>
///
/// Gets the current number of charges.
/// </summary>
public unsafe ushort CurrentCharges => (ushort)ActionManager.Instance()->GetCurrentCharges(_action.Info.AdjustedID);

/// <summary>
///
/// Gets the maximum number of charges.
/// </summary>
public unsafe ushort MaxCharges => Math.Max(ActionManager.GetMaxCharges(_action.Info.AdjustedID, (uint)Player.Level), (ushort)1);

/// <summary>
/// Gets the raw recast time for one charge.
/// </summary>
internal float RecastTimeOneChargeRaw => ActionManager.GetAdjustedRecastTime(ActionType.Action, _action.Info.AdjustedID) / 1000f;

float ICooldown.RecastTimeOneChargeRaw => RecastTimeOneChargeRaw;

/// <summary>
///
/// Gets the remaining recast time for one charge minus the default GCD remain.
/// </summary>
public float RecastTimeRemainOneCharge => RecastTimeRemainOneChargeRaw - DataCenter.DefaultGCDRemain;

float RecastTimeRemainOneChargeRaw => RecastTimeRemain % RecastTimeOneChargeRaw;
/// <summary>
/// Gets the raw remaining recast time for one charge.
/// </summary>
private float RecastTimeRemainOneChargeRaw => RecastTimeRemain % RecastTimeOneChargeRaw;

/// <summary>
///
/// Gets the elapsed recast time for one charge minus the default GCD elapsed.
/// </summary>
public float RecastTimeElapsedOneCharge => RecastTimeElapsedOneChargeRaw - DataCenter.DefaultGCDElapsed;

float RecastTimeElapsedOneChargeRaw => RecastTimeElapsedRaw % RecastTimeOneChargeRaw;
/// <summary>
/// Gets the raw elapsed recast time for one charge.
/// </summary>
private float RecastTimeElapsedOneChargeRaw => RecastTimeElapsedRaw % RecastTimeOneChargeRaw;

/// <summary>
/// The default constructor.
/// Initializes a new instance of the <see cref="ActionCooldownInfo"/> struct.
/// </summary>
/// <param name="action">the action.</param>
/// <param name="action">The action.</param>
public ActionCooldownInfo(IBaseAction action)
{
_action = action;
CoolDownGroup = _action.Action.GetCoolDownGroup();
}

/// <summary>
///
/// Determines whether one charge has elapsed after the specified GCD count and offset.
/// </summary>
/// <param name="gcdCount"></param>
/// <param name="offset"></param>
/// <returns></returns>
/// <param name="gcdCount">The GCD count.</param>
/// <param name="offset">The offset.</param>
/// <returns>True if one charge has elapsed; otherwise, false.</returns>
public bool ElapsedOneChargeAfterGCD(uint gcdCount = 0, float offset = 0)
=> ElapsedOneChargeAfter(DataCenter.GCDTime(gcdCount, offset));

/// <summary>
///
/// Determines whether one charge has elapsed after the specified time.
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
/// <param name="time">The time.</param>
/// <returns>True if one charge has elapsed; otherwise, false.</returns>
public bool ElapsedOneChargeAfter(float time)
=> IsCoolingDown && time <= RecastTimeElapsedOneCharge;

/// <summary>
///
/// Determines whether the action has elapsed after the specified GCD count and offset.
/// </summary>
/// <param name="gcdCount"></param>
/// <param name="offset"></param>
/// <returns></returns>
/// <param name="gcdCount">The GCD count.</param>
/// <param name="offset">The offset.</param>
/// <returns>True if the action has elapsed; otherwise, false.</returns>
public bool ElapsedAfterGCD(uint gcdCount = 0, float offset = 0)
=> ElapsedAfter(DataCenter.GCDTime(gcdCount, offset));

/// <summary>
///
/// Determines whether the action has elapsed after the specified time.
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
/// <param name="time">The time.</param>
/// <returns>True if the action has elapsed; otherwise, false.</returns>
public bool ElapsedAfter(float time)
=> IsCoolingDown && time <= RecastTimeElapsed;

/// <summary>
///
/// Determines whether the action will have one charge after the specified GCD count and offset.
/// </summary>
/// <param name="gcdCount"></param>
/// <param name="offset"></param>
/// <returns></returns>
/// <param name="gcdCount">The GCD count.</param>
/// <param name="offset">The offset.</param>
/// <returns>True if the action will have one charge; otherwise, false.</returns>
public bool WillHaveOneChargeGCD(uint gcdCount = 0, float offset = 0)
=> WillHaveOneCharge(DataCenter.GCDTime(gcdCount, offset));

/// <summary>
///
/// Determines whether the action will have one charge after the specified remaining time.
/// </summary>
/// <param name="remain"></param>
/// <returns></returns>
/// <param name="remain">The remaining time.</param>
/// <returns>True if the action will have one charge; otherwise, false.</returns>
public bool WillHaveOneCharge(float remain)
=> HasOneCharge || RecastTimeRemainOneCharge <= remain;

/// <summary>
/// Is this action used after several time.
/// Determines whether the action was just used after the specified time.
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
/// <param name="time">The time.</param>
/// <returns>True if the action was just used; otherwise, false.</returns>
public bool JustUsedAfter(float time)
{
var elapsed = RecastTimeElapsedRaw % RecastTimeOneChargeRaw;
return elapsed + DataCenter.DefaultGCDRemain < time;
}

/// <summary>
/// Checks the cooldown status of the action.
/// </summary>
/// <param name="isEmpty">Indicates whether the action is empty.</param>
/// <param name="gcdCountForAbility">The GCD count for the ability.</param>
/// <returns>True if the action can be used; otherwise, false.</returns>
internal bool CooldownCheck(bool isEmpty, byte gcdCountForAbility)
{
if (!_action.Info.IsGeneralGCD)
Expand Down Expand Up @@ -170,4 +194,4 @@ internal bool CooldownCheck(bool isEmpty, byte gcdCountForAbility)
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static partial void ModifySteelMusePvE(ref ActionSetting setting)

static partial void ModifyHammerStampPvE(ref ActionSetting setting)
{
setting.ActionCheck = () => HammerStacks == 3;
setting.ActionCheck = () => HammerStacks == 3 || (!EnhancedPictomancyIiTrait.EnoughLevel && HammerStacks > 0);
setting.CreateConfig = () => new ActionConfig()
{
AoeCount = 1,
Expand Down

0 comments on commit c0f46ea

Please sign in to comment.