From 94d4039174b565398ff5d4482b6be33c6f6e527f Mon Sep 17 00:00:00 2001 From: Robbe Bryssinck Date: Sat, 11 Dec 2021 22:54:39 +0100 Subject: [PATCH] feat: progress on leveled actor sync --- Code/client/Games/Fallout4/Forms/TESForm.h | 6 ++++++ Code/client/Games/Skyrim/Forms/TESForm.h | 2 ++ Code/client/Services/Generic/CharacterService.cpp | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Code/client/Games/Fallout4/Forms/TESForm.h b/Code/client/Games/Fallout4/Forms/TESForm.h index 533a1ceac..a86642d27 100644 --- a/Code/client/Games/Fallout4/Forms/TESForm.h +++ b/Code/client/Games/Fallout4/Forms/TESForm.h @@ -27,6 +27,11 @@ struct TESForm : BaseFormComponent uint32_t unkC; }; + enum FormFlags + { + DISABLED = 1 << 0xB, + }; + static TESForm* GetById(uint32_t aId); virtual void sub_7(); @@ -106,6 +111,7 @@ struct TESForm : BaseFormComponent // TODO: fallout 4 impl return; } + bool IsDisabled() const noexcept { return (flags & DISABLED) != 0; } uintptr_t unk8; uint32_t flags; diff --git a/Code/client/Games/Skyrim/Forms/TESForm.h b/Code/client/Games/Skyrim/Forms/TESForm.h index 123a8bd7b..fcb28109a 100644 --- a/Code/client/Games/Skyrim/Forms/TESForm.h +++ b/Code/client/Games/Skyrim/Forms/TESForm.h @@ -29,6 +29,7 @@ struct TESForm : BaseFormComponent enum FormFlags { + DISABLED = 1 << 0xB, IGNORE_FRIENDLY_HITS = 1 << 0x14, }; @@ -101,6 +102,7 @@ struct TESForm : BaseFormComponent else flags &= IGNORE_FRIENDLY_HITS; } + bool IsDisabled() const noexcept { return (flags & DISABLED) != 0; } uintptr_t unk4; uint32_t flags; diff --git a/Code/client/Services/Generic/CharacterService.cpp b/Code/client/Services/Generic/CharacterService.cpp index a24095dfb..ded6e02d1 100644 --- a/Code/client/Services/Generic/CharacterService.cpp +++ b/Code/client/Services/Generic/CharacterService.cpp @@ -292,7 +292,7 @@ void CharacterService::OnCharacterSpawn(const CharacterSpawnRequest& acMessage) const auto cNpcId = World::Get().GetModSystem().GetGameId(acMessage.BaseId); if(cNpcId == 0) { - spdlog::error("Failed to retrieve NPC, it will not be spawned, possibly missing mod"); + spdlog::error("Failed to retrieve NPC, it will not be spawned, possibly missing mod, base: {:X}:{:X}, form: {:X}:{:X}", acMessage.BaseId.BaseId, acMessage.BaseId.ModId, acMessage.FormId.BaseId, acMessage.FormId.ModId); return; } @@ -337,6 +337,9 @@ void CharacterService::OnCharacterSpawn(const CharacterSpawnRequest& acMessage) spdlog::error("Actor object {:X} could not be created.", acMessage.ServerId); return; } + + if (pActor->IsDisabled()) + pActor->Enable(); pActor->GetExtension()->SetRemote(true); pActor->rotation.x = acMessage.Rotation.x;