diff --git a/sp/src/game/server/hl2/npc_BaseZombie.cpp b/sp/src/game/server/hl2/npc_BaseZombie.cpp index fee51dd7..37ddb534 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.cpp +++ b/sp/src/game/server/hl2/npc_BaseZombie.cpp @@ -159,6 +159,10 @@ ConVar zombie_decaymax( "zombie_decaymax", "0.4" ); ConVar zombie_ambushdist( "zombie_ambushdist", "16000" ); +#ifdef MAPBASE +ConVar zombie_no_flinch_during_unique_anim( "zombie_no_flinch_during_unique_anim", "1", FCVAR_NONE, "Prevents zombies from flinching during actbusies and scripted sequences." ); +#endif + //========================================================= // For a couple of reasons, we keep a running count of how // many zombies in the world are angry at any given time. @@ -1927,6 +1931,31 @@ void CNPC_BaseZombie::OnScheduleChange( void ) } +//--------------------------------------------------------- +//--------------------------------------------------------- + +bool CNPC_BaseZombie::CanFlinch( void ) +{ + if (!BaseClass::CanFlinch()) + return false; + +#ifdef MAPBASE + if (zombie_no_flinch_during_unique_anim.GetBool()) + { + // Don't flinch if currently playing actbusy animation (navigating to or from one is fine) + if (m_ActBusyBehavior.IsInsideActBusy()) + return false; + + // Don't flinch if currently playing scripted sequence (navigating to or from one is fine) + if (m_NPCState == NPC_STATE_SCRIPT && (IsCurSchedule( SCHED_SCRIPTED_WAIT, false ) || IsCurSchedule( SCHED_SCRIPTED_FACE, false ))) + return false; + } +#endif + + return true; +} + + //--------------------------------------------------------- //--------------------------------------------------------- int CNPC_BaseZombie::SelectFailSchedule( int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode ) diff --git a/sp/src/game/server/hl2/npc_BaseZombie.h b/sp/src/game/server/hl2/npc_BaseZombie.h index 743186de..90add2d2 100644 --- a/sp/src/game/server/hl2/npc_BaseZombie.h +++ b/sp/src/game/server/hl2/npc_BaseZombie.h @@ -151,6 +151,8 @@ public: int OnTakeDamage_Alive( const CTakeDamageInfo &info ); virtual float GetReactionDelay( CBaseEntity *pEnemy ) { return 0.0; } + bool CanFlinch( void ); + virtual int SelectSchedule ( void ); virtual int SelectFailSchedule( int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode ); virtual void BuildScheduleTestBits( void );