Skip to content

Commit

Permalink
Merge pull request #401 from FFXIV-CombatReborn/NPC-heal-fix
Browse files Browse the repository at this point in the history
Fix typos, update Configs, and enhance NPC handling
  • Loading branch information
LTS-FFXIV authored Sep 23, 2024
2 parents a4c3b71 + b1cac62 commit 3685cfb
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
6 changes: 5 additions & 1 deletion RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public const string
PvEFilter = JobFilterType.None)]
private static readonly bool _raisePlayerBySwift = true;

[ConditionBool, UI("Raise any player in range in Alliance Raids)",
[ConditionBool, UI("Raise any player in range in Alliance Raids",
Filter = HealingActionCondition, Section = 2,
PvEFilter = JobFilterType.Raise, PvPFilter = JobFilterType.NoJob)]
private static readonly bool _raiseAll = false;
Expand Down Expand Up @@ -471,6 +471,10 @@ public const string
Filter = HealingActionCondition, Section = 3)]
private static readonly bool _friendlyBattleNPCHeal = false;

[ConditionBool, UI("Heal and raise Party NPCs.",
Filter = HealingActionCondition, Section = 3)]
private static readonly bool _friendlyPartyNPCHeal = false;

[ConditionBool, UI("Heal/Dance partner your chocobo. (Experimental)",
Filter = HealingActionCondition, Section = 3)]
private static readonly bool _chocoboPartyMember = false;
Expand Down
20 changes: 19 additions & 1 deletion RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public static unsafe IBattleChara[] FriendlyNPCMembers

// Filter and cast objects safely
return Svc.Objects
.Where(obj => obj != null && obj.ObjectKind == ObjectKind.BattleNpc && obj.GetNameplateKind() == NameplateKind.FriendlyBattleNPC)
.Where(obj => obj != null && obj.ObjectKind == Dalamud.Game.ClientState.Objects.Enums.ObjectKind.BattleNpc && (obj.GetNameplateKind() == NameplateKind.FriendlyBattleNPC || obj.GetBattleNPCSubKind() == BattleNpcSubKind.NpcPartyMember))
.OfType<IBattleChara>()
.ToArray();
}
Expand Down Expand Up @@ -381,6 +381,7 @@ public static IBattleChara? DeathTarget

var deathAll = AllianceMembers.GetDeath();
var deathParty = PartyMembers.GetDeath();
var deathNPC = FriendlyNPCMembers.GetDeath();

if (deathParty.Any())
{
Expand Down Expand Up @@ -411,6 +412,23 @@ public static IBattleChara? DeathTarget
return deathAll.FirstOrDefault();
}

if (deathNPC.Any() && Service.Config.FriendlyPartyNpcHeal)
{
var deathNPCT = deathNPC.GetJobCategory(JobRole.Tank).ToList();
var deathNPCH = deathNPC.GetJobCategory(JobRole.Healer).ToList();

if (deathNPCT.Count > 1)
{
return deathNPCT.FirstOrDefault();
}

if (deathNPCH.Any()) return deathNPCH.FirstOrDefault();

if (deathNPCT.Any()) return deathNPCT.FirstOrDefault();

return deathNPC.FirstOrDefault();
}

return null;
}
}
Expand Down
3 changes: 1 addition & 2 deletions RotationSolver.Basic/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ internal static bool IsParty(this IGameObject gameObject)
// Accessing Player.Object and Svc.Party within the lock to ensure thread safety
if (gameObject.GameObjectId == Player.Object?.GameObjectId) return true;
if (Svc.Party.Any(p => p.GameObject?.GameObjectId == gameObject.GameObjectId)) return true;
if (gameObject.SubKind == 9) return true;
if (Service.Config.FriendlyPartyNpcHeal && gameObject.GetBattleNPCSubKind() == BattleNpcSubKind.NpcPartyMember) return true;

// Check if ChocoboPartyMember is enabled
if (Service.Config.ChocoboPartyMember)
Expand All @@ -186,7 +186,6 @@ internal static bool IsParty(this IGameObject gameObject)
if (Service.Config.FriendlyBattleNpcHeal && gameObject.GetNameplateKind() == NameplateKind.FriendlyBattleNPC) return true;

}

return false;
}

Expand Down
47 changes: 47 additions & 0 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,52 @@ private static unsafe void DrawStatus()
ImGui.Text($"Combo Time: {DataCenter.ComboTime}");
ImGui.Text($"Merged Status: {DataCenter.MergedStatus}");
ImGui.Text($"TargetingType: {DataCenter.TargetingType}");
ImGui.Text($"DeathTarget: {DataCenter.DeathTarget}");

// Display dead party members
var deadPartyMembers = DataCenter.PartyMembers.GetDeath();
if (deadPartyMembers.Any())
{
ImGui.Text("Dead Party Members:");
foreach (var member in deadPartyMembers)
{
ImGui.Text($"- {member.Name}");
}
}
else
{
ImGui.Text("Dead Party Members: None");
}

// Display all party members
var partyMembers = DataCenter.PartyMembers;
if (partyMembers.Any())
{
ImGui.Text("Party Members:");
foreach (var member in partyMembers)
{
ImGui.Text($"- {member.Name}");
}
}
else
{
ImGui.Text("Party Members: None");
}

// Display all party members
var friendlyNPCMembers = DataCenter.FriendlyNPCMembers;
if (friendlyNPCMembers.Any())
{
ImGui.Text("Friendly NPC Members:");
foreach (var member in friendlyNPCMembers)
{
ImGui.Text($"- {member.Name}");
}
}
else
{
ImGui.Text("Friendly NPC Members: None");
}

ImGui.Text($"TerritoryType: {DataCenter.TerritoryContentType}");
ImGui.Text($"DPSTaken: {DataCenter.DPSTaken}");
Expand Down Expand Up @@ -2537,6 +2583,7 @@ private static unsafe void DrawTargetData()
ImGui.Text($"Rank: {battleChara.GetObjectNPC()?.Rank.ToString() ?? string.Empty}");
ImGui.Text($"Has Positional: {battleChara.HasPositional()}");
ImGui.Text($"Is Dying: {battleChara.IsDying()}");
ImGui.Text($"Is Party: {battleChara.IsParty()}");
ImGui.Text($"EventType: {battleChara.GetEventType()}");
ImGui.Text($"NamePlate: {battleChara.GetNamePlateIcon()}");
ImGui.Text($"StatusFlags: {battleChara.StatusFlags}");
Expand Down

0 comments on commit 3685cfb

Please sign in to comment.