Skip to content

Commit 5b94e3c

Browse files
committed
Look for better weapons when searching for enemy
1 parent c6fad9b commit 5b94e3c

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/game/server/neo/bot/behavior/neo_bot_ctg_lone_wolf.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#pragma once
22

33
#include "bot/neo_bot.h"
4-
#include <memory>
5-
6-
class CNEOIgnoredWeaponsCache;
74

85
//--------------------------------------------------------------------------------------------------------
96
class CNEOBotCtgLoneWolf : public Action< CNEOBot >

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "bot/neo_bot.h"
33
#include "bot/behavior/neo_bot_attack.h"
44
#include "bot/behavior/neo_bot_ctg_lone_wolf_seek.h"
5+
#include "bot/behavior/neo_bot_seek_weapon.h"
56
#include "bot/neo_bot_path_compute.h"
67
#include "neo_gamerules.h"
78
#include "neo_player.h"
@@ -75,6 +76,15 @@ class CSearchForUnexplored : public ISearchSurroundingAreasFunctor
7576
int m_iAreaLimit;
7677
};
7778

79+
//---------------------------------------------------------------------------------------------
80+
CNEOBotCtgLoneWolfSeek::CNEOBotCtgLoneWolfSeek( void )
81+
{
82+
m_pIgnoredWeapons = std::make_unique<CNEOIgnoredWeaponsCache>();
83+
}
84+
85+
//---------------------------------------------------------------------------------------------
86+
CNEOBotCtgLoneWolfSeek::~CNEOBotCtgLoneWolfSeek() = default;
87+
7888
//---------------------------------------------------------------------------------------------
7989
ActionResult< CNEOBot > CNEOBotCtgLoneWolfSeek::OnStart( CNEOBot *me, Action< CNEOBot > *priorAction )
8090
{
@@ -87,6 +97,9 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolfSeek::OnStart( CNEOBot *me, Action< CN
8797
m_vecLastGhostPos = NEORules()->GetGhostPos();
8898
m_pCachedGhostArea = TheNavMesh->GetNearestNavArea( m_vecLastGhostPos );
8999

100+
m_scavengeTimer.Invalidate();
101+
m_pIgnoredWeapons->Reset();
102+
90103
return Continue();
91104
}
92105

@@ -133,6 +146,18 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolfSeek::Update( CNEOBot *me, float inter
133146
me->ReloadIfLowClip(true); // force reload true
134147
}
135148

149+
// Periodically look for better weapons
150+
if ( ( !m_scavengeTimer.HasStarted() || m_scavengeTimer.IsElapsed() ) )
151+
{
152+
m_scavengeTimer.Start( RandomFloat( 3.0f, 6.0f ) );
153+
154+
CBaseEntity *pNearbyWeapon = FindNearestPrimaryWeapon( me, true, m_pIgnoredWeapons.get() );
155+
if ( pNearbyWeapon )
156+
{
157+
return SuspendFor( new CNEOBotSeekWeapon( pNearbyWeapon, m_pIgnoredWeapons.get() ), "Scavenging for nearby weapon" );
158+
}
159+
}
160+
136161
Vector vecSoundPos = me->GetAudibleEnemySoundPos();
137162
if ( vecSoundPos != CNEO_Player::VECTOR_INVALID_WAYPOINT )
138163
{

src/game/server/neo/bot/behavior/neo_bot_ctg_lone_wolf_seek.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
#include "bot/neo_bot.h"
44
#include "bot/behavior/neo_bot_ctg_lone_wolf.h"
55
#include "utlmap.h"
6+
#include <memory>
67

78
class CWeaponDetpack;
9+
class CNEOIgnoredWeaponsCache;
810

911
//--------------------------------------------------------------------------------------------------------
1012
class CNEOBotCtgLoneWolfSeek : public CNEOBotCtgLoneWolf
1113
{
1214
public:
1315
typedef CNEOBotCtgLoneWolf BaseClass;
14-
CNEOBotCtgLoneWolfSeek( void ) = default;
16+
CNEOBotCtgLoneWolfSeek( void );
17+
virtual ~CNEOBotCtgLoneWolfSeek();
1518

1619
virtual ActionResult< CNEOBot > OnStart( CNEOBot *me, Action< CNEOBot > *priorAction ) override;
1720
virtual ActionResult< CNEOBot > Update( CNEOBot *me, float interval ) override;
@@ -35,5 +38,8 @@ class CNEOBotCtgLoneWolfSeek : public CNEOBotCtgLoneWolf
3538
int m_iExplorationTargetId{-1};
3639
Vector m_vecSearchWaypoint{CNEO_Player::VECTOR_INVALID_WAYPOINT};
3740

41+
std::unique_ptr<CNEOIgnoredWeaponsCache> m_pIgnoredWeapons;
42+
CountdownTimer m_scavengeTimer;
43+
3844
void MarkVisibleAreasAsExplored( CNEOBot *me, CNavArea *currentArea, CNavArea *ghostArea = nullptr );
3945
};

0 commit comments

Comments
 (0)