From 89ce257248d69238475f8713bd1251fd6d9a3f71 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 14 May 2016 23:57:56 +0100 Subject: [PATCH 1/3] Fix all the NiGHTS issues in one fell swoop (assuming they are fixed, that is, lol) Basically I kind of worked around any potential trig inaccuracies by not using the player position directly for setting momx/momy. This way, if player->angle_pos == player->old_angle_pos, momx/momy are zero --- src/p_user.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 26b60e76b..ff95537e7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4952,8 +4952,9 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad else { const angle_t fa = player->angle_pos>>ANGLETOFINESHIFT; - player->mo->momx = player->mo->target->x + FixedMul(FINECOSINE(fa),radius) - player->mo->x; - player->mo->momy = player->mo->target->y + FixedMul(FINESINE(fa),radius) - player->mo->y; + const angle_t faold = player->old_angle_pos>>ANGLETOFINESHIFT; + player->mo->momx = FixedMul(FINECOSINE(fa),radius) - FixedMul(FINECOSINE(faold),radius); + player->mo->momy = FixedMul(FINESINE(fa),radius) - FixedMul(FINESINE(faold),radius); } if (player->exiting) From ea1cac8e246056b83516e7d783318fb63c0067dc Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 15 May 2016 22:09:22 +0100 Subject: [PATCH 2/3] Fix NiGHTS drill constantly starting if you're moving sideways on ground Also disabled normal mobj friction from NiGHTS and tweaked bouncing code just in case? --- src/p_mobj.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7171a5b84..0e7cbd55b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1900,6 +1900,9 @@ void P_XYMovement(mobj_t *mo) if (player && player->homing) // no friction for homing return; + if (player && player->pflags & PF_NIGHTSMODE) + return; // no friction for NiGHTS players + #ifdef ESLOPE if ((mo->type == MT_BIGTUMBLEWEED || mo->type == MT_LITTLETUMBLEWEED) && (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)) // Special exception for tumbleweeds on slopes @@ -2656,11 +2659,16 @@ static void P_PlayerZMovement(mobj_t *mo) if (mo->player->pflags & PF_NIGHTSMODE) { - if (mo->player->flyangle < 90 || mo->player->flyangle >= 270) - mo->player->flyangle += P_MobjFlip(mo)*90; - else - mo->player->flyangle -= P_MobjFlip(mo)*90; - mo->player->speed = FixedMul(mo->player->speed, 4*FRACUNIT/5); + // bounce off floor if you were flying towards it + if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 0 && mo->player->flyangle < 180) + || (!(mo->eflags & MFE_VERTICALFLIP) && mo->player->flyangle > 180 && mo->player->flyangle <= 359)) + { + if (mo->player->flyangle < 90 || mo->player->flyangle >= 270) + mo->player->flyangle += P_MobjFlip(mo)*90; + else + mo->player->flyangle -= P_MobjFlip(mo)*90; + mo->player->speed = FixedMul(mo->player->speed, 4*FRACUNIT/5); + } goto nightsdone; } // Get up if you fell. @@ -2851,12 +2859,17 @@ nightsdone: if (mo->player->pflags & PF_NIGHTSMODE) { - if (mo->player->flyangle < 90 || mo->player->flyangle >= 270) - mo->player->flyangle -= P_MobjFlip(mo)*90; - else - mo->player->flyangle += P_MobjFlip(mo)*90; - mo->player->flyangle %= 360; - mo->player->speed = FixedMul(mo->player->speed, 4*FRACUNIT/5); + // bounce off ceiling if you were flying towards it + if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 180 && mo->player->flyangle <= 359) + || (!(mo->eflags & MFE_VERTICALFLIP) && mo->player->flyangle > 0 && mo->player->flyangle < 180)) + { + if (mo->player->flyangle < 90 || mo->player->flyangle >= 270) + mo->player->flyangle -= P_MobjFlip(mo)*90; + else + mo->player->flyangle += P_MobjFlip(mo)*90; + mo->player->flyangle %= 360; + mo->player->speed = FixedMul(mo->player->speed, 4*FRACUNIT/5); + } } // Check for "Mario" blocks to hit and bounce them @@ -3719,7 +3732,8 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } else { - mobj->player->jumping = 0; + if (!(mobj->player->pflags & PF_NIGHTSMODE)) // "jumping" is used for drilling + mobj->player->jumping = 0; mobj->player->pflags &= ~PF_JUMPED; if (mobj->player->secondjump || mobj->player->powers[pw_tailsfly]) { From e3dac00aa91d0c545cc1901548397940487a7752 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 16 May 2016 19:00:34 +0100 Subject: [PATCH 3/3] If player is at wrong distance from axis, correct x/y position in a similar fashion to how momentum is set for homing attacks. Don't use trig here for most cases since that just re-introduces the side drift issue and friends all over again. This fixes the CEZS issue where the player start is not actually on the track, preventing the player from going backwards until they hit a wall. --- src/p_user.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index ff95537e7..559eacd4d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5661,6 +5661,29 @@ static void P_NiGHTSMovement(player_t *player) if (player->mo->eflags & MFE_VERTICALFLIP) cmd->forwardmove = (SINT8)(-cmd->forwardmove); + if (!(player->pflags & PF_TRANSFERTOCLOSEST)) + { + fixed_t realdist = R_PointToDist2(player->mo->x, player->mo->y, player->mo->target->x, player->mo->target->y); + // teleport player to correct radius if neccessary + if (realdist>>FRACBITS != radius>>FRACBITS) + { + CONS_Debug(DBG_NIGHTS, "Aligning player with axis\n"); + P_UnsetThingPosition(player->mo); + if (realdist == 0) // other method won't work if we're exactly on the target lol + { + const angle_t fa = player->old_angle_pos>>ANGLETOFINESHIFT; + player->mo->x = player->mo->target->x + FixedMul(FINECOSINE(fa), radius); + player->mo->y = player->mo->target->y + FixedMul(FINESINE(fa), radius); + } + else + { + player->mo->x = player->mo->target->x + FixedMul(FixedDiv(player->mo->x - player->mo->target->x, realdist), radius); + player->mo->y = player->mo->target->y + FixedMul(FixedDiv(player->mo->y - player->mo->target->y, realdist), radius); + } + P_SetThingPosition(player->mo); + } + } + // Currently reeling from being hit. if (player->powers[pw_flashing] > (2*flashingtics)/3) {