Skip to content

Commit

Permalink
Fix soldiers looking at enemies when they don't see them
Browse files Browse the repository at this point in the history
  • Loading branch information
Blixibon committed Jan 26, 2025
1 parent 1776328 commit 3f4ba3c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sp/src/game/server/hl2/npc_combine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5891,10 +5891,10 @@ void CNPC_Combine::OnEndMoveAndShoot()
//-----------------------------------------------------------------------------
bool CNPC_Combine::PickTacticalLookTarget( AILookTargetArgs_t *pArgs )
{
if( GetState() == NPC_STATE_COMBAT )
if ( HasCondition( COND_SEE_ENEMY ) )
{
CBaseEntity *pEnemy = GetEnemy();
if ( pEnemy && FVisible( pEnemy ) && ValidHeadTarget(pEnemy->EyePosition()) )
if ( pEnemy && ValidHeadTarget( pEnemy->EyePosition() ) )
{
// Look at the enemy if possible.
pArgs->hTarget = pEnemy;
Expand All @@ -5903,8 +5903,12 @@ bool CNPC_Combine::PickTacticalLookTarget( AILookTargetArgs_t *pArgs )
}
else
{
// Look at yourself instead. We can't be looking in random directions.
pArgs->hTarget = this;
// Look ahead instead. We can't be looking in random directions.
Vector vecForward;
GetVectors( &vecForward, NULL, NULL );

pArgs->vTarget = EyePosition() + (vecForward * 16.0f);
pArgs->hTarget = NULL;
pArgs->flInfluence = random->RandomFloat( 0.8, 1.0 );
pArgs->flRamp = 0;
}
Expand Down

0 comments on commit 3f4ba3c

Please sign in to comment.