mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-21 03:01:36 +00:00
- processMovement()
. Remove cl_exhumedoldturn
CVAR and tidy up numeric literals in use.
* In our older codebase before the input code was refactored, Exhumed's turning was broken and was only applying the base factor of 12, significantly slower than the other games.
* Upon doing some testing in PCExhumed, I noticed their turning was faster as when the counter meets its target, the turn value is shifted left by 2, effectively making it 48: b90417ed8e/source/exhumed/src/player.cpp (L336-L337)
* Removed this CVAR because of this.
* Reworked turning code so that pressing left+right together cancel each other out and that pressing both doesn't call `updateTurnHeldAmt(scaleAdjust)` twice.
* Redid turn averages factoring in Exhumed's speeds, rounded off values and stored in an enum for clarity.
This commit is contained in:
parent
389f760d45
commit
c424f7c8dd
5 changed files with 48 additions and 45 deletions
|
@ -80,7 +80,6 @@ CVARD(Bool, cl_syncinput, false, CVAR_ARCHIVE, "enable/disable synchronized inpu
|
|||
CVARD(Bool, cl_swsmoothsway, true, CVAR_ARCHIVE, "move SW weapon left and right smoothly while bobbing")
|
||||
CVARD(Bool, cl_showmagamt, false, CVAR_ARCHIVE, "show the amount of rounds left in the magazine of your weapon on the modern HUD")
|
||||
CVARD(Bool, cl_nomeleeblur, false, CVAR_ARCHIVE, "enable/disable blur effect with melee weapons in SW")
|
||||
CVARD(Bool, cl_exhumedoldturn, false, CVAR_ARCHIVE, "enable/disable legacy turning speed for Powerslave/Exhumed")
|
||||
CVARD(Bool, cl_hudinterpolation, true, CVAR_ARCHIVE, "enable/disable HUD (weapon drawer) interpolation")
|
||||
CVARD(Bool, cl_bloodvanillarun, true, CVAR_ARCHIVE, "enable/disable Blood's vanilla run mode")
|
||||
CVARD(Bool, cl_bloodvanillabobbing, true, CVAR_ARCHIVE, "enable/disable Blood's vanilla bobbing while not using vanilla run mode")
|
||||
|
|
|
@ -25,7 +25,6 @@ EXTERN_CVAR(Bool, cl_syncinput)
|
|||
EXTERN_CVAR(Bool, cl_swsmoothsway)
|
||||
EXTERN_CVAR(Bool, cl_showmagamt)
|
||||
EXTERN_CVAR(Bool, cl_nomeleeblur)
|
||||
EXTERN_CVAR(Bool, cl_exhumedoldturn)
|
||||
EXTERN_CVAR(Bool, cl_hudinterpolation)
|
||||
EXTERN_CVAR(Bool, cl_bloodvanillarun)
|
||||
EXTERN_CVAR(Bool, cl_bloodvanillabobbing)
|
||||
|
|
|
@ -70,16 +70,31 @@ binangle getincanglebam(binangle a, binangle na)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
// Turbo turn time.
|
||||
Blood: 24 * 30 = 720;
|
||||
Duke: 120 / 8 * 30 = 450;
|
||||
SW: 120 / 8 * 40 = 600;
|
||||
Exhumed: N/A;
|
||||
Average: 590.;
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
BUILDTICRATE = 120,
|
||||
TURBOTURNBASE = 590,
|
||||
};
|
||||
|
||||
static double turnheldtime;
|
||||
|
||||
void updateTurnHeldAmt(double const scaleAdjust)
|
||||
{
|
||||
turnheldtime += scaleAdjust * (120. / GameTicRate);
|
||||
turnheldtime += scaleAdjust * (double(BUILDTICRATE) / GameTicRate);
|
||||
}
|
||||
|
||||
bool isTurboTurnTime()
|
||||
{
|
||||
return turnheldtime >= 590. / GameTicRate;
|
||||
return turnheldtime >= double(TURBOTURNBASE) / GameTicRate;
|
||||
}
|
||||
|
||||
void resetTurnHeldAmt()
|
||||
|
@ -98,36 +113,39 @@ void resetTurnHeldAmt()
|
|||
Blood: 92 / 4 * 2 * 30 = 1380;
|
||||
Duke: 15 * 2 * 2 * 30 = 1800;
|
||||
SW: 28 * 1.40625 * 40 = 1575; // Precisely, ((((28 * 12) + ((28 * 12) / 4)) * 3) / 32) * 40
|
||||
Average: 1585.;
|
||||
Exhumed: 12 * 4 * 30 = 1440;
|
||||
Average: 1548.75;
|
||||
|
||||
// Normal speed.
|
||||
Blood: 92 / 4 * 30 = 690;
|
||||
Duke: 15 * 2 * 30 = 900;
|
||||
SW: 18 * 1.40625 * 40 = 1012.5; // Precisely, (((((12 + 6) * 12) + (((12 + 6) * 12) / 4)) * 3) / 32) * 40
|
||||
Average: 867.5;
|
||||
Exhumed: 8 * 4 * 30 = 960;
|
||||
Average: 890.625;
|
||||
|
||||
// Preamble.
|
||||
Blood: N/A;
|
||||
Blood: N/A;
|
||||
Exhumed: N/A;
|
||||
Duke: 5 * 2 * 30 = 300;
|
||||
SW: 3 * 1.40625 * 40 = 168.75; // Precisely, ((((3 * 12) + ((3 * 12) / 4)) * 3) / 32) * 40
|
||||
Average: 234.375;
|
||||
Ratio: 867.5 / 234.375 = (2776. / 750.);
|
||||
|
||||
// Turbo turn time.
|
||||
Blood: 24 * 30 = 720;
|
||||
Duke: 128 / 8 * 30 = 450;
|
||||
SW: 128 / 8 * 40 = 600;
|
||||
Average: 590.;
|
||||
*/
|
||||
|
||||
void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt, bool const allowstrafe, double const turnscale)
|
||||
enum
|
||||
{
|
||||
RUNNINGTURNBASE = 1549,
|
||||
NORMALTURNBASE = 891,
|
||||
PREAMBLEBASE = 234,
|
||||
};
|
||||
|
||||
void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt, bool const allowstrafe, double const turnscale)
|
||||
{
|
||||
// set up variables
|
||||
int const running = !!(inputBuffer->actions & SB_RUN);
|
||||
int const keymove = gi->playerKeyMove() << running;
|
||||
int const cntrlvelscale = g_gameType & GAMEFLAG_PSEXHUMED ? 8 : 1;
|
||||
float const mousevelscale = keymove / 160.f;
|
||||
double const hidspeed = ((running ? 1585. : 867.5) / GameTicRate) * BAngToDegree;
|
||||
float const mousevelscale = keymove * (1.f / 160.f);
|
||||
double const cntrlvelscale = g_gameType & GAMEFLAG_PSEXHUMED ? 8. : 1.;
|
||||
double const hidspeed = (double(running ? RUNNINGTURNBASE : NORMALTURNBASE) / GameTicRate) * BAngToDegree;
|
||||
|
||||
// process mouse and initial controller input.
|
||||
if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe)
|
||||
|
@ -165,24 +183,21 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
|
|||
}
|
||||
else
|
||||
{
|
||||
double turnamount = hidspeed * turnscale;
|
||||
double preambleturn = turnamount * (750. / 2776.);
|
||||
bool const turnleft = buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !allowstrafe);
|
||||
bool const turnright = buttonMap.ButtonDown(gamefunc_Turn_Right) || (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !allowstrafe);
|
||||
|
||||
// allow Exhumed to use its legacy values given the drastic difference from the other games.
|
||||
if ((g_gameType & GAMEFLAG_PSEXHUMED) && cl_exhumedoldturn)
|
||||
if (turnleft || turnright)
|
||||
{
|
||||
preambleturn = turnamount = (running ? 12 : 8) * BAngToDegree;
|
||||
}
|
||||
double const turnamount = hidspeed * turnscale;
|
||||
double const preambleturn = turnamount * (double(PREAMBLEBASE) / double(NORMALTURNBASE));
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !allowstrafe))
|
||||
{
|
||||
updateTurnHeldAmt(scaleAdjust);
|
||||
currInput->avel -= float(scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn));
|
||||
}
|
||||
else if (buttonMap.ButtonDown(gamefunc_Turn_Right) || (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !allowstrafe))
|
||||
{
|
||||
updateTurnHeldAmt(scaleAdjust);
|
||||
currInput->avel += float(scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn));
|
||||
|
||||
if (turnleft)
|
||||
currInput->avel -= float(scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn));
|
||||
|
||||
if (turnright)
|
||||
currInput->avel += float(scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -206,19 +221,13 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
|
|||
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
||||
{
|
||||
currInput->fvel += keymove;
|
||||
if (drink_amt & 1)
|
||||
currInput->svel += keymove;
|
||||
else
|
||||
currInput->svel -= keymove;
|
||||
currInput->svel += drink_amt & 1 ? keymove : -keymove;
|
||||
}
|
||||
|
||||
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
||||
{
|
||||
currInput->fvel -= keymove;
|
||||
if (drink_amt & 1)
|
||||
currInput->svel -= keymove;
|
||||
else
|
||||
currInput->svel += keymove;
|
||||
currInput->svel -= drink_amt & 1 ? keymove : -keymove;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -256,4 +256,4 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerPosition& w,
|
|||
void updateTurnHeldAmt(double const scaleAdjust);
|
||||
bool isTurboTurnTime();
|
||||
void resetTurnHeldAmt();
|
||||
void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt = 0, bool const allowstrafe = true, double const turnscale = 1);
|
||||
void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt = 0, bool const allowstrafe = true, double const turnscale = 1);
|
||||
|
|
|
@ -992,10 +992,6 @@ OptionMenu GameplayOptions protected
|
|||
Option "$EXPLOS_BEHAVIOR", "cl_bloodvanillaexplosions", "ExplosBehavior"
|
||||
Option "$ENEMY_BEHAVIOR", "cl_bloodvanillaenemies", "EnemyBehavior"
|
||||
}
|
||||
ifgame(Exhumed)
|
||||
{
|
||||
Option "$PLRMNU_EXHUMEDOLDTURN", "cl_exhumedoldturn", "OnOff"
|
||||
}
|
||||
StaticText ""
|
||||
ifgame(Blood)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue