Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling, Mudra status check for role actions on NIN, SGE Pepsis restriction, Auto off fix #568

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions RotationSolver.Basic/Actions/ActionTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,39 @@ private bool CheckStatus(IGameObject gameObject, bool skipStatusProvideCheck)
/// </returns>
private bool CheckResistance(IGameObject gameObject)
{
if (action.Info.AttackType == AttackType.Magic)
if (gameObject == null) return false;

try
{
if (gameObject.HasStatus(false, StatusHelper.MagicResistance))
if (action.Info.AttackType == AttackType.Magic)
{
return false;
if (gameObject.HasStatus(false, StatusHelper.MagicResistance))
{
return false;
}
}
}
else if (action.Info.Aspect != Aspect.Piercing) // Physical
{
if (gameObject.HasStatus(false, StatusHelper.PhysicalResistance))
else if (action.Info.Aspect != Aspect.Piercing) // Physical
{
return false;
if (gameObject.HasStatus(false, StatusHelper.PhysicalResistance))
{
return false;
}
}
}
if (Range >= 20) // Range
{
if (gameObject.HasStatus(false, StatusID.RangedResistance, StatusID.EnergyField))
if (Range >= 20) // Range
{
return false;
if (gameObject.HasStatus(false, StatusID.RangedResistance, StatusID.EnergyField))
{
return false;
}
}
}
catch (Exception ex)
{
// Log the exception for debugging purposes
Svc.Log.Error($"Error checking resistance: {ex.Message}");
return false;
}

return true;
}

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 @@ -132,12 +132,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 == 1 || battleChara.TargetObject is IBattleChara,
TargetHostileType.AllTargetsWhenSoloInDuty => (DataCenter.PartyMembers.Count == 1 && (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 == 1 && (Svc.Condition[ConditionFlag.BoundByDuty] || Svc.Condition[ConditionFlag.BoundByDuty56])) || battleChara.TargetObject is IBattleChara target && target.IsInEnemiesList(),
TargetHostileType.AllTargetsWhenSoloInDutyTargetIsInEnemiesList => DataCenter.PartyMembers.Count == 1 || battleChara.TargetObject is IBattleChara target && target.IsInEnemiesList(),
_ => true,
};
}
Expand Down
27 changes: 22 additions & 5 deletions RotationSolver.Basic/Helpers/StatusHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Game.ClientState.Statuses;
using ECommons.Automation;
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using ECommons.Logging;
using RotationSolver.Basic.Configuration;
Expand Down Expand Up @@ -339,11 +340,27 @@ private static IEnumerable<Status> GetAllStatus(this IGameObject obj, bool isFro
if (obj is not IBattleChara b) return Enumerable.Empty<Status>();

var playerId = Player.Object?.GameObjectId ?? 0;
// Ensure b.StatusList is not null
return b.StatusList?.Where(status => !isFromSelf
|| status.SourceId == playerId
|| status.SourceObject?.OwnerId == playerId)
?? Enumerable.Empty<Status>();

try
{
// Ensure b.StatusList is not null
if (b.StatusList == null)
{
PluginLog.Error("StatusList is null. Cannot get statuses.");
return Enumerable.Empty<Status>();
}

return b.StatusList.Where(status => !isFromSelf
|| status.SourceId == playerId
|| status.SourceObject?.OwnerId == playerId)
?? Enumerable.Empty<Status>();
}
catch (Exception ex)
{
// Log the exception
Svc.Log.Error($"Failed to get statuses: {ex.Message}");
return Enumerable.Empty<Status>();
}
}

/// <summary>
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 @@ -528,7 +528,7 @@ protected sealed override bool MoveForwardAbility(IAction nextGCD, out IAction?
[RotationDesc(ActionID.FeintPvE)]
protected sealed override bool DefenseAreaAbility(IAction nextGCD, out IAction? act)
{
if (FeintPvE.CanUse(out act)) return true;
if (FeintPvE.CanUse(out act) && !Player.HasStatus(true, StatusID.Mudra)) return true;
return base.DefenseAreaAbility(nextGCD, out act);
}

Expand Down
1 change: 1 addition & 0 deletions RotationSolver.Basic/Rotations/Basic/SageRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ static partial void ModifyZoePvE(ref ActionSetting setting)

static partial void ModifyPepsisPvE(ref ActionSetting setting)
{
setting.StatusNeed = [StatusID.EukrasianPrognosis];
setting.CreateConfig = () => new ActionConfig()
{
AoeCount = 1,
Expand Down
14 changes: 7 additions & 7 deletions RotationSolver.Basic/Rotations/CustomRotation_Ability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private bool Ability(IAction nextGCD, out IAction? act)
var role = DataCenter.Role;

IBaseAction.TargetOverride = TargetType.Interrupt;
if (DataCenter.MergedStatus.HasFlag(AutoStatus.Interrupt) && MyInterruptAbility(role, nextGCD, out act))
if (DataCenter.MergedStatus.HasFlag(AutoStatus.Interrupt) && !Player.HasStatus(true, StatusID.Mudra) && MyInterruptAbility(role, nextGCD, out act))
{
return true;
}
Expand Down Expand Up @@ -71,7 +71,7 @@ private bool Ability(IAction nextGCD, out IAction? act)
{
IBaseAction.ShouldEndSpecial = true;
}
if (DataCenter.MergedStatus.HasFlag(AutoStatus.AntiKnockback) && AntiKnockback(role, nextGCD, out act))
if (DataCenter.MergedStatus.HasFlag(AutoStatus.AntiKnockback) && !Player.HasStatus(true, StatusID.Mudra) && AntiKnockback(role, nextGCD, out act))
{
return true;
}
Expand All @@ -81,7 +81,7 @@ private bool Ability(IAction nextGCD, out IAction? act)
{
IBaseAction.ShouldEndSpecial = true;
}
if (DataCenter.MergedStatus.HasFlag(AutoStatus.Positional) && TrueNorthPvE.Cooldown.CurrentCharges > 0 && !IsLastAbility(true, TrueNorthPvE) && TrueNorthPvE.CanUse(out act, skipComboCheck: true, usedUp: true))
if (DataCenter.MergedStatus.HasFlag(AutoStatus.Positional) && !Player.HasStatus(true, StatusID.Mudra) && TrueNorthPvE.Cooldown.CurrentCharges > 0 && !IsLastAbility(true, TrueNorthPvE) && TrueNorthPvE.CanUse(out act, skipComboCheck: true, usedUp: true))
{
return true;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ private bool MyInterruptAbility(JobRole role, IAction nextGCD, out IAction? act)
break;

case JobRole.Melee:
if (LegSweepPvE.CanUse(out act)) return true;
if (LegSweepPvE.CanUse(out act) && !Player.HasStatus(true, StatusID.Mudra)) return true;
break;

case JobRole.RangedPhysical:
Expand Down Expand Up @@ -312,7 +312,7 @@ private bool AntiKnockback(JobRole role, IAction nextGCD, out IAction? act)
{
case JobRole.Tank:
case JobRole.Melee:
if (ArmsLengthPvE.CanUse(out act)) return true;
if (ArmsLengthPvE.CanUse(out act) && !Player.HasStatus(true, StatusID.Mudra)) return true;
break;
case JobRole.Healer:
case JobRole.RangedMagical:
Expand Down Expand Up @@ -372,8 +372,8 @@ private bool GeneralUsingAbility(JobRole role, IAction nextGCD, out IAction? act
break;

case JobRole.Melee:
if (SecondWindPvE.CanUse(out act)) return true;
if (BloodbathPvE.CanUse(out act)) return true;
if (SecondWindPvE.CanUse(out act) && !Player.HasStatus(true, StatusID.Mudra)) return true;
if (BloodbathPvE.CanUse(out act) && !Player.HasStatus(true, StatusID.Mudra)) return true;
break;

case JobRole.Healer:
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ internal static void UpdateRotationState()
(DataCenter.RightSet.SwitchCancelConditionSet?.IsTrue(DataCenter.RightNowRotation) ?? false))
{
CancelState();
#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
if (Player.Job != null && Player.Job != _previousJob) _previousJob = Player.Job;
#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
if (ActionUpdater.AutoCancelTime != DateTime.MinValue) ActionUpdater.AutoCancelTime = DateTime.MinValue;
}
else if ((Service.Config.AutoOnPvPMatchStart && Svc.Condition[ConditionFlag.BetweenAreas] &&
Expand Down