fix(entity): proximity and pathfinding from a script only when the client makes the script

The client's script allocator adds them only for a script component it makes
(a registry script with a non-zero id, or a custom script in the config it is
sent). Characters and the registry-id-0 script LOTs no longer get them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-01 17:51:44 -05:00
parent b81ffb2d28
commit 0fccea55b8

View File

@@ -488,7 +488,12 @@ void Entity::DoObjectComponentLoad(ObjectLoadState& state) {
const bool hasCustomScript = !GetVarAsString(u"custom_script_server").empty() || !GetVarAsString(u"custom_script_client").empty();
if (scriptComponentID >= 0 || m_Character || hasCustomScript) {
AddComponent<ScriptComponent>(scriptComponentID);
addProximityAndPathfinding();
// The client's script allocator adds these only when it makes a script component: a registry script with a
// non-zero id or a custom script in the config it is sent (a character's script is the server's own)
const auto clientCustomScript = [this](const std::u16string& key) { return IsVarSentToClient(key) && !GetVarAsString(key).empty(); };
if (scriptComponentID > 0 || (m_TemplateID != 176 && (clientCustomScript(u"custom_script_server") || clientCustomScript(u"custom_script_client")))) {
addProximityAndPathfinding();
}
}
// ZoneControl script