Skip to content

[TF2] Bots will now follow players during mimic taunts#1827

Open
FlaminSarge wants to merge 4 commits intoValveSoftware:masterfrom
FlaminSarge:bot-taunt
Open

[TF2] Bots will now follow players during mimic taunts#1827
FlaminSarge wants to merge 4 commits intoValveSoftware:masterfrom
FlaminSarge:bot-taunt

Conversation

@FlaminSarge
Copy link
Contributor

@FlaminSarge FlaminSarge commented Mar 9, 2026

Description

This implements a 'partner' param for CTFBotTaunt and causes bots to attempt to follow their partner during a taunt.

  • Uses AimHeadTowards behavior to stay aiming their body within 10 degrees on either side of the target, and presses Forward button to move within 50 HU of their target's collision boxes. In practice, this ends up being a reasonable follow distance behind the target, though the bots do end up a bit slower than normal players when pressing Forward during taunt for some reason.
  • Every 5 seconds (outside of setup time), bots will roll to stop taunting based on tf_bot_taunt_stop_chance cvar. (After about 30 seconds at the default of 30%, the chance they've stopped taunting is about 88%, as an example. There are no escalating odds.)
  • Bots will also stop taunting if their partner is missing, no longer taunting, or no longer in LOS or 600 range.
  • This PR also adds bounds to tf_bot_taunt_victim_chance and corrects the check for that cvar, which could previously proc at value 0.
  • TauntMove() now looks at Bots' buttons for what magnitude to set flMoveDir, since TauntMove assumes players are using cl_forwardspeed/cl_backspeed which isn't true for bots (they set m_flForwardMove/etc to GetRunSpeed() instead).

Note that the 'target yaw' is set based on a stored var rather than GetCurrentYaw, since AimHeadTowards (and therefore current yaw) may lag behind the target yaw, and so without letting target yaw accumulate, bot turning gets slowed to a crawl. Also note that we have to initialize this after the bot is confirmed as taunting, otherwise the bot tends to snap to some arbitrary angle before properly trying to aim at the player, due to that not being initialized properly.

The taunt turn speed logic is pulled from C_TFPlayer::CreateMove()'s taunt turn speed handling.

Demonstration: soon™

@GrubPL
Copy link

GrubPL commented Mar 9, 2026

Wouldn't this possibly let 1 player to basically make a bunch of bots (if not all of them) basically useless until the player stops taunting/the bots manage to die

@FlaminSarge
Copy link
Contributor Author

FlaminSarge commented Mar 9, 2026

Wouldn't this possibly let 1 player to basically make a bunch of bots (if not all of them) basically useless until the player stops taunting/the bots manage to die

Probably. If you have any suggestions on how to curtail that, let me know.
One thing I can think of is a cvar that causes the end timer to start even with the long taunt conditions.

Oddly enough, bots are not set up to override CTFBotTaunt with other actions like 'respond to threats or attacks', so they don't interrupt the taunt behavior for those. Other behaviors are interruptible by higher-priority behaviors. I could probably set the partner taunts to be a lower priority than other behaviors like that.

One other situation I could probably handle is if the bot hasn't moved from its current location in a while (e.g. a player has herded it into a corner) it could stop taunting. I could also just have a hard limit of like 30 seconds on the taunt in general, too.

Someone else suggested LOS or FOV checks.

@FlaminSarge FlaminSarge marked this pull request as draft March 9, 2026 13:17
@FlaminSarge
Copy link
Contributor Author

I've got a pretty good idea: if during setup, let them taunt forever; if not during setup, roll for them to stop the taunt with a cvar-configurable percentage every 5-15 seconds, maybe even with escalating odds.

@GrubPL
Copy link

GrubPL commented Mar 9, 2026

I've got a pretty good idea: if during setup, let them taunt forever; if not during setup, roll for them to stop the taunt with a cvar-configurable percentage every 5-15 seconds, maybe even with escalating odds.

That sounds good to me

@FlaminSarge FlaminSarge force-pushed the bot-taunt branch 3 times, most recently from 59836d6 to 5b58e8e Compare March 9, 2026 16:09
@FlaminSarge FlaminSarge marked this pull request as ready for review March 9, 2026 16:10
Bots will attempt to face the person they mimicked for the taunt to within 10 degrees and stay within 100 range of them
Bots will stop taunting if the target stops taunting, or if they lose LOS of the target or are outside 800 range of them
Bots will roll every 5 seconds for whether to stop taunting based on tf_bot_taunt_stop_chance, default 30
Also correct tf_bot_taunt_victim_chance so it can't trigger when set to 0 and can never not trigger at 100
@FlaminSarge
Copy link
Contributor Author

FlaminSarge commented Mar 9, 2026

Alright this should work out nicely now, added various stop behaviors.

Comment on lines -383 to -385
CTFPlayer *pTauntPartner = pTFPlayer->GetTauntPartner();

Vector vPositionToFace = ( pTauntPartner ? pTauntPartner->GetAbsOrigin() : vec3_origin );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was entirely unused, and hence cleaned up.

if ( !ToTFPlayer( victim )->IsBot() && me->IsEnemy( victim ) && me->IsSelf( info.GetAttacker() ) )
{
bool isTaunting = !me->HasTheFlag() && RandomFloat( 0.0f, 100.0f ) <= tf_bot_taunt_victim_chance.GetFloat();
bool shouldTaunt = !me->HasTheFlag() && RandomFloat( 0.0f, 100.0f ) < tf_bot_taunt_victim_chance.GetFloat();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the <= was causing a bug where even at cvar 0 they could taunt

@FlaminSarge FlaminSarge changed the title [TF2] Bots will now follow players during mimic taunts and will not stop until the person they mimic stops [TF2] Bots will now follow players during mimic taunts Mar 9, 2026
@FlaminSarge FlaminSarge force-pushed the bot-taunt branch 2 times, most recently from aa18950 to bf78418 Compare March 10, 2026 03:38
@FlaminSarge
Copy link
Contributor Author

FlaminSarge commented Mar 10, 2026

This is mostly ready to go, but one problem I'm running into that I can't quite track down is that the bots are very slightly slower than humans when they're holding Forward on a taunt that they can control movement for. I just can't figure out why that's happening; setting them to hold Forward for longer than 'interval' didn't help, so it's not that they're not holding it for long enough each tick. Setting maxFacingAngle to 0 so they always aim directly at the player also didn't help.
EDIT: it looks like this is because humans set their forwardMove to cl_forwardspeed, but bots set it to their run speed which is almost always lower than cl_forwardspeed; TauntMove then does forwardMove/cl_forwardspeed to find what speed to move the player...

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.

2 participants