Skip to content

Commit cbab0e8

Browse files
Implement basic robots outside of Man vs Machine
1 parent c623a7c commit cbab0e8

File tree

8 files changed

+65
-16
lines changed

8 files changed

+65
-16
lines changed

src/game/client/tf/c_tf_player.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ void C_TFRagdoll::OnDataChanged( DataUpdateType_t type )
12441244
CreateTFHeadGib();
12451245
EmitSound( "TFPlayer.Decapitated" );
12461246

1247-
bool bBlood = true;
1247+
bool bBlood = !( pPlayer && IsRobotTeam( pPlayer->GetTeamNumber() ) );
12481248
if ( TFGameRules() && ( TFGameRules()->UseSillyGibs() ||
12491249
( TFGameRules()->IsMannVsMachineMode() && pPlayer && pPlayer->GetTeamNumber() == TF_TEAM_PVE_INVADERS ) ) )
12501250
{
@@ -5800,7 +5800,7 @@ bool C_TFPlayer::CanLightCigarette( void )
58005800
}
58015801

58025802
// don't light for MvM Spy robots
5803-
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS )
5803+
if ( IsRobotTeam( GetTeamNumber() ) || ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS ) )
58045804
return false;
58055805

58065806
// Don't light if we are invis.
@@ -10568,7 +10568,7 @@ void C_TFPlayer::UpdateKillStreakEffects( int iCount, bool bKillScored /* = fals
1056810568

1056910569
void C_TFPlayer::UpdateMVMEyeGlowEffect( bool bVisible )
1057010570
{
10571-
if ( !TFGameRules() || !TFGameRules()->IsMannVsMachineMode() || GetTeamNumber() != TF_TEAM_PVE_INVADERS )
10571+
if ( !IsRobotTeam( GetTeamNumber() ) || !TFGameRules() || !TFGameRules()->IsMannVsMachineMode() || GetTeamNumber() != TF_TEAM_PVE_INVADERS )
1057210572
{
1057310573
return;
1057410574
}

src/game/client/tf/tf_fx_impacts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void ImpactCallback( const CEffectData &data )
6565
bool bPlaySound = true;
6666
bool bIsRobotImpact = false;
6767

68-
if ( bIsMVM && pPlayer && nApparentTeam == TF_TEAM_PVE_INVADERS )
68+
if ( ( pPlayer && IsRobotTeam( nApparentTeam ) ) || ( bIsMVM && pPlayer && nApparentTeam == TF_TEAM_PVE_INVADERS ) )
6969
{
7070
bPlaySound = true;
7171
bIsRobotImpact = true;

src/game/server/tf/bot/behavior/spy/tf_bot_spy_hide.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ActionResult< CTFBot > CTFBotSpyHide::Update( CTFBot *me, float interval )
7070
if ( m_talkTimer.IsElapsed() )
7171
{
7272
m_talkTimer.Start( RandomFloat( 5.0f, 10.0f ) );
73-
if ( TFGameRules()->IsMannVsMachineMode() && me->GetTeamNumber() == TF_TEAM_PVE_INVADERS )
73+
if ( IsRobotTeam( me->GetTeamNumber() ) || ( TFGameRules()->IsMannVsMachineMode() && me->GetTeamNumber() == TF_TEAM_PVE_INVADERS ) )
7474
{
7575
me->EmitSound( "Spy.MVM_TeaseVictim" );
7676
}

src/game/server/tf/tf_player.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ void CTFPlayer::SetGrapplingHookTarget( CBaseEntity *pTarget, bool bShouldBleed
12211221
//-----------------------------------------------------------------------------
12221222
bool CTFPlayer::CanBeForcedToLaugh( void )
12231223
{
1224-
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && IsBot() && ( GetTeamNumber() == TF_TEAM_PVE_INVADERS ) )
1224+
if ( IsRobotTeam( GetTeamNumber() ) || ( TFGameRules() && ( TFGameRules()->IsMannVsMachineMode() && IsBot() && ( GetTeamNumber() == TF_TEAM_PVE_INVADERS ) ) ) )
12251225
return false;
12261226

12271227
return true;
@@ -10834,7 +10834,7 @@ int CTFPlayer::OnTakeDamage_Alive( const CTakeDamageInfo &info )
1083410834
vDamagePos = WorldSpaceCenter();
1083510835
}
1083610836

10837-
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS )
10837+
if ( IsRobotTeam( GetTeamNumber() ) || ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS ) )
1083810838
{
1083910839
if ( ( IsMiniBoss() && static_cast< float >( GetHealth() ) / GetMaxHealth() > 0.3f ) || realDamage < 50 )
1084010840
{
@@ -12420,7 +12420,7 @@ void CTFPlayer::Event_Killed( const CTakeDamageInfo &info )
1242012420
SetGibbedOnLastDeath( bGib );
1242112421

1242212422
bool bIsMvMRobot = TFGameRules()->IsMannVsMachineMode() && IsBot();
12423-
if ( bGib && !bIsMvMRobot && IsPlayerClass( TF_CLASS_SCOUT ) && RandomInt( 1, 100 ) <= SCOUT_ADD_BIRD_ON_GIB_CHANCE )
12423+
if ( bGib && !bIsMvMRobot && !IsRobotTeam( GetTeamNumber() ) && IsPlayerClass( TF_CLASS_SCOUT ) && RandomInt( 1, 100 ) <= SCOUT_ADD_BIRD_ON_GIB_CHANCE )
1242412424
{
1242512425
Vector vecPos = WorldSpaceCenter();
1242612426
SpawnClientsideFlyingBird( vecPos );
@@ -14721,6 +14721,22 @@ void CTFPlayer::ForceRespawn( void )
1472114721
}
1472214722

1472314723
m_bSwitchedClass = false;
14724+
14725+
if ( IsRobotTeam( GetTeamNumber() ) )
14726+
{
14727+
const int nClassIndex = ( GetPlayerClass() ? GetPlayerClass()->GetClassIndex() : TF_CLASS_UNDEFINED );
14728+
if ( nClassIndex >= TF_CLASS_SCOUT && nClassIndex <= TF_CLASS_ENGINEER && g_pFullFileSystem->FileExists( g_szBotModels[ nClassIndex ] ) )
14729+
SetCustomModelWithClassAnimations( g_szBotModels[nClassIndex] );
14730+
14731+
SetBloodColor( DONT_BLEED );
14732+
}
14733+
else
14734+
{
14735+
if ( GetPlayerClass()->HasCustomModel() )
14736+
SetCustomModelWithClassAnimations( NULL );
14737+
14738+
SetBloodColor( BLOOD_COLOR_RED );
14739+
}
1472414740
}
1472514741

1472614742
//-----------------------------------------------------------------------------
@@ -15156,7 +15172,16 @@ void CTFPlayer::PainSound( const CTakeDamageInfo &info )
1515615172
TFPlayerClassData_t *pData = GetPlayerClass()->GetData();
1515715173
if ( pData )
1515815174
{
15159-
EmitSound( pData->GetDeathSound( DEATH_SOUND_GENERIC ) );
15175+
int deathSound = DEATH_SOUND_GENERIC;
15176+
if ( IsRobotTeam( GetTeamNumber() ) || ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS ) )
15177+
{
15178+
deathSound = DEATH_SOUND_GENERIC_MVM;
15179+
if ( IsMiniBoss() )
15180+
{
15181+
deathSound = DEATH_SOUND_GENERIC_GIANT_MVM;
15182+
}
15183+
}
15184+
EmitSound( pData->GetDeathSound( deathSound ) );
1516015185
}
1516115186
}
1516215187
return;
@@ -15258,7 +15283,7 @@ void CTFPlayer::DeathSound( const CTakeDamageInfo &info )
1525815283

1525915284
int nDeathSoundOffset = DEATH_SOUND_FIRST;
1526015285

15261-
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS )
15286+
if ( IsRobotTeam( GetTeamNumber() ) || ( TFGameRules() && ( TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS ) ) )
1526215287
{
1526315288
nDeathSoundOffset = IsMiniBoss() ? DEATH_SOUND_GIANT_MVM_FIRST : DEATH_SOUND_MVM_FIRST;
1526415289
}
@@ -15317,7 +15342,7 @@ void CTFPlayer::DeathSound( const CTakeDamageInfo &info )
1531715342
//-----------------------------------------------------------------------------
1531815343
const char* CTFPlayer::GetSceneSoundToken( void )
1531915344
{
15320-
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS )
15345+
if ( IsRobotTeam( GetTeamNumber() ) || ( TFGameRules() && ( TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS ) ) )
1532115346
{
1532215347
if ( IsMiniBoss() )
1532315348
{

src/game/shared/tf/tf_gamerules.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,8 @@ ConVar tf_mvm_respec_credit_goal( "tf_mvm_respec_credit_goal", "2000", FCVAR_CHE
918918
ConVar tf_mvm_buybacks_method( "tf_mvm_buybacks_method", "0", FCVAR_REPLICATED | FCVAR_HIDDEN, "When set to 0, use the traditional, currency-based system. When set to 1, use finite, charge-based system.", true, 0.0, true, 1.0 );
919919
ConVar tf_mvm_buybacks_per_wave( "tf_mvm_buybacks_per_wave", "3", FCVAR_REPLICATED | FCVAR_HIDDEN, "The fixed number of buybacks players can use per-wave." );
920920

921+
ConVar tf_robot_team( "tf_robot_team", "1", FCVAR_GAMEDLL, "Whether to turn a given team into robots outside of Man vs Machine." );
922+
921923

922924
#ifdef GAME_DLL
923925
enum { kMVM_CurrencyPackMinSize = 1, };
@@ -1023,6 +1025,24 @@ bool IsCustomGameMode()
10231025
}
10241026
#endif
10251027

1028+
bool IsRobotTeam( int team )
1029+
{
1030+
const int setting = tf_robot_team.GetInt();
1031+
1032+
if ( setting == 1 )
1033+
{
1034+
return true;
1035+
}
1036+
else if ( setting == 0 )
1037+
{
1038+
return false;
1039+
}
1040+
else
1041+
{
1042+
return team == setting;
1043+
}
1044+
}
1045+
10261046
// Fetch holiday setting taking into account convars, etc, but NOT
10271047
// taking into consideration the current game rules, map, etc.
10281048
//
@@ -3550,7 +3570,7 @@ void CTFGameRules::Precache( void )
35503570
CMerasmus::PrecacheMerasmus();
35513571
}
35523572

3553-
if ( MapHasPrefix( STRING( gpGlobals->mapname ), "mvm_" ) )
3573+
if ( MapHasPrefix( STRING( gpGlobals->mapname ), "mvm_" ) || tf_robot_team.GetInt() != 0 )
35543574
{
35553575
CTFPlayer::PrecacheMvM();
35563576
}

src/game/shared/tf/tf_gamerules.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ class CMannVsMachineUpgrades;
9999
extern ConVar tf_mvm_defenders_team_size;
100100
extern ConVar tf_mvm_max_invaders;
101101

102+
extern ConVar tf_robot_team;
103+
104+
extern bool IsRobotTeam( int );
105+
102106
const int kLadder_TeamSize_6v6 = 6;
103107
const int kLadder_TeamSize_9v9 = 9;
104108
const int kLadder_TeamSize_12v12 = 12;

src/game/shared/tf/tf_player_shared.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11979,7 +11979,7 @@ void CTFPlayer::SetStepSoundTime( stepsoundtimes_t iStepSoundTime, bool bWalking
1197911979
const char *CTFPlayer::GetOverrideStepSound( const char *pszBaseStepSoundName )
1198011980
{
1198111981

11982-
if( TFGameRules() && TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS && !IsMiniBoss() && !m_Shared.InCond( TF_COND_DISGUISED ) )
11982+
if( IsRobotTeam( GetTeamNumber() ) || ( TFGameRules() && ( TFGameRules()->IsMannVsMachineMode() && GetTeamNumber() == TF_TEAM_PVE_INVADERS && !IsMiniBoss() && !m_Shared.InCond( TF_COND_DISGUISED ) ) ) )
1198311983
{
1198411984
return "MVM.BotStep";
1198511985
}

src/game/shared/tf/tf_weaponbase_melee.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void CTFWeaponBaseMelee::Precache()
100100
{
101101
BaseClass::Precache();
102102

103-
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() )
103+
if ( tf_robot_team.GetInt() != 0 && ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() ) )
104104
{
105105
char szMeleeSoundStr[128] = "MVM_";
106106
const char *shootsound = GetShootSound( MELEE_HIT );
@@ -570,9 +570,9 @@ bool CTFWeaponBaseMelee::OnSwingHit( trace_t &trace )
570570

571571
bool bPlayMvMHitOnly = false;
572572
// handle hitting a robot
573-
if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() )
573+
if ( tf_robot_team.GetInt() != 0 || ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() ) )
574574
{
575-
if ( pTargetPlayer && pTargetPlayer->GetTeamNumber() == TF_TEAM_PVE_INVADERS && !pTargetPlayer->IsPlayer() )
575+
if ( pTargetPlayer && ( IsRobotTeam( pTargetPlayer->GetTeamNumber() ) || ( pTargetPlayer->GetTeamNumber() == TF_TEAM_PVE_INVADERS && !pTargetPlayer->IsPlayer() ) ) )
576576
{
577577
bPlayMvMHitOnly = true;
578578

0 commit comments

Comments
 (0)