mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-28 18:00:40 +00:00
- SW: Handle DoPlayerTurn()
/DoPlayerHorizon()
better while dead.
This commit is contained in:
parent
681a8ebec2
commit
e1a5e37126
2 changed files with 102 additions and 96 deletions
|
@ -278,9 +278,9 @@ static void processMovement(PLAYERp const pp, ControlInfo* const hidInput, bool
|
||||||
if (!cl_syncinput)
|
if (!cl_syncinput)
|
||||||
{
|
{
|
||||||
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN))
|
if (TEST(pp->Flags2, PF2_INPUT_CAN_TURN))
|
||||||
DoPlayerTurn(pp, !TEST(pp->Flags, PF_DEAD) || TEST(pp->Flags, PF_DEAD) && TEST(pp->Flags, PF_DEAD_HEAD|PF_HEAD_CONTROL) ? q16avel : 0, scaleAdjust);
|
DoPlayerTurn(pp, q16avel, scaleAdjust);
|
||||||
if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM))
|
if (TEST(pp->Flags2, PF2_INPUT_CAN_AIM))
|
||||||
DoPlayerHorizon(pp, !TEST(pp->Flags, PF_DEAD) ? q16horz : 0, scaleAdjust);
|
DoPlayerHorizon(pp, q16horz, scaleAdjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL);
|
loc.fvel = clamp(loc.fvel + fvel, -MAXFVEL, MAXFVEL);
|
||||||
|
|
|
@ -1551,63 +1551,66 @@ DoPlayerCrawlHeight(PLAYERp pp)
|
||||||
void
|
void
|
||||||
DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
|
DoPlayerTurn(PLAYERp pp, fixed_t const q16avel, double const scaleAdjust)
|
||||||
{
|
{
|
||||||
if (!TEST(pp->Flags, PF_TURN_180))
|
if (!TEST(pp->Flags, PF_DEAD) || TEST(pp->Flags, PF_DEAD) && TEST(pp->Flags, PF_DEAD_HEAD|PF_HEAD_CONTROL))
|
||||||
{
|
{
|
||||||
if (pp->input.actions & SB_TURNAROUND)
|
if (!TEST(pp->Flags, PF_TURN_180))
|
||||||
{
|
{
|
||||||
if (pp->KeyPressBits & SB_TURNAROUND)
|
if (pp->input.actions & SB_TURNAROUND)
|
||||||
{
|
{
|
||||||
fixed_t delta_ang;
|
if (pp->KeyPressBits & SB_TURNAROUND)
|
||||||
|
{
|
||||||
|
fixed_t delta_ang;
|
||||||
|
|
||||||
pp->KeyPressBits &= ~SB_TURNAROUND;
|
pp->KeyPressBits &= ~SB_TURNAROUND;
|
||||||
|
|
||||||
pp->turn180_target = pp->q16ang + IntToFixed(1024);
|
pp->turn180_target = pp->q16ang + IntToFixed(1024);
|
||||||
|
|
||||||
// make the first turn in the clockwise direction
|
// make the first turn in the clockwise direction
|
||||||
// the rest will follow
|
// the rest will follow
|
||||||
delta_ang = labs(GetDeltaQ16Angle(pp->turn180_target, pp->q16ang)) >> TURN_SHIFT;
|
delta_ang = labs(GetDeltaQ16Angle(pp->turn180_target, pp->q16ang)) >> TURN_SHIFT;
|
||||||
pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * delta_ang)) & 0x7FFFFFF;
|
pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * delta_ang)) & 0x7FFFFFF;
|
||||||
|
|
||||||
SET(pp->Flags, PF_TURN_180);
|
SET(pp->Flags, PF_TURN_180);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pp->KeyPressBits |= SB_TURNAROUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (TEST(pp->Flags, PF_TURN_180))
|
||||||
{
|
{
|
||||||
pp->KeyPressBits |= SB_TURNAROUND;
|
fixed_t delta_ang;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TEST(pp->Flags, PF_TURN_180))
|
delta_ang = GetDeltaQ16Angle(pp->turn180_target, pp->q16ang) >> TURN_SHIFT;
|
||||||
{
|
pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * delta_ang)) & 0x7FFFFFF;
|
||||||
fixed_t delta_ang;
|
|
||||||
|
|
||||||
delta_ang = GetDeltaQ16Angle(pp->turn180_target, pp->q16ang) >> TURN_SHIFT;
|
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
|
||||||
pp->q16ang = (pp->q16ang + xs_CRoundToInt(scaleAdjust * delta_ang)) & 0x7FFFFFF;
|
|
||||||
|
|
||||||
sprite[pp->PlayerSprite].ang = FixedToInt(pp->q16ang);
|
if (!Prediction && pp->PlayerUnderSprite >= 0)
|
||||||
|
{
|
||||||
|
sprite[pp->PlayerUnderSprite].ang = FixedToInt(pp->q16ang);
|
||||||
|
}
|
||||||
|
|
||||||
if (!Prediction && pp->PlayerUnderSprite >= 0)
|
// get new delta to see how close we are
|
||||||
{
|
delta_ang = GetDeltaQ16Angle(pp->turn180_target, pp->q16ang);
|
||||||
sprite[pp->PlayerUnderSprite].ang = FixedToInt(pp->q16ang);
|
|
||||||
|
if (labs(delta_ang) < (IntToFixed(3) << TURN_SHIFT))
|
||||||
|
{
|
||||||
|
pp->q16ang = pp->turn180_target;
|
||||||
|
RESET(pp->Flags, PF_TURN_180);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get new delta to see how close we are
|
if (q16avel != 0)
|
||||||
delta_ang = GetDeltaQ16Angle(pp->turn180_target, pp->q16ang);
|
|
||||||
|
|
||||||
if (labs(delta_ang) < (IntToFixed(3) << TURN_SHIFT))
|
|
||||||
{
|
{
|
||||||
pp->q16ang = pp->turn180_target;
|
pp->q16ang = (pp->q16ang + q16avel) & 0x7FFFFFF;
|
||||||
RESET(pp->Flags, PF_TURN_180);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (q16avel != 0)
|
|
||||||
{
|
|
||||||
pp->q16ang = (pp->q16ang + q16avel) & 0x7FFFFFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cl_syncinput && pp->angAdjust)
|
if (!cl_syncinput && pp->angAdjust)
|
||||||
|
@ -1859,67 +1862,70 @@ PlayerAutoLook(PLAYERp pp, double const scaleAdjust)
|
||||||
void
|
void
|
||||||
DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust)
|
DoPlayerHorizon(PLAYERp pp, fixed_t const q16horz, double const scaleAdjust)
|
||||||
{
|
{
|
||||||
// Fixme: This should probably be made optional.
|
if (!TEST(pp->Flags, PF_DEAD))
|
||||||
if (cl_slopetilting)
|
|
||||||
PlayerAutoLook(pp, scaleAdjust);
|
|
||||||
|
|
||||||
if (q16horz)
|
|
||||||
{
|
{
|
||||||
pp->q16horizbase += q16horz;
|
// Fixme: This should probably be made optional.
|
||||||
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
|
if (cl_slopetilting)
|
||||||
}
|
PlayerAutoLook(pp, scaleAdjust);
|
||||||
|
|
||||||
// this is the locked type
|
if (q16horz)
|
||||||
if (pp->input.actions & (SB_AIM_UP|SB_AIM_DOWN))
|
|
||||||
{
|
|
||||||
// set looking because player is manually looking.
|
|
||||||
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
|
|
||||||
|
|
||||||
// adjust q16horiz negative
|
|
||||||
if (pp->input.actions & SB_AIM_DOWN)
|
|
||||||
pp->q16horizbase -= FloatToFixed(scaleAdjust * (HORIZ_SPEED >> 1));
|
|
||||||
|
|
||||||
// adjust q16horiz positive
|
|
||||||
if (pp->input.actions & SB_AIM_UP)
|
|
||||||
pp->q16horizbase += FloatToFixed(scaleAdjust * (HORIZ_SPEED >> 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is the unlocked type
|
|
||||||
if (pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN|SB_CENTERVIEW))
|
|
||||||
{
|
|
||||||
RESET(pp->Flags, PF_LOCK_HORIZ);
|
|
||||||
SET(pp->Flags, PF_LOOKING);
|
|
||||||
|
|
||||||
// adjust q16horiz negative
|
|
||||||
if (pp->input.actions & SB_LOOK_DOWN)
|
|
||||||
pp->q16horizbase -= FloatToFixed(scaleAdjust * HORIZ_SPEED);
|
|
||||||
|
|
||||||
// adjust q16horiz positive
|
|
||||||
if (pp->input.actions & SB_LOOK_UP)
|
|
||||||
pp->q16horizbase += FloatToFixed(scaleAdjust * HORIZ_SPEED);
|
|
||||||
|
|
||||||
if (pp->input.actions & SB_CENTERVIEW)
|
|
||||||
pp->q16horizoff = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TEST(pp->Flags, PF_LOCK_HORIZ))
|
|
||||||
{
|
|
||||||
if (!(pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
|
||||||
{
|
{
|
||||||
// not pressing the q16horiz keys
|
pp->q16horizbase += q16horz;
|
||||||
if (pp->q16horizbase != IntToFixed(100))
|
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is the locked type
|
||||||
|
if (pp->input.actions & (SB_AIM_UP|SB_AIM_DOWN))
|
||||||
|
{
|
||||||
|
// set looking because player is manually looking.
|
||||||
|
SET(pp->Flags, PF_LOCK_HORIZ | PF_LOOKING);
|
||||||
|
|
||||||
|
// adjust q16horiz negative
|
||||||
|
if (pp->input.actions & SB_AIM_DOWN)
|
||||||
|
pp->q16horizbase -= FloatToFixed(scaleAdjust * (HORIZ_SPEED >> 1));
|
||||||
|
|
||||||
|
// adjust q16horiz positive
|
||||||
|
if (pp->input.actions & SB_AIM_UP)
|
||||||
|
pp->q16horizbase += FloatToFixed(scaleAdjust * (HORIZ_SPEED >> 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is the unlocked type
|
||||||
|
if (pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN|SB_CENTERVIEW))
|
||||||
|
{
|
||||||
|
RESET(pp->Flags, PF_LOCK_HORIZ);
|
||||||
|
SET(pp->Flags, PF_LOOKING);
|
||||||
|
|
||||||
|
// adjust q16horiz negative
|
||||||
|
if (pp->input.actions & SB_LOOK_DOWN)
|
||||||
|
pp->q16horizbase -= FloatToFixed(scaleAdjust * HORIZ_SPEED);
|
||||||
|
|
||||||
|
// adjust q16horiz positive
|
||||||
|
if (pp->input.actions & SB_LOOK_UP)
|
||||||
|
pp->q16horizbase += FloatToFixed(scaleAdjust * HORIZ_SPEED);
|
||||||
|
|
||||||
|
if (pp->input.actions & SB_CENTERVIEW)
|
||||||
|
pp->q16horizoff = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TEST(pp->Flags, PF_LOCK_HORIZ))
|
||||||
|
{
|
||||||
|
if (!(pp->input.actions & (SB_LOOK_UP|SB_LOOK_DOWN)))
|
||||||
{
|
{
|
||||||
// move q16horiz back to 100
|
// not pressing the q16horiz keys
|
||||||
for (int i = 1; i; i--)
|
if (pp->q16horizbase != IntToFixed(100))
|
||||||
{
|
{
|
||||||
// this formula does not work for q16horiz = 101-103
|
// move q16horiz back to 100
|
||||||
pp->q16horizbase += xs_CRoundToInt(scaleAdjust * (IntToFixed(25) - (pp->q16horizbase >> 2)));
|
for (int i = 1; i; i--)
|
||||||
|
{
|
||||||
|
// this formula does not work for q16horiz = 101-103
|
||||||
|
pp->q16horizbase += xs_CRoundToInt(scaleAdjust * (IntToFixed(25) - (pp->q16horizbase >> 2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// not looking anymore because q16horiz is back at 100
|
||||||
|
RESET(pp->Flags, PF_LOOKING);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// not looking anymore because q16horiz is back at 100
|
|
||||||
RESET(pp->Flags, PF_LOOKING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue