Skip to content
Closed
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
13 changes: 11 additions & 2 deletions src/game/server/neo/bot/behavior/neo_bot_path_clear_breakable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ extern ConVar neo_bot_fire_weapon_allowed;
ConVar neo_bot_fire_at_breakable_weapon_min_time( "neo_bot_fire_at_breakable_weapon_min_time", "0.2", FCVAR_CHEAT,
"Minimum time to fire at breakables", true, 0.0f, true, 60.0f );

//--------------------------------------------------------------------------------------------------------
// A prop never counts as alive (CBaseProp::IsAlive),
// so the action ends on its first update for a breakable prop
static bool IsBreakableIntact( CBaseEntity *breakable )
{
return breakable && breakable->IsAlive() && breakable->GetHealth() > 0;
}

//--------------------------------------------------------------------------------------------------------
CBaseEntity *CNEOBotPathClearBreakable::GetBreakableInPath( CNEOBot *me )
{
Expand Down Expand Up @@ -60,7 +68,8 @@ CBaseEntity *CNEOBotPathClearBreakable::GetBreakableInPath( CNEOBot *me )

if ( tr.DidHit() && tr.m_pEnt )
{
if ( me->IsAbleToBreak( tr.m_pEnt ) )
// Only start on a breakable the action would not end on at once
if ( me->IsAbleToBreak( tr.m_pEnt ) && IsBreakableIntact( tr.m_pEnt ) )
{
return tr.m_pEnt;
}
Expand Down Expand Up @@ -123,7 +132,7 @@ ActionResult< CNEOBot > CNEOBotPathClearBreakable::Update( CNEOBot *me, float in
CBaseEntity *breakable = m_hBreakable.Get();

// If the breakable is destroyed or invalid, we're done
if ( !breakable || !breakable->IsAlive() || breakable->GetHealth() <= 0 )
if ( !IsBreakableIntact( breakable ) )
{
return Done( "Path is clear" );
}
Expand Down
Loading