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 @@ -1440,6 +1440,18 @@ target_sources_grouped(
neo/bot/behavior/neo_bot_command_follow.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 @@ -122,6 +122,9 @@ class INextBotPlayerInput
virtual void ReleaseJumpButton( void ) = 0;

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

virtual void PressThermopticButton( float duration = -1.0f ) = 0;
virtual void ReleaseThermopticButton( void ) = 0;
#endif // NEO
Expand Down Expand Up @@ -202,6 +205,9 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI
virtual void ReleaseSpecialFireButton( void );

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

virtual void PressThermopticButton( float duration = -1.0f );
virtual void ReleaseThermopticButton( void );
#endif
Expand Down Expand Up @@ -286,6 +292,7 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI
CountdownTimer m_walkButtonTimer;
CountdownTimer m_buttonScaleTimer;
#ifdef NEO
CountdownTimer m_dropButtonTimer;
CountdownTimer m_thermopticButtonTimer;
CountdownTimer m_leanLeftButtonTimer;
CountdownTimer m_leanRightButtonTimer;
Expand Down Expand Up @@ -450,6 +457,20 @@ inline void NextBotPlayer< PlayerType >::ReleaseJumpButton( void )
}

#ifdef NEO
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 >::PressThermopticButton( float duration )
{
Expand Down Expand Up @@ -642,6 +663,7 @@ inline void NextBotPlayer< PlayerType >::Spawn( void )
m_forwardScale = m_rightScale = 0.04;
m_burningTimer.Invalidate();
#ifdef NEO
m_dropButtonTimer.Invalidate();
m_thermopticButtonTimer.Invalidate();
m_leanLeftButtonTimer.Invalidate();
m_leanRightButtonTimer.Invalidate();
Expand Down Expand Up @@ -780,6 +802,9 @@ inline void NextBotPlayer< PlayerType >::PhysicsSimulate( void )
m_inputButtons |= IN_SPEED;

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

if ( !m_leanLeftButtonTimer.IsElapsed() )
m_inputButtons |= IN_LEAN_LEFT;

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 @@ -92,6 +92,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
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ActionResult< CNEOBot > CNEOBotCommandFollow::Update(CNEOBot *me, float interval
}

m_path.Update(me);
m_ghostEquipmentHandler.Update( me );

return Continue();
}
Expand Down
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_command_follow.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#endif

#include "NextBotBehavior.h"
#include "bot/behavior/neo_bot_ctg_carrier.h"

class CNEOBotCommandFollow : public Action< CNEOBot >
{
Expand All @@ -24,6 +25,7 @@ class CNEOBotCommandFollow : public Action< CNEOBot >

PathFollower m_path;
CountdownTimer m_repathTimer;
CNEOBotGhostEquipmentHandler m_ghostEquipmentHandler;

EHANDLE m_hTargetEntity;
bool m_bGoingToTargetEntity = false;
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