NSWeapon: add "speed_mod" key for manipulating the player speed.
This commit is contained in:
parent
5bb9fbf3af
commit
24a9ef71ac
3 changed files with 15 additions and 1 deletions
|
@ -197,6 +197,7 @@ private:
|
|||
string m_strLastFireInfo;
|
||||
float m_jointTrailWorld;
|
||||
float m_jointTrailView;
|
||||
float m_flSpeedMod;
|
||||
|
||||
/* cached fireInfo */
|
||||
string m_fiDetonateOnFire;
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue