2020-10-11 14:33:43 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2019 Christoph Oelckers
|
|
|
|
Copyright (C) 2020 Mitchell Richters
|
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "gamecontrol.h"
|
|
|
|
#include "gameinput.h"
|
|
|
|
#include "gamestruct.h"
|
2020-10-11 14:55:12 +00:00
|
|
|
#include "serializer.h"
|
2022-08-04 21:47:29 +00:00
|
|
|
#include "gamefuncs.h"
|
2022-06-11 08:36:20 +00:00
|
|
|
|
2022-09-27 07:08:01 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Static constants used throughout functions.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
BUILDTICRATE = 120,
|
|
|
|
TURBOTURNBASE = 590,
|
|
|
|
};
|
|
|
|
|
2022-09-28 02:33:22 +00:00
|
|
|
static constexpr double YAW_TURNSPEEDS[3] = { 41.1987304, 156.555175, 272.24121 };
|
2022-09-27 07:08:01 +00:00
|
|
|
static constexpr double YAW_PREAMBLESCALE = YAW_TURNSPEEDS[0] / YAW_TURNSPEEDS[1];
|
2022-09-28 02:33:22 +00:00
|
|
|
static constexpr DAngle YAW_LOOKINGSPEED = DAngle::fromDeg(801.5625);
|
2022-10-13 00:50:16 +00:00
|
|
|
static constexpr DAngle YAW_ROTATESPEED = DAngle::fromDeg(63.28125);
|
2022-09-28 02:33:22 +00:00
|
|
|
static constexpr DAngle YAW_LOOKRETURN = DAngle::fromDeg(7.5);
|
|
|
|
static constexpr DAngle YAW_SPINSTAND = DAngle::fromDeg(675.);
|
|
|
|
static constexpr DAngle YAW_SPINCROUCH = YAW_SPINSTAND * 0.5;
|
|
|
|
static constexpr DAngle PITCH_LOOKSPEED = DAngle::fromDeg(222.83185);
|
|
|
|
static constexpr DAngle PITCH_AIMSPEED = PITCH_LOOKSPEED * 0.5;
|
2022-12-09 09:00:37 +00:00
|
|
|
static constexpr DAngle PITCH_CENTERSPEED = DAngle::fromDeg(10.7375);
|
2022-12-09 07:00:42 +00:00
|
|
|
static constexpr DAngle PITCH_CNTRSINEOFFSET = DAngle90 / 8.;
|
2022-12-07 04:21:52 +00:00
|
|
|
static constexpr DAngle PITCH_HORIZOFFSPEED = DAngle::fromDeg(4.375);
|
2022-12-07 02:11:59 +00:00
|
|
|
static constexpr DAngle PITCH_HORIZOFFCLIMB = DAngle::fromDeg(-38.);
|
2022-09-28 02:33:22 +00:00
|
|
|
static constexpr DAngle PITCH_HORIZOFFPUSH = DAngle::fromDeg(0.4476);
|
2022-09-27 07:08:01 +00:00
|
|
|
|
|
|
|
|
2022-07-22 04:56:38 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Input scale helper functions.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-09-28 02:33:22 +00:00
|
|
|
template<class T>
|
|
|
|
inline static T getTicrateScale(const T value)
|
2022-07-22 04:56:38 +00:00
|
|
|
{
|
2022-09-28 02:33:22 +00:00
|
|
|
return T(value / GameTicRate);
|
2022-07-22 04:56:38 +00:00
|
|
|
}
|
|
|
|
|
2022-09-12 08:15:35 +00:00
|
|
|
inline static double getCorrectedScale(const double scaleAdjust)
|
2022-07-22 04:56:38 +00:00
|
|
|
{
|
2022-09-12 08:15:35 +00:00
|
|
|
// When using the output of I_GetInputFrac() to scale input adjustments at framerate, deviations of over 100 ms can occur.
|
2022-09-25 09:57:37 +00:00
|
|
|
// Below formula corrects the deviation, with 0.2125 being an average between an ideal value of 0.20 for 40Hz and 0.22 for 30Hz.
|
2022-09-12 08:15:35 +00:00
|
|
|
// We use the average value here as the difference is under 5 ms and is not worth complicating the algorithm for such precision.
|
2022-09-25 09:57:37 +00:00
|
|
|
return scaleAdjust < 1. ? scaleAdjust * (1. + 0.21 * (1. - scaleAdjust)) : scaleAdjust;
|
2022-08-28 02:09:44 +00:00
|
|
|
}
|
|
|
|
|
2022-09-28 02:33:22 +00:00
|
|
|
inline static DAngle getscaledangle(const DAngle value, const double scaleAdjust, const DAngle object, const DAngle push)
|
2022-07-22 04:56:38 +00:00
|
|
|
{
|
2022-09-12 08:15:35 +00:00
|
|
|
return ((object.Normalized180() * getTicrateScale(value)) + push) * getCorrectedScale(scaleAdjust);
|
2022-07-22 04:56:38 +00:00
|
|
|
}
|
|
|
|
|
2022-09-30 04:30:19 +00:00
|
|
|
inline static void scaletozero(DAngle& object, const DAngle value, const double scaleAdjust, const DAngle push = DAngle::fromDeg(32. / 465.))
|
2022-07-22 04:56:38 +00:00
|
|
|
{
|
2022-08-27 11:48:57 +00:00
|
|
|
if (auto sgn = object.Sgn())
|
2022-07-22 04:56:38 +00:00
|
|
|
{
|
2022-09-30 04:30:19 +00:00
|
|
|
object -= getscaledangle(value, scaleAdjust, object, push * sgn);
|
2022-08-28 00:40:50 +00:00
|
|
|
if (sgn != object.Sgn()) object = nullAngle;
|
2022-07-22 04:56:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-01 22:53:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Functions for determining whether its turbo turn time (turn key held for a number of tics).
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static double turnheldtime;
|
|
|
|
|
|
|
|
void updateTurnHeldAmt(double const scaleAdjust)
|
|
|
|
{
|
2022-05-30 11:06:32 +00:00
|
|
|
turnheldtime += getTicrateScale(BUILDTICRATE) * scaleAdjust;
|
2021-01-01 22:53:03 +00:00
|
|
|
}
|
|
|
|
|
2021-10-08 17:06:41 +00:00
|
|
|
bool isTurboTurnTime()
|
2021-01-01 22:53:03 +00:00
|
|
|
{
|
2021-11-06 01:39:19 +00:00
|
|
|
return turnheldtime >= getTicrateScale(TURBOTURNBASE);
|
2021-01-01 22:53:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void resetTurnHeldAmt()
|
|
|
|
{
|
|
|
|
turnheldtime = 0;
|
|
|
|
}
|
|
|
|
|
2022-06-11 08:36:20 +00:00
|
|
|
|
2020-10-11 14:33:43 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Player's movement function, called from game's ticker or from gi->GetInput() as required.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-11-05 22:28:39 +00:00
|
|
|
void processMovement(InputPacket* const currInput, InputPacket* const inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt, bool const allowstrafe, double const turnscale)
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-09-19 23:54:01 +00:00
|
|
|
// set up variables.
|
|
|
|
int const keymove = 1 << int(!!(inputBuffer->actions & SB_RUN));
|
2022-09-27 07:08:01 +00:00
|
|
|
float const hidspeed = float(getTicrateScale(YAW_TURNSPEEDS[2]) * turnscale);
|
2022-09-19 23:54:01 +00:00
|
|
|
float const scaleAdjustf = float(scaleAdjust);
|
|
|
|
|
|
|
|
// determine player input.
|
|
|
|
auto const turning = buttonMap.ButtonDown(gamefunc_Turn_Right) - buttonMap.ButtonDown(gamefunc_Turn_Left);
|
|
|
|
auto const moving = buttonMap.ButtonDown(gamefunc_Move_Forward) - buttonMap.ButtonDown(gamefunc_Move_Backward) + hidInput->dz * scaleAdjustf;
|
|
|
|
auto const strafing = buttonMap.ButtonDown(gamefunc_Strafe_Right) - buttonMap.ButtonDown(gamefunc_Strafe_Left) - hidInput->dx * scaleAdjustf;
|
|
|
|
|
|
|
|
// process player angle input.
|
|
|
|
if (!(buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe))
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-09-19 23:54:01 +00:00
|
|
|
float const turndir = clamp(turning + strafing * !allowstrafe, -1.f, 1.f);
|
2022-09-27 07:08:01 +00:00
|
|
|
float const turnspeed = float(getTicrateScale(YAW_TURNSPEEDS[keymove]) * turnscale * (isTurboTurnTime() ? 1. : YAW_PREAMBLESCALE));
|
2022-09-19 23:54:01 +00:00
|
|
|
currInput->avel += hidInput->mouseturnx + (hidInput->dyaw * hidspeed + turndir * turnspeed) * scaleAdjustf;
|
|
|
|
if (turndir) updateTurnHeldAmt(scaleAdjust); else resetTurnHeldAmt();
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
2022-06-11 07:12:56 +00:00
|
|
|
else
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-09-19 23:54:01 +00:00
|
|
|
currInput->svel += hidInput->mousemovex + (hidInput->dyaw + turning) * keymove * scaleAdjustf;
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
2022-06-11 07:12:56 +00:00
|
|
|
|
2022-09-19 23:54:01 +00:00
|
|
|
// process player pitch input.
|
|
|
|
if (!(inputBuffer->actions & SB_AIMMODE))
|
2022-10-11 06:46:56 +00:00
|
|
|
currInput->horz += hidInput->mouseturny - hidInput->dpitch * hidspeed * scaleAdjustf;
|
2022-06-11 07:12:56 +00:00
|
|
|
else
|
2022-09-19 23:54:01 +00:00
|
|
|
currInput->fvel -= hidInput->mousemovey + hidInput->dpitch * keymove * scaleAdjustf;
|
|
|
|
|
|
|
|
// process movement input.
|
|
|
|
currInput->fvel += moving * keymove;
|
|
|
|
currInput->svel += strafing * keymove * allowstrafe;
|
2022-10-27 22:43:56 +00:00
|
|
|
|
|
|
|
// process RR's drunk state.
|
|
|
|
if (isRR() && drink_amt >= 66 && drink_amt <= 87)
|
|
|
|
currInput->svel += drink_amt & 1 ? -currInput->fvel : currInput->fvel;
|
2020-10-11 14:33:43 +00:00
|
|
|
|
|
|
|
// add collected input to game's local input accumulation packet.
|
2022-11-07 08:38:22 +00:00
|
|
|
inputBuffer->fvel = clamp(inputBuffer->fvel + currInput->fvel, -(float)keymove, (float)keymove);
|
|
|
|
inputBuffer->svel = clamp(inputBuffer->svel + currInput->svel, -(float)keymove, (float)keymove);
|
|
|
|
inputBuffer->avel = clamp(inputBuffer->avel + currInput->avel, -179.f, 179.f);
|
|
|
|
inputBuffer->horz = clamp(inputBuffer->horz + currInput->horz, -179.f, 179.f);
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
|
|
|
|
2022-09-27 07:08:01 +00:00
|
|
|
|
2020-10-11 14:33:43 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Player's horizon function, called from game's ticker or from gi->GetInput() as required.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-11-25 05:43:37 +00:00
|
|
|
void PlayerHorizon::applyPitch(float const horz, ESyncBits* actions, double const scaleAdjust)
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-06-11 08:36:20 +00:00
|
|
|
// Process only if movement isn't locked.
|
2022-11-27 02:56:35 +00:00
|
|
|
if (!lockedPitch())
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-09-27 08:52:13 +00:00
|
|
|
// Process mouse input.
|
|
|
|
if (horz)
|
2021-04-02 11:41:47 +00:00
|
|
|
{
|
2022-11-25 03:48:31 +00:00
|
|
|
ZzHORIZON += DAngle::fromDeg(horz);
|
2022-10-27 22:43:56 +00:00
|
|
|
*actions &= ~SB_CENTERVIEW;
|
2022-09-27 08:52:13 +00:00
|
|
|
}
|
2021-04-02 11:41:47 +00:00
|
|
|
|
2022-09-27 08:52:13 +00:00
|
|
|
// Process keyboard input.
|
2022-10-27 22:43:56 +00:00
|
|
|
if (auto aiming = !!(*actions & SB_AIM_DOWN) - !!(*actions & SB_AIM_UP))
|
2022-09-27 08:52:13 +00:00
|
|
|
{
|
2022-11-25 03:48:31 +00:00
|
|
|
ZzHORIZON += getTicrateScale(PITCH_AIMSPEED) * scaleAdjust * aiming;
|
2022-10-27 22:43:56 +00:00
|
|
|
*actions &= ~SB_CENTERVIEW;
|
|
|
|
}
|
|
|
|
if (auto looking = !!(*actions & SB_LOOK_DOWN) - !!(*actions & SB_LOOK_UP))
|
|
|
|
{
|
2022-11-25 03:48:31 +00:00
|
|
|
ZzHORIZON += getTicrateScale(PITCH_LOOKSPEED) * scaleAdjust * looking;
|
2022-10-27 22:43:56 +00:00
|
|
|
*actions |= SB_CENTERVIEW;
|
|
|
|
}
|
2022-09-25 09:40:19 +00:00
|
|
|
|
2022-09-27 08:52:13 +00:00
|
|
|
// Do return to centre.
|
|
|
|
if ((*actions & SB_CENTERVIEW) && !(*actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
|
|
|
{
|
2022-11-25 03:48:31 +00:00
|
|
|
const auto pitch = abs(ZzHORIZON);
|
2022-12-09 07:00:42 +00:00
|
|
|
const auto scale = pitch > PITCH_CNTRSINEOFFSET ? (pitch - PITCH_CNTRSINEOFFSET).Cos() : 1.;
|
2022-11-25 03:48:31 +00:00
|
|
|
scaletozero(ZzHORIZON, PITCH_CENTERSPEED * scale, scaleAdjust);
|
|
|
|
if (!ZzHORIZON.Sgn()) *actions &= ~SB_CENTERVIEW;
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
2022-09-27 08:52:13 +00:00
|
|
|
|
|
|
|
// clamp before we finish, even if it's clamped in the drawer.
|
2022-11-25 03:48:31 +00:00
|
|
|
ZzHORIZON = ClampViewPitch(ZzHORIZON);
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
2021-04-02 12:23:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*actions &= ~SB_CENTERVIEW;
|
|
|
|
}
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
|
|
|
|
2022-06-11 08:36:20 +00:00
|
|
|
|
2020-10-11 14:33:43 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Player's angle function, called from game's ticker or from gi->GetInput() as required.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2021-04-21 10:41:04 +00:00
|
|
|
void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const scaleAdjust)
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2021-11-07 00:37:12 +00:00
|
|
|
// Process angle return to zeros.
|
2022-11-25 05:29:02 +00:00
|
|
|
scaletozero(ZzROTSCRNANG, YAW_LOOKRETURN, scaleAdjust);
|
2022-11-25 05:27:11 +00:00
|
|
|
scaletozero(ZzLOOKANG, YAW_LOOKRETURN, scaleAdjust);
|
2020-10-11 14:33:43 +00:00
|
|
|
|
2021-11-06 06:57:00 +00:00
|
|
|
// Process keyboard input.
|
2022-10-27 22:43:56 +00:00
|
|
|
if (auto looking = !!(*actions & SB_LOOK_RIGHT) - !!(*actions & SB_LOOK_LEFT))
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-11-25 05:27:11 +00:00
|
|
|
ZzLOOKANG += getTicrateScale(YAW_LOOKINGSPEED) * getCorrectedScale(scaleAdjust) * looking;
|
2022-11-25 05:29:02 +00:00
|
|
|
ZzROTSCRNANG -= getTicrateScale(YAW_ROTATESPEED) * getCorrectedScale(scaleAdjust) * looking;
|
2022-10-27 22:43:56 +00:00
|
|
|
}
|
2020-10-11 14:33:43 +00:00
|
|
|
|
2022-11-27 02:58:53 +00:00
|
|
|
if (!lockedYaw())
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-10-27 22:43:56 +00:00
|
|
|
// add player's input
|
2022-11-25 05:24:03 +00:00
|
|
|
ZzANGLE += DAngle::fromDeg(avel);
|
2022-10-27 22:43:56 +00:00
|
|
|
|
2021-04-02 11:41:47 +00:00
|
|
|
if (*actions & SB_TURNAROUND)
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-11-25 05:31:44 +00:00
|
|
|
if (YawSpin == nullAngle)
|
2021-04-02 11:41:47 +00:00
|
|
|
{
|
|
|
|
// currently not spinning, so start a spin
|
2022-11-25 05:31:44 +00:00
|
|
|
YawSpin = -DAngle180;
|
2021-04-02 11:41:47 +00:00
|
|
|
}
|
|
|
|
*actions &= ~SB_TURNAROUND;
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
|
|
|
|
2022-11-25 05:31:44 +00:00
|
|
|
if (YawSpin < nullAngle)
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2021-04-02 11:41:47 +00:00
|
|
|
// return spin to 0
|
2022-09-28 02:33:22 +00:00
|
|
|
DAngle add = getTicrateScale(!(*actions & SB_CROUCH) ? YAW_SPINSTAND : YAW_SPINCROUCH) * scaleAdjust;
|
2022-11-25 05:31:44 +00:00
|
|
|
YawSpin += add;
|
|
|
|
if (YawSpin > nullAngle)
|
2021-04-02 11:41:47 +00:00
|
|
|
{
|
|
|
|
// Don't overshoot our target. With variable factor this is possible.
|
2022-11-25 05:31:44 +00:00
|
|
|
add -= YawSpin;
|
|
|
|
YawSpin = nullAngle;
|
2021-04-02 11:41:47 +00:00
|
|
|
}
|
2022-11-25 05:24:03 +00:00
|
|
|
ZzANGLE += add;
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-02 11:41:47 +00:00
|
|
|
else
|
2020-10-11 14:33:43 +00:00
|
|
|
{
|
2022-11-25 05:31:44 +00:00
|
|
|
YawSpin = nullAngle;
|
2020-10-11 14:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-11 08:36:20 +00:00
|
|
|
|
2021-01-01 13:30:01 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Player's slope tilt when playing without a mouse and on a slope.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-11-25 05:43:37 +00:00
|
|
|
void PlayerHorizon::doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust, bool const climbing)
|
2021-01-01 13:30:01 +00:00
|
|
|
{
|
2021-11-24 01:03:53 +00:00
|
|
|
if (cl_slopetilting && cursectnum != nullptr)
|
2021-01-01 13:30:01 +00:00
|
|
|
{
|
2021-01-01 13:34:44 +00:00
|
|
|
if (aimmode && canslopetilt) // If the floor is sloped
|
2021-01-01 13:30:01 +00:00
|
|
|
{
|
2021-01-02 03:40:35 +00:00
|
|
|
// Get a point, 512 (64 for Blood) units ahead of player's position
|
2022-09-27 05:51:42 +00:00
|
|
|
auto rotpt = pos + ang.ToVector() * (isBlood() ? 4 : 32);
|
2021-11-24 01:03:53 +00:00
|
|
|
auto tempsect = cursectnum;
|
2022-09-27 05:51:42 +00:00
|
|
|
updatesector(rotpt, &tempsect);
|
2021-01-01 13:34:44 +00:00
|
|
|
|
2021-11-24 01:03:53 +00:00
|
|
|
if (tempsect != nullptr) // If the new point is inside a valid sector...
|
2021-01-01 13:30:01 +00:00
|
|
|
{
|
2021-01-01 13:34:44 +00:00
|
|
|
// Get the floorz as if the new (x,y) point was still in
|
2022-12-09 06:48:26 +00:00
|
|
|
// your sector, unless it's Blood.
|
2022-09-27 11:59:57 +00:00
|
|
|
double const j = getflorzofslopeptr(cursectnum, pos);
|
2022-12-09 06:48:26 +00:00
|
|
|
double const k = getflorzofslopeptr(!isBlood() ? cursectnum : tempsect, rotpt);
|
2021-01-01 13:34:44 +00:00
|
|
|
|
|
|
|
// If extended point is in same sector as you or the slopes
|
|
|
|
// of the sector of the extended point and your sector match
|
|
|
|
// closely (to avoid accidently looking straight out when
|
|
|
|
// you're at the edge of a sector line) then adjust horizon
|
|
|
|
// accordingly
|
2022-09-27 11:59:57 +00:00
|
|
|
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, rotpt) - k) <= 4))
|
2021-01-01 13:34:44 +00:00
|
|
|
{
|
2022-11-25 03:53:27 +00:00
|
|
|
ZzHORIZOFF -= maphoriz(scaleAdjust * ((j - k) * (!isBlood() ? 0.625 : 5.5)));
|
2021-01-01 13:34:44 +00:00
|
|
|
}
|
2021-01-01 13:30:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-01 13:34:44 +00:00
|
|
|
if (climbing)
|
2021-01-01 13:30:01 +00:00
|
|
|
{
|
2021-01-01 13:34:44 +00:00
|
|
|
// tilt when climbing but you can't even really tell it.
|
2022-11-25 03:53:27 +00:00
|
|
|
if (ZzHORIZOFF > PITCH_HORIZOFFCLIMB) ZzHORIZOFF += getscaledangle(PITCH_HORIZOFFSPEED, scaleAdjust, deltaangle(ZzHORIZOFF, PITCH_HORIZOFFCLIMB), PITCH_HORIZOFFPUSH);
|
2021-01-01 13:30:01 +00:00
|
|
|
}
|
2021-11-07 07:25:37 +00:00
|
|
|
else
|
2021-01-01 13:30:01 +00:00
|
|
|
{
|
2021-01-01 13:34:44 +00:00
|
|
|
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
2022-11-25 03:53:27 +00:00
|
|
|
scaletozero(ZzHORIZOFF, PITCH_HORIZOFFSPEED, scaleAdjust, PITCH_HORIZOFFPUSH);
|
2021-01-01 13:30:01 +00:00
|
|
|
}
|
2022-09-27 06:37:37 +00:00
|
|
|
|
2022-09-28 03:39:01 +00:00
|
|
|
// Clamp off against the maximum allowed pitch.
|
2022-11-25 03:53:27 +00:00
|
|
|
ZzHORIZOFF = ClampViewPitch(ZzHORIZOFF);
|
2021-01-01 13:30:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-11 08:36:20 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2020-10-11 14:55:12 +00:00
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
2022-11-25 05:24:03 +00:00
|
|
|
arc("ang", w.ZzANGLE)
|
2022-11-25 05:27:11 +00:00
|
|
|
("lookang", w.ZzLOOKANG)
|
2022-11-25 05:29:02 +00:00
|
|
|
("rotscrnang", w.ZzROTSCRNANG)
|
2022-11-25 05:31:44 +00:00
|
|
|
("spin", w.YawSpin)
|
2022-11-25 05:41:09 +00:00
|
|
|
("inputdisabled", w.legacyDisabledYaw)
|
2020-10-11 14:55:12 +00:00
|
|
|
.EndObject();
|
|
|
|
|
|
|
|
if (arc.isReading())
|
|
|
|
{
|
2022-11-25 05:26:47 +00:00
|
|
|
w.ZzOLDANGLE = w.ZzANGLE;
|
2022-11-25 05:27:55 +00:00
|
|
|
w.ZzOLDLOOKANG = w.ZzLOOKANG;
|
2022-11-25 05:31:29 +00:00
|
|
|
w.ZzOLDROTSCRNANG = w.ZzROTSCRNANG;
|
2022-11-25 05:41:09 +00:00
|
|
|
w.legacyDisabledYaw = w.legacyDisabledYaw;
|
2022-11-27 02:58:53 +00:00
|
|
|
w.resetAdjustmentYaw();
|
2020-10-11 14:55:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def)
|
|
|
|
{
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
{
|
2022-11-25 03:48:31 +00:00
|
|
|
arc("horiz", w.ZzHORIZON)
|
2022-11-25 03:53:27 +00:00
|
|
|
("horizoff", w.ZzHORIZOFF)
|
2022-11-25 05:41:51 +00:00
|
|
|
("inputdisabled", w.legacyDisabledPitch)
|
2020-10-11 14:55:12 +00:00
|
|
|
.EndObject();
|
|
|
|
|
|
|
|
if (arc.isReading())
|
|
|
|
{
|
2022-11-25 03:51:53 +00:00
|
|
|
w.ZzOLDHORIZON = w.ZzHORIZON;
|
2022-11-25 03:55:05 +00:00
|
|
|
w.ZzOHORIZOFF = w.ZzHORIZOFF;
|
2022-11-25 05:41:51 +00:00
|
|
|
w.legacyDisabledPitch = w.legacyDisabledPitch;
|
2022-11-27 02:56:35 +00:00
|
|
|
w.resetAdjustmentPitch();
|
2020-10-11 14:55:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return arc;
|
|
|
|
}
|