diff --git a/src/g_game.cpp.bak b/src/g_game.cpp index 7f6305c..bd97987 100644 --- a/src/g_game.cpp.bak +++ b/src/g_game.cpp @@ -199,8 +199,6 @@ fixed_t angleturn[4] = {640, 1280, 320, 320}; // + slow turn fixed_t flyspeed[2] = {1*256, 3*256}; int lookspeed[2] = {450, 512}; -#define SLOWTURNTICS 6 - CVAR (Bool, cl_run, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Always run? CVAR (Bool, invertmouse, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Invert mouse look down/up? CVAR (Bool, freelook, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // Always mlook? @@ -289,6 +287,14 @@ CCMD (turnspeeds) } } +CUSTOM_CVAR (Int, slowturntics, 6, 0) +{ + if (self < 0) + self = 0; + if (self > 350) + self = 350; +} + CCMD (slot) { if (argv.argc() > 1) @@ -568,18 +574,27 @@ void G_BuildTiccmd (ticcmd_t *cmd) else { int tspeed = speed; + int angle = angleturn[tspeed]; + + if (turnheld < slowturntics) + { + int fast = angleturn[tspeed]; + int slow = angleturn[tspeed + 2]; + int turnheld2 = turnheld * turnheld; + int slowturntics3 = slowturntics * slowturntics * slowturntics; + // use smoothstep to interpolate between speeds + angle = 3 * turnheld2 * slowturntics - 2 * turnheld2 * turnheld; + angle = (angle * (fast - slow)) / slowturntics3 + slow; + } - if (turnheld < SLOWTURNTICS) - tspeed += 2; // slow turn - if (Button_Right.bDown) { - G_AddViewAngle (angleturn[tspeed]); + G_AddViewAngle (angle); LocalKeyboardTurner = true; } if (Button_Left.bDown) { - G_AddViewAngle (-angleturn[tspeed]); + G_AddViewAngle (-angle); LocalKeyboardTurner = true; } }