2024-07-24 20:30:12 +00:00
|
|
|
|
using Dalamud.IoC;
|
|
|
|
|
using Dalamud.Plugin;
|
|
|
|
|
using Dalamud.Plugin.Services;
|
2024-07-24 21:48:24 +00:00
|
|
|
|
using FFXIVClientStructs.FFXIV.Client.Game.Group;
|
|
|
|
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
|
|
|
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
2024-07-24 20:30:12 +00:00
|
|
|
|
|
|
|
|
|
namespace PartyDamage;
|
|
|
|
|
|
|
|
|
|
public class Plugin : IDalamudPlugin {
|
|
|
|
|
[PluginService]
|
|
|
|
|
internal static IPluginLog Log { get; private set; }
|
|
|
|
|
|
2024-07-24 21:48:24 +00:00
|
|
|
|
[PluginService]
|
|
|
|
|
private IClientState ClientState { get; init; }
|
|
|
|
|
|
|
|
|
|
[PluginService]
|
|
|
|
|
private IFramework Framework { get; init; }
|
|
|
|
|
|
2024-07-24 20:30:12 +00:00
|
|
|
|
private Client Client { get; }
|
|
|
|
|
|
|
|
|
|
public Plugin() {
|
|
|
|
|
this.Client = new Client();
|
2024-07-24 21:48:24 +00:00
|
|
|
|
this.Framework!.Update += this.OnFramework;
|
2024-07-24 20:30:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose() {
|
2024-07-24 21:48:24 +00:00
|
|
|
|
this.Framework!.Update -= this.OnFramework;
|
2024-07-24 20:30:12 +00:00
|
|
|
|
this.Client.Dispose();
|
|
|
|
|
}
|
2024-07-24 21:48:24 +00:00
|
|
|
|
|
|
|
|
|
private unsafe void OnFramework(IFramework framework) {
|
|
|
|
|
if (this.Client.Data is not { } data) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.ClientState.LocalPlayer is not { } player) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var list = (AddonPartyList*) AtkStage.Instance()->RaptureAtkUnitManager->GetAddonByName("_PartyList");
|
|
|
|
|
|
|
|
|
|
var names = new List<string>();
|
|
|
|
|
var group = GroupManager.Instance()->GetGroup();
|
|
|
|
|
if (group == null) {
|
|
|
|
|
Plugin.Log.Info("group null");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < group->MemberCount; i++) {
|
|
|
|
|
names.Add(group->PartyMembers[i].NameString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var numPlayers = list->PartyMembers.Length;
|
|
|
|
|
foreach (var combatant in data.Combatants.Values) {
|
|
|
|
|
var idx = combatant.Name == "YOU"
|
|
|
|
|
? 0
|
|
|
|
|
: names.IndexOf(combatant.Name);
|
|
|
|
|
if (idx == -1 || idx >= numPlayers) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!float.TryParse(combatant.EncDps, out var dps)) {
|
|
|
|
|
dps = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dpsText = dps switch {
|
|
|
|
|
float.PositiveInfinity => "0",
|
|
|
|
|
float.NegativeInfinity => "0",
|
|
|
|
|
< 1_000 => dps.ToString("N1"),
|
|
|
|
|
< 1_000_000 => $"{dps / 1_000:N1}K",
|
|
|
|
|
_ => $"{dps / 1_000_000:N1}M",
|
|
|
|
|
};
|
|
|
|
|
list->PartyMembers[idx].Name->SetText(dpsText);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-24 20:30:12 +00:00
|
|
|
|
}
|