From 3d96a29f21177772c59cd18a86886c4af6195190 Mon Sep 17 00:00:00 2001 From: Sabrina Bjurman Date: Mon, 19 Feb 2024 18:43:04 +0100 Subject: [PATCH 1/4] AIProcess::forms = list of equipped objects and the slot they are equipped to + renamed to equippedForms (equippedObjects was taken). --- include/RE/A/AIProcess.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/RE/A/AIProcess.h b/include/RE/A/AIProcess.h index 30814c154..052c061db 100644 --- a/include/RE/A/AIProcess.h +++ b/include/RE/A/AIProcess.h @@ -134,6 +134,13 @@ namespace RE }; using Hand = Hands::Hand; + struct EquippedObject + { + TESBoundObject* object; // 00 + BGSEquipSlot* slot; // 08 + }; + static_assert(sizeof(EquippedObject) == 0x10); + struct Data0B8 { public: @@ -202,7 +209,7 @@ namespace RE float deathTime; // 094 float trackedDamage; // 098 std::uint32_t pad09C; // 09C - BSTArray forms; // 0A0 + BSTArray equippedForms; // 0A0 Data0B8 unk0B8; // 0B8 TESForm* equippedObjects[Hand::kTotal]; // 0F0 std::uint64_t unk100; // 100 From 2fd14d26800512f778159ce3cc8204eebdcf07c2 Mon Sep 17 00:00:00 2001 From: Sabrina Bjurman Date: Mon, 19 Feb 2024 18:51:18 +0100 Subject: [PATCH 2/4] Convenient function to get object equipped in a specific equipslot. --- include/RE/A/Actor.h | 1 + src/RE/A/Actor.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/RE/A/Actor.h b/include/RE/A/Actor.h index f897e7953..4676491ae 100644 --- a/include/RE/A/Actor.h +++ b/include/RE/A/Actor.h @@ -529,6 +529,7 @@ namespace RE InventoryEntryData* GetEquippedEntryData(bool a_leftHand) const; TESForm* GetEquippedObject(bool a_leftHand) const; float GetEquippedWeight(); + TESBoundObject* GetEquippedObjectInSlot(const BGSEquipSlot* slot) const; std::int32_t GetFactionRank(TESFaction* a_faction, bool a_isPlayer); std::int32_t GetGoldAmount(bool a_noInit = false); ActorHandle GetHandle(); diff --git a/src/RE/A/Actor.cpp b/src/RE/A/Actor.cpp index 239ad8c47..1b1c5c3aa 100644 --- a/src/RE/A/Actor.cpp +++ b/src/RE/A/Actor.cpp @@ -396,6 +396,21 @@ namespace RE } } + TESBoundObject* Actor::GetEquippedObjectInSlot(const BGSEquipSlot* slot) const + { + if (!currentProcess) { + return nullptr; + } + + for (const auto& equippedObject : currentProcess->equippedForms) { + if (equippedObject.slot == slot) { + return equippedObject.object; + } + } + + return nullptr; + } + float Actor::GetEquippedWeight() { if (equippedWeight < 0.0f) { From baf0c8cc58d07e915b3b2dc28be5b98b588db8a1 Mon Sep 17 00:00:00 2001 From: Sabrina Bjurman Date: Mon, 19 Feb 2024 18:53:41 +0100 Subject: [PATCH 3/4] yeah --- include/RE/A/Actor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/RE/A/Actor.h b/include/RE/A/Actor.h index 4676491ae..0cb6e6b68 100644 --- a/include/RE/A/Actor.h +++ b/include/RE/A/Actor.h @@ -528,8 +528,8 @@ namespace RE const TESShout* GetCurrentShout() const; InventoryEntryData* GetEquippedEntryData(bool a_leftHand) const; TESForm* GetEquippedObject(bool a_leftHand) const; - float GetEquippedWeight(); TESBoundObject* GetEquippedObjectInSlot(const BGSEquipSlot* slot) const; + float GetEquippedWeight(); std::int32_t GetFactionRank(TESFaction* a_faction, bool a_isPlayer); std::int32_t GetGoldAmount(bool a_noInit = false); ActorHandle GetHandle(); From c3c9df7d84a401d606d48526c15442bc708d1249 Mon Sep 17 00:00:00 2001 From: Sabrina Bjurman Date: Mon, 19 Feb 2024 19:25:05 +0100 Subject: [PATCH 4/4] On a second thought it's probably TESForm and not TESBoundObject since shouts are not bound objects. --- include/RE/A/AIProcess.h | 6 +++--- include/RE/A/Actor.h | 2 +- src/RE/A/Actor.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/RE/A/AIProcess.h b/include/RE/A/AIProcess.h index 052c061db..550d3ef4c 100644 --- a/include/RE/A/AIProcess.h +++ b/include/RE/A/AIProcess.h @@ -136,8 +136,8 @@ namespace RE struct EquippedObject { - TESBoundObject* object; // 00 - BGSEquipSlot* slot; // 08 + TESForm* object; // 00 + BGSEquipSlot* slot; // 08 }; static_assert(sizeof(EquippedObject) == 0x10); @@ -209,7 +209,7 @@ namespace RE float deathTime; // 094 float trackedDamage; // 098 std::uint32_t pad09C; // 09C - BSTArray equippedForms; // 0A0 + BSTArray equippedForms; // 0A0 Data0B8 unk0B8; // 0B8 TESForm* equippedObjects[Hand::kTotal]; // 0F0 std::uint64_t unk100; // 100 diff --git a/include/RE/A/Actor.h b/include/RE/A/Actor.h index 0cb6e6b68..cbf210e86 100644 --- a/include/RE/A/Actor.h +++ b/include/RE/A/Actor.h @@ -528,7 +528,7 @@ namespace RE const TESShout* GetCurrentShout() const; InventoryEntryData* GetEquippedEntryData(bool a_leftHand) const; TESForm* GetEquippedObject(bool a_leftHand) const; - TESBoundObject* GetEquippedObjectInSlot(const BGSEquipSlot* slot) const; + TESForm* GetEquippedObjectInSlot(const BGSEquipSlot* slot) const; float GetEquippedWeight(); std::int32_t GetFactionRank(TESFaction* a_faction, bool a_isPlayer); std::int32_t GetGoldAmount(bool a_noInit = false); diff --git a/src/RE/A/Actor.cpp b/src/RE/A/Actor.cpp index 1b1c5c3aa..3ef846858 100644 --- a/src/RE/A/Actor.cpp +++ b/src/RE/A/Actor.cpp @@ -396,7 +396,7 @@ namespace RE } } - TESBoundObject* Actor::GetEquippedObjectInSlot(const BGSEquipSlot* slot) const + TESForm* Actor::GetEquippedObjectInSlot(const BGSEquipSlot* slot) const { if (!currentProcess) { return nullptr;