From e3dac00aa91d0c545cc1901548397940487a7752 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 16 May 2016 19:00:34 +0100 Subject: [PATCH] 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) {