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
8 changes: 6 additions & 2 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ ActionResult<CNEOBot> CNEOBotCtgCapture::Update( CNEOBot *me, float interval )
{
if ( !CNEOBotPathCompute( me, m_path, m_hObjective->GetAbsOrigin(), FASTEST_ROUTE ) )
{
return Done( "Unable to find a path to the ghost capture target" );
// Something has gone wrong if we can't path to a ghost that we by convention started close to
// Transition to search around the ghost behavior to avoid cycle of ghost search failure and retry attempts
return ChangeTo( new CNEOBotCtgLoneWolf(), "Unable to find a path to the ghost capture target, searching around nearest areas" );
}
m_repathTimer.Start( RandomFloat( 0.3f, 0.6f ) );
}
Expand Down Expand Up @@ -84,7 +86,9 @@ ActionResult<CNEOBot> CNEOBotCtgCapture::Update( CNEOBot *me, float interval )

if ( m_captureAttemptTimer.IsElapsed() )
{
return ChangeTo( new CNEOBotSeekWeapon, "Failed to capture ghost in time" );
// If the bot fails to capture the ghost, it's sometimes because the ghost is lodged into an awkward position
// Have the bot search around the location instead, to avoid cycle of failing to pick up ghost and retrying
return ChangeTo( new CNEOBotCtgLoneWolf(), "Failed to pick up ghost in time, searching around nearest areas" );
}

return Continue();
Expand Down
41 changes: 41 additions & 0 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 @@ -2,6 +2,8 @@
#include "neo_player.h"
#include "bot/neo_bot.h"
#include "bot/behavior/neo_bot_attack.h"
#include "bot/behavior/neo_bot_ctg_enemy.h"
#include "bot/behavior/neo_bot_ctg_escort.h"
#include "bot/behavior/neo_bot_ctg_lone_wolf.h"
#include "bot/behavior/neo_bot_ctg_lone_wolf_ambush.h"
#include "bot/behavior/neo_bot_ctg_lone_wolf_seek.h"
Expand All @@ -23,6 +25,12 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::OnStart( CNEOBot *me, Action< CNEOBo
//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotCtgLoneWolf::Update( CNEOBot *me, float interval )
{
ActionResult< CNEOBot > result = ConsiderGhostCaptureTransition( me );
if ( result.IsRequestingChange() )
{
return result;
}

if ( me->DropGhost() )
{
return Continue(); // ghost drop in progress
Expand Down Expand Up @@ -142,6 +150,39 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolf::ConsiderGhostVisualCheck( CNEOBot *m
}


//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotCtgLoneWolf::ConsiderGhostCaptureTransition( CNEOBot *me )
{
if (NEORules()->GhostExists())
{
int iGhosterPlayer = NEORules()->GetGhosterPlayer();
if (iGhosterPlayer > 0 && iGhosterPlayer <= gpGlobals->maxClients)
{
CNEO_Player* pGhostCarrier = ToNEOPlayer(UTIL_PlayerByIndex(iGhosterPlayer));
if (pGhostCarrier && pGhostCarrier != me)
{
// We sometimes flow into CNEOBotCtgLoneWolf if this bot failed to get the ghost
// Use ChangeTo to reset scenario evaluation after reacting to ghost pickup
if (pGhostCarrier->GetTeamNumber() == me->GetTeamNumber())
{
return ChangeTo(new CNEOBotCtgEscort, "Protect teammate that had better luck capturing ghost");
}
else
{
return ChangeTo(new CNEOBotCtgEnemy, "Intercepting the ghost carrier!");
}
}
}
}
else
{
return Done("No ghost exists, exiting behavior to reevaluate situation.");
}

return Continue();
}


//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotCtgLoneWolf::OnSuspend( CNEOBot *me, Action< CNEOBot > *interruptingAction )
{
Expand Down
1 change: 1 addition & 0 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_lone_wolf.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CNEOBotCtgLoneWolf : public Action< CNEOBot >
protected:
virtual ActionResult< CNEOBot > ConsiderGhostInterception( CNEOBot *me, const CBaseCombatCharacter *pGhostOwner = nullptr );
virtual ActionResult< CNEOBot > ConsiderGhostVisualCheck( CNEOBot *me );
virtual ActionResult< CNEOBot > ConsiderGhostCaptureTransition( CNEOBot *me );

Vector GetNearestEnemyCapPoint( CNEOBot *me ) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolfAmbush::OnStart( CNEOBot *me, Action<
//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotCtgLoneWolfAmbush::Update( CNEOBot *me, float interval )
{
ActionResult< CNEOBot > result = ConsiderGhostCaptureTransition( me );
if ( result.IsRequestingChange() )
{
return result;
}

CWeaponGhost *pGhost = NEORules()->m_pGhost;
if ( !pGhost )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ ActionResult< CNEOBot > CNEOBotCtgLoneWolfSeek::OnStart( CNEOBot *me, Action< CN
//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotCtgLoneWolfSeek::Update( CNEOBot *me, float interval )
{
ActionResult< CNEOBot > result = ConsiderGhostCaptureTransition( me );
if ( result.IsRequestingChange() )
{
return result;
}

me->PressCrouchButton( 0.2f ); // Keep a lower profile

if ( !NEORules()->GhostExists() || !NEORules()->m_pGhost )
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/neo/bot/behavior/neo_bot_ctg_seek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ActionResult< CNEOBot > CNEOBotCtgSeek::Update( CNEOBot *me, float interval )
}
else
{
return Done("Capture target was not a ghost");
return SuspendFor(new CNEOBotCtgLoneWolf, "Capture target is blocked by some other entity, searching around the nearest areas");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case can be reached if the ghost is behind a bike, as the line of sight check hits the bike before the ghost.

}
}
}
Expand Down