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/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,18 @@ target_sources_grouped(
neo/bot/behavior/neo_bot_behavior.h
neo/bot/behavior/neo_bot_dead.cpp
neo/bot/behavior/neo_bot_dead.h
neo/bot/behavior/neo_bot_ctg_capture.cpp
neo/bot/behavior/neo_bot_ctg_capture.h
neo/bot/behavior/neo_bot_ctg_carrier.cpp
neo/bot/behavior/neo_bot_ctg_carrier.h
neo/bot/behavior/neo_bot_ctg_enemy.cpp
neo/bot/behavior/neo_bot_ctg_enemy.h
neo/bot/behavior/neo_bot_ctg_escort.cpp
neo/bot/behavior/neo_bot_ctg_escort.h
neo/bot/behavior/neo_bot_ctg_lone_wolf.cpp
neo/bot/behavior/neo_bot_ctg_lone_wolf.h
neo/bot/behavior/neo_bot_ctg_seek.cpp
neo/bot/behavior/neo_bot_ctg_seek.h
neo/bot/behavior/neo_bot_jgr_capture.cpp
neo/bot/behavior/neo_bot_jgr_capture.h
neo/bot/behavior/neo_bot_jgr_enemy.cpp
Expand Down
25 changes: 25 additions & 0 deletions src/game/server/NextBot/Player/NextBotPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ class INextBotPlayerInput
virtual void PressReloadButton( float duration = -1.0f ) = 0;
virtual void ReleaseReloadButton( void ) = 0;

virtual void PressDropButton( float duration = -1.0f ) = 0;
virtual void ReleaseDropButton( void ) = 0;

virtual void PressForwardButton( float duration = -1.0f ) = 0;
virtual void ReleaseForwardButton( void ) = 0;

Expand Down Expand Up @@ -212,6 +215,9 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI
virtual void PressReloadButton( float duration = -1.0f );
virtual void ReleaseReloadButton( void );

virtual void PressDropButton( float duration = -1.0f );
virtual void ReleaseDropButton( void );

virtual void PressForwardButton( float duration = -1.0f );
virtual void ReleaseForwardButton( void );

Expand Down Expand Up @@ -277,6 +283,7 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI
CountdownTimer m_specialFireButtonTimer;
CountdownTimer m_useButtonTimer;
CountdownTimer m_reloadButtonTimer;
CountdownTimer m_dropButtonTimer;
CountdownTimer m_forwardButtonTimer;
CountdownTimer m_backwardButtonTimer;
CountdownTimer m_leftButtonTimer;
Expand Down Expand Up @@ -430,6 +437,20 @@ inline void NextBotPlayer< PlayerType >::ReleaseReloadButton( void )
m_reloadButtonTimer.Invalidate();
}

template < typename PlayerType >
inline void NextBotPlayer< PlayerType >::PressDropButton( float duration )
{
m_inputButtons |= IN_DROP;
m_dropButtonTimer.Start( duration );
}

template < typename PlayerType >
inline void NextBotPlayer< PlayerType >::ReleaseDropButton( void )
{
m_inputButtons &= ~IN_DROP;
m_dropButtonTimer.Invalidate();
}

template < typename PlayerType >
inline void NextBotPlayer< PlayerType >::PressJumpButton( float duration )
{
Expand Down Expand Up @@ -631,6 +652,7 @@ inline void NextBotPlayer< PlayerType >::Spawn( void )
m_specialFireButtonTimer.Invalidate();
m_useButtonTimer.Invalidate();
m_reloadButtonTimer.Invalidate();
m_dropButtonTimer.Invalidate();
m_forwardButtonTimer.Invalidate();
m_backwardButtonTimer.Invalidate();
m_leftButtonTimer.Invalidate();
Expand Down Expand Up @@ -758,6 +780,9 @@ inline void NextBotPlayer< PlayerType >::PhysicsSimulate( void )
if ( !m_reloadButtonTimer.IsElapsed() )
m_inputButtons |= IN_RELOAD;

if ( !m_dropButtonTimer.IsElapsed() )
m_inputButtons |= IN_DROP;

if ( !m_forwardButtonTimer.IsElapsed() )
m_inputButtons |= IN_FORWARD;

Expand Down
7 changes: 7 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ ActionResult< CNEOBot > CNEOBotMainAction::Update( CNEOBot *me, float interval )
// make sure our vision FOV matches the player's
me->GetVisionInterface()->SetFieldOfView( me->GetFOV() );

if (me->IsCarryingGhost())
{
// Don't waste cloak power
// Incidentally flashing cloak is fine, everyone can see you anyway
me->DisableCloak();
}

// track aim velocity ourselves, since body aim "steady" is too loose
float deltaYaw = me->EyeAngles().y - m_priorYaw;
m_yawRate = fabs( deltaYaw / ( interval + 0.0001f ) );
Expand Down
90 changes: 90 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_capture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include "cbase.h"
#include "bot/behavior/neo_bot_ctg_capture.h"
#include "bot/behavior/neo_bot_seek_weapon.h"
#include "bot/neo_bot_path_compute.h"
#include "weapon_ghost.h"


//---------------------------------------------------------------------------------------------
CNEOBotCtgCapture::CNEOBotCtgCapture( CWeaponGhost *pObjective )
{
m_hObjective = pObjective;
}


//---------------------------------------------------------------------------------------------
ActionResult<CNEOBot> CNEOBotCtgCapture::OnStart( CNEOBot *me, Action<CNEOBot> *priorAction )
{
m_captureAttemptTimer.Invalidate();
m_repathTimer.Invalidate();
m_path.Invalidate();

if ( !m_hObjective )
{
return Done( "No ghost capture target specified." );
}

return Continue();
}


//---------------------------------------------------------------------------------------------
ActionResult<CNEOBot> CNEOBotCtgCapture::Update( CNEOBot *me, float interval )
{
if ( me->IsDead() )
{
return Done( "I died before I could capture the ghost" );
}

if ( !m_hObjective )
{
return Done( "Ghost capture target lost" );
}

if ( me->IsCarryingGhost() )
{
return Done( "Captured ghost" );
}

if ( m_hObjective->GetOwner() )
{
return Done( "Ghost was taken by someone else" );
}

if ( !m_repathTimer.HasStarted() || m_repathTimer.IsElapsed() )
{
if ( !CNEOBotPathCompute( me, m_path, m_hObjective->GetAbsOrigin(), FASTEST_ROUTE ) )
{
return Done( "Unable to find a path to the ghost capture target" );
}
m_repathTimer.Start( RandomFloat( 0.3f, 0.6f ) );
}
m_path.Update( me );

if ( !m_captureAttemptTimer.HasStarted() )
{
// If this timer expires, give up
m_captureAttemptTimer.Start( 3.0f );
}

CBaseCombatWeapon *pPrimary = me->Weapon_GetSlot( 0 );
if ( pPrimary )
{
// Switch to primary weapon to drop it, if not already active
if ( me->GetActiveWeapon() != pPrimary )
{
me->Weapon_Switch( pPrimary );
}
else
{
me->PressDropButton( 0.1f );
}
}

if ( m_captureAttemptTimer.IsElapsed() )
{
return ChangeTo( new CNEOBotSeekWeapon, "Failed to capture ghost in time" );
}

return Continue();
}
26 changes: 26 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_capture.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef NEO_BOT_CTG_CAPTURE_H
#define NEO_BOT_CTG_CAPTURE_H

#include "NextBotBehavior.h"
#include "bot/neo_bot.h"

//----------------------------------------------------------------------------------------------------------------
class CNEOBotCtgCapture : public Action<CNEOBot>
{
public:
CNEOBotCtgCapture( CWeaponGhost *pObjective );
virtual ~CNEOBotCtgCapture() { }

virtual const char *GetName() const override { return "ctgCapture"; }

virtual ActionResult<CNEOBot> OnStart( CNEOBot *me, Action<CNEOBot> *priorAction ) override;
virtual ActionResult<CNEOBot> Update( CNEOBot *me, float interval ) override;

private:
CHandle<CWeaponGhost> m_hObjective;
CountdownTimer m_captureAttemptTimer;
CountdownTimer m_repathTimer;
PathFollower m_path;
};

#endif // NEO_BOT_CTG_CAPTURE_H
Loading