From 56f7da5e0c6940e38da0a7eb12c6c2feeb9ebb06 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Wed, 24 Jul 2024 13:23:54 -0700 Subject: [PATCH 1/2] feat: Add helper to get the character's current mount --- .../Game/ClientState/Objects/Types/Character.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Dalamud/Game/ClientState/Objects/Types/Character.cs b/Dalamud/Game/ClientState/Objects/Types/Character.cs index 67f8c8b62..c4c91f5b0 100644 --- a/Dalamud/Game/ClientState/Objects/Types/Character.cs +++ b/Dalamud/Game/ClientState/Objects/Types/Character.cs @@ -93,6 +93,11 @@ public interface ICharacter : IGameObject /// Gets the status flags. /// public StatusFlags StatusFlags { get; } + + /// + /// Gets the current mount for this character. Will be null if the character doesn't have a mount. + /// + public ExcelResolver? CurrentMount { get; } } /// @@ -172,6 +177,18 @@ internal unsafe class Character : GameObject, ICharacter (this.Struct->IsAllianceMember ? StatusFlags.AllianceMember : StatusFlags.None) | (this.Struct->IsFriend ? StatusFlags.Friend : StatusFlags.None) | (this.Struct->IsCasting ? StatusFlags.IsCasting : StatusFlags.None); + + /// + public ExcelResolver? CurrentMount + { + get + { + if (this.Struct->IsNotMounted()) return null; // safety i guess? + + var mountId = this.Struct->Mount.MountId; + return mountId == 0 ? null : new ExcelResolver(mountId); + } + } /// /// Gets the underlying structure. From 35520fab8c7d7cb3bd47f1e4d0a6090cf1c737eb Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Wed, 24 Jul 2024 13:36:33 -0700 Subject: [PATCH 2/2] feat: Add CurrentMinion to Character --- .../ClientState/Objects/Types/Character.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Dalamud/Game/ClientState/Objects/Types/Character.cs b/Dalamud/Game/ClientState/Objects/Types/Character.cs index c4c91f5b0..72f6a9950 100644 --- a/Dalamud/Game/ClientState/Objects/Types/Character.cs +++ b/Dalamud/Game/ClientState/Objects/Types/Character.cs @@ -98,6 +98,13 @@ public interface ICharacter : IGameObject /// Gets the current mount for this character. Will be null if the character doesn't have a mount. /// public ExcelResolver? CurrentMount { get; } + + /// + /// Gets the current minion summoned for this character. Will be null if the character doesn't have a minion. + /// This method *will* return information about a spawned (but invisible) minion, e.g. if the character is riding a + /// mount. + /// + public ExcelResolver? CurrentMinion { get; } } /// @@ -183,13 +190,27 @@ internal unsafe class Character : GameObject, ICharacter { get { - if (this.Struct->IsNotMounted()) return null; // safety i guess? + if (this.Struct->IsNotMounted()) return null; // just for safety. var mountId = this.Struct->Mount.MountId; return mountId == 0 ? null : new ExcelResolver(mountId); } } + /// + public ExcelResolver? CurrentMinion + { + get + { + if (this.Struct->CompanionObject != null) + return new ExcelResolver(this.Struct->CompanionObject->BaseId); + + // this is only present if a minion is summoned but hidden (e.g. the player's on a mount). + var hiddenCompanionId = this.Struct->CompanionData.CompanionId; + return hiddenCompanionId == 0 ? null : new ExcelResolver(hiddenCompanionId); + } + } + /// /// Gets the underlying structure. ///