Skip to content

Commit 54b1a25

Browse files
committed
Bots swap for more powerful weapons
1 parent 555142c commit 54b1a25

File tree

9 files changed

+420
-107
lines changed

9 files changed

+420
-107
lines changed

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CNEOBotCtgLoneWolf::CNEOBotCtgLoneWolf( void )
2020
m_bHasRetreatedFromGhost = false;
2121
m_vecDropThreatPos = CNEO_Player::VECTOR_INVALID_WAYPOINT;
2222
m_closestCapturePoint = CNEO_Player::VECTOR_INVALID_WAYPOINT;
23+
m_pIgnoredWeapons = std::make_unique<CNEOIgnoredWeaponsCache>();
2324
}
2425

2526
//---------------------------------------------------------------------------------------------
@@ -33,6 +34,8 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::OnStart( CNEOBot *me, Action< CNEOBo
3334
m_repathTimer.Invalidate();
3435
m_stalemateTimer.Invalidate();
3536
m_capPointUpdateTimer.Invalidate();
37+
m_scavengeTimer.Invalidate();
38+
m_pIgnoredWeapons->Reset();
3639
m_vecDropThreatPos = CNEO_Player::VECTOR_INVALID_WAYPOINT;
3740
m_closestCapturePoint = CNEO_Player::VECTOR_INVALID_WAYPOINT;
3841
m_hPursueTarget = nullptr;
@@ -62,7 +65,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
6265
// First, ensure we have a weapon.
6366
if ( !me->Weapon_GetSlot( 0 ) )
6467
{
65-
return SuspendFor( new CNEOBotSeekWeapon(), "Scavenging for weapon to hunt threat" );
68+
return SuspendFor( new CNEOBotSeekWeapon(nullptr, m_pIgnoredWeapons.get()), "Scavenging for weapon to hunt threat" );
6669
}
6770

6871
// We have a weapon. Investigate the last known location.
@@ -207,22 +210,19 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
207210
else
208211
{
209212
// Enemy is closer to goal (blocking us) or gaining on us.
210-
211-
// If we see a weapon nearby, drop the ghost and take it
212-
CBaseEntity *pNearbyWeapon = FindNearestPrimaryWeapon( me->GetAbsOrigin(), true );
213-
if ( pNearbyWeapon )
213+
if ( m_scavengeTimer.IsElapsed() )
214214
{
215-
CBaseCombatWeapon *pGhostWep = me->Weapon_GetSlot( 0 );
216-
if ( pGhostWep )
215+
m_scavengeTimer.Start( RandomFloat( 0.5f, 1.0f ) );
216+
217+
// If we see a weapon nearby, drop the ghost and take it
218+
CBaseEntity *pNearbyWeapon = FindNearestPrimaryWeapon( me, true, m_pIgnoredWeapons.get() );
219+
if ( pNearbyWeapon )
217220
{
218-
if ( me->GetActiveWeapon() != pGhostWep )
221+
CBaseCombatWeapon *pGhostWep = me->Weapon_GetSlot( 0 );
222+
if ( pGhostWep )
219223
{
220-
me->Weapon_Switch( pGhostWep );
221-
return Continue();
224+
return SuspendFor( new CNEOBotSeekWeapon( pNearbyWeapon, m_pIgnoredWeapons.get() ), "Dropping ghost to scavenge nearby weapon" );
222225
}
223-
224-
me->PressDropButton( 0.1f );
225-
return ChangeTo( new CNEOBotSeekWeapon(), "Dropping ghost to scavenge nearby weapon" );
226226
}
227227
}
228228

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

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

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

58
//--------------------------------------------------------------------------------------------------------
69
class CNEOBotCtgLoneWolf : public Action< CNEOBot >
@@ -29,6 +32,8 @@ class CNEOBotCtgLoneWolf : public Action< CNEOBot >
2932
Vector m_vecDropThreatPos;
3033
CHandle<CBaseEntity> m_hPursueTarget;
3134
bool m_bPursuingDropThreat;
35+
std::unique_ptr<CNEOIgnoredWeaponsCache> m_pIgnoredWeapons;
36+
CountdownTimer m_scavengeTimer;
3237

3338
ActionResult< CNEOBot > UpdateLookAround( CNEOBot *me, const Vector &anchorPos );
3439
CountdownTimer m_lookAroundTimer;

0 commit comments

Comments
 (0)