Skip to content

[TF2] Add CTFBotFreezeInput behavior to make bots respect TF_COND_FREEZE_INPUT #1331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/game/server/server_tf.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ $Project "Server (TF)"
$File "tf\bot\behavior\tf_bot_melee_attack.h"
$File "tf\bot\behavior\tf_bot_approach_object.cpp"
$File "tf\bot\behavior\tf_bot_approach_object.h"
$File "tf\bot\behavior\tf_bot_freeze_input.cpp"
$File "tf\bot\behavior\tf_bot_freeze_input.h"
$File "tf\bot\behavior\tf_bot_get_health.cpp"
$File "tf\bot\behavior\tf_bot_get_health.h"
$File "tf\bot\behavior\tf_bot_get_ammo.cpp"
Expand All @@ -541,7 +543,7 @@ $Project "Server (TF)"
$File "tf\bot\behavior\tf_bot_escort.cpp"
$File "tf\bot\behavior\tf_bot_escort.h"
$File "tf\bot\behavior\tf_bot_use_item.cpp"
$File "tf\bot\behavior\tf_bot_use_item.h"
$File "tf\bot\behavior\tf_bot_use_item.h"
$File "tf\bot\behavior\tf_bot_mvm_deploy_bomb.cpp"
$File "tf\bot\behavior\tf_bot_mvm_deploy_bomb.h"

Expand Down
7 changes: 7 additions & 0 deletions src/game/server/tf/bot/behavior/tf_bot_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "bot/tf_bot_manager.h"
#include "bot/behavior/tf_bot_behavior.h"
#include "bot/behavior/tf_bot_dead.h"
#include "bot/behavior/tf_bot_freeze_input.h"
#include "NextBot/NavMeshEntities/func_nav_prerequisite.h"
#include "bot/behavior/nav_entities/tf_bot_nav_ent_destroy_entity.h"
#include "bot/behavior/nav_entities/tf_bot_nav_ent_move_to.h"
Expand Down Expand Up @@ -106,6 +107,12 @@ ActionResult< CTFBot > CTFBotMainAction::Update( CTFBot *me, float interval )
return Done( "Not on a playing team" );
}

if ( me->m_Shared.InCond( TF_COND_FREEZE_INPUT ) || me->m_Shared.InCond( TF_COND_HALLOWEEN_THRILLER ) )
{
// frozen - do nothing
return SuspendFor( new CTFBotFreezeInput, "Frozen by TF_COND" );
}

// Should I accept taunt from my partner?
if ( me->FindPartnerTauntInitiator() )
{
Expand Down
20 changes: 20 additions & 0 deletions src/game/server/tf/bot/behavior/tf_bot_freeze_input.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
// tf_bot_freeze_input.cpp
// Don't do anything until the TF_COND_FREEZE_INPUT condition expires
// Community-contributed, June 2025

#include "cbase.h"
#include "bot/tf_bot.h"
#include "bot/behavior/tf_bot_freeze_input.h"


//---------------------------------------------------------------------------------------------
ActionResult< CTFBot > CTFBotFreezeInput::Update( CTFBot *me, float interval )
{
if ( !me->m_Shared.InCond( TF_COND_FREEZE_INPUT ) && !me->m_Shared.InCond( TF_COND_HALLOWEEN_THRILLER ) )
{
return Done( "No longer frozen by TF_COND" );
}

return Continue();
}
20 changes: 20 additions & 0 deletions src/game/server/tf/bot/behavior/tf_bot_freeze_input.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
// tf_bot_freeze_input.h
// Don't do anything until the TF_COND_FREEZE_INPUT condition expires
// Community-contributed, June 2025

#ifndef TF_BOT_FREEZE_INPUT_H
#define TF_BOT_FREEZE_INPUT_H


//-----------------------------------------------------------------------------
class CTFBotFreezeInput : public Action< CTFBot >
{
public:
virtual ActionResult< CTFBot > Update( CTFBot *me, float interval );

virtual const char *GetName( void ) const { return "FreezeInput"; };
};


#endif // TF_BOT_FREEZE_INPUT_H