From 375e350e46fd684a3de46885ecbd9647b3d25d40 Mon Sep 17 00:00:00 2001 From: FalloutCascadia <54562300+FalloutCascadia@users.noreply.github.com> Date: Tue, 10 Dec 2024 21:31:23 +0100 Subject: [PATCH] Actor Utils (#25) * feat: Class `ActorUtils` declared. --- CommonLibF4/cmake/sourcelist.cmake | 1 + CommonLibF4/include/RE/Bethesda/ActorUtils.h | 60 +++++++++++++++++++ .../include/RE/Bethesda/PipboyInventoryData.h | 15 +++++ .../RE/Bethesda/PipboyPrimitiveValue.h | 2 +- CommonLibF4/include/RE/Bethesda/PipboyValue.h | 14 +++++ CommonLibF4/include/RE/Fallout.h | 1 + 6 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 CommonLibF4/include/RE/Bethesda/ActorUtils.h diff --git a/CommonLibF4/cmake/sourcelist.cmake b/CommonLibF4/cmake/sourcelist.cmake index ab82cb69..5d2bea4e 100644 --- a/CommonLibF4/cmake/sourcelist.cmake +++ b/CommonLibF4/cmake/sourcelist.cmake @@ -10,6 +10,7 @@ set(SOURCES include/RE/Bethesda/AITimeStamp.h include/RE/Bethesda/ActiveEffect.h include/RE/Bethesda/Actor.h + include/RE/Bethesda/ActorUtils.h include/RE/Bethesda/ActorValueInfo.h include/RE/Bethesda/Archive2.h include/RE/Bethesda/Atomic.h diff --git a/CommonLibF4/include/RE/Bethesda/ActorUtils.h b/CommonLibF4/include/RE/Bethesda/ActorUtils.h new file mode 100644 index 00000000..1dba286a --- /dev/null +++ b/CommonLibF4/include/RE/Bethesda/ActorUtils.h @@ -0,0 +1,60 @@ +#pragma once + +#include "RE/Bethesda/TESBoundObjects.h" + +namespace RE +{ + namespace ActorUtils + { + class __declspec(novtable) ArmorRatingVisitorBase + { + public: + static constexpr auto RTTI{ RTTI::ActorUtils__ArmorRatingVisitorBase }; + static constexpr auto VTABLE{ VTABLE::ActorUtils__ArmorRatingVisitorBase }; + + ArmorRatingVisitorBase() + { + stl::emplace_vtable(this); + } + + virtual bool ShouldProcess(TESBoundObject*) { return 1; }; // 00 + virtual void PostPRocess(TESBoundObject*){}; // 01 + + Actor* actor; // 08 + float rating; // 10 + float armorPerks; // 14 + bool checkEquipped; // 18 + + void ctor(const Actor* a_actor, bool a_checkEquipped) + { + using func_t = decltype(&ArmorRatingVisitorBase::ctor); + REL::Relocation func{ REL::ID(2227205) }; + return func(this, a_actor, a_checkEquipped); + } + + ArmorRatingVisitorBase(const Actor* a_actor, bool a_checkEquipped) + { + ctor(a_actor, a_checkEquipped); + } + + std::int64_t operator()(const BGSInventoryItem* a_item, std::uint32_t a_stackID) + { + using func_t = decltype(&ArmorRatingVisitorBase::operator()); + REL::Relocation func{ REL::ID(2227206) }; + return func(this, a_item, a_stackID); + } + }; + static_assert(offsetof(ArmorRatingVisitorBase, rating) == 0x10); + static_assert(sizeof(ArmorRatingVisitorBase) == 0x20); + + class __declspec(novtable) ArmorRatingVisitor : + public ArmorRatingVisitorBase // 00 + { + static constexpr auto RTTI{ RTTI::ActorUtils__ArmorRatingVisitor }; + static constexpr auto VTABLE{ VTABLE::ActorUtils__ArmorRatingVisitor }; + + BSScrapArray foundArmor; // 20 + }; + static_assert(sizeof(ArmorRatingVisitor) == 0x40); + } +} diff --git a/CommonLibF4/include/RE/Bethesda/PipboyInventoryData.h b/CommonLibF4/include/RE/Bethesda/PipboyInventoryData.h index abfb4a6f..0d4d76c0 100644 --- a/CommonLibF4/include/RE/Bethesda/PipboyInventoryData.h +++ b/CommonLibF4/include/RE/Bethesda/PipboyInventoryData.h @@ -6,6 +6,7 @@ #include "RE/Bethesda/BSTHashMap.h" #include "RE/Bethesda/BSTList.h" #include "RE/Bethesda/Events.h" +#include "RE/Bethesda/PipboyArray.h" #include "RE/Bethesda/PipboyDataGroup.h" namespace RE @@ -86,6 +87,20 @@ namespace RE return func(this, itemTypeID); } + void PopulateItemCardInfo(const BGSInventoryItem* a_inventoryItem, const BGSInventoryItem::Stack* a_stack, PipboyObject* a_data) + { + using func_t = decltype(&PipboyInventoryData::PopulateItemCardInfo); + static REL::Relocation func{ REL::ID(2225266) }; + return func(this, a_inventoryItem, a_stack, a_data); + } + + void AddItemCardInfoEntry(const BSFixedStringCS* a_string, float a_value, PipboyArray* a_itemCardSection) + { + using func_t = decltype(&PipboyInventoryData::AddItemCardInfoEntry); + static REL::Relocation func{ REL::ID(2225267) }; + return func(this, a_string, a_value, a_itemCardSection); + } + // members PipboyObject* inventoryObject; // E8 BSTHashMap itemEntries; // F0 diff --git a/CommonLibF4/include/RE/Bethesda/PipboyPrimitiveValue.h b/CommonLibF4/include/RE/Bethesda/PipboyPrimitiveValue.h index ed25f104..ecb558ad 100644 --- a/CommonLibF4/include/RE/Bethesda/PipboyPrimitiveValue.h +++ b/CommonLibF4/include/RE/Bethesda/PipboyPrimitiveValue.h @@ -37,7 +37,7 @@ namespace RE // members std::uint32_t value; // 18 }; - static_assert(sizeof(PipboyPrimitiveValue) == 0x20); + static_assert(sizeof(PipboyPrimitiveValue) == 0x20); template <> class __declspec(novtable) PipboyPrimitiveValue : public PipboyValue diff --git a/CommonLibF4/include/RE/Bethesda/PipboyValue.h b/CommonLibF4/include/RE/Bethesda/PipboyValue.h index 67f84532..9a03fba6 100644 --- a/CommonLibF4/include/RE/Bethesda/PipboyValue.h +++ b/CommonLibF4/include/RE/Bethesda/PipboyValue.h @@ -76,6 +76,20 @@ namespace RE virtual void SerializeChanges(BSBinarySerializer& a_serializer, bool a_fullSerialize) override; // 03 virtual SERIALIZATION_DATA_TYPE GetType() override; // 04 + template + T GetMember(const BSFixedString& a_name) + { + const auto it = memberMap.find(a_name); + return (it != memberMap.end()) ? static_cast(it->second) : nullptr; + } + + void AddMember(const BSFixedString* a_name, PipboyValue* a_member) + { + using func_t = decltype(&PipboyObject::AddMember); + static REL::Relocation func{ REL::ID(2225699) }; + return func(this, a_name, a_member); + } + // members BSTHashMap memberMap; // 18 BSTSet addedMemberIDs; // 48 diff --git a/CommonLibF4/include/RE/Fallout.h b/CommonLibF4/include/RE/Fallout.h index 38a56600..7ae1cf62 100644 --- a/CommonLibF4/include/RE/Fallout.h +++ b/CommonLibF4/include/RE/Fallout.h @@ -5,6 +5,7 @@ #include "RE/Bethesda/AITimeStamp.h" #include "RE/Bethesda/ActiveEffect.h" #include "RE/Bethesda/Actor.h" +#include "RE/Bethesda/ActorUtils.h" #include "RE/Bethesda/ActorValueInfo.h" #include "RE/Bethesda/Archive2.h" #include "RE/Bethesda/Atomic.h"