Do not follow rally point commands for observers

When observing a player with camera follow enabled, the camera would
jump to newly trained units as they executed their
rally point commands, which were just rendering the "Follow Player"
feature frustrating.
This commit is contained in:
Atrik
2026-04-19 15:39:55 +02:00
committed by Vantha
parent 77a53121e0
commit 68d8604c51
2 changed files with 9 additions and 6 deletions
@@ -251,19 +251,18 @@ var g_NotificationsTypes =
},
"playercommand": function(notification, player)
{
// For observers, focus the camera on units commanded by the selected player
// For observers, focus the camera on units commanded by the selected player
if (!g_FollowPlayer || player != g_ViewedPlayer)
return;
const cmd = notification.cmd;
// Ignore rallypoint commands of trained animals
const entState = cmd.entities && cmd.entities[0] && GetEntityState(cmd.entities[0]);
if (g_ViewedPlayer != 0 &&
entState && entState.identity && entState.identity.classes &&
entState.identity.classes.indexOf("Animal") != -1)
// Ignore commands executed because of units following rally points
if (cmd.fromRallyPoint)
return;
const entState = cmd.entities && cmd.entities[0] && GetEntityState(cmd.entities[0]);
// Focus the structure to build.
if (cmd.type == "repair")
{
@@ -295,7 +295,11 @@ Trainer.prototype.Item.prototype.Spawn = function()
if (spawnedEnts.length && cmpRallyPoint)
for (const com of GetRallyPointCommands(cmpRallyPoint, spawnedEnts))
{
// Tag this command as coming from a rally point
com.fromRallyPoint = true;
ProcessCommand(this.player, com);
}
const cmpPlayer = QueryOwnerInterface(this.trainer);
if (createdEnts.length)