Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/game/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,7 @@ set(UNITY_SOURCE_NEO_BOT
neo/bot/behavior/neo_bot_pause.cpp
neo/bot/behavior/neo_bot_retreat_to_cover.cpp
neo/bot/behavior/neo_bot_retreat_from_grenade.cpp
neo/bot/behavior/neo_bot_retreat_from_hazard_area.cpp
neo/bot/behavior/neo_bot_scenario_monitor.cpp
neo/bot/behavior/neo_bot_seek_and_destroy.cpp
neo/bot/behavior/neo_bot_seek_weapon.cpp
Expand Down
17 changes: 17 additions & 0 deletions src/game/server/NextBot/NextBotVisionInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "neo_player.h"
#include "neo_smokelineofsightblocker.h"
#include "bot/neo_bot.h"
#include "bot/neo_bot_path_reservation.h"
#include "nav_mesh.h"
#endif

#include "tier0/vprof.h"
Expand Down Expand Up @@ -794,6 +796,21 @@ bool IVision::IsLineOfSightClearToEntity( const CBaseEntity *subject, Vector *vi
UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), firstPosition, MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );
if ( result.DidHit() )
{
// Check if first center traceline hit any blocking smoke
if (neo_bot_path_reservation_enable.GetBool()
&& result.m_pEnt
&& FStrEq(result.m_pEnt->GetClassname(), SMOKELINEOFSIGHTBLOCKER_ENTITYNAME))
{
auto pSmoke = static_cast<CNEOSmokeLineOfSightBlocker*>(result.m_pEnt);
CNavArea *area = TheNavMesh->GetNearestNavArea(pSmoke->GetAbsOrigin());
if (area && neoBot)
{
// Register smoke sightlines for team to avoid as hazardous
int team = neoBot->GetTeamNumber();
CNEOBotPathReservations()->AddSmokeHazard(area->GetID(), pSmoke->GetNextThink(), team);
}
}

UTIL_TraceLine( GetBot()->GetBodyInterface()->GetEyePosition(), secondPosition, MASK_BLOCKLOS_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE, &filter, &result );

if ( result.DidHit() )
Expand Down
21 changes: 13 additions & 8 deletions src/game/server/neo/bot/behavior/neo_bot_attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CSearchForAttackCover : public ISearchSurroundingAreasFunctor
m_threatArea = threat->GetLastKnownArea();
m_goalArea = goalArea ? goalArea : m_threatArea; // prioritize movement towards input goal area or threat
m_myDistToGoalSq = m_goalArea ? ( m_goalArea->GetCenter() - m_me->GetAbsOrigin() ).LengthSqr() : 0;
m_onStuckPenalty = neo_bot_path_reservation_onstuck_penalty.GetFloat();
}

virtual bool operator() ( CNavArea *baseArea, CNavArea *priorArea, float travelDistanceSoFar )
Expand All @@ -79,10 +80,18 @@ class CSearchForAttackCover : public ISearchSurroundingAreasFunctor
return true; // skip our starting area
}

if ( neo_bot_path_reservation_enable.GetBool() &&
( CNEOBotPathReservations()->GetAreaAvoidPenalty(area->GetID()) > 0 ) )
// Skip areas that are hazardous or where bots get stuck
if ( neo_bot_path_reservation_enable.GetBool() )
{
return true; // skip areas that have had navigation hiccups
int navAreaId = area->GetID();
if (CNEOBotPathReservations()->IsAreaHazardous(navAreaId, m_me))
{
return true;
}
if (CNEOBotPathReservations()->GetAreaAvoidPenalty(navAreaId) >= m_onStuckPenalty)

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.

I forgot I added avoidance penalties for areas where a bot died, so I made the threshold under which a bot got stuck in a location, allowing to minor penalty for death areas to be used as candidates if under the OnStuck threshold.

{
return true;
}
}

if ( m_attackCoverArea )
Expand Down Expand Up @@ -199,6 +208,7 @@ class CSearchForAttackCover : public ISearchSurroundingAreasFunctor
const CNavArea *m_myArea; // reference point of myself
const CNavArea *m_threatArea; // reference point of the threat
float m_myDistToGoalSq; // the bot's current distance to the threat
float m_onStuckPenalty; // cache onstuck penalty
};


Expand Down Expand Up @@ -452,11 +462,6 @@ QueryResultType CNEOBotAttack::ShouldRetreat( const INextBot *me ) const
return ANSWER_UNDEFINED;
}

if ( m_goalArea && m_attackCoverArea )
{
return ANSWER_NO;

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.

While preventing the bots from retreating when they are rushing for a cover area was okay for proving out #2000, it made the bots a bit suicidal when their chosen advancing cover was too exposed, so I think it's better to retreat when there's any incoming fire.

This also encourages more grenade throw attempts which is helpful for viewing the smoke and grenade avoidance behavior.

}

return ANSWER_UNDEFINED;
}

Expand Down
20 changes: 10 additions & 10 deletions src/game/server/neo/bot/behavior/neo_bot_behavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "bot/behavior/neo_bot_tactical_monitor.h"
#include "weapons/weapon_balc.h"

extern ConVar sv_neo_grenade_fuse_timer;

ConVar neo_bot_path_lookahead_range( "neo_bot_path_lookahead_range", "300" );
ConVar neo_bot_sniper_aim_error( "neo_bot_sniper_aim_error", "0.01", FCVAR_CHEAT );
ConVar neo_bot_sniper_aim_steady_rate( "neo_bot_sniper_aim_steady_rate", "10", FCVAR_CHEAT );
Expand Down Expand Up @@ -195,16 +197,14 @@ EventDesiredResult<CNEOBot> CNEOBotMainAction::OnKilled( CNEOBot *me, const CTak
// Intended to add some variance to pathing for similar starting scenarios
if ( const CNavArea *navArea = me->GetLastKnownArea() )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty( navArea->GetID(), neo_bot_path_reservation_killed_penalty.GetFloat() );
}
else
{
// Fallback if GetLastKnownArea is null, try finding nearest nav area
CNavArea *nearestArea = TheNavMesh->GetNearestNavArea( me->GetAbsOrigin() );

@sunzenshen sunzenshen Jul 14, 2026

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.

I decided that if for some reason the situation was bugged enough that we don't know the GetLastKnownArea of a bot, we shouldn't bother trying to search for GetNearestNavArea. GetNearestNavArea is a bit more expensive and, if the situation is glitched, might not even return an appropriate navarea.

if ( nearestArea )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty( nearestArea->GetID(), neo_bot_path_reservation_killed_penalty.GetFloat() );
}
int areaId = navArea->GetID();
int teamId = me->GetTeamNumber();
CNEOBotPathReservations()->IncrementAreaAvoidPenalty( areaId, neo_bot_path_reservation_killed_penalty.GetFloat() );

// Discourage friendlies from stepping out into recent danger zone
// Use grenade fuse timer so that we don't need to compare expiration times with previous entries
// where the frag grenade timer is the usual time input into AddFragHazard
CNEOBotPathReservations()->AddDeadlyHazard(areaId, gpGlobals->curtime + sv_neo_grenade_fuse_timer.GetFloat(), teamId);
}

return TryChangeTo( new CNEOBotDead, RESULT_CRITICAL, "I died!" );
Expand Down
5 changes: 5 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_carrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ EventDesiredResult< CNEOBot > CNEOBotCtgCarrier::OnStuck( CNEOBot *me )
m_teammates.RemoveAll();
CollectPlayers( me, &m_teammates );
UpdateFollowPath( me, m_teammates );
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Expand All @@ -679,5 +680,9 @@ EventDesiredResult< CNEOBot > CNEOBotCtgCarrier::OnMoveToSuccess( CNEOBot *me, c
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotCtgCarrier::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
m_teammates.RemoveAll();
CollectPlayers( me, &m_teammates );
UpdateFollowPath( me, m_teammates );
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ ActionResult< CNEOBot > CNEOBotCtgEnemy::OnResume( CNEOBot *me, Action< CNEOBot
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotCtgEnemy::OnStuck( CNEOBot *me )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Expand All @@ -74,5 +75,6 @@ EventDesiredResult< CNEOBot > CNEOBotCtgEnemy::OnMoveToSuccess( CNEOBot *me, con
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotCtgEnemy::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_ctg_escort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ EventDesiredResult< CNEOBot > CNEOBotCtgEscort::OnStuck( CNEOBot *me )
m_chasePath.Invalidate();
m_path.Invalidate();
m_repathTimer.Invalidate();
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Expand All @@ -232,6 +233,7 @@ EventDesiredResult< CNEOBot > CNEOBotCtgEscort::OnMoveToSuccess( CNEOBot *me, co
EventDesiredResult< CNEOBot > CNEOBotCtgEscort::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
m_repathTimer.Invalidate();
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Expand Down
8 changes: 8 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 @@ -160,9 +160,17 @@ EventDesiredResult< CNEOBot > CNEOBotCtgLoneWolf::OnStuck( CNEOBot *me )
{
m_path.Invalidate();
me->GetLocomotionInterface()->Jump();
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotCtgLoneWolf::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
m_path.Invalidate();
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

//---------------------------------------------------------------------------------------------
Vector CNEOBotCtgLoneWolf::GetNearestEnemyCapPoint( CNEOBot *me ) const
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 @@ -14,6 +14,7 @@ class CNEOBotCtgLoneWolf : public Action< CNEOBot >
virtual ActionResult< CNEOBot > OnResume( CNEOBot *me, Action< CNEOBot > *interruptingAction ) override;

virtual EventDesiredResult< CNEOBot > OnStuck( CNEOBot *me ) override;
virtual EventDesiredResult< CNEOBot > OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason ) override;

virtual const char *GetName( void ) const override { return "ctgLoneWolf"; }

Expand Down
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_get_ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ EventDesiredResult< CNEOBot > CNEOBotGetAmmo::OnContact( CNEOBot *me, CBaseEntit
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotGetAmmo::OnStuck( CNEOBot *me )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryDone( RESULT_CRITICAL, "Stuck trying to reach ammo" );
}

Expand All @@ -214,6 +215,7 @@ EventDesiredResult< CNEOBot > CNEOBotGetAmmo::OnMoveToSuccess( CNEOBot *me, cons
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotGetAmmo::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryDone( RESULT_CRITICAL, "Failed to reach ammo" );
}

Expand Down
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_get_health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ ActionResult< CNEOBot > CNEOBotGetHealth::Update( CNEOBot *me, float interval )
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotGetHealth::OnStuck( CNEOBot *me )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryDone( RESULT_CRITICAL, "Stuck trying to reach health kit" );
}

Expand All @@ -244,6 +245,7 @@ EventDesiredResult< CNEOBot > CNEOBotGetHealth::OnMoveToSuccess( CNEOBot *me, co
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotGetHealth::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryDone( RESULT_CRITICAL, "Failed to reach health kit" );
}

Expand Down
11 changes: 11 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_grenade_throw_frag.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "cbase.h"
#include "bot/neo_bot.h"
#include "bot/neo_bot_path_compute.h"
#include "bot/neo_bot_path_reservation.h"
#include "bot/behavior/neo_bot_grenade_throw_frag.h"
#include "neo_gamerules.h"
#include "neo_player.h"
#include "weapon_neobasecombatweapon.h"

#include "nav_mesh.h"
#include "nav_pathfind.h"

extern ConVar sv_neo_grenade_blast_radius;
Expand Down Expand Up @@ -106,6 +108,15 @@ CNEOBotGrenadeThrow::ThrowTargetResult CNEOBotGrenadeThrowFrag::UpdateGrenadeTar
return THROW_TARGET_CANCEL; // risk of friendly fire
}

// Register explosive hazard at the target position
// so the throwing bot's team can avoid the trajectory and landing areas
CNavArea *area = TheNavMesh->GetNearestNavArea(m_vecTarget);
if (area)
{
int team = me->GetTeamNumber();
CNEOBotPathReservations()->AddFragHazard(area->GetID(), gpGlobals->curtime + sv_neo_grenade_fuse_timer.GetFloat(), team);
}

return THROW_TARGET_READY;
}

Expand Down
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_jgr_enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ ActionResult< CNEOBot > CNEOBotJgrEnemy::OnResume( CNEOBot *me, Action< CNEOBot
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotJgrEnemy::OnStuck( CNEOBot *me )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotJgrEnemy::OnMoveToSuccess( CNEOBot *me, const Path *path )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Expand Down
2 changes: 2 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_jgr_escort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ ActionResult< CNEOBot > CNEOBotJgrEscort::OnResume( CNEOBot *me, Action< CNEOBot
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotJgrEscort::OnStuck( CNEOBot *me )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Expand All @@ -96,5 +97,6 @@ EventDesiredResult< CNEOBot > CNEOBotJgrEscort::OnMoveToSuccess( CNEOBot *me, co
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotJgrEscort::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ EventDesiredResult< CNEOBot > CNEOBotJgrJuggernaut::OnStuck( CNEOBot *me )
me->PressRightButton();
}

CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ EventDesiredResult< CNEOBot > CNEOBotMoveToVantagePoint::OnMoveToSuccess( CNEOBo
EventDesiredResult< CNEOBot > CNEOBotMoveToVantagePoint::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
m_path.Invalidate();
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Expand Down
37 changes: 37 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_retreat_from_grenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "bot/behavior/neo_bot_retreat_from_grenade.h"
#include "bot/behavior/neo_bot_retreat_to_cover.h"
#include "bot/neo_bot_path_compute.h"
#include "bot/neo_bot_path_reservation.h"
#include "nav_mesh.h"
#include "sdk/sdk_basegrenade_projectile.h"

// memdbgon must be the last include file in a .cpp file!!!
Expand Down Expand Up @@ -72,6 +74,7 @@ class CSearchForCoverFromGrenade : public ISearchSurroundingAreasFunctor
{
m_me = me;
m_grenade = grenade;
m_onStuckPenalty = neo_bot_path_reservation_onstuck_penalty.GetFloat();
m_pGrenadeStats = dynamic_cast<CBaseGrenadeProjectile *>( grenade );
m_safeRadiusSqr = m_pGrenadeStats ? Square(m_pGrenadeStats->m_DmgRadius * sv_neo_bot_grenade_frag_safety_range_multiplier.GetFloat()) : 0.0f;

Expand All @@ -91,6 +94,20 @@ class CSearchForCoverFromGrenade : public ISearchSurroundingAreasFunctor
return false; // can't search if there's no threat source
}

// Skip areas that are hazardous or where bots get stuck
if ( neo_bot_path_reservation_enable.GetBool() )
{
int navAreaId = area->GetID();
if (CNEOBotPathReservations()->IsAreaHazardous(navAreaId, m_me))
{
return true;
}
if (CNEOBotPathReservations()->GetAreaAvoidPenalty(navAreaId) >= m_onStuckPenalty)
{
return true;
}
}

if ( m_pGrenadeStats )
{
if ( ( area->GetCenter() - m_pGrenadeStats->GetAbsOrigin() ).LengthSqr() < m_safeRadiusSqr * 2 )
Expand Down Expand Up @@ -138,6 +155,7 @@ class CSearchForCoverFromGrenade : public ISearchSurroundingAreasFunctor
CNEOBot *m_me;
CBaseEntity *m_grenade;
CBaseGrenadeProjectile *m_pGrenadeStats;
float m_onStuckPenalty;
float m_safeRadiusSqr;
CUtlVector< CNavArea * > m_coverAreaVector;
};
Expand Down Expand Up @@ -181,6 +199,19 @@ ActionResult< CNEOBot > CNEOBotRetreatFromGrenade::OnStart( CNEOBot *me, Action<
m_grenade = FindDangerousGrenade( me );
}

if ( !m_grenade ) // not a duplicate, check FindDangerousGrenade result
{
return Done("No grenade found");
}

// Register explosive hazard for the bot's team at the grenade's initial position
CNavArea *grenadeArea = TheNavMesh->GetNearestNavArea( m_grenade->GetAbsOrigin() );
if (grenadeArea)
{
int team = me->GetTeamNumber();
CNEOBotPathReservations()->AddFragHazard(grenadeArea->GetID(), gpGlobals->curtime + sv_neo_grenade_fuse_timer.GetFloat(), team);
}

// Sometimes grenades can be in a bad limbo state, so force exit eventually
m_expiryTimer.Start( sv_neo_grenade_fuse_timer.GetFloat() );

Expand Down Expand Up @@ -247,6 +278,9 @@ ActionResult< CNEOBot > CNEOBotRetreatFromGrenade::Update( CNEOBot *me, float in
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotRetreatFromGrenade::OnStuck( CNEOBot *me )
{
m_coverArea = FindCoverArea( me );
CNEOBotPathCompute(me, m_path, m_coverArea->GetCenter(), FASTEST_ROUTE);
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());

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.

If a bot gets stuck, sometimes the chosen cover area is the culprit, so look for another random cover area to reset.

return TryContinue();
}

Expand All @@ -261,6 +295,9 @@ EventDesiredResult< CNEOBot > CNEOBotRetreatFromGrenade::OnMoveToSuccess( CNEOBo
//---------------------------------------------------------------------------------------------
EventDesiredResult< CNEOBot > CNEOBotRetreatFromGrenade::OnMoveToFailure( CNEOBot *me, const Path *path, MoveToFailureType reason )
{
m_coverArea = FindCoverArea( me );
CNEOBotPathCompute(me, m_path, m_coverArea->GetCenter(), FASTEST_ROUTE);
CNEOBotPathReservations()->IncrementAreaAvoidPenalty(me->GetLastKnownArea()->GetID(), neo_bot_path_reservation_onstuck_penalty.GetFloat());
return TryContinue();
}

Expand Down
Loading