Skip to content
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
12 changes: 12 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 @@ -1360,6 +1360,18 @@ void CTFBotMainAction::FireWeaponAtEnemy( CTFBot *me )
{
// bounce missiles with compression blast
me->PressAltFireButton();

if ( !me->m_CompressionBlastTimer.HasStarted() )
{
if ( me->IsDifficulty( CTFBot::EXPERT ) )
{
me->m_CompressionBlastTimer.Start( RandomFloat( 0.25f, 0.5f ) );
}
else
{
me->m_CompressionBlastTimer.Start( RandomFloat( 0.5f, 1.0f ) );
}
}
}
else if ( threat->GetTimeSinceLastSeen() < 1.0f &&
me->IsDistanceBetweenLessThan( threat->GetEntity(), me->GetMaxAttackRange() ) )
Expand Down
79 changes: 67 additions & 12 deletions src/game/server/tf/bot/tf_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "tf_weapon_medigun.h"
#include "func_respawnroom.h"
#include "soundenvelope.h"
#include "tf_projectile_energy_ball.h"

#include "econ_entity_creation.h"

Expand All @@ -42,7 +43,6 @@ ConVar tf_bot_force_class( "tf_bot_force_class", "", FCVAR_GAMEDLL, "If set to a
ConVar tf_bot_notice_gunfire_range( "tf_bot_notice_gunfire_range", "3000", FCVAR_GAMEDLL );
ConVar tf_bot_notice_quiet_gunfire_range( "tf_bot_notice_quiet_gunfire_range", "500", FCVAR_GAMEDLL );
ConVar tf_bot_sniper_personal_space_range( "tf_bot_sniper_personal_space_range", "1000", FCVAR_CHEAT, "Enemies beyond this range don't worry the Sniper" );
ConVar tf_bot_pyro_deflect_tolerance( "tf_bot_pyro_deflect_tolerance", "0.5", FCVAR_CHEAT );
ConVar tf_bot_keep_class_after_death( "tf_bot_keep_class_after_death", "0", FCVAR_GAMEDLL );
ConVar tf_bot_prefix_name_with_difficulty( "tf_bot_prefix_name_with_difficulty", "0", FCVAR_GAMEDLL, "Append the skill level of the bot to the bot's name" );
ConVar tf_bot_near_point_travel_distance( "tf_bot_near_point_travel_distance", "750", FCVAR_CHEAT, "If within this travel distance to the current point, bot is 'near' it" );
Expand Down Expand Up @@ -4072,6 +4072,16 @@ bool CTFBot::ScriptIsWeaponRestricted( HSCRIPT script ) const
//
bool CTFBot::ShouldFireCompressionBlast( void )
{
if ( !m_CompressionBlastTimer.IsElapsed() )
{
return false;
}
else
{
// invalidate the timer when we go for another blast.
m_CompressionBlastTimer.Invalidate();
}

if ( TFGameRules()->IsInTraining() )
{
// no reflection in training mode
Expand Down Expand Up @@ -4171,12 +4181,61 @@ bool CTFBot::ShouldFireCompressionBlast( void )
if ( pObject->IsPlayer() )
continue;

// is this something I want to deflect?
if ( !pObject->IsDeflectable() )
bool bSeesProjectile = false;

CTFBaseRocket *pBaseRocket = dynamic_cast< CTFBaseRocket * >( pObject );
if ( pBaseRocket )
{
// is this something I want to deflect?
if ( pBaseRocket->IsDeflectable() )
{
bSeesProjectile = true;
}
}

if ( !bSeesProjectile )
{
CTFGrenadePipebombProjectile *pBaseGrenade = dynamic_cast< CTFGrenadePipebombProjectile * >( pObject );
if ( pBaseGrenade )
{
// is this something I want to deflect?
if ( pBaseGrenade->IsDeflectable() )
{
bSeesProjectile = true;
}
}
}

// we can't deflect it.
if ( !bSeesProjectile )
continue;

if ( FClassnameIs( pObject, "tf_projectile_rocket" ) || FClassnameIs( pObject, "tf_projectile_energy_ball" ) )
if ( bSeesProjectile )
{
// on hard or expert, we're not restricted to what projectiles we should reflect.
// on lower difficulties, only deflect rockets or energy balls.
if ( !IsDifficulty( CTFBot::HARD ) && !IsDifficulty( CTFBot::EXPERT ) )
{
bool bCanReflectThisProj = false;

CTFProjectile_Rocket *pRocket = dynamic_cast< CTFProjectile_Rocket * >( pObject );
if ( pRocket )
{
bCanReflectThisProj = true;
}
else
{
CTFProjectile_EnergyBall *pBall = dynamic_cast< CTFProjectile_EnergyBall * >( pObject );
if ( pBall )
{
bCanReflectThisProj = true;
}
}

if ( !bCanReflectThisProj )
continue;
}

// is it headed right for me?
Vector vecThemUnitVel = pObject->GetAbsVelocity();
vecThemUnitVel.z = 0.0f;
Expand All @@ -4185,16 +4244,12 @@ bool CTFBot::ShouldFireCompressionBlast( void )
Vector horzForward( vecForward.x, vecForward.y, 0.0f );
horzForward.NormalizeInPlace();

if ( DotProduct( horzForward, vecThemUnitVel ) > -tf_bot_pyro_deflect_tolerance.GetFloat() )
if ( DotProduct( horzForward, vecThemUnitVel ) > 0 )
continue;
}

// can I see it?
if ( !GetVisionInterface()->IsLineOfSightClear( pObject->WorldSpaceCenter() ) )
continue;

// bounce it!
return true;
// bounce it!
return true;
}
}

return false;
Expand Down
3 changes: 3 additions & 0 deletions src/game/server/tf/bot/tf_bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ class CTFBot: public NextBotPlayer< CTFPlayer >, public CGameEventListener

bool ShouldReEvaluateCurrentClass( void ) const;
void ReEvaluateCurrentClass( void );

public:
CountdownTimer m_CompressionBlastTimer;

private:
CTFBotLocomotion *m_locomotor;
Expand Down