Skip to content

Commit

Permalink
Merge pull request #553 from FFXIV-CombatReborn/bigfiveoh
Browse files Browse the repository at this point in the history
Refactor and improve code readability and performance
  • Loading branch information
LTS-FFXIV authored Jan 11, 2025
2 parents b2e1837 + 9190888 commit b277aad
Show file tree
Hide file tree
Showing 30 changed files with 879 additions and 749 deletions.
4 changes: 2 additions & 2 deletions BasicRotations/Healer/SGE_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ protected override bool DefenseSingleAbility(IAction nextGCD, out IAction? act)
[RotationDesc(ActionID.KeracholePvE, ActionID.PhysisPvE, ActionID.HolosPvE, ActionID.IxocholePvE)]
protected override bool HealAreaAbility(IAction nextGCD, out IAction? act)
{
if ((!MergedStatus.HasFlag(AutoStatus.DefenseArea) || !MergedStatus.HasFlag(AutoStatus.DefenseSingle)) && PepsisPvE.CanUse(out act)) return true;

if (KeracholePvE.CanUse(out act) && EnhancedKeracholeTrait.EnoughLevel) return true;

if (IxocholePvE.CanUse(out act)) return true;
Expand Down Expand Up @@ -213,8 +215,6 @@ protected override bool GeneralAbility(IAction nextGCD, out IAction? act)

if (SoteriaPvE.CanUse(out act) && PartyMembers.Any(b => b.HasStatus(true, StatusID.Kardion) && b.GetHealthRatio() < HealthSingleAbility)) return true;

if (PepsisPvE.CanUse(out act)) return true;

return base.GeneralAbility(nextGCD, out act);
}
#endregion
Expand Down
6 changes: 2 additions & 4 deletions BasicRotations/Magical/PCT_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
[Api(4)]
public sealed class PCT_Default : PictomancerRotation
{
private const float CountdownBuffer = 0.2f;

#region Config Options
[RotationConfig(CombatType.PvE, Name = "Use HolyInWhite or CometInBlack while moving")]
public bool HolyCometMoving { get; set; } = true;
Expand Down Expand Up @@ -41,7 +39,7 @@ public sealed class PCT_Default : PictomancerRotation
if (!LandscapeMotifDrawn && StarrySkyMotifPvE.CanUse(out act) && !HasHyperphantasia) return act;
}

if (remainTime <= RainbowDripPvE.Info.CastTime + CountdownBuffer + CountDownAhead && RainbowDripPvE.CanUse(out act))
if (remainTime <= RainbowDripPvE.Info.CastTime + CountDownAhead && RainbowDripPvE.CanUse(out act))
{
return act;
}
Expand Down Expand Up @@ -146,7 +144,7 @@ protected override bool GeneralGCD(out IAction? act)
if (Paint == HolyCometMax && HolyInWhitePvE.CanUse(out act)) return true;

// Landscape Paining Burst
if (RainbowDripPvE.CanUse(out act)) return true;
if (HasRainbowBright && RainbowDripPvE.CanUse(out act, skipCastingCheck: HasRainbowBright)) return true;
if (StarPrismPvE.CanUse(out act)) return true;

// timings for motif casting
Expand Down
4 changes: 2 additions & 2 deletions BasicRotations/Magical/SMN_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum SummonOrderType : byte
[RotationConfig(CombatType.PvE, Name = "Use this if there's no other raid buff in your party")]
public bool SecondTypeOpenerLogic { get; set; } = false;

[RotationConfig(CombatType.PvE, Name = "Use Physick")]
[RotationConfig(CombatType.PvE, Name = "Use Physick above level 30")]
public bool Healbot { get; set; } = false;

