Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add InCombat property for every object.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 28, 2023
1 parent 941ae29 commit b2c34bd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
10 changes: 10 additions & 0 deletions RotationSolver.Basic/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ public static bool IsDying(this BattleChara b)
return b.GetDeadTime() <= Service.Config.GetValue(Configuration.PluginConfigFloat.DeadTimeDying) || b.GetHealthRatio() < 0.02f;
}

/// <summary>
/// Whether the character is in combat.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static unsafe bool InCombat(this BattleChara obj)
{
return obj.Struct()->Character.InCombat;
}

private static readonly TimeSpan CheckSpan = TimeSpan.FromSeconds(2.5);

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver.Basic/Rotations/CustomRotation_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ public override bool CanUse(out IAction act, CanUseOption option = CanUseOption.
/// <summary>
///
/// </summary>
public static unsafe IBaseAction Peloton { get; } = new RoleAction(ActionID.Peloton, new JobRole[] { JobRole.RangedPhysical }, ActionOption.Friendly)
public static IBaseAction Peloton { get; } = new RoleAction(ActionID.Peloton, new JobRole[] { JobRole.RangedPhysical }, ActionOption.Friendly)
{
ActionCheck = (b, m) => NotInCombatDelay && PartyMembers.GetObjectInRadius(20)
.Any(p => p.WillStatusEnd(3, false, StatusID.Peloton) && !p.Struct()->Character.InCombat),
.Any(p => p.WillStatusEnd(3, false, StatusID.Peloton) && !p.InCombat()),
};

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions RotationSolver/ActionSequencer/TargetCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public bool IsTrue(ICustomRotation rotation)
result = tar.IsDying();
break;

case TargetConditionType.InCombat:
result = tar.InCombat();
break;

case TargetConditionType.Distance:
result = tar.DistanceToPlayer() > DistanceOrTime;
break;
Expand Down Expand Up @@ -179,6 +183,7 @@ public void Draw(ICustomRotation rotation)
break;
case TargetConditionType.IsDying:
case TargetConditionType.IsBoss:
case TargetConditionType.InCombat:
case TargetConditionType.CastingAction:
combos = new string[]
{
Expand Down Expand Up @@ -309,6 +314,7 @@ public enum TargetConditionType : byte
HasStatus,
IsDying,
IsBoss,
InCombat,
Distance,
StatusEnd,
StatusEndGCD,
Expand Down
6 changes: 6 additions & 0 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,12 @@ private static unsafe void DrawParty()
ImGui.Text("CanHealAreaSpell: " + DataCenter.CanHealAreaSpell.ToString());
ImGui.Text("CanHealAreaSpell: " + DataCenter.CanHealAreaSpell.ToString());
ImGui.Text("PartyMembersAverHP: " + DataCenter.PartyMembersAverHP.ToString());

foreach (var p in Svc.Party)
{
if (p.GameObject is not BattleChara b) continue;
ImGui.Text($"In Combat: {b.InCombat()}");
}
}

private static unsafe void DrawTargetData()
Expand Down

0 comments on commit b2c34bd

Please sign in to comment.