Skip to content

Commit

Permalink
Merge pull request entropy-zero#273 from Blixibon/mapbase/feature/zom…
Browse files Browse the repository at this point in the history
…bie-no-flinch-during-unique-anim

Cvar to disable zombie flinching during actbusies or scripted sequences
  • Loading branch information
Blixibon authored Feb 4, 2024
2 parents 4e3f58f + a3fe8b5 commit 782053e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions sp/src/game/server/hl2/npc_BaseZombie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1931,6 +1935,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 )
Expand Down
2 changes: 2 additions & 0 deletions sp/src/game/server/hl2/npc_BaseZombie.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ abstract_class CNPC_BaseZombie : public CAI_BaseZombieBase
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 );
Expand Down

0 comments on commit 782053e

Please sign in to comment.