Skip to content

Commit

Permalink
feat: TESObjectREFR, Actor RE (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 authored Oct 9, 2023
1 parent 5a777e5 commit f905386
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 41 deletions.
29 changes: 20 additions & 9 deletions CommonLibSF/include/RE/A/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

#include "RE/A/AIProcess.h"
#include "RE/A/ActorState.h"
#include "RE/A/ActorValueStorage.h"
#include "RE/I/IMovementStateStore.h"
#include "RE/I/IStoreAnimationActions.h"
#include "RE/M/MagicTarget.h"
#include "RE/P/PerkRankData.h"
#include "RE/T/TESObjectREFR.h"

namespace RE
{
class AIProcess;
class BGSPerk;
class CombatController;
class CombatGroup;
class MovementMessageUpdateRequestImmediate;
Expand All @@ -24,7 +27,6 @@ namespace RE
struct BSMovementDataChangedEvent;
struct BSNavmeshChangeEvent;
struct BSSubGraphActivationUpdate;
struct Perks;

namespace PerkValueEvents
{
Expand All @@ -45,6 +47,15 @@ namespace RE
kTotal
};

struct Perks
{
public:
// members
BSTArray<PerkRankData>* perkRanks; // 00
BSTArray<void*> unk10; // 08
};
static_assert(sizeof(Perks) == 0x18);

class Actor :
public TESObjectREFR, // 000
public MagicTarget, // 110
Expand Down Expand Up @@ -265,6 +276,8 @@ namespace RE
virtual void Unk_1A0(); // 1A0
virtual void Unk_1A1(); // 1A1

[[nodiscard]] bool IsHostileToActor(Actor* a_actor);

// members
stl::enumeration<BOOL_BITS, std::uint32_t> boolBits; // 240
std::uint32_t unk244; // 244
Expand All @@ -278,19 +291,16 @@ namespace RE
std::uint64_t unk280; // 280
CombatController* combatController; // 288
std::uint64_t unk290; // 290
std::uint64_t unk298; // 298
std::uint64_t unk2A0; // 2A0
std::uint64_t unk2A8; // 2A8
std::uint64_t unk2B0; // 2B0
std::uint64_t unk2B8; // 2B8
ActorValueStorage avStorage; // 298
std::uint64_t unk2C0; // 2C0
stl::enumeration<ACTOR_CRITICAL_STAGE, std::int32_t> criticalStage; // 2C8
std::uint32_t dialogueItemTarget; // 2CC - TESPointerHandle
std::uint32_t currentCombatTarget; // 2D0 - TESPointerHandle
std::uint32_t myKiller; // 2D4 - TESPointerHandle
std::uint64_t unk2D8; // 2D8
std::uint64_t unk2E0; // 2E0
std::uint64_t unk2E8; // 2E8
std::uint32_t actionValue; // 2E8
float timerOnAction; // 2EC
std::uint64_t unk2F0; // 2F0
std::uint32_t intimidateBribeDayStamp; // 2F8
std::uint32_t unk2FC; // 2FC
Expand All @@ -313,8 +323,9 @@ namespace RE
std::uint64_t unk380; // 380
TESRace* race; // 388
Perks* perks; // 390
std::uint64_t unk398; // 398
std::uint64_t unk3A0; // 3A0
std::uint32_t unk398; // 398
mutable BSReadWriteLock perkArrayLock; // 39C
std::uint32_t unk3A4; // 394
stl::enumeration<BOOL_FLAGS, std::uint32_t> boolFlags; // 3A8
stl::enumeration<BOOL_FLAGS2, std::uint32_t> boolFlags2; // 3AC
std::uint64_t unk3B0; // 3B0
Expand Down
25 changes: 25 additions & 0 deletions CommonLibSF/include/RE/A/ActorValueStorage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "RE/B/BSTArray.h"
#include "RE/B/BSLock.h"

namespace RE
{
struct Modifiers
{
public:
// members
float modifiers[3]; // 0
};
static_assert(sizeof(Modifiers) == 0xC);

class ActorValueStorage
{
public:
// members
BSTArray<void*> baseValues; // 00 - BSTTuple<std::uint32_t, float>
BSTArray<void*> modifiers; // 10 - BSTTuple<std::uint32_t, Modifiers>
BSReadWriteLock avLock; // 20
};
static_assert(sizeof(ActorValueStorage) == 0x28);
}
29 changes: 29 additions & 0 deletions CommonLibSF/include/RE/B/BGSInventoryList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "RE/B/BSTArray.h"
#include "RE/B/BSTEvent.h"

namespace RE
{
class BGSInventoryItem;

namespace BGSInventoryListEvent
{
struct Event;
}

class BGSInventoryList :
public BSTEventSource<BGSInventoryListEvent::Event> // 00
{
public:
SF_RTTI_VTABLE(BGSInventoryList);

~BGSInventoryList() override; // 00

// members
BSTArray<BGSInventoryItem> data; // 28
std::uint32_t ownerHandle; // 38
float cachedWeight; // 3C
};
static_assert(sizeof(BGSInventoryList) == 0x40);
}
13 changes: 3 additions & 10 deletions CommonLibSF/include/RE/P/PlayerCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,9 @@ namespace RE
virtual void Unk_1A4(); // 1A4
virtual void Unk_1A5(); // 1A5

[[nodiscard]] static PlayerCharacter* GetSingleton()
{
static REL::Relocation<PlayerCharacter**> singleton{ REL::ID(865059) };
return *singleton;
}
[[nodiscard]] static PlayerCharacter* GetSingleton();

bool IsInChargen()
{
return *(stl::adjust_pointer<bool>(this, 0xF24));
}
bool IsInChargen();

// members
std::uint64_t unk0670; // 0670
Expand Down Expand Up @@ -361,7 +354,7 @@ namespace RE
std::uint64_t unk0F38; // 0F38
std::uint64_t unk0F40; // 0F40
std::uint64_t unk0F48; // 0F48
TESObjectREFR* crosshairRef; // 0F50 NiPointer?
TESObjectREFR* crosshairRef; // 0F50 - NiPointer?
std::uint64_t unk0F58; // 0F58
std::uint64_t unk0F60; // 0F60
std::uint64_t unk0F68; // 0F68
Expand Down
58 changes: 36 additions & 22 deletions CommonLibSF/include/RE/T/TESObjectREFR.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#pragma once

#include "RE/A/ActorValueOwner.h"
#include "RE/B/BGSInventoryList.h"
#include "RE/B/BSLock.h"
#include "RE/B/BSTEvent.h"
#include "RE/I/IAnimationGraphManagerHolder.h"
#include "RE/I/IKeywordFormBase.h"
#include "RE/I/IMovementInterface.h"
#include "RE/I/IPostAnimationChannelUpdateFunctor.h"
#include "RE/N/NiPoint3.h"
#include "RE/N/NiSmartPointer.h"
#include "RE/T/TESHandleForm.h"

namespace RE
Expand All @@ -16,23 +19,20 @@ namespace RE
class BGSScene;
class BSAnimationGraphEvent;
class BSTransformDeltaEvent;
class NiAVObject;
class TESBoundObject;
class TESModel;
class TESObjectCELL;
class TESRace;
class TESTopicInfo;
class TESWorldSpace;
class TESWaterForm;

namespace ActorValueEvents
{
struct ActorValueChangedEvent;
}

namespace BGSInventoryListEvent
{
struct Event;
}

class IMovementProcessMessageInterface :
public IMovementInterface // 00
{
Expand All @@ -48,12 +48,26 @@ namespace RE
{
public:
// members
NiPoint3A angle; // 00
NiPoint3A location; // 10
TESBoundObject* objectReference; // 20
NiPoint3A angle; // 00
NiPoint3A location; // 10
NiPointer<TESBoundObject> objectReference; // 20 - ref counted in SetObjectReference vfunc
};
static_assert(sizeof(OBJ_REFR) == 0x30);

struct LOADED_REF_DATA
{
public:
// members
void* handleList; // 00 - TODO
NiPointer<NiAVObject> data3D; // 08
TESWaterForm* currentWaterType; // 10
float relevantWaterHeight; // 18
float cachedRadius; // 1C
std::uint32_t flags; // 20
std::uint16_t underwaterCount; // 24
};
static_assert(sizeof(LOADED_REF_DATA) == 0x28);

class TESObjectREFR :
public TESHandleForm, // 00
public BSTEventSink<BSTransformDeltaEvent>, // 38
Expand Down Expand Up @@ -222,7 +236,7 @@ namespace RE
virtual void Unk_F4(); // 0F4
virtual void Unk_F5(); // 0F5
virtual void Unk_F6(); // 0F6
virtual void Unk_F7(); // 0F7
virtual void SetObjectReference(TESBoundObject* a_object, bool a_clearData); // 0F7
virtual void Unk_F8(); // 0F8
virtual void Unk_F9(); // 0F9
virtual void Unk_FA(); // 0FA
Expand Down Expand Up @@ -284,8 +298,8 @@ namespace RE
[[nodiscard]] constexpr float GetAngleX() const { return data.angle.x; }
[[nodiscard]] constexpr float GetAngleY() const { return data.angle.y; }
[[nodiscard]] constexpr float GetAngleZ() const { return data.angle.z; }
[[nodiscard]] TESBoundObject* GetBaseObject() { return data.objectReference; }
[[nodiscard]] const TESBoundObject* GetBaseObject() const { return data.objectReference; };
[[nodiscard]] TESBoundObject* GetBaseObject() { return data.objectReference.get(); }
[[nodiscard]] const TESBoundObject* GetBaseObject() const { return data.objectReference.get(); }
[[nodiscard]] BGSLocation* GetCurrentLocation();
[[nodiscard]] TESObjectREFR* GetLinkedRef(BGSKeyword* a_keyword);
[[nodiscard]] TESWorldSpace* GetParentWorldSpace();
Expand All @@ -304,17 +318,17 @@ namespace RE
[[nodiscard]] bool IsSpaceshipLanded();

// members
OBJ_REFR data; // 0A0
std::uint64_t unkD0; // 0D0
std::uint64_t unkD8; // 0D8
TESObjectCELL* parentCell; // 0E0
void* loadedData; // 0E8
std::uint64_t unkF0; // 0F0
std::uint64_t extraDataList; // 0F8
std::uint64_t unk100; // 100
std::uint16_t scale; // 108
std::uint8_t unk10A; // 10A
std::uint8_t unk10B; // 10B
OBJ_REFR data; // 0A0
BGSInventoryList* inventoryList; // 0D0 - this + lock is one struct?
mutable BSReadWriteLock inventoryListLock; // 0D8
TESObjectCELL* parentCell; // 0E0
LOADED_REF_DATA* loadedData; // 0E8 - same as above
mutable BSReadWriteLock loadedDataLock; // 0F0
std::uint64_t extraDataList; // 0F8
BGSLocalizedString unk100; // 100 - empty?
std::uint16_t scale; // 108
bool unk10A; // 10A
std::uint8_t flags; // 10B
};
static_assert(sizeof(TESObjectREFR) == 0x110);
}
11 changes: 11 additions & 0 deletions CommonLibSF/src/RE/A/Actor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "RE/A/Actor.h"

namespace RE
{
bool Actor::IsHostileToActor(Actor* a_actor)
{
using func_t = decltype(&Actor::IsHostileToActor);
REL::Relocation<func_t> func{ REL::ID(150777) };
return func(this, a_actor);
}
}
15 changes: 15 additions & 0 deletions CommonLibSF/src/RE/P/PlayerCharacter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "RE/P/PlayerCharacter.h"

namespace RE
{
PlayerCharacter* PlayerCharacter::GetSingleton()
{
static REL::Relocation<PlayerCharacter**> singleton{ REL::ID(865059) };
return *singleton;
}

bool PlayerCharacter::IsInChargen()
{
return *(stl::adjust_pointer<bool>(this, 0xF24));
}
}

0 comments on commit f905386

Please sign in to comment.