Skip to content

Commit 517bb3c

Browse files
committed
Bots swap for more powerful weapons
1 parent c669c39 commit 517bb3c

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;
@@ -59,7 +62,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
5962
// First, ensure we have a weapon.
6063
if ( !me->Weapon_GetSlot( 0 ) )
6164
{
62-
return SuspendFor( new CNEOBotSeekWeapon(), "Scavenging for weapon to hunt threat" );
65+
return SuspendFor( new CNEOBotSeekWeapon(nullptr, m_pIgnoredWeapons.get()), "Scavenging for weapon to hunt threat" );
6366
}
6467

6568
// We have a weapon. Investigate the last known location.
@@ -204,22 +207,19 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
204207
else
205208
{
206209
// Enemy is closer to goal (blocking us) or gaining on us.
207-
208-
// If we see a weapon nearby, drop the ghost and take it
209-
CBaseEntity *pNearbyWeapon = FindNearestPrimaryWeapon( me->GetAbsOrigin(), true );
210-
if ( pNearbyWeapon )
210+
if ( m_scavengeTimer.IsElapsed() )
211211
{
212-
CBaseCombatWeapon *pGhostWep = me->Weapon_GetSlot( 0 );
213-
if ( pGhostWep )
212+
m_scavengeTimer.Start( RandomFloat( 0.5f, 1.0f ) );
213+
214+
// If we see a weapon nearby, drop the ghost and take it
215+
CBaseEntity *pNearbyWeapon = FindNearestPrimaryWeapon( me, true, m_pIgnoredWeapons.get() );
216+
if ( pNearbyWeapon )
214217
{
215-
if ( me->GetActiveWeapon() != pGhostWep )
218+
CBaseCombatWeapon *pGhostWep = me->Weapon_GetSlot( 0 );
219+
if ( pGhostWep )
216220
{
217-
me->Weapon_Switch( pGhostWep );
218-
return Continue();
221+
return SuspendFor( new CNEOBotSeekWeapon( pNearbyWeapon, m_pIgnoredWeapons.get() ), "Dropping ghost to scavenge nearby weapon" );
219222
}
220-
221-
me->PressDropButton( 0.1f );
222-
return ChangeTo( new CNEOBotSeekWeapon(), "Dropping ghost to scavenge nearby weapon" );
223223
}
224224
}
225225

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)