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

Commit

Permalink
Merge commit 'refs/pull/1716/head' of https://github.com/Nik-Potokar/…
Browse files Browse the repository at this point in the history
  • Loading branch information
Taurenkey committed Aug 22, 2024
2 parents dc7a64d + 280478c commit 954e9e6
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 35 deletions.
23 changes: 18 additions & 5 deletions XIVSlothCombo/CustomCombo/Functions/Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ public static byte GetBuffStacks(ushort effectId)
return eff?.StackCount ?? 0;
}

public unsafe static float GetBuffRemainingTime(ushort effectId)
/// <summary> Gets the duration of a status effect on the player. By default, the effect must be owned by the player or unowned. </summary>
/// <param name="effectId"> Status effect ID. </param>
/// <param name="isPlayerOwned"> Whether the status effect must be owned by the player or can be owned by anyone. </param>
/// <returns> The duration of the status effect. </returns>
public unsafe static float GetBuffRemainingTime(ushort effectId, bool isPlayerOwned = true)
{
Status? eff = FindEffect(effectId);
Status? eff = (isPlayerOwned == true)
? FindEffect(effectId)
: FindEffectAny(effectId);

if (eff is null) return 0;
if (eff.RemainingTime < 0) return (eff.RemainingTime * -1) + ActionManager.Instance()->AnimationLock;
return eff.RemainingTime;
Expand All @@ -43,10 +50,16 @@ public unsafe static float GetBuffRemainingTime(ushort effectId)
/// <returns> Status object or null. </returns>
public static Status? FindTargetEffect(ushort effectID) => FindEffect(effectID, CurrentTarget, LocalPlayer?.GameObjectId);

/// <summary></summary>
public unsafe static float GetDebuffRemainingTime(ushort effectId)
/// <summary> Gets the duration of a status effect on the current target. By default, the effect must be owned by the player or unowned. </summary>
/// <param name="effectId"> Status effect ID. </param>
/// <param name="isPlayerOwned"> Whether the status effect must be owned by the player or can be owned by anyone. </param>
/// <returns> The duration of the status effect. </returns>
public unsafe static float GetDebuffRemainingTime(ushort effectId, bool isPlayerOwned = true)
{
Status? eff = FindTargetEffect(effectId);
Status? eff = (isPlayerOwned == true)
? FindTargetEffect(effectId)
: FindTargetEffectAny(effectId);

if (eff is null) return 0;
if (eff.RemainingTime < 0) return (eff.RemainingTime * -1) + ActionManager.Instance()->AnimationLock;
return eff.RemainingTime;
Expand Down
186 changes: 157 additions & 29 deletions XIVSlothCombo/Window/Tabs/Debug.cs
Original file line number Diff line number Diff line change
@@ -1,74 +1,202 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Interface.Colors;
using ECommons.DalamudServices;
using ImGuiNET;
using System;
using System.Linq;
using System.Numerics;
using XIVSlothCombo.Combos;
using XIVSlothCombo.CustomComboNS;
using XIVSlothCombo.CustomComboNS.Functions;
using XIVSlothCombo.Data;
using XIVSlothCombo.Services;
using Status = Dalamud.Game.ClientState.Statuses.Status;


namespace XIVSlothCombo.Window.Tabs
{

internal class Debug : ConfigWindow
{
public static int debugNum = 0;

internal class DebugCombo : CustomCombo
{
protected internal override CustomComboPreset Preset { get; }

protected override uint Invoke(uint actionID, uint lastComboActionID, float comboTime, byte level) => actionID;
}

public static int debugNum = 0;
internal unsafe static new void Draw()
{
IPlayerCharacter? LocalPlayer = Svc.ClientState.LocalPlayer;
DebugCombo? comboClass = new();
IPlayerCharacter? LocalPlayer = Svc.ClientState.LocalPlayer;
uint[] statusBlacklist = { 360, 361, 362, 363, 364, 365, 366, 367, 368 }; // Duration will not be displayed for these status effects

// Custom Styling
static void CustomStyleText(string label, object? value)
{
if (!string.IsNullOrEmpty(label))
{
ImGui.TextUnformatted(label);
ImGui.SameLine(0, 4f);
}
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudGrey);
ImGui.TextUnformatted(value?.ToString() ?? "");
ImGui.PopStyleColor();
}

if (LocalPlayer != null)
{
if (Svc.ClientState.LocalPlayer.TargetObject is IBattleChara chara)
// Player Status Effects
if (ImGui.CollapsingHeader("Player Status Effects"))
{
foreach (Status? status in chara.StatusList)
foreach (Status? status in LocalPlayer.StatusList)
{
ImGui.TextUnformatted($"TARGET STATUS CHECK: {chara.Name} -> {ActionWatching.GetStatusName(status.StatusId)}: {status.StatusId} {Math.Round(status.RemainingTime, 1)}");
// Null Check (Source Name)
if (status.SourceObject is not null)
{
ImGui.TextUnformatted($"{status.SourceObject.Name} ->");
ImGui.SameLine(0, 4f);
}

// Null Check (Status Name)
if (!string.IsNullOrEmpty(ActionWatching.GetStatusName(status.StatusId)))
{
CustomStyleText(ActionWatching.GetStatusName(status.StatusId) + ":", status.StatusId);
}
else CustomStyleText("", status.StatusId);

// Duration + Blacklist Check
float buffDuration = CustomComboFunctions.GetBuffRemainingTime((ushort)status.StatusId, false);
if (buffDuration != 0 && !statusBlacklist.Contains(status.StatusId))
{
string formattedDuration;
if (buffDuration >= 60)
{
int minutes = (int)(buffDuration / 60);
formattedDuration = $"{minutes}m";
}
else formattedDuration = $"{buffDuration:F1}s";

ImGui.SameLine(0, 4f);
CustomStyleText("", $"({formattedDuration})");
}
}
}

foreach (Status? status in (Svc.ClientState.LocalPlayer as IBattleChara).StatusList)
// Target Status Effects
if (ImGui.CollapsingHeader("Target Status Effects"))
{
ImGui.TextUnformatted($"SELF STATUS CHECK: {Svc.ClientState.LocalPlayer.Name} -> {ActionWatching.GetStatusName(status.StatusId)}: {status.StatusId} {Math.Round(status.RemainingTime, 1)}");
if (LocalPlayer.TargetObject is IBattleChara chara)
{
foreach (Status? status in chara.StatusList)
{
// Null Check (Source Name)
if (status.SourceObject is not null)
{
ImGui.TextUnformatted($"{status.SourceObject.Name} ->");
ImGui.SameLine(0, 4f);
}

// Null Check (Status Name)
if (!string.IsNullOrEmpty(ActionWatching.GetStatusName(status.StatusId)))
{
CustomStyleText(ActionWatching.GetStatusName(status.StatusId) + ":", status.StatusId);
}
else CustomStyleText("", status.StatusId);

// Duration + Blacklist Check
float debuffDuration = CustomComboFunctions.GetDebuffRemainingTime((ushort)status.StatusId, false);
if (debuffDuration != 0 && !statusBlacklist.Contains(status.StatusId))
{
string formattedDuration;
if (debuffDuration >= 60)
{
int minutes = (int)(debuffDuration / 60);
formattedDuration = $"{minutes}m";
}
else formattedDuration = $"{debuffDuration:F1}s";

ImGui.SameLine(0, 4f);
CustomStyleText("", $"({formattedDuration})");
}
}

}
}
ImGui.Spacing();

// Player Info
ImGui.Spacing();
ImGui.Text("Player Info");
ImGui.Separator();
CustomStyleText("Job:", $"{LocalPlayer.ClassJob.GameData.NameEnglish} (ID: {LocalPlayer.ClassJob.Id})");
CustomStyleText("Zone:", $"{Svc.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.TerritoryType>()?.FirstOrDefault(x => x.RowId == Svc.ClientState.TerritoryType).PlaceName.Value.Name} (ID: {Svc.ClientState.TerritoryType})");
CustomStyleText("In PvP:", CustomComboFunctions.InPvP());
CustomStyleText("In Combat:", CustomComboFunctions.InCombat());
CustomStyleText("Hitbox Radius:", LocalPlayer.HitboxRadius);
ImGui.Spacing();

// Target Info
ImGui.Spacing();
ImGui.Text("Target Info");
ImGui.Separator();
CustomStyleText("ObjectId:", LocalPlayer.TargetObject?.GameObjectId);
CustomStyleText("ObjectKind:", LocalPlayer.TargetObject?.ObjectKind);
CustomStyleText("Is BattleChara:", LocalPlayer.TargetObject is IBattleChara);
CustomStyleText("Is PlayerCharacter:", LocalPlayer.TargetObject is IPlayerCharacter);
CustomStyleText("Distance:", $"{Math.Round(CustomComboFunctions.GetTargetDistance(), 2)}y");
CustomStyleText("Hitbox Radius:", LocalPlayer.TargetObject?.HitboxRadius);
CustomStyleText("In Melee Range:", CustomComboFunctions.InMeleeRange());
CustomStyleText("Relative Position:", CustomComboFunctions.AngleToTarget() is 2 ? "Rear" : (CustomComboFunctions.AngleToTarget() is 1 or 3) ? "Flank" : CustomComboFunctions.AngleToTarget() is 4 ? "Front" : "");
CustomStyleText("Health:", $"{CustomComboFunctions.EnemyHealthCurrentHp().ToString("N0")} / {CustomComboFunctions.EnemyHealthMaxHp().ToString("N0")} ({Math.Round(CustomComboFunctions.GetTargetHPPercent(), 2)}%)");
ImGui.Spacing();

// Action Info
ImGui.Spacing();
ImGui.Text("Action Info");
ImGui.Separator();
CustomStyleText("Last Action:", ActionWatching.LastAction == 0 ? string.Empty : $"{(string.IsNullOrEmpty(ActionWatching.GetActionName(ActionWatching.LastAction)) ? "Unknown" : ActionWatching.GetActionName(ActionWatching.LastAction))} (ID: {ActionWatching.LastAction})");
CustomStyleText("Last Action Cost:", CustomComboFunctions.GetResourceCost(ActionWatching.LastAction));
CustomStyleText("Last Action Type:", ActionWatching.GetAttackType(ActionWatching.LastAction));
CustomStyleText("Last Weaponskill:", ActionWatching.GetActionName(ActionWatching.LastWeaponskill));
CustomStyleText("Last Spell:", ActionWatching.GetActionName(ActionWatching.LastSpell));
CustomStyleText("Last Ability:", ActionWatching.GetActionName(ActionWatching.LastAbility));
CustomStyleText("Combo Timer:", $"{CustomComboFunctions.ComboTimer:F1}");
CustomStyleText("Combo Action:", CustomComboFunctions.ComboAction == 0 ? string.Empty : $"{(string.IsNullOrEmpty(ActionWatching.GetActionName(CustomComboFunctions.ComboAction)) ? "Unknown" : ActionWatching.GetActionName(CustomComboFunctions.ComboAction))} (ID: {CustomComboFunctions.ComboAction})");
CustomStyleText("Cast Time:", $"{LocalPlayer.CurrentCastTime:F2} / {LocalPlayer.TotalCastTime:F2}");
CustomStyleText("Cast Action:", LocalPlayer.CastActionId == 0 ? string.Empty : $"{(string.IsNullOrEmpty(ActionWatching.GetActionName(LocalPlayer.CastActionId)) ? "Unknown" : ActionWatching.GetActionName(LocalPlayer.CastActionId))} (ID: {LocalPlayer.CastActionId})");
ImGui.Spacing();

ImGui.TextUnformatted($"TERRITORY: {Svc.ClientState.TerritoryType}");
ImGui.TextUnformatted($"TARGET OBJECT KIND: {Svc.ClientState.LocalPlayer.TargetObject?.ObjectKind}");
ImGui.TextUnformatted($"TARGET IS BATTLE CHARA: {Svc.ClientState.LocalPlayer.TargetObject is IBattleChara}");
ImGui.TextUnformatted($"IN COMBAT: {CustomComboFunctions.InCombat()}");
ImGui.TextUnformatted($"IN MELEE RANGE: {CustomComboFunctions.InMeleeRange()}");
ImGui.TextUnformatted($"DISTANCE FROM TARGET: {CustomComboFunctions.GetTargetDistance()}");
ImGui.TextUnformatted($"TARGET HP VALUE: {CustomComboFunctions.EnemyHealthCurrentHp()}");
ImGui.TextUnformatted($"LAST ACTION: {ActionWatching.GetActionName(ActionWatching.LastAction)} (ID:{ActionWatching.LastAction})");
ImGui.TextUnformatted($"LAST ACTION COST: {CustomComboFunctions.GetResourceCost(ActionWatching.LastAction)}");
ImGui.TextUnformatted($"LAST ACTION TYPE: {ActionWatching.GetAttackType(ActionWatching.LastAction)}");
ImGui.TextUnformatted($"LAST WEAPONSKILL: {ActionWatching.GetActionName(ActionWatching.LastWeaponskill)}");
ImGui.TextUnformatted($"LAST SPELL: {ActionWatching.GetActionName(ActionWatching.LastSpell)}");
ImGui.TextUnformatted($"LAST ABILITY: {ActionWatching.GetActionName(ActionWatching.LastAbility)}");
ImGui.TextUnformatted($"ZONE: {Svc.ClientState.TerritoryType}");
ImGui.BeginChild("BLUSPELLS", new Vector2(250, 100), false);
ImGui.TextUnformatted($"SELECTED BLU SPELLS:\n{string.Join("\n", Service.Configuration.ActiveBLUSpells.Select(x => ActionWatching.GetActionName(x)).OrderBy(x => x))}");
ImGui.EndChild();
// Party Info
ImGui.Spacing();
ImGui.Text("Party Info");
ImGui.Separator();
CustomStyleText("Party ID:", Svc.Party.PartyId);
CustomStyleText("Party Size:", Svc.Party.Length);
if (ImGui.CollapsingHeader("Party Members"))
{
for (int i = 1; i <= 8; i++)
{
if (CustomComboFunctions.GetPartySlot(i) is not IBattleChara member || member is null) continue;
ImGui.TextUnformatted($"Slot {i} ->");
ImGui.SameLine(0, 4f);
CustomStyleText($"{CustomComboFunctions.GetPartySlot(i).Name}", $"({member.ClassJob.GameData.Abbreviation})");
}
}
ImGui.Spacing();

// Misc. Info
ImGui.Spacing();
ImGui.Text("Miscellaneous Info");
ImGui.Separator();
if (ImGui.CollapsingHeader("Active Blue Mage Spells"))
{
ImGui.TextUnformatted($"{string.Join("\n", Service.Configuration.ActiveBLUSpells.Select(x => ActionWatching.GetActionName(x)).OrderBy(x => x))}");
}
}

else
{
ImGui.TextUnformatted("Please log in to use this tab.");
ImGui.TextUnformatted("Please log into the game to use this tab.");
}
}
}
Expand Down

0 comments on commit 954e9e6

Please sign in to comment.