Skip to content

Conversation

@sunzenshen
Copy link
Contributor

@sunzenshen sunzenshen commented Aug 21, 2025

Description

Proof of concept for taking over AFK players and bots as a spectator

Toolchain

  • Windows MSVC VS2022

Linked Issues

@sunzenshen sunzenshen force-pushed the bot-spectator-possession branch 6 times, most recently from 7bb32c3 to 0568d9c Compare August 26, 2025 03:02
@sunzenshen sunzenshen marked this pull request as ready for review August 26, 2025 06:26
@sunzenshen sunzenshen changed the title Spectator ability to take over bots Spectator ability to take over bots and AFK players Aug 26, 2025
@sunzenshen sunzenshen requested a review from a team August 26, 2025 06:27
Rainyan

This comment was marked as resolved.

@Rainyan Rainyan requested a review from a team August 26, 2025 13:59
@Rainyan

This comment was marked as resolved.

@sunzenshen sunzenshen force-pushed the bot-spectator-possession branch 3 times, most recently from 015f565 to 63aee57 Compare August 30, 2025 04:25
@sunzenshen
Copy link
Contributor Author

A possessed bot can still see its own IFF HUD icon in the place where it got taken over.

It seems that players who possess a bot, and then disconnect, will cause the restored bot to A-pose:

At this point, I believe marking the bot as dead/invisible/non-solid is the cleanest way to handle these two cases.

Here's a video that demonstrates a player taking over a bot and disconnecting:

bot_takeover_player_disconnect.mp4

In order to add some options to mitigate griefing with this feature, I have added a configurable minimum XP threshold under which players cannot use the takeover feature anymore. This is aimed specifically for a self kill takeover another bot repetition.

Known bug? I wasn't able to get the AFK feature working on my test setup, because GetTimeSinceLastUserCommand() always returns 0 with my local test setup. For now I have left the feature convar disabled by default.

@sunzenshen sunzenshen force-pushed the bot-spectator-possession branch 5 times, most recently from 08ebb0c to 4c3b01f Compare September 1, 2025 20:18
@sunzenshen
Copy link
Contributor Author

The latest changes involve changing the criteria for which players are counted as AFK to use a different timer based on the last time they fired their weapon. This is admittedly kind of a jank workaround for the previous timer always being 0, but at least it allowed me to test takeovers of AFK players. That led to removing the freezing flag from the taken over player, because there was a bug where an AFK player could not move around as a spectator after being taken over, until the round reset.

As far as I can tell, I have addressed the feedback from earlier threads, so I will mark those as resolved, but feel free to revisit them to see if I have addressed the issues in the way that is satisfactory.

@Rainyan
Copy link
Collaborator

Rainyan commented Sep 2, 2025

@sunzenshen Thanks! Is this PR good for another review, then?

@sunzenshen
Copy link
Contributor Author

@sunzenshen Thanks! Is this PR good for another review, then?

Yup, would appreciate any thoughts.

Rainyan

This comment was marked as resolved.

@Rainyan

This comment was marked as outdated.

@sunzenshen sunzenshen force-pushed the bot-spectator-possession branch from 030f808 to 044caa6 Compare September 10, 2025 07:24
@sunzenshen sunzenshen requested a review from a team September 10, 2025 07:53
@sunzenshen sunzenshen force-pushed the bot-spectator-possession branch from 044caa6 to 86d56ea Compare September 11, 2025 06:00
Rainyan
Rainyan previously approved these changes Sep 20, 2025
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.

LGTM, tested again with 2 Steam clients (1 Windows, 1 Linux). Sorry about the delay with the review.

@Rainyan Rainyan requested a review from a team September 20, 2025 18:58
@sunzenshen sunzenshen force-pushed the bot-spectator-possession branch from 86d56ea to 9a9fea7 Compare September 20, 2025 20:12
@sunzenshen sunzenshen force-pushed the bot-spectator-possession branch from 9a9fea7 to f1b7a7d Compare September 20, 2025 20:15
@sunzenshen
Copy link
Contributor Author

Done resolving the merge conflict, it was just an additional newline at the neo_player.cpp that caused a collision. Squashed to simplify the rebase, rebuilt, and sanity checked that the feature still works on a single machine.

Rainyan
Rainyan previously approved these changes Sep 20, 2025
Rainyan
Rainyan previously approved these changes Sep 21, 2025
@sunzenshen sunzenshen requested a review from a team September 21, 2025 00:38
NeotokyoRebuild#1254

Clarify when to hard reset and not for takeover revert

Configurable post-takeover loadout change

Allow AFK to PreThink player takeover

Evaluate everywhere SpectatorTakeoverPlayerRevert should be called

Also check that AFK player has not returned when reverting

Prevent loadout change after takeover

Also fix ghost capture single point award for possessing player.

Refactor CTG and VIP game modes to use same award logic

Also transfer possessed XP in Winning Team logic.

Fix 2nd extra death of taken over player

- new USERID2NEOPLAYER macro similar to USERID2PLAYER
- don't penalize taken over player for possessing player's mistakes
- increase AFK time threshold because WIP approach of getting last weapon fired time might lead to premature takeover situations.
- Remove version of restore player from takeover that also transferred a 2nd death event.

Allow AFK players to move after getting kicked to spectate.

Change AFK timer check to use GetTimeSinceWeaponFired

Because GetTimeSinceLastUserCommand seems to be always 0 if player is connected, and I want this to work on LAN.

Also tweaked the failed takeover messages to be more lore appropriate, though at the possible risk of less clarity.
- Increase AFK takeover time threshold
- Format nit for IsAFK
@sunzenshen
Copy link
Contributor Author

bot_takeover_post_lamdba_refactoring_mistake.mp4

@sunzenshen sunzenshen merged commit 20eef83 into NeotokyoRebuild:master Sep 21, 2025
7 checks passed
@sunzenshen sunzenshen deleted the bot-spectator-possession branch December 6, 2025 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Take over bots

4 participants