From 78737513dafd7a2e20263c20f7c46e94689e85b8 Mon Sep 17 00:00:00 2001 From: powerof3 Date: Sat, 12 Oct 2024 05:50:24 +0530 Subject: [PATCH] Update --- cmake/sourcelist.cmake | 1 + include/RE/A/AIProcess.h | 8 +- include/RE/A/Actor.h | 2 +- include/RE/A/ActorState.h | 16 +++- include/RE/A/AutoVanityState.h | 27 +++++++ include/RE/H/HighProcessData.h | 2 +- include/RE/M/MovementControllerNPC.h | 24 +++--- include/RE/P/PlayerCamera.h | 1 + include/RE/P/ProcessLists.h | 1 + include/RE/Skyrim.h | 1 + include/RE/T/TESPackage.h | 105 ++++++++++++++++++++++----- src/RE/A/AIProcess.cpp | 28 +++++++ src/RE/A/Actor.cpp | 8 +- src/RE/P/PlayerCamera.cpp | 7 ++ src/RE/P/ProcessLists.cpp | 7 ++ 15 files changed, 198 insertions(+), 40 deletions(-) create mode 100644 include/RE/A/AutoVanityState.h diff --git a/cmake/sourcelist.cmake b/cmake/sourcelist.cmake index 88d98b3b9..64cc8e6ce 100644 --- a/cmake/sourcelist.cmake +++ b/cmake/sourcelist.cmake @@ -50,6 +50,7 @@ set(SOURCES include/RE/A/AutoMoveHandler.h include/RE/A/AutoRegisterCreator.h include/RE/A/AutoRegisterFactory.h + include/RE/A/AutoVanityState.h include/RE/A/ahkpCharacterProxy.h include/RE/A/ahkpWorld.h include/RE/B/BGSAbilityPerkEntry.h diff --git a/include/RE/A/AIProcess.h b/include/RE/A/AIProcess.h index 60304d4ed..79243a0ff 100644 --- a/include/RE/A/AIProcess.h +++ b/include/RE/A/AIProcess.h @@ -156,8 +156,10 @@ namespace RE }; static_assert(sizeof(Data0B8) == 0x38); + void AddToProcedureIndexRunning(Actor* a_actor, std::uint32_t a_num); void ClearActionHeadtrackTarget(bool a_defaultHold); void ClearMuzzleFlashes(); + void ComputeLastTimeProcessed(); float GetCachedHeight() const; bhkCharacterController* GetCharController(); ActorHandle GetCommandingActor() const; @@ -182,11 +184,13 @@ namespace RE bool IsInCommandState() const; void KnockExplosion(Actor* a_actor, const NiPoint3& a_location, float a_magnitude); bool PlayIdle(Actor* a_actor, TESIdleForm* a_idle, TESObjectREFR* a_target); + void RandomlyPlaySpecialIdles(Actor* a_actor); void SetActorsDetectionEvent(Actor* a_actor, const NiPoint3& a_location, std::int32_t a_soundLevel, TESObjectREFR* a_ref); void SetArrested(bool a_arrested); void SetCachedHeight(float a_height); void SetHeadtrackTarget(Actor* a_owner, NiPoint3& a_targetPosition); void Set3DUpdateFlag(RESET_3D_FLAGS a_flags); + void SetRunOncePackage(TESPackage* a_package, Actor* a_actor); bool SetupSpecialIdle(Actor* a_actor, DEFAULT_OBJECT a_action, TESIdleForm* a_idle, bool a_arg5, bool a_arg6, TESObjectREFR* a_target); void StopCurrentIdle(Actor* a_actor, bool a_forceIdleStop); void Update3DModel(Actor* a_actor); @@ -197,8 +201,8 @@ namespace RE MiddleHighProcessData* middleHigh; // 008 HighProcessData* high; // 010 ActorPackage currentPackage; // 018 - float unk048; // 048 - std::uint32_t unk04C; // 04C + float hourLastProcessed; // 048 + float dateLastProcessed; // 04C CachedValues* cachedValues; // 050 std::int32_t numberItemsActivate; // 058 std::uint32_t pad05C; // 05C diff --git a/include/RE/A/Actor.h b/include/RE/A/Actor.h index 9dd068653..b252cc424 100644 --- a/include/RE/A/Actor.h +++ b/include/RE/A/Actor.h @@ -413,7 +413,7 @@ namespace RE virtual void InitiateSpectator(Actor* a_target); // 0DC - { return; } virtual void InitiateFlee(TESObjectREFR* a_fleeRef, bool a_runOnce, bool a_knows, bool a_combatMode, TESObjectCELL* a_cell, TESObjectREFR* a_ref, float a_fleeFromDist, float a_fleeToDist); // 0DD virtual void InitiateGetUpPackage(); // 0DE - virtual void PutCreatedPackage(TESPackage* a_package, bool a_tempPackage, bool a_createdPackage, bool a_allowFromFurniture); // 0DF + virtual void PutCreatedPackage(TESPackage* a_package, bool a_tempPackage, bool a_createdPackage); // 0DF virtual void UpdateAlpha(); // 0E0 virtual void SetAlpha(float a_alpha = 1.0); // 0E1 virtual float GetAlpha(); // 0E2 diff --git a/include/RE/A/ActorState.h b/include/RE/A/ActorState.h index 9ce53e665..d9615b655 100644 --- a/include/RE/A/ActorState.h +++ b/include/RE/A/ActorState.h @@ -150,8 +150,8 @@ namespace RE void Unk_08(void) override; // 08 - { return 0; } // add - virtual void Unk_14(void); // 14 - virtual void Unk_15(void); // 15 + virtual bool DoSetSitSleepState(SIT_SLEEP_STATE a_state); // 14 + virtual void Unk_15(void); // 15 [[nodiscard]] ATTACK_STATE_ENUM GetAttackState() const noexcept { return actorState1.meleeAttackState; } [[nodiscard]] FLY_STATE GetFlyState() const noexcept { return actorState1.flyState; } @@ -183,6 +183,18 @@ namespace RE } [[nodiscard]] bool IsReanimated() const noexcept { return GetLifeState() == ACTOR_LIFE_STATE::kReanimate; } + + [[nodiscard]] bool IsSitting() const noexcept + { + switch (GetSitSleepState()) { + case SIT_SLEEP_STATE::kIsSitting: + case SIT_SLEEP_STATE::kWantToStand: + return true; + default: + return false; + } + } + [[nodiscard]] bool IsSneaking() const noexcept { return static_cast(actorState1.sneaking); } [[nodiscard]] bool IsSprinting() const noexcept { return static_cast(actorState1.sprinting); } [[nodiscard]] bool IsSwimming() const noexcept { return static_cast(actorState1.swimming); } diff --git a/include/RE/A/AutoVanityState.h b/include/RE/A/AutoVanityState.h new file mode 100644 index 000000000..649299e0d --- /dev/null +++ b/include/RE/A/AutoVanityState.h @@ -0,0 +1,27 @@ +#pragma once + +#include "RE/T/TESCameraState.h" + +namespace RE +{ + class AutoVanityState : public TESCameraState + { + public: + inline static constexpr auto RTTI = RTTI_AutoVanityState; + inline static constexpr auto VTABLE = VTABLE_AutoVanityState; + + ~AutoVanityState() override; // 00 + + // override (TESCameraState) + void Begin() override; // 01 + void End() override; // 02 + void Update(BSTSmartPointer& a_nextState) override; // 03 + void GetRotation(NiQuaternion& a_rotation) override; // 04 + void GetTranslation(NiPoint3& a_translation) override; // 05 + + // members + float autoVanityRot; // 20 + std::uint32_t pad24; // 24 + }; + static_assert(sizeof(AutoVanityState) == 0x28); +} diff --git a/include/RE/H/HighProcessData.h b/include/RE/H/HighProcessData.h index ee572abfd..bd5e9eb0a 100644 --- a/include/RE/H/HighProcessData.h +++ b/include/RE/H/HighProcessData.h @@ -248,7 +248,7 @@ namespace RE float takeBackTimer; // 200 std::uint32_t pad204; // 204 Data208* unk208; // 208 - std::uint32_t unk210; // 210 + float avoidWaitTimer; // 210 PLAYER_ACTION playerActionReaction; // 214 BSFixedString voiceSubtitle; // 218 BSTArray>> knowledgeArray; // 220 diff --git a/include/RE/M/MovementControllerNPC.h b/include/RE/M/MovementControllerNPC.h index fe60807b6..a1990371c 100644 --- a/include/RE/M/MovementControllerNPC.h +++ b/include/RE/M/MovementControllerNPC.h @@ -26,17 +26,17 @@ namespace RE ~MovementControllerNPC() override; // 00 // add - virtual void Unk_0A(void); // 0A - virtual void Unk_0B(void); // 0B - virtual void DisablePlayerControls(); // 0C - virtual void EnablePlayerControls(); // 0D - virtual bool IsPlayerControlsDisabled(); // 0E - { return unk1C5 == 0; } - virtual bool IsPlayerControlsEnabled(); // 0F - { return unk1C5; } - virtual void Unk_10(void); // 10 - virtual void Unk_11(void); // 11 - virtual void Unk_12(void); // 12 - virtual void Unk_13(void); // 13 - virtual void Unk_14(void); // 14 + virtual void Unk_0A(void); // 0A + virtual void Unk_0B(void); // 0B + virtual void SetAIDriven(); // 0C + virtual void SetControlsDriven(); // 0D + virtual bool GetAIDriven(); // 0E - { return controlsDriven == 0; } + virtual bool GetControlsDriven(); // 0F - { return controlsDriven; } + virtual void Unk_10(void); // 10 + virtual void Unk_11(void); // 11 + virtual void Unk_12(void); // 12 + virtual void Unk_13(void); // 13 + virtual void Unk_14(void); // 14 // members std::uint64_t unk150; // 150 @@ -55,7 +55,7 @@ namespace RE std::uint64_t unk1B8; // 1B8 std::uint32_t unk1C0; // 1C0 std::uint8_t unk1C4; // 1C4 - bool playerControls; // 1C5 + bool controlsDriven; // 1C5 std::uint16_t unk1C6; // 1C6 std::uint64_t unk1C8; // 1C8 }; diff --git a/include/RE/P/PlayerCamera.h b/include/RE/P/PlayerCamera.h index c35846eb8..a0c8856eb 100644 --- a/include/RE/P/PlayerCamera.h +++ b/include/RE/P/PlayerCamera.h @@ -66,6 +66,7 @@ namespace RE bool IsInFirstPerson() const; bool IsInFreeCameraMode() const; bool IsInThirdPerson() const; + void PushCameraState(CameraState a_state); void ToggleFreeCameraMode(bool a_freezeTime); void UpdateThirdPerson(bool a_weaponDrawn); diff --git a/include/RE/P/ProcessLists.h b/include/RE/P/ProcessLists.h index 8f9a15d04..0f5a89467 100644 --- a/include/RE/P/ProcessLists.h +++ b/include/RE/P/ProcessLists.h @@ -36,6 +36,7 @@ namespace RE static ProcessLists* GetSingleton(); + bool AreHostileActorsNear(BSScrapArray* a_arrayOut); void ClearCachedFactionFightReactions() const; void ForAllActors(std::function a_callback); void ForEachHighActor(std::function a_callback); diff --git a/include/RE/Skyrim.h b/include/RE/Skyrim.h index 3256e6a29..33f4c3e64 100644 --- a/include/RE/Skyrim.h +++ b/include/RE/Skyrim.h @@ -53,6 +53,7 @@ #include "RE/A/AutoMoveHandler.h" #include "RE/A/AutoRegisterCreator.h" #include "RE/A/AutoRegisterFactory.h" +#include "RE/A/AutoVanityState.h" #include "RE/A/ahkpCharacterProxy.h" #include "RE/A/ahkpWorld.h" #include "RE/B/BGSAbilityPerkEntry.h" diff --git a/include/RE/T/TESPackage.h b/include/RE/T/TESPackage.h index 117632712..b97e6c6fc 100644 --- a/include/RE/T/TESPackage.h +++ b/include/RE/T/TESPackage.h @@ -31,10 +31,10 @@ namespace RE kFOOD = 15 }; - enum class PACKAGE_PROCEDURE_TYPE + enum class PACKAGE_TYPE { - kNone = static_cast>(-1), - kFind = 0, + kNone = static_cast>(-1), + kExplore = 0, kFollow = 1, kEscort = 2, kEat = 3, @@ -51,7 +51,7 @@ namespace RE kGuard = 14, kDialogue = 15, kUseWeapon = 16, - kFind2 = 17, + kFind = 17, kPackage = 18, kPackageTemplate = 19, kActivate = 20, @@ -73,13 +73,67 @@ namespace RE kMovementBlocked = 36, kVampireFeed = 37, kCannibal = 38, - kUnk39 = 39, - kUnk40 = 40, - kUnk41 = 41, - kUnk42 = 42, - kUnk43 = 43, - kUnk44 = 44, - kUnk45 = 45, + kLanding = 39, + kUnused = 40, + kMountActor = 41, + kDismountActor = 42, + kClearMountPosition = 43, + + kTotal = 44 + }; + + enum class PACKAGE_PROCEDURE_TYPE + { + kNone = static_cast>(-1), + kExploreTravel = 0, + kExploreWander = 1, + ExploreActivate = 2, + kExploreAcquire = 3, + kSleep = 4, + kEat = 5, + kFollowWithEscort = 6, + kAmbushFollow = 7, + kEscortActor = 8, + kEscortObject = 9, + kDialogue = 10, + kAlarm = 11, + kActivate = 12, + kGreet = 13, + kObserveCombat = 14, + kObserveDialogue = 15, + kTalkToDead = 16, + kFlee = 17, + kTrespass = 18, + kGetUpFromChairBed = 19, + kExploreNPC = 20, + kMountActor = 21, + kDismountActor = 22, + kDoNothing = 23, + kExploreAcquireGeneric = 24, + kAccompany = 25, + kUseItemAt = 26, + kVampireFeed = 27, + kAmbush = 28, + kSurface = 29, + kFleeNotCombat = 30, + kSearchForAttacker = 31, + kClearMountPosition = 32, + kWaitForDialogue = 33, + kAvoidPlayer = 34, + kSandbox = 35, + kPatrol = 36, + kReactToDestroyedObject = 37, + kReactToGrenadeOrMine = 38, + kGuard = 39, + kStealWarning = 40, + kPickPocketWarning = 41, + kUseWeapon = 42, + kFollowWithoutEscort = 43, + kMovementBlocked = 44, + kCannibal = 45, + kPackage = 46, + kLanding = 47, + kKeepAnEyeOn = 48 }; enum class PACK_EVENT_ACTION_TYPE @@ -112,6 +166,7 @@ namespace RE kUnlocksDoorsAtPackageEnd = 1 << 7, kContinueIfPCNear = 1 << 9, kOncePerDay = 1 << 10, + kCreated = 1 << 11, kPreferredSpeed = 1 << 13, kAlwaysSneak = 1 << 17, kAllowSwimming = 1 << 18, @@ -145,13 +200,13 @@ namespace RE }; // members - stl::enumeration packFlags; // 0 - stl::enumeration packType; // 4 - stl::enumeration interruptOverrideType; // 5 - stl::enumeration maxSpeed; // 6 - std::uint8_t pad7; // 7 - stl::enumeration foBehaviorFlags; // 8 - std::uint16_t packageSpecificFlags; // A + stl::enumeration packFlags; // 0 + stl::enumeration packType; // 4 + stl::enumeration interruptOverrideType; // 5 + stl::enumeration maxSpeed; // 6 + std::uint8_t pad7; // 7 + stl::enumeration foBehaviorFlags; // 8 + std::uint16_t packageSpecificFlags; // A }; static_assert(sizeof(PACKAGE_DATA) == 0xC); @@ -296,6 +351,20 @@ namespace RE virtual bool IsTargetAtLocation(Actor* a_actor, std::int32_t a_arg2); // 3E virtual bool IsPackageOwner(Actor* a_actor); // 3F - { return true; } + static TESPackage* CreatePackage(PACKAGE_PROCEDURE_TYPE a_type) + { + using func_t = decltype(&TESPackage::CreatePackage); + static REL::Relocation func{ RELOCATION_ID(28732, 29496) }; + return func(a_type); + } + + void SetPackType(PACKAGE_PROCEDURE_TYPE a_type) + { + using func_t = decltype(&TESPackage::SetPackType); + static REL::Relocation func{ RELOCATION_ID(28751, 29525) }; + return func(this, a_type); + } + // members PACKAGE_DATA packData; // 20 - PKDT std::uint32_t pad2C; // 2C diff --git a/src/RE/A/AIProcess.cpp b/src/RE/A/AIProcess.cpp index 6c8ae17c6..1792a203a 100644 --- a/src/RE/A/AIProcess.cpp +++ b/src/RE/A/AIProcess.cpp @@ -10,6 +10,13 @@ namespace RE { + void AIProcess::AddToProcedureIndexRunning(Actor* a_actor, std::uint32_t a_num) + { + using func_t = decltype(&AIProcess::AddToProcedureIndexRunning); + static REL::Relocation func{ RELOCATION_ID(38198, 39158) }; + return func(this, a_actor, a_num); + } + void AIProcess::ClearActionHeadtrackTarget(bool a_defaultHold) { if (high) { @@ -24,6 +31,13 @@ namespace RE return func(this); } + void AIProcess::ComputeLastTimeProcessed() + { + using func_t = decltype(&AIProcess::ComputeLastTimeProcessed); + static REL::Relocation func{ RELOCATION_ID(38158, 39116) }; + return func(this); + } + float AIProcess::GetCachedHeight() const { return high ? high->cachedActorHeight : static_cast(-1.0); @@ -211,6 +225,13 @@ namespace RE return SetupSpecialIdle(a_actor, DEFAULT_OBJECT::kActionIdle, a_idle, true, false, a_target); } + void AIProcess::RandomlyPlaySpecialIdles(Actor* a_actor) + { + using func_t = decltype(&AIProcess::RandomlyPlaySpecialIdles); + static REL::Relocation func{ RELOCATION_ID(38308, 39281) }; + return func(this, a_actor); + } + void AIProcess::SetActorsDetectionEvent(Actor* a_actor, const NiPoint3& a_location, std::int32_t a_soundLevel, TESObjectREFR* a_ref) { using func_t = decltype(&AIProcess::SetActorsDetectionEvent); @@ -246,6 +267,13 @@ namespace RE } } + void AIProcess::SetRunOncePackage(TESPackage* a_package, Actor* a_actor) + { + using func_t = decltype(&AIProcess::SetRunOncePackage); + static REL::Relocation func{ RELOCATION_ID(38819, 39849) }; + return func(this, a_package, a_actor); + } + bool AIProcess::SetupSpecialIdle(Actor* a_actor, DEFAULT_OBJECT a_action, TESIdleForm* a_idle, bool a_arg5, bool a_arg6, TESObjectREFR* a_target) { using func_t = decltype(&AIProcess::SetupSpecialIdle); diff --git a/src/RE/A/Actor.cpp b/src/RE/A/Actor.cpp index ba971d2a9..9e8499a9e 100644 --- a/src/RE/A/Actor.cpp +++ b/src/RE/A/Actor.cpp @@ -551,7 +551,7 @@ namespace RE bool Actor::GetPlayerControls() const { if (movementController) { - return movementController->IsPlayerControlsEnabled(); + return movementController->GetControlsDriven(); } return false; } @@ -764,7 +764,7 @@ namespace RE bool Actor::IsAlarmed() const { auto currentPackage = GetCurrentPackage(); - return currentPackage && currentPackage->packData.packType.get() == PACKAGE_PROCEDURE_TYPE::kAlarm; + return currentPackage && currentPackage->packData.packType.get() == PACKAGE_TYPE::kAlarm; } bool Actor::IsAMount() const @@ -1094,9 +1094,9 @@ namespace RE if (movementController) { EnableAI(!a_enable); if (a_enable) { - movementController->EnablePlayerControls(); + movementController->SetControlsDriven(); } else { - movementController->DisablePlayerControls(); + movementController->SetAIDriven(); } } } diff --git a/src/RE/P/PlayerCamera.cpp b/src/RE/P/PlayerCamera.cpp index 28693b85e..e54915c56 100644 --- a/src/RE/P/PlayerCamera.cpp +++ b/src/RE/P/PlayerCamera.cpp @@ -42,6 +42,13 @@ namespace RE return QCameraEquals(CameraState::kThirdPerson); } + void PlayerCamera::PushCameraState(CameraState a_state) + { + using func_t = decltype(&PlayerCamera::PushCameraState); + static REL::Relocation func{ RELOCATION_ID(49947, 50880) }; + return func(this, a_state); + } + bool PlayerCamera::QCameraEquals(CameraState a_cameraState) const { return currentState && currentState == cameraStates[a_cameraState]; diff --git a/src/RE/P/ProcessLists.cpp b/src/RE/P/ProcessLists.cpp index be0c64970..72f43d371 100644 --- a/src/RE/P/ProcessLists.cpp +++ b/src/RE/P/ProcessLists.cpp @@ -14,6 +14,13 @@ namespace RE return *singleton; } + bool ProcessLists::AreHostileActorsNear(BSScrapArray* a_arrayOut) + { + using func_t = decltype(&ProcessLists::AreHostileActorsNear); + static REL::Relocation func{ RELOCATION_ID(40388, 41402) }; + return func(this, a_arrayOut); + } + void ProcessLists::ClearCachedFactionFightReactions() const { using func_t = decltype(&ProcessLists::ClearCachedFactionFightReactions);