diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 95175d9f4..5f4337daf 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -728,7 +728,7 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream& outBitStream, eReplicaPacke outBitStream.Write(m_ParentEntity != nullptr); if (m_ParentEntity) { outBitStream.Write(m_ParentEntity->GetObjectID()); - outBitStream.Write0(); // Updates position with parent, usually false in live. Haven't seen a case where its supposed to be true + outBitStream.Write(m_UpdatesWithParentPosition); } outBitStream.Write(!m_ChildEntities.empty()); if (!m_ChildEntities.empty()) { diff --git a/dGame/Entity.h b/dGame/Entity.h index 8a2b93c5b..ed785a6f3 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -370,6 +370,10 @@ public: // Scale will only be communicated to the client when the construction packet is sent void SetScale(const float scale) { m_Scale = scale; }; + // The client moves the object with its parent (LWOGameObject::updatesWithParentPosition), sent with the parent; + // the spawn behavior's updatePositionWithParent sets it (live: the Engineer Personal Fortress, LOT 9479) + void SetUpdatesWithParentPosition(const bool value) { m_UpdatesWithParentPosition = value; m_IsParentChildDirty = true; } + // The zone scene the object was placed in (EntityInfo::scene), -1 when it came from none int32_t GetScene() const { return m_Scene; } @@ -466,6 +470,7 @@ private: int8_t m_Observers = 0; bool m_IsParentChildDirty = true; + bool m_UpdatesWithParentPosition = false; // When this object was created on this server. Construction sends its age from this, as live did. std::chrono::steady_clock::time_point m_CreationTime = std::chrono::steady_clock::now(); diff --git a/dGame/dBehaviors/SpawnBehavior.cpp b/dGame/dBehaviors/SpawnBehavior.cpp index 8d3a51da1..ecaec863e 100644 --- a/dGame/dBehaviors/SpawnBehavior.cpp +++ b/dGame/dBehaviors/SpawnBehavior.cpp @@ -51,6 +51,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStrea } entity->SetOwnerOverride(context->originator); + entity->SetUpdatesWithParentPosition(m_UpdatePositionWithParent); // Unset the flag to reposition the player, this makes it harder to glitch out of the map auto* quickBuildComponent = entity->GetComponent(); @@ -106,4 +107,5 @@ void SpawnBehavior::End(BehaviorContext* context, const BehaviorBranchContext br void SpawnBehavior::Load() { this->m_lot = GetInt("LOT_ID"); this->m_Distance = GetFloat("distance"); + this->m_UpdatePositionWithParent = GetBoolean("updatePositionWithParent"); } diff --git a/dGame/dBehaviors/SpawnBehavior.h b/dGame/dBehaviors/SpawnBehavior.h index fad576042..fc1d9e84c 100644 --- a/dGame/dBehaviors/SpawnBehavior.h +++ b/dGame/dBehaviors/SpawnBehavior.h @@ -6,6 +6,8 @@ class SpawnBehavior final : public Behavior public: LOT m_lot; float m_Distance; + // The spawned object moves with the one that spawned it (its parent) + bool m_UpdatePositionWithParent; /* * Inherited