#endregion
Expand Down Expand Up @@ -169,7 +169,7 @@ protected override bool EmergencyAbility(IAction nextGCD, out IAction? act)
[RotationDesc(ActionID.PhysickPvE)]
protected override bool HealSingleGCD(out IAction? act)
{
if ((Healbot || Player.Level <= 20) && PhysickPvE.CanUse(out act)) return true;
if ((Healbot || Player.Level <= 30) && PhysickPvE.CanUse(out act)) return true;
return base.HealSingleGCD(out act);
}

Expand Down
12 changes: 9 additions & 3 deletions BasicRotations/Melee/NIN_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ public sealed class NIN_Default : NinjaRotation

[RotationConfig(CombatType.PvE, Name = "Use Mudras Outside of Combat when enemies are near")]
public bool CommbatMudra { get; set; } = true;

[RotationConfig(CombatType.PvE, Name = "Use Forked Raiju instead of Fleeting Raiju if you are outside of range (Dangerous)")]
public bool ForkedUse { get; set; } = false;
#endregion

#region Tracking Properties
// Properties to track RabbitMediumPvE failures and related information.
private int _rabbitMediumFailures = 0;
private IBaseAction? _lastNinActionAim = null;
private IAction? _followUpGCDAction = null;
#endregion

#region CountDown Logic
Expand Down Expand Up @@ -399,13 +401,17 @@ protected override bool GeneralGCD(out IAction? act)
{
act = null;

if (RabbitMediumPvE.CanUse(out act)) return true;
if (_ninActionAim == null && RabbitMediumPvE.CanUse(out act)) return true;

if (!IsExecutingMudra && (InTrickAttack || InMug) && NoNinjutsu && !HasRaijuReady
&& !Player.HasStatus(true, StatusID.TenChiJin)
&& PhantomKamaitachiPvE.CanUse(out act)) return true;

if (!IsExecutingMudra && FleetingRaijuPvE.CanUse(out act)) return true;
if (!IsExecutingMudra)
{
if (FleetingRaijuPvE.CanUse(out act)) return true;
if (ForkedUse && ForkedRaijuPvE.CanUse(out act)) return true;
}

if ((InCombat || (CommbatMudra && HasHostilesInMaxRange)) && ChoiceNinjutsu(out act)) return true;
if (((!InCombat && CommbatMudra && HasHostilesInMaxRange) || !CombatElapsedLess(7)) && DoNinjutsu(out act)) return true;
Expand Down
1 change: 0 additions & 1 deletion Resources/InvincibleStatus.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
151,
198,
385,
469,
592,
1240,
Expand Down
22 changes: 11 additions & 11 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,6 @@ public const string
[ConditionBool, UI("Record knockback actions", Filter = List2)]
private static readonly bool _recordKnockbackies = false;

[JobConfig, UI("Override Action Ahead Timer", Description = "If you don't know what this does, you don't need to modify it",
Filter = BasicTimer)]
private static readonly bool _overrideActionAheadTimer = false;

[UI("Use additional conditions", Filter = BasicParams)]
public bool UseAdditionalConditions { get; set; } = false;

Expand Down Expand Up @@ -634,9 +630,9 @@ public const string
public int AutoDefenseNumber { get; set; } = 2;

#endregion

#region PvP

[JobConfig, UI("Ignore Invincibility for PvP purposes.", Filter = PvPSpecificControls)]
private readonly bool _ignorePvPInvincibility = false;

Expand Down Expand Up @@ -687,15 +683,19 @@ public const string
PvEFilter = JobFilterType.Tank)]
private readonly float _healthForAutoDefense = 1;

[JobConfig, UI("Engage settings", Filter = TargetConfig, PvPFilter = JobFilterType.NoJob)]
private readonly TargetHostileType _hostileType = TargetHostileType.AllTargetsWhenSoloInDuty;

[JobConfig, UI("Override Action Ahead Timer", Description = "If you don't know what this does, you don't need to modify it",
Filter = BasicTimer)]
private readonly bool _overrideActionAheadTimer = false;

[JobConfig, Range(0, 1.0f, ConfigUnitType.Seconds)]
[UI("Action Ahead (How far in advance of GCD being available RSR will try to queue the next GCD)",
Description = "This setting controls how many oGCDs RSR will try to fit in a single GCD window\nLower numbers mean more oGCDs, but potentially more GCD clipping",
Parent = nameof(OverrideActionAheadTimer))]
Description = "This setting controls how many oGCDs RSR will try to fit in a single GCD window\nLower numbers mean more oGCDs, but potentially more GCD clipping",
Parent = nameof(OverrideActionAheadTimer))]
private readonly float _action4head = 0.4f;

[JobConfig, UI("Engage settings", Filter = TargetConfig, PvPFilter = JobFilterType.NoJob)]
private readonly TargetHostileType _hostileType = TargetHostileType.AllTargetsWhenSoloInDuty;

[JobConfig]
private readonly string _PvPRotationChoice = string.Empty;

Expand Down
8 changes: 4 additions & 4 deletions RotationSolver.Basic/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ internal static bool IsAttackable(this IBattleChara battleChara)
{
TargetHostileType.AllTargetsCanAttack => true,
TargetHostileType.TargetsHaveTarget => battleChara.TargetObject is IBattleChara,
TargetHostileType.AllTargetsWhenSolo => DataCenter.PartyMembers.Count() < 2 || battleChara.TargetObject is IBattleChara,
TargetHostileType.AllTargetsWhenSoloInDuty => (DataCenter.PartyMembers.Count() < 2 && (Svc.Condition[ConditionFlag.BoundByDuty] || Svc.Condition[ConditionFlag.BoundByDuty56]))
TargetHostileType.AllTargetsWhenSolo => DataCenter.PartyMembers.Count < 2 || battleChara.TargetObject is IBattleChara,
TargetHostileType.AllTargetsWhenSoloInDuty => (DataCenter.PartyMembers.Count < 2 && (Svc.Condition[ConditionFlag.BoundByDuty] || Svc.Condition[ConditionFlag.BoundByDuty56]))
|| battleChara.TargetObject is IBattleChara,
TargetHostileType.TargetIsInEnemiesList => battleChara.TargetObject is IBattleChara target && target.IsInEnemiesList(),
TargetHostileType.AllTargetsWhenSoloTargetIsInEnemiesList => (DataCenter.PartyMembers.Count() < 2 && (Svc.Condition[ConditionFlag.BoundByDuty] || Svc.Condition[ConditionFlag.BoundByDuty56])) || battleChara.TargetObject is IBattleChara target && target.IsInEnemiesList(),
TargetHostileType.AllTargetsWhenSoloInDutyTargetIsInEnemiesList => DataCenter.PartyMembers.Count() < 2 || battleChara.TargetObject is IBattleChara target && target.IsInEnemiesList(),
TargetHostileType.AllTargetsWhenSoloTargetIsInEnemiesList => (DataCenter.PartyMembers.Count < 2 && (Svc.Condition[ConditionFlag.BoundByDuty] || Svc.Condition[ConditionFlag.BoundByDuty56])) || battleChara.TargetObject is IBattleChara target && target.IsInEnemiesList(),
TargetHostileType.AllTargetsWhenSoloInDutyTargetIsInEnemiesList => DataCenter.PartyMembers.Count < 2 || battleChara.TargetObject is IBattleChara target && target.IsInEnemiesList(),
_ => true,
};
}
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/Basic/NinjaRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ partial class NinjaRotation
/// <summary>
/// Do you need to prep or currently use shadowwalker
/// </summary>
public bool ShadowWalkerNeeded => (TrickAttackPvE.EnoughLevel && TrickAttackPvE.Cooldown.WillHaveOneCharge(18)) || (KunaisBanePvE.EnoughLevel && KunaisBanePvE.Cooldown.WillHaveOneCharge(18)) || (MeisuiPvE.EnoughLevel && MeisuiPvE.Cooldown.WillHaveOneCharge(18));
public bool ShadowWalkerNeeded => (TrickAttackPvE.EnoughLevel && TrickAttackPvE.Cooldown.WillHaveOneCharge(18)) || (KunaisBanePvE.EnoughLevel && KunaisBanePvE.Cooldown.WillHaveOneCharge(18));

/// <summary>
/// Determines if Trick Attack is in its effective period.
Expand Down
6 changes: 5 additions & 1 deletion RotationSolver.Basic/Rotations/Basic/PictomancerRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ public override void DisplayStatus()
/// </summary>
public static bool HasStarryMuse => !Player.WillStatusEnd(0, true, StatusID.StarryMuse);

/// <summary>
/// Indicates if the player has Rainbow Bright.
/// </summary>
public static bool HasRainbowBright => !Player.WillStatusEnd(0, true, StatusID.RainbowBright);

/// <summary>
/// Holds the remaining amount of HammerTime stacks
/// </summary>
Expand Down Expand Up @@ -500,7 +505,6 @@ static partial void ModifyCometInBlackPvE(ref ActionSetting setting)

static partial void ModifyRainbowDripPvE(ref ActionSetting setting)
{
setting.StatusNeed = [StatusID.RainbowBright];
setting.CreateConfig = () => new ActionConfig()
{
AoeCount = 1,
Expand Down
25 changes: 16 additions & 9 deletions RotationSolver.Basic/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ internal class Service : IDisposable
private EzHook<ActorVfxCreateDelegate2> actorVfxCreateHook = null!;
private unsafe delegate IntPtr ActorVfxCreateDelegate2(char* a1, nint a2, nint a3, float a4, char a5, ushort a6, char a7);


// From https://GitHub.com/PunishXIV/Orbwalker/blame/master/Orbwalker/Memory.cs#L74-L76
[Signature("F3 0F 10 05 ?? ?? ?? ?? 0F 2E C7", ScanType = ScanType.StaticAddress,
Fallibility = Fallibility.Infallible)]
[Signature("F3 0F 10 05 ?? ?? ?? ?? 0F 2E C7", ScanType = ScanType.StaticAddress, Fallibility = Fallibility.Infallible)]
static IntPtr forceDisableMovementPtr = IntPtr.Zero;

private static unsafe ref int ForceDisableMovement => ref *(int*)(forceDisableMovementPtr + 4);
Expand Down Expand Up @@ -69,8 +67,6 @@ private unsafe IntPtr ActorVfxCreateDetour(char* a1, nint a2, nint a3, float a4,
throw new Exception("Failed to create object reference during VfxCreateDetour");
}

//Svc.Log.Verbose($"{obj.Name} is casting {path}");

var newVfx = new VfxNewData(obj.GameObjectId, path);
DataCenter.VfxDataQueue.Add(newVfx);
}
Expand Down Expand Up @@ -122,7 +118,6 @@ public static ActionID GetAdjustedActionId(ActionID id)
public static unsafe uint GetAdjustedActionId(uint id)
=> ActionManager.Instance()->GetAdjustedActionId(id);


private static readonly ConcurrentDictionary<Type, AddonAttribute?> AddonCache = new();

/// <summary>
Expand Down Expand Up @@ -159,11 +154,23 @@ public static IEnumerable<IntPtr> GetAddons<T>() where T : struct
/// <summary>
/// Releases unmanaged resources and performs other cleanup operations.
/// </summary>
public void Dispose()
protected virtual void Dispose(bool disposing)
{
if (!_canMove && ForceDisableMovement > 0)
if (disposing)
{
ForceDisableMovement--;
if (!_canMove && ForceDisableMovement > 0)
{
ForceDisableMovement--;
}
}
}

/// <summary>
/// Releases unmanaged resources and performs other cleanup operations.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
Loading

0 comments on commit b277aad

Please sign in to comment.