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
29 changes: 16 additions & 13 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_lone_wolf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ CNEOBotCtgLoneWolf::CNEOBotCtgLoneWolf( void )
m_bHasRetreatedFromGhost = false;
m_vecDropThreatPos = CNEO_Player::VECTOR_INVALID_WAYPOINT;
m_closestCapturePoint = CNEO_Player::VECTOR_INVALID_WAYPOINT;
m_pIgnoredWeapons = std::make_unique<CNEOIgnoredWeaponsCache>();
}

//---------------------------------------------------------------------------------------------
CNEOBotCtgLoneWolf::~CNEOBotCtgLoneWolf() = default;

//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotCtgLoneWolf::OnStart( CNEOBot *me, Action< CNEOBot > *priorAction )
{
Expand All @@ -33,6 +37,8 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::OnStart( CNEOBot *me, Action< CNEOBo
m_repathTimer.Invalidate();
m_stalemateTimer.Invalidate();
m_capPointUpdateTimer.Invalidate();
m_scavengeTimer.Invalidate();
m_pIgnoredWeapons->Reset();
m_vecDropThreatPos = CNEO_Player::VECTOR_INVALID_WAYPOINT;
m_closestCapturePoint = CNEO_Player::VECTOR_INVALID_WAYPOINT;
m_hPursueTarget = nullptr;
Expand All @@ -59,7 +65,7 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
// First, ensure we have a weapon.
if ( !me->Weapon_GetSlot( 0 ) )
{
return SuspendFor( new CNEOBotSeekWeapon(), "Scavenging for weapon to hunt threat" );
return SuspendFor( new CNEOBotSeekWeapon(nullptr, m_pIgnoredWeapons.get()), "Scavenging for weapon to hunt threat" );
}

// We have a weapon. Investigate the last known location.
Expand Down Expand Up @@ -204,22 +210,19 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval
else
{
// Enemy is closer to goal (blocking us) or gaining on us.

// If we see a weapon nearby, drop the ghost and take it
CBaseEntity *pNearbyWeapon = FindNearestPrimaryWeapon( me->GetAbsOrigin(), true );
if ( pNearbyWeapon )
if ( m_scavengeTimer.IsElapsed() )
{
CBaseCombatWeapon *pGhostWep = me->Weapon_GetSlot( 0 );
if ( pGhostWep )
m_scavengeTimer.Start( RandomFloat( 0.5f, 1.0f ) );

// If we see a weapon nearby, drop the ghost and take it
CBaseEntity *pNearbyWeapon = FindNearestPrimaryWeapon( me, true, m_pIgnoredWeapons.get() );
if ( pNearbyWeapon )
{
if ( me->GetActiveWeapon() != pGhostWep )
CBaseCombatWeapon *pGhostWep = me->Weapon_GetSlot( 0 );
if ( pGhostWep )
{
me->Weapon_Switch( pGhostWep );
return Continue();
return SuspendFor( new CNEOBotSeekWeapon( pNearbyWeapon, m_pIgnoredWeapons.get() ), "Dropping ghost to scavenge nearby weapon" );
}

me->PressDropButton( 0.1f );
return ChangeTo( new CNEOBotSeekWeapon(), "Dropping ghost to scavenge nearby weapon" );
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_lone_wolf.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#pragma once

#include "bot/neo_bot.h"
#include <memory>

class CNEOIgnoredWeaponsCache;

//--------------------------------------------------------------------------------------------------------
class CNEOBotCtgLoneWolf : public Action< CNEOBot >
{
public:
CNEOBotCtgLoneWolf( void );
virtual ~CNEOBotCtgLoneWolf();

virtual ActionResult< CNEOBot > OnStart( CNEOBot *me, Action< CNEOBot > *priorAction ) override;
virtual ActionResult< CNEOBot > Update( CNEOBot *me, float interval ) override;
Expand All @@ -29,6 +33,8 @@ class CNEOBotCtgLoneWolf : public Action< CNEOBot >
Vector m_vecDropThreatPos;
CHandle<CBaseEntity> m_hPursueTarget;
bool m_bPursuingDropThreat;
std::unique_ptr<CNEOIgnoredWeaponsCache> m_pIgnoredWeapons;
CountdownTimer m_scavengeTimer;

ActionResult< CNEOBot > UpdateLookAround( CNEOBot *me, const Vector &anchorPos );
CountdownTimer m_lookAroundTimer;
Expand Down
Loading
Loading