ValveSoftware / Source-1-Games

Source 1 based games such as TF2 and Counter-Strike: Source
624 stars 73 forks source link

[TF2] [Regression] AI Bots: BLU Engineer and Sniper bots use Attack/Defend behavior in Territorial Control #3839

Open FoxMcCloud45 opened 2 years ago

FoxMcCloud45 commented 2 years ago

This issue is a regression possibly introduced in the Jungle Inferno update and thus no indication from the 2017 source code can be provided as the bots behaved correctly from ~2010 to 2017.

On Territorial Control maps (e.g. Hydro), BLU Engineer and Sniper bots actually use RED's capture point as their objective instead of the BLU one, while RED Engineers and Snipers properly defend their point.

The version of TF2 from the leaked 2017 source code shows that, for each bot, a vector of points to defend and a vector of points to capture are populated by the TFGameRules. From there, if there is any defendable control point, the Engineer/Sniper bots as well as bots with the PRIORITIZE_DEFENSE attribute use that point as their objective. This was notably used for 5CP support and it worked on Territorial Control by pure coincidence due to a similar capture point logic.

The reason why the AI behavior was changed is quite obscure since the pre-Jungle Inferno code essentially checked if Engineer/Sniper bots had an unlocked point their team owned in order to defend it. The new code seems to override their AI to force them to go for the capture point, for some reason, on Attack/Defend maps. They still behave correctly in 5CP.

When the map enters the final BLU Base stage, where BLU must defend their point for 5 minutes and RED's capture point is unreachable and locked, all BLU bots properly defend the base's point, including Engineers/Snipers, since there is no point for them to capture.

The function that returns which control point a bot must target in the 2017 code is CTFBot::GetMyControlPoint( void ) in game/server/tf/bot/tf_bot.cpp.

The function that computes control points to defend is CTFGameRules::CollectDefendPoints( CBasePlayer *player, CUtlVector< CTeamControlPoint * > *defendVector ) in game/tf/shared/tf_gamerules.cpp.

Solution:

  1. Have Engineer/Sniper bots prioritize defense again, should there be an unlocked capture point on their team…?
  2. If bots now detect that the map is Attack/Defend or 5CP, use the 5CP code path on TC?

I really don't know how the code was changed to trigger this bug, nor why it was changed. Some people have said that this was done so BLU Engineers and Snipers actually push on offense in Attack/Defend maps, but the pre_jungleinferno_demos beta shows that they already seemed to do that. In that beta, BLU Engineer bots push on Dustbowl and work properly in Hydro.

FoxMcCloud45 commented 2 years ago

As Hydro does not come with a navigation mesh file by default, here is one with hand-edited support for dynamic paths, within the limits of the navigation mesh system's capabilities for dynamic terrain, for testing. It's not impossible for me to have missed a path.

tc_hydro.nav.zip EDIT: New version with slope/doorway fixes: tc_hydro.nav.zip