- uplift boatApplyTurn() with changes from e0bc2c6c97.

* Handle button-mashing to provide a better experience.
* Rename `bike_turn` to `boat_turn`.
* Move application of scale to returning value within `boatApplyTurn()`.
* Use doubled return values like Rednukem (20 -> 40, 10 -> 20, 6 -> 12, 3 -> 6, 2 -> 4, 1 -> 2).
* Return `p->TiltStatus` towards 0 if `p->MotoSpeed` == 0 and `p->NotOnWater`.
* Always test if `p->TiltStatus` < `0.025`.
This commit is contained in:
Mitchell Richters 2020-07-24 21:27:47 +10:00
parent e0bc2c6c97
commit 4bf5c3d6b5

View file

@ -1017,11 +1017,14 @@ static double motoApplyTurn(player_struct* p, int turnl, int turnr, int bike_tur
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static int boatApplyTurn(player_struct *p, int turnl, int turnr, int bike_turn, double factor) static double boatApplyTurn(player_struct *p, int turnl, int turnr, int boat_turn, double factor)
{ {
int turnvel = 0;
int tics = getticssincelastupdate(); int tics = getticssincelastupdate();
if (p->MotoSpeed) if (p->MotoSpeed)
{
if (turnl || turnr || p->moto_drink != 0)
{ {
if (turnl || p->moto_drink < 0) if (turnl || p->moto_drink < 0)
{ {
@ -1032,18 +1035,19 @@ static int boatApplyTurn(player_struct *p, int turnl, int turnr, int bike_turn,
if (p->TiltStatus < -10) if (p->TiltStatus < -10)
p->TiltStatus = -10; p->TiltStatus = -10;
} }
if (turnheldtime >= TURBOTURNTIME && p->MotoSpeed != 0) if (turnheldtime >= TURBOTURNTIME)
{ {
if (p->NotOnWater) return bike_turn ? -6 : -3; if (p->NotOnWater) turnvel += boat_turn ? -12 : -6;
else return bike_turn ? -20 : -10; else turnvel += boat_turn ? -40 : -20;
} }
else if (turnheldtime < TURBOTURNTIME && p->MotoSpeed != 0) else
{ {
if (p->NotOnWater) return bike_turn ? -2 : -1; if (p->NotOnWater) turnvel += boat_turn ? -4 : -2;
else return bike_turn ? -6 : -3; else turnvel += boat_turn ? -12 : -6;
} }
} }
else if (turnr || p->moto_drink > 0)
if (turnr || p->moto_drink > 0)
{ {
turnheldtime += tics; turnheldtime += tics;
if (!p->NotOnWater) if (!p->NotOnWater)
@ -1052,15 +1056,16 @@ static int boatApplyTurn(player_struct *p, int turnl, int turnr, int bike_turn,
if (p->TiltStatus > 10) if (p->TiltStatus > 10)
p->TiltStatus = 10; p->TiltStatus = 10;
} }
if (turnheldtime >= TURBOTURNTIME && p->MotoSpeed != 0) if (turnheldtime >= TURBOTURNTIME)
{ {
if (p->NotOnWater) return bike_turn ? 6 : 3; if (p->NotOnWater) turnvel += boat_turn ? 12 : 6;
else return bike_turn ? 20 : 10; else turnvel += boat_turn ? 40 : 20;
} }
else if (turnheldtime < TURBOTURNTIME && p->MotoSpeed != 0) else
{ {
if (p->NotOnWater) return bike_turn ? 2 : 1; if (p->NotOnWater) turnvel += boat_turn ? 4 : 2;
else return bike_turn ? 6 : 3; else turnvel += boat_turn ? 12 : 6;
}
} }
} }
else if (!p->NotOnWater) else if (!p->NotOnWater)
@ -1072,17 +1077,23 @@ static int boatApplyTurn(player_struct *p, int turnl, int turnr, int bike_turn,
p->TiltStatus -= (float)factor; p->TiltStatus -= (float)factor;
else if (p->TiltStatus < 0) else if (p->TiltStatus < 0)
p->TiltStatus += (float)factor; p->TiltStatus += (float)factor;
if (fabs(p->TiltStatus) < 0.025)
p->TiltStatus = 0;
} }
} }
else else if (!p->NotOnWater)
{ {
turnheldtime = 0; turnheldtime = 0;
lastcontroltime = 0; lastcontroltime = 0;
if (p->TiltStatus > 0)
p->TiltStatus -= (float)factor;
else if (p->TiltStatus < 0)
p->TiltStatus += (float)factor;
} }
return 0;
if (fabs(p->TiltStatus) < 0.025)
p->TiltStatus = 0;
return turnvel * factor;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1132,7 +1143,7 @@ static void processVehicleInput(player_struct *p, ControlInfo& info, input_t& in
} }
else else
{ {
turnvel = boatApplyTurn(p, turnl, turnr, turnspeed != 0, scaleAdjust) * scaleAdjust * 2; turnvel = boatApplyTurn(p, turnl, turnr, turnspeed != 0, scaleAdjust);
} }
// What is this? Optimization for playing with a mouse which the original did not have? // What is this? Optimization for playing with a mouse which the original did not have?