Skip to content

Commit de4978d

Browse files
committed
Bot CTG gameplay behaviors
1 parent 4909560 commit de4978d

21 files changed

Lines changed: 2169 additions & 124 deletions

src/game/server/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,18 @@ target_sources_grouped(
14401440
neo/bot/behavior/neo_bot_command_follow.h
14411441
neo/bot/behavior/neo_bot_dead.cpp
14421442
neo/bot/behavior/neo_bot_dead.h
1443+
neo/bot/behavior/neo_bot_ctg_capture.cpp
1444+
neo/bot/behavior/neo_bot_ctg_capture.h
1445+
neo/bot/behavior/neo_bot_ctg_carrier.cpp
1446+
neo/bot/behavior/neo_bot_ctg_carrier.h
1447+
neo/bot/behavior/neo_bot_ctg_enemy.cpp
1448+
neo/bot/behavior/neo_bot_ctg_enemy.h
1449+
neo/bot/behavior/neo_bot_ctg_escort.cpp
1450+
neo/bot/behavior/neo_bot_ctg_escort.h
1451+
neo/bot/behavior/neo_bot_ctg_lone_wolf.cpp
1452+
neo/bot/behavior/neo_bot_ctg_lone_wolf.h
1453+
neo/bot/behavior/neo_bot_ctg_seek.cpp
1454+
neo/bot/behavior/neo_bot_ctg_seek.h
14431455
neo/bot/behavior/neo_bot_jgr_capture.cpp
14441456
neo/bot/behavior/neo_bot_jgr_capture.h
14451457
neo/bot/behavior/neo_bot_jgr_enemy.cpp

src/game/server/NextBot/Player/NextBotPlayer.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class INextBotPlayerInput
106106
virtual void PressReloadButton( float duration = -1.0f ) = 0;
107107
virtual void ReleaseReloadButton( void ) = 0;
108108

109+
virtual void PressDropButton( float duration = -1.0f ) = 0;
110+
virtual void ReleaseDropButton( void ) = 0;
111+
109112
virtual void PressForwardButton( float duration = -1.0f ) = 0;
110113
virtual void ReleaseForwardButton( void ) = 0;
111114

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

218+
virtual void PressDropButton( float duration = -1.0f );
219+
virtual void ReleaseDropButton( void );
220+
215221
virtual void PressForwardButton( float duration = -1.0f );
216222
virtual void ReleaseForwardButton( void );
217223

@@ -277,6 +283,7 @@ class NextBotPlayer : public PlayerType, public INextBot, public INextBotPlayerI
277283
CountdownTimer m_specialFireButtonTimer;
278284
CountdownTimer m_useButtonTimer;
279285
CountdownTimer m_reloadButtonTimer;
286+
CountdownTimer m_dropButtonTimer;
280287
CountdownTimer m_forwardButtonTimer;
281288
CountdownTimer m_backwardButtonTimer;
282289
CountdownTimer m_leftButtonTimer;
@@ -430,6 +437,20 @@ inline void NextBotPlayer< PlayerType >::ReleaseReloadButton( void )
430437
m_reloadButtonTimer.Invalidate();
431438
}
432439

440+
template < typename PlayerType >
441+
inline void NextBotPlayer< PlayerType >::PressDropButton( float duration )
442+
{
443+
m_inputButtons |= IN_DROP;
444+
m_dropButtonTimer.Start( duration );
445+
}
446+
447+
template < typename PlayerType >
448+
inline void NextBotPlayer< PlayerType >::ReleaseDropButton( void )
449+
{
450+
m_inputButtons &= ~IN_DROP;
451+
m_dropButtonTimer.Invalidate();
452+
}
453+
433454
template < typename PlayerType >
434455
inline void NextBotPlayer< PlayerType >::PressJumpButton( float duration )
435456
{
@@ -631,6 +652,7 @@ inline void NextBotPlayer< PlayerType >::Spawn( void )
631652
m_specialFireButtonTimer.Invalidate();
632653
m_useButtonTimer.Invalidate();
633654
m_reloadButtonTimer.Invalidate();
655+
m_dropButtonTimer.Invalidate();
634656
m_forwardButtonTimer.Invalidate();
635657
m_backwardButtonTimer.Invalidate();
636658
m_leftButtonTimer.Invalidate();
@@ -758,6 +780,9 @@ inline void NextBotPlayer< PlayerType >::PhysicsSimulate( void )
758780
if ( !m_reloadButtonTimer.IsElapsed() )
759781
m_inputButtons |= IN_RELOAD;
760782

783+
if ( !m_dropButtonTimer.IsElapsed() )
784+
m_inputButtons |= IN_DROP;
785+
761786
if ( !m_forwardButtonTimer.IsElapsed() )
762787
m_inputButtons |= IN_FORWARD;
763788

src/game/server/neo/bot/behavior/neo_bot_behavior.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ ActionResult< CNEOBot > CNEOBotMainAction::Update( CNEOBot *me, float interval )
9090
// make sure our vision FOV matches the player's
9191
me->GetVisionInterface()->SetFieldOfView( me->GetFOV() );
9292

93+
if (me->IsCarryingGhost())
94+
{
95+
// Don't waste cloak power
96+
// Incidentally flashing cloak is fine, everyone can see you anyway
97+
me->DisableCloak();
98+
}
99+
93100
// track aim velocity ourselves, since body aim "steady" is too loose
94101
float deltaYaw = me->EyeAngles().y - m_priorYaw;
95102
m_yawRate = fabs( deltaYaw / ( interval + 0.0001f ) );
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#include "cbase.h"
2+
#include "bot/behavior/neo_bot_ctg_capture.h"
3+
#include "bot/behavior/neo_bot_seek_weapon.h"
4+
#include "bot/neo_bot_path_compute.h"
5+
#include "weapon_ghost.h"
6+
7+
8+
//---------------------------------------------------------------------------------------------
9+
CNEOBotCtgCapture::CNEOBotCtgCapture( CWeaponGhost *pObjective )
10+
{
11+
m_hObjective = pObjective;
12+
}
13+
14+
15+
//---------------------------------------------------------------------------------------------
16+
ActionResult<CNEOBot> CNEOBotCtgCapture::OnStart( CNEOBot *me, Action<CNEOBot> *priorAction )
17+
{
18+
m_captureAttemptTimer.Invalidate();
19+
m_repathTimer.Invalidate();
20+
m_path.Invalidate();
21+
22+
if ( !m_hObjective )
23+
{
24+
return Done( "No ghost capture target specified." );
25+
}
26+
27+
return Continue();
28+
}
29+
30+
31+
//---------------------------------------------------------------------------------------------
32+
ActionResult<CNEOBot> CNEOBotCtgCapture::Update( CNEOBot *me, float interval )
33+
{
34+
if ( me->IsDead() )
35+
{
36+
return Done( "I died before I could capture the ghost" );
37+
}
38+
39+
if ( !m_hObjective )
40+
{
41+
return Done( "Ghost capture target lost" );
42+
}
43+
44+
if ( me->IsCarryingGhost() )
45+
{
46+
return Done( "Captured ghost" );
47+
}
48+
49+
if ( m_hObjective->GetOwner() )
50+
{
51+
return Done( "Ghost was taken by someone else" );
52+
}
53+
54+
if ( !m_repathTimer.HasStarted() || m_repathTimer.IsElapsed() )
55+
{
56+
if ( !CNEOBotPathCompute( me, m_path, m_hObjective->GetAbsOrigin(), FASTEST_ROUTE ) )
57+
{
58+
return Done( "Unable to find a path to the ghost capture target" );
59+
}
60+
m_repathTimer.Start( RandomFloat( 0.3f, 0.6f ) );
61+
}
62+
m_path.Update( me );
63+
64+
if ( !m_captureAttemptTimer.HasStarted() )
65+
{
66+
// If this timer expires, give up
67+
m_captureAttemptTimer.Start( 3.0f );
68+
}
69+
70+
CBaseCombatWeapon *pPrimary = me->Weapon_GetSlot( 0 );
71+
if ( pPrimary )
72+
{
73+
// Switch to primary weapon to drop it, if not already active
74+
if ( me->GetActiveWeapon() != pPrimary )
75+
{
76+
me->Weapon_Switch( pPrimary );
77+
}
78+
else
79+
{
80+
me->PressDropButton( 0.1f );
81+
}
82+
}
83+
84+
if ( m_captureAttemptTimer.IsElapsed() )
85+
{
86+
return ChangeTo( new CNEOBotSeekWeapon, "Failed to capture ghost in time" );
87+
}
88+
89+
return Continue();
90+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef NEO_BOT_CTG_CAPTURE_H
2+
#define NEO_BOT_CTG_CAPTURE_H
3+
4+
#include "NextBotBehavior.h"
5+
#include "bot/neo_bot.h"
6+
7+
//----------------------------------------------------------------------------------------------------------------
8+
class CNEOBotCtgCapture : public Action<CNEOBot>
9+
{
10+
public:
11+
CNEOBotCtgCapture( CWeaponGhost *pObjective );
12+
virtual ~CNEOBotCtgCapture() { }
13+
14+
virtual const char *GetName() const override { return "ctgCapture"; }
15+
16+
virtual ActionResult<CNEOBot> OnStart( CNEOBot *me, Action<CNEOBot> *priorAction ) override;
17+
virtual ActionResult<CNEOBot> Update( CNEOBot *me, float interval ) override;
18+
19+
private:
20+
CHandle<CWeaponGhost> m_hObjective;
21+
CountdownTimer m_captureAttemptTimer;
22+
CountdownTimer m_repathTimer;
23+
PathFollower m_path;
24+
};
25+
26+
#endif // NEO_BOT_CTG_CAPTURE_H

0 commit comments

Comments
 (0)