From 3f4ba3ccbde960baed968accc05f283e745c1863 Mon Sep 17 00:00:00 2001 From: "ALLEN-PC\\acj30" Date: Sun, 26 Jan 2025 13:31:43 -0600 Subject: [PATCH] Fix soldiers looking at enemies when they don't see them --- sp/src/game/server/hl2/npc_combine.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sp/src/game/server/hl2/npc_combine.cpp b/sp/src/game/server/hl2/npc_combine.cpp index 7c36d0f0e1..2216ec1fec 100644 --- a/sp/src/game/server/hl2/npc_combine.cpp +++ b/sp/src/game/server/hl2/npc_combine.cpp @@ -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; @@ -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; }