Add cvar to prevent zombies from flinching during actbusies and scripted sequences

This commit is contained in:
ALLEN-PC\acj30 2024-01-05 14:55:01 -06:00
parent e34e0d3b10
commit a3fe8b5284
2 changed files with 31 additions and 0 deletions

View File

@ -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 )

View File

@ -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 );