From aea4949cf38e23230408a664490394526fc73ded Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 1 Oct 2026 09:38:46 -0500 Subject: [PATCH] feat(entity): script objects get the client's proximity monitor and pathfinding control Co-Authored-By: Claude Opus 5.5 --- dGame/Entity.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 77cf71392..1bf104925 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -322,6 +322,15 @@ void Entity::Initialize() { const auto petComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PET); const auto collectibleComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::COLLECTIBLE); const auto combatAiID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BASE_COMBAT_AI); + // LWOScriptComponent::Allocator (0x0104d710) and LWOBaseCombatAiComponent::Allocator (0x0104c7b0) add a proximity + // monitor when there is none, and pathfinding control when the object has movement physics (controllable, + // projectile, vehicle or havok vehicle) and none yet + const auto addProximityAndPathfinding = [this]() { + if (!HasComponent(eReplicaComponentType::PROXIMITY_MONITOR)) AddComponent(-1); + const bool hasMovementPhysics = HasComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS) || HasComponent(eReplicaComponentType::PROJECTILE_PHYSICS) + || HasComponent(eReplicaComponentType::VEHICLE_PHYSICS) || HasComponent(eReplicaComponentType::HAVOK_VEHICLE_PHYSICS); + if (hasMovementPhysics && !HasComponent(eReplicaComponentType::PATHFINDING)) AddComponent(-1); + }; // If an entity is marked a phantom, simple physics is made into phantom phyics. const bool markedAsPhantom = GetVar(u"markedAsPhantom"); @@ -577,6 +586,7 @@ void Entity::Initialize() { if (!scriptName.empty() || client || m_Character || scriptComponentID >= 0) { AddComponent(scriptComponentID, scriptName, true, client && scriptName.empty()); + addProximityAndPathfinding(); } // ZoneControl script