server: fix monster yaw speed (#137)

This makes the yaw speed for all monsters (scientists, headcrabs, etc.) framerate independent.

Fix by Solokiller with mikela-valve's adjustments:
https://github.com/ValveSoftware/halflife/issues/2458
This commit is contained in:
Logan 2020-10-10 13:06:04 -04:00 committed by GitHub
parent dbd9b1c698
commit 4be53d8527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -328,5 +328,9 @@ public:
BOOL CineCleanup();
CBaseEntity* DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item.
#ifdef MONSTER_YAWSPEED_FIX
float m_flLastYawTime;
#endif
};
#endif // BASEMONSTER_H

View File

@ -2022,6 +2022,10 @@ void CBaseMonster::MonsterInit( void )
SetThink( &CBaseMonster::MonsterInitThink );
pev->nextthink = gpGlobals->time + 0.1f;
SetUse( &CBaseMonster::MonsterUse );
#ifdef MONSTER_YAWSPEED_FIX
m_flLastYawTime = gpGlobals->time;
#endif
}
//=========================================================
@ -2504,7 +2508,15 @@ float CBaseMonster::ChangeYaw( int yawSpeed )
ideal = pev->ideal_yaw;
if( current != ideal )
{
#ifdef MONSTER_YAWSPEED_FIX
float delta = gpGlobals->time - m_flLastYawTime;
if( delta > 0.25 )
delta = 0.25;
speed = (float)yawSpeed * delta * 2;
#else
speed = (float)yawSpeed * gpGlobals->frametime * 10;
#endif
move = ideal - current;
if( ideal > current )
@ -2548,6 +2560,10 @@ float CBaseMonster::ChangeYaw( int yawSpeed )
else
move = 0;
#ifdef MONSTER_YAWSPEED_FIX
m_flLastYawTime = gpGlobals->time;
#endif
return move;
}

View File

@ -275,6 +275,7 @@ def configure(conf):
conf.define('CROWBAR_DELAY_FIX', False)
conf.define('CROWBAR_FIX_RAPID_CROWBAR', False)
conf.define('GAUSS_OVERCHARGE_FIX', False)
conf.define('MONSTER_YAWSPEED_FIX', False)
if conf.env.DEST_OS == 'android' or conf.options.ENABLE_MOD_HACKS:
conf.define('MOBILE_HACKS', '1')