Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
https://github.com/ValveSoftware/halflife/issues/2458
Browse files Browse the repository at this point in the history
Fix NPCs change yaw more slowly when game is running at higher FPS by SamVanheer
  • Loading branch information
hammermaps committed Jun 10, 2019
1 parent ebf10ba commit 0ed056d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dlls/basemonster.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class CBaseMonster : public CBaseToggle

Vector m_HackedGunPos; // HACK until we can query end of gun

float m_flLastYawTime; // Fix for higher FPS NPC yaw speed

// Scripted sequence Info
SCRIPTSTATE m_scriptState; // internal cinematic state
CCineMonster *m_pCine;
Expand Down
13 changes: 12 additions & 1 deletion dlls/monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ TYPEDESCRIPTION CBaseMonster::m_SaveData[] =
DEFINE_FIELD(CBaseMonster, m_flDistLook, FIELD_FLOAT),
DEFINE_FIELD(CBaseMonster, m_iTriggerCondition, FIELD_INTEGER),
DEFINE_FIELD(CBaseMonster, m_iszTriggerTarget, FIELD_STRING),
DEFINE_FIELD(CBaseMonster, m_flLastYawTime, FIELD_FLOAT),

DEFINE_FIELD(CBaseMonster, m_HackedGunPos, FIELD_VECTOR),

Expand Down Expand Up @@ -2557,7 +2558,15 @@ float CBaseMonster::ChangeYaw(int yawSpeed)
ideal = pev->ideal_yaw;
if (current != ideal)
{
speed = (float)yawSpeed * gpGlobals->frametime * 10;
//speed = (float)yawSpeed * gpGlobals->frametime * 10;
float delta = gpGlobals->time - m_flLastYawTime;

//Clamp delta like the engine does with frametime
if (delta > 0.25)
delta = 0.25;

speed = (float)yawSpeed * delta * 10;

move = ideal - current;

if (ideal > current)
Expand Down Expand Up @@ -2597,6 +2606,8 @@ float CBaseMonster::ChangeYaw(int yawSpeed)
else
move = 0;

m_flLastYawTime = gpGlobals->time;

return move;
}

Expand Down

0 comments on commit 0ed056d

Please sign in to comment.