Skip to content

Commit

Permalink
Add new duty checks, focus target handling, and UI updates
Browse files Browse the repository at this point in the history
- Modified `IsLastGCD` in `SGE_Default.cs` to check with `true` to correct duplicate casts
- Added config option in `Configs.cs` for focus-targeted players.
- Enhanced `DataCenter.cs` with new duty check properties/methods.
- Updated `ObjectHelper.cs` with new using directive, alliance check,
  focus target method, and fully qualified `ObjectKind`.
- Simplified `ModifyPepsisPvE` in `SageRotation.cs`.
- Added alliance raid and duty checks in `CustomRotation_OtherInfo.cs`.
- Updated `RotationConfigWindow.cs` with new UI text elements for
  status information.
  • Loading branch information
LTS-FFXIV committed Jan 12, 2025
1 parent d2ecbb4 commit 2d4b2ec
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 24 deletions.
2 changes: 1 addition & 1 deletion BasicRotations/Healer/SGE_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private bool ChoiceEukrasia(out IAction? act)

// If the last action performed matches any of a list of specific actions, it clears the Eukrasia aim.
// This serves as a reset/cleanup mechanism to ensure the decision logic starts fresh for the next cycle.
if (IsLastGCD(false, EukrasianPrognosisIiPvE, EukrasianPrognosisPvE,
if (IsLastGCD(true, EukrasianPrognosisIiPvE, EukrasianPrognosisPvE,
EukrasianDiagnosisPvE, EukrasianDyskrasiaPvE, EukrasianDosisIiiPvE, EukrasianDosisIiPvE,
EukrasianDosisPvE) || !InCombat)
{
Expand Down
4 changes: 4 additions & 0 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ public const string
Filter = HealingActionCondition, Section = 3)]
private static readonly bool _chocoboPartyMember = false;

[ConditionBool, UI("Treat focus targetted player as party member", Description = "Experimental.",
Filter = HealingActionCondition, Section = 3)]
private static readonly bool _focusTargetIsParty = false;

[ConditionBool, UI("Heal party members with GCD if there is nothing to do in combat.",
Filter = HealingActionCondition, Section = 3)]
private static readonly bool _healWhenNothingTodo = true;
Expand Down
24 changes: 19 additions & 5 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ internal static bool HasApplyStatus(ulong id, StatusID[] ids)
public static TerritoryInfo? Territory { get; set; }

public static bool IsPvP => Territory?.IsPvP ?? false;
public static bool IsInDuty => Svc.Condition[ConditionFlag.BoundByDuty] || Svc.Condition[ConditionFlag.BoundByDuty56];
public static bool IsInAllianceRaid
{
get
{
var allianceTerritoryIds = new HashSet<ushort>
{
151, 174, 372, 508, 556, 627, 734, 776, 826, 882, 917, 966, 1054, 1118, 1178, 1248, 1241
};
return allianceTerritoryIds.Contains(TerritoryID);
}
}

public static ushort TerritoryID => Svc.ClientState.TerritoryType;
public static bool IsInUCoB => TerritoryID == 733;
Expand All @@ -112,6 +124,8 @@ internal static bool HasApplyStatus(ulong id, StatusID[] ids)
public static bool IsInDSR => TerritoryID == 968;
public static bool IsInTOP => TerritoryID == 1122;
public static bool IsInFRU => TerritoryID == 1238;
public static bool IsInCOD => TerritoryID == 1241;


public static AutoStatus MergedStatus => AutoStatus | CommandStatus;

Expand Down Expand Up @@ -322,13 +336,13 @@ internal static float RaidTimeRaw
}
}

public static List<IBattleChara> PartyMembers { get; set; } = new();
public static List<IBattleChara> PartyMembers { get; set; } = [];

public static List<IBattleChara> AllianceMembers { get; set; } = new();
public static List<IBattleChara> AllianceMembers { get; set; } = [];

public static List<IBattleChara> FriendlyNPCMembers { get; set; } = new();
public static List<IBattleChara> FriendlyNPCMembers { get; set; } = [];

public static List<IBattleChara> AllHostileTargets { get; set; } = new();
public static List<IBattleChara> AllHostileTargets { get; set; } = [];

public static IBattleChara? InterruptTarget { get; set; }

Expand All @@ -338,7 +352,7 @@ internal static float RaidTimeRaw

public static IBattleChara? DispelTarget { get; set; }

public static List<IBattleChara> AllTargets { get; set; } = new();
public static List<IBattleChara> AllTargets { get; set; } = [];

public static ulong[] TreasureCharas
{
Expand Down
16 changes: 12 additions & 4 deletions RotationSolver.Basic/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Common.Component.BGCollision;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Excel.Sheets;
using RotationSolver.Basic.Configuration;
using System.Collections.Concurrent;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -246,9 +247,8 @@ internal static unsafe bool IsEnemy(this IGameObject obj)

internal static unsafe bool IsAlliance(this IGameObject obj)
=> obj.GameObjectId is not 0
&& (!DataCenter.IsPvP && obj is IPlayerCharacter
|| ActionManager.CanUseActionOnTarget((uint)ActionID.CurePvE, obj.Struct()));

&& (!DataCenter.IsPvP && DataCenter.IsInAllianceRaid && obj is IPlayerCharacter
|| DataCenter.IsInAllianceRaid && ActionManager.CanUseActionOnTarget((uint)ActionID.CurePvE, obj.Struct()));

private static readonly object _lock = new object();

Expand All @@ -268,10 +268,17 @@ internal static bool IsParty(this IGameObject gameObject)
if (Service.Config.FriendlyPartyNpcHealRaise2 && gameObject.GetBattleNPCSubKind() == BattleNpcSubKind.NpcPartyMember) return true;
if (Service.Config.ChocoboPartyMember && gameObject.GetNameplateKind() == NameplateKind.PlayerCharacterChocobo) return true;
if (Service.Config.FriendlyBattleNpcHeal && gameObject.GetNameplateKind() == NameplateKind.FriendlyBattleNPC) return true;
if (Service.Config.FocusTargetIsParty && gameObject.IsFocusTarget() == true && gameObject.IsAlliance() == true) return true;
}
return false;
}

internal static bool IsFocusTarget(this IGameObject gameObject)
{
var focusTarget = Svc.Targets.FocusTarget;
return focusTarget != null && focusTarget.GameObjectId == gameObject.GameObjectId;
}

internal static bool IsTargetOnSelf(this IBattleChara IBattleChara)
{
return IBattleChara.TargetObject?.TargetObject == IBattleChara;
Expand Down Expand Up @@ -301,7 +308,8 @@ internal static bool IsAlive(this IGameObject obj)
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static unsafe ObjectKind GetObjectKind(this IGameObject obj) => (ObjectKind)obj.Struct()->ObjectKind;
public static unsafe Dalamud.Game.ClientState.Objects.Enums.ObjectKind GetObjectKind(this IGameObject obj)
=> (Dalamud.Game.ClientState.Objects.Enums.ObjectKind)obj.Struct()->ObjectKind;

/// <summary>
/// Determines whether the specified game object is a top priority hostile target based on its name being listed.
Expand Down
10 changes: 0 additions & 10 deletions RotationSolver.Basic/Rotations/Basic/SageRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,6 @@ static partial void ModifyZoePvE(ref ActionSetting setting)

static partial void ModifyPepsisPvE(ref ActionSetting setting)
{
setting.ActionCheck = () =>
{
foreach (var chara in DataCenter.PartyMembers)
{
if (chara.HasStatus(true, StatusID.EukrasianDiagnosis, StatusID.EukrasianPrognosis)
&& chara.GetHealthRatio() < 0.9) return true;
}

return false;
};
setting.CreateConfig = () => new ActionConfig()
{
AoeCount = 1,
Expand Down
16 changes: 14 additions & 2 deletions RotationSolver.Basic/Rotations/CustomRotation_OtherInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ public static bool IsLongerThan(float time)
[Description("Is in the high-end duty")]
public static bool IsInHighEndDuty => DataCenter.Territory?.IsHighEndDuty ?? false;

/// <summary>
/// Is player in a normal or chaotic Alliance Raid.
/// </summary>
[Description("Is in an Alliance Raid (including Chaotic)")]
public static bool IsInAllianceRaid => DataCenter.IsInAllianceRaid;

/// <summary>
/// Is player in UCoB duty.
/// </summary>
Expand Down Expand Up @@ -327,11 +333,17 @@ public static bool IsLongerThan(float time)
[Description("Is in FRU duty")]
public static bool IsInFRU => DataCenter.IsInFRU;

///<summary>
/// Is player in COD duty.
///</summary>
[Description("Is in FRU duty")]
public static bool IsInCOD => DataCenter.IsInCOD;

/// <summary>
/// Is player in duty.
/// Is player in any instanced duty.
/// </summary>
[Description("Is player in duty")]
public static bool IsInDuty => Svc.Condition[ConditionFlag.BoundByDuty];
public static bool IsInDuty => DataCenter.IsInDuty;

/// <summary>
/// Your ping.
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2709,6 +2709,7 @@ private static void DrawDebugRotationStatus()

private static unsafe void DrawStatus()
{
ImGui.Text($"Merged Status: {DataCenter.MergedStatus}");
if ((IntPtr)FateManager.Instance() != IntPtr.Zero)
{
ImGui.Text($"Fate: {DataCenter.FateId}");
Expand All @@ -2729,7 +2730,6 @@ private static unsafe void DrawStatus()
ImGui.Text($"Stop Moving: {DataCenter.StopMovingRaw}");
ImGui.Text($"CountDownTime: {Service.CountDownTime}");
ImGui.Text($"Combo Time: {DataCenter.ComboTime}");
ImGui.Text($"Merged Status: {DataCenter.MergedStatus}");
ImGui.Text($"TargetingType: {DataCenter.TargetingType}");
ImGui.Text($"DeathTarget: {DataCenter.DeathTarget}");
foreach (var item in DataCenter.AttackedTargets)
Expand Down Expand Up @@ -2839,8 +2839,8 @@ private static unsafe void DrawStatus()
private static unsafe void DrawParty()
{
ImGui.Text($"Your combat state: {DataCenter.InCombat}");

ImGui.Text($"Number of Party Members: {DataCenter.PartyMembers.Count}");
ImGui.Text($"Is in Alliance Raid: {DataCenter.IsInAllianceRaid}");
ImGui.Text($"Number of Alliance Members: {DataCenter.AllianceMembers.Count}");
ImGui.Text($"Average Party HP Percent: {DataCenter.PartyMembersAverHP * 100}");
foreach (var p in Svc.Party)
Expand Down Expand Up @@ -2872,6 +2872,7 @@ private static unsafe void DrawTargetData()
if (target is IBattleChara battleChara)
{
ImGui.Text($"HP: {battleChara.CurrentHp} / {battleChara.MaxHp}");
ImGui.Text($"Is Current Focus Target: {battleChara.IsFocusTarget()}");
ImGui.Text($"TTK: {battleChara.GetTimeToKill()}");
ImGui.Text($"Is Boss TTK: {battleChara.IsBossFromTTK()}");
ImGui.Text($"Is Boss Icon: {battleChara.IsBossFromIcon()}");
Expand Down

0 comments on commit 2d4b2ec

Please sign in to comment.