Skip to content

Conversation

@sunzenshen
Copy link
Contributor

@sunzenshen sunzenshen commented Sep 14, 2025

Description

  • Implemented ability for players to command bots via the +use action, which also sets the bot's squad star to that of the now commanding player
  • Switch command between independent groups of bot squads by changing one's own squad
  • Snake formation for following bots to minimize collisions
  • Bot behavior mirroring of the commander's cloaking and crouch/stand state.
  • Navigation logic for bots to follow commander-issued ping waypoints relevant to their squad star, overriding default behavior
  • Bot collision avoidance and squad angle covering routines
  • Visual feedback on the HUD for identifying commanded bots, using an outline border or team-color highlight in the player list, depending on HUD style configuration

Toolchain

  • Windows MSVC VS2022

@sunzenshen
Copy link
Contributor Author

bot_follow_snake_line_collect.mp4
bot_follow_snake_release.mp4

@sunzenshen sunzenshen requested a review from a team September 14, 2025 04:44
@AdamTadeusz
Copy link
Contributor

https://tenor.com/view/heavy-time-to-dance-conga-tf2-gif-19530172

@sunzenshen
Copy link
Contributor Author

sunzenshen commented Sep 20, 2025

To start off a conversation, I suppose it might actually be suboptimal to have the bots mimic your cloak and crouch behavior, because for the former you might want to peek around a corner without expending their thermoptic power, and for the latter you might want to allow a friendly bot to shoot over your head.

Also generally, snake formation is kind of a suboptimal formation for general NT gameplay since the initial proposed distance is a bit bunched up. I think the general helpful use case might be to bring a bot along as either extra cover, or to reserve some bots for bot takeover. In either case, maybe it would be much better to have the bots farther away to reduce bunching up or blocked sightlines.

@sunzenshen sunzenshen force-pushed the bot-follow-player-when-used branch from a9399b5 to 794d342 Compare September 21, 2025 08:07
@sunzenshen sunzenshen marked this pull request as draft September 21, 2025 08:16
@sunzenshen sunzenshen force-pushed the bot-follow-player-when-used branch from 794d342 to fd82fd3 Compare September 25, 2025 08:51
@Rainyan Rainyan removed the request for review from a team September 25, 2025 08:53
@Rainyan

This comment was marked as outdated.

@sunzenshen sunzenshen changed the title Bots follow you when you press +use on them Bots follow you and your pings when you press +use on them Sep 26, 2025
@sunzenshen sunzenshen requested a review from a team September 26, 2025 10:08
@sunzenshen sunzenshen marked this pull request as ready for review September 26, 2025 10:08
@sunzenshen
Copy link
Contributor Author

I was randomly hit by an idea that the formation spreading logic that this PR implements could be adapted to make the bots attempt to run away from incoming grenades:

bot_command_flee_grenades.mp4

@sunzenshen
Copy link
Contributor Author

bot_command_ping_separate_star_squads.mp4
  • collecting bots for your current squad star by pressing use on them
  • if a bot is in a different squad star, they will change their squad star to match your current one
  • highlights which bots are in your squad star with color in the top-left squad star menu
  • placing a ping sends bots in your currently selected squad star to that waypoint
bot_command_squad_star__angle_coverage.mp4
  • bots in a squad star attempt to cover surrounding angles using a rudimentary vector repulsion calculation where bots are repulsed from looking at close walls and nearby squad star teammates
  • (known fixed issue in the video: the bots had a tendency to look randomly up or down, which was fixed by setting the z dimension of their final look vector to 0)
  • collect bots waiting at a squad star waypoint by walking near to have them follow you

Not shown in the videos:

  • calibrating how close bots follow you by setting a ping near your feet. distance clamped between a cvar minimum following distance and a maximum following distance
  • releasing bots to follow default behaviors by pressing use on them while your squad star is the same.

@sunzenshen sunzenshen force-pushed the bot-follow-player-when-used branch from 66bfe0a to 085a82a Compare September 30, 2025 06:32
@sunzenshen
Copy link
Contributor Author

Added a check on player death to see if their commander was the perpetrator. If so, unassign all squadmates from that commander. You can still run after bots to collect them again.

@sunzenshen
Copy link
Contributor Author

Looked into improving the bot spacing and angle coverage when they arrive at the ghost objective:

  • increased arrival zone to prevent bots from re-navigating on top of ghost
  • proximity based player repulsion instead of squad based repulsion before, in order to allow non squad members to adjust fanout next to each other
  • recalculate path on commander ping to improve responsiveness of repositioning
  • reduced ping cooldown for bot following to make bots more responsive to following

The behavior inside of enclosed spaces with windows is admittedly be bit odd in the latter part of this clip:

bot_command_spread_ghost_obj_garage.mp4

Spaces that are more open with clear sightlines tend to work a bit better:

bot_command_spread_ghost_obj_alley.mp4

@AdamTadeusz
Copy link
Contributor

If I make a bot follow me and then change squads, they will continue to follow me but disregard my command to move somewhere with my ping

@AdamTadeusz
Copy link
Contributor

AdamTadeusz commented Oct 7, 2025

Also I guess this should be a separate PR, but it would be cool if the squad leader was sneaking, for the bots to sneak as well as long as they're fairly close.

@AdamTadeusz
Copy link
Contributor

Once the game crashing in deathmatch with bots is fixed, the bots will react to the player's request to follow them and move to the player's pings in deathmatch

image

@AdamTadeusz
Copy link
Contributor

also can the cs2 squad hud get the unique colour for bots following the player too 👉 👈

@sunzenshen
Copy link
Contributor Author

also can the cs2 squad hud get the unique colour for bots following the player too 👉 👈

Would something like this work?

bot_command_neo_hud_highlight.mp4

@sunzenshen sunzenshen force-pushed the bot-follow-player-when-used branch from 98e4691 to b5b5d15 Compare October 9, 2025 04:07
@sunzenshen
Copy link
Contributor Author

sunzenshen commented Oct 9, 2025

If I make a bot follow me and then change squads, they will continue to follow me but disregard my command to move somewhere with my ping

This behavior of independent waypoints for different squads was actually a request from @Agiel but this is a good reminder that I need to write up a feature overview for this PR to get reviewers on the same page.

Also I guess this should be a separate PR, but it would be cool if the squad leader was sneaking, for the bots to sneak as well as long as they're fairly close.

Yeah, I think it's better to address this as a new Issue, as currently the bot default of running all the time would clash with trying to get the bots to walk. I don't quite want to modify how the run/walk logic works with bots in this large PR yet.

@sunzenshen sunzenshen force-pushed the bot-follow-player-when-used branch from b5b5d15 to f1486de Compare October 9, 2025 04:14
@sunzenshen
Copy link
Contributor Author

Write-up on the current discussion points for this PR:
https://docs.google.com/document/d/17tUGLYxV8_e_bJZPhjDzV-pVSHEd948y8e0M5SIGT54/edit?usp=sharing

@AdamTadeusz
Copy link
Contributor

also can the cs2 squad hud get the unique colour for bots following the player too 👉 👈

Would something like this work?
bot_command_neo_hud_highlight.mp4

I was looking at this on my phone thinking you went crazy and changed selected bot's class icon to the vip icon

@Agiel
Copy link
Contributor

Agiel commented Oct 9, 2025

also can the cs2 squad hud get the unique colour for bots following the player too 👉 👈

Would something like this work?

bot_command_neo_hud_highlight.mp4

I think I'd go with something like a border around the avatar instead. The class symbols are very likely to be replaced in the future.

@sunzenshen
Copy link
Contributor Author

I think I'd go with something like a border around the avatar instead. The class symbols are very likely to be replaced in the future.

Yeah, the design I struggled with is that there's only what seems like a 2 pixel gap between avatars, and I struggled to think of a color to use to highlight the border then. Unlike the original squad list, using the team color results in the colors merging. 🤔

I could try drawing over the insides of the borders but then that would cover a little bit of the avatar pictures.

@sunzenshen sunzenshen removed the Conflict conflicts with master label Dec 22, 2025
@sunzenshen sunzenshen force-pushed the bot-follow-player-when-used branch from 8ac32c3 to a4e55c7 Compare December 29, 2025 08:09
}
}

ConVar sv_neo_bot_cmdr_enable("sv_neo_bot_cmdr_enable", "0",
Copy link
Contributor Author

@sunzenshen sunzenshen Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled this feature by default so that we can use this feature for navmesh debugging while not impacting the player experience if this feature is disabled.

Copy link
Contributor Author

@sunzenshen sunzenshen Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FCVAR_REPLICATED - I need this flag to be shared with the client so that their playerlist UI can switch between the original player/avatar list behavior or the new highlighted commanded bots version.

FCVAR_ARCHIVE - Allows server operators or single players to decide once if they want to try out the feature, but this feature is still off by default so that parity gameplay is not affected for those not opting into using the feature.

@Rainyan Rainyan requested review from Rainyan and removed request for a team December 29, 2025 11:14
Copy link
Collaborator

@Rainyan Rainyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, great job 👍

Left some nits that that I don't really require be addressed, but we should probably take a look at the potential UB at src/game/server/neo/bot/behavior/neo_bot_pause.cpp:48

AdamTadeusz
AdamTadeusz previously approved these changes Jan 1, 2026
ConVar sv_neo_bot_cmdr_look_weights_friendly_max_dist_sq("sv_neo_bot_cmdr_look_weights_friendly_max_dist_sq", "5000",
FCVAR_CHEAT, "Distance to compare friendly repulsion forces", true, 1, true, 100000);
ConVar sv_neo_bot_cmdr_look_weights_wall_repulsion_whisker_dist("sv_neo_bot_cmdr_look_weights_wall_repulsion_whisker_dist", "500",
FCVAR_CHEAT, "Distance to extend whiskers", true, 1, true, 100000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps the max value here should be MAX_TRACE_LENGTH

@AdamTadeusz
Copy link
Contributor

https://youtu.be/9igxY8wBTlY?si=kEXNhAJgWFiMhRe8

Rainyan
Rainyan previously approved these changes Jan 2, 2026
Copy link
Collaborator

@Rainyan Rainyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an awesome feature and I wish we can reach consensus to default-enable it eventually.

@sunzenshen
Copy link
Contributor Author

This is an awesome feature and I wish we can reach consensus to default-enable it eventually.

My thinking was that we could wait to enable this feature by default until after the spring tournament build cutoff is released. By enabling the feature by default after the spring tournament, we can avoid any possible unintended issues cropping up during the the competition, and also benefit from some potential increased attention to advertise the feature.
Then after a few months of baking or even just before anyone wants to make updates to neo_hud_round_state, we could have a PR ready to make the bot version of the round state code the primary path that always happens, and then later on we just completely delete the old version of the round state code when we feel confident about the bot-command-aware approach.

assert convar

collapse indent

max players loop optimization

memdbg header and convar name tweak

simplify assignment check

Define invalid vector waypoint constant

Collapse more indentation

Collapse indentation

Fix wrong comment re: default value

Flatten conditions

NextBotBehavior.h

override specifier

memdbgon

Override specifier

DevWarning

ConVar Min follow distance

use GetLocalNEOPlayer
- Removed FCVAR_CHEAT to allow admins to decide if they want to enable this feature without needing to turn on sv_cheats
- Replicated flag is needed for some feature flags on the client side related to player list GUI elements
- Archive flag in case server has a preference for turning on the feature on or off for future server sessions.
@sunzenshen sunzenshen force-pushed the bot-follow-player-when-used branch from 42ce32c to d804359 Compare January 5, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bots Related to bot players Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants