NSWeapon: add "speed_mod" key for manipulating the player speed.

This commit is contained in:
Marco Cawthorne 2024-07-24 14:25:41 -07:00
parent 5bb9fbf3af
commit 24a9ef71ac
Signed by: eukara
GPG key ID: CE2032F0A2882A22
3 changed files with 15 additions and 1 deletions

View file

@ -197,6 +197,7 @@ private:
string m_strLastFireInfo;
float m_jointTrailWorld;
float m_jointTrailView;
float m_flSpeedMod;
/* cached fireInfo */
string m_fiDetonateOnFire;

View file

@ -40,6 +40,7 @@ NSWeapon::NSWeapon(void)
m_flFireRate = 1.0f;
m_dState = 0;
m_strLastFireInfo = __NULL__;
m_flSpeedMod = 1.0f;
}
void
@ -547,6 +548,13 @@ NSWeapon::_CacheWeaponDefVariables(void)
string muzzleModel;
string ammoRequired;
/* movement vars */
m_flSpeedMod = GetDefFloat("speed_mod");
if (m_flSpeedMod <= 0.0) {
m_flSpeedMod = 1.0f;
}
/* string lookups can be expensive if done too often
so we'll need to cache them whenever something
big in the game state changes. like a save/load. */

View file

@ -418,6 +418,11 @@ NSClientPlayer::Physics_MaxSpeed(void)
float crouchSpeed = g_pmoveVars.pm_crouchspeed;
float walkSpeed = g_pmoveVars.pm_walkspeed;
float proneSpeed = g_pmoveVars.pm_pronespeed;
float speedMod = 1.0f;
if (m_activeWeapon) {
speedMod = m_activeWeapon.m_flSpeedMod;
}
if (CanSprint() && IsSprinting()) {
if (m_flStamina < maxStamina) {
@ -439,7 +444,7 @@ NSClientPlayer::Physics_MaxSpeed(void)
wishSpeed = walkSpeed;
}
return wishSpeed;
return wishSpeed * speedMod;
}
void