diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/tf/bot/tf_bot_locomotion.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/tf/bot/tf_bot_locomotion.cpp')
| -rw-r--r-- | game/server/tf/bot/tf_bot_locomotion.cpp | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/game/server/tf/bot/tf_bot_locomotion.cpp b/game/server/tf/bot/tf_bot_locomotion.cpp new file mode 100644 index 0000000..8ff19c1 --- /dev/null +++ b/game/server/tf/bot/tf_bot_locomotion.cpp @@ -0,0 +1,137 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// tf_bot_locomotion.cpp +// Team Fortress NextBot locomotion interface +// Michael Booth, May 2010 + +#include "cbase.h" + +#include "tf_bot.h" +#include "tf_bot_locomotion.h" +#include "particle_parse.h" + + +//----------------------------------------------------------------------------------------- +void CTFBotLocomotion::Update( void ) +{ + BaseClass::Update(); + + CTFBot *me = ToTFBot( GetBot()->GetEntity() ); + if ( !me ) + { + return; + } + + // always 'crouch jump' + if ( IsOnGround() ) + { + if ( !me->IsPlayerClass( TF_CLASS_ENGINEER ) ) + { + // engineers need to crouch behind their guns + me->ReleaseCrouchButton(); + } + } + else + { + me->PressCrouchButton( 0.3f ); + } +} + + +//----------------------------------------------------------------------------------------- +// Move directly towards the given position +void CTFBotLocomotion::Approach( const Vector &pos, float goalWeight ) +{ + if ( TFGameRules()->IsMannVsMachineMode() ) + { + if ( !IsOnGround() && !IsClimbingOrJumping() ) + { + // no air control + return; + } + } + + BaseClass::Approach( pos, goalWeight ); +} + + +//----------------------------------------------------------------------------------------- +// Distance at which we will die if we fall +float CTFBotLocomotion::GetDeathDropHeight( void ) const +{ + return 1000.0f; +} + + +//----------------------------------------------------------------------------------------- +// Get maximum running speed +float CTFBotLocomotion::GetRunSpeed( void ) const +{ + CTFBot *me = (CTFBot *)GetBot()->GetEntity(); + return me->GetPlayerClass()->GetMaxSpeed(); +} + + +//----------------------------------------------------------------------------------------- +// Return true if given area can be used for navigation +bool CTFBotLocomotion::IsAreaTraversable( const CNavArea *baseArea ) const +{ + CTFBot *me = (CTFBot *)GetBot()->GetEntity(); + CTFNavArea *area = (CTFNavArea *)baseArea; + + if ( area->IsBlocked( me->GetTeamNumber() ) ) + { + return false; + } + + if ( !TFGameRules()->RoundHasBeenWon() || TFGameRules()->GetWinningTeam() != me->GetTeamNumber() ) + { + if ( area->HasAttributeTF( TF_NAV_SPAWN_ROOM_RED ) && me->GetTeamNumber() == TF_TEAM_BLUE ) + { + return false; + } + + if ( area->HasAttributeTF( TF_NAV_SPAWN_ROOM_BLUE ) && me->GetTeamNumber() == TF_TEAM_RED ) + { + return false; + } + } + + return true; +} + + +//----------------------------------------------------------------------------------------- +bool CTFBotLocomotion::IsEntityTraversable( CBaseEntity *obstacle, TraverseWhenType when ) const +{ + // assume all players are "traversable" in that they will move or can be killed + if ( obstacle && obstacle->IsPlayer() ) + { + return true; + } + + return PlayerLocomotion::IsEntityTraversable( obstacle, when ); +} + + +void CTFBotLocomotion::Jump( void ) +{ + BaseClass::Jump(); + + CTFBot *me = ToTFBot( GetBot()->GetEntity() ); + if ( !me ) + { + return; + } + + if ( TFGameRules() && TFGameRules()->IsMannVsMachineMode() ) + { + int iCustomJumpParticle = 0; + CALL_ATTRIB_HOOK_INT_ON_OTHER( me, iCustomJumpParticle, bot_custom_jump_particle ); + if ( iCustomJumpParticle ) + { + const char *pEffectName = "rocketjump_smoke"; + DispatchParticleEffect( pEffectName, PATTACH_POINT_FOLLOW, me, "foot_L" ); + DispatchParticleEffect( pEffectName, PATTACH_POINT_FOLLOW, me, "foot_R" ); + } + } +} |