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) {