Make lookback instantaneous

This commit is contained in:
lachwright 2020-04-21 05:24:48 +08:00
parent 6905cfb064
commit c92634c71e

View file

@ -7157,13 +7157,14 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled) boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled)
{ {
static UINT8 lookbackdelay[4] = {0,0,0,0}; static boolean lookbackactive[MAXSPLITSCREENPLAYERS];
static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS];
UINT8 num; UINT8 num;
angle_t angle = 0, focusangle = 0, focusaiming = 0, pitch = 0; angle_t angle = 0, focusangle = 0, focusaiming = 0, pitch = 0;
fixed_t x, y, z, dist, distxy, distz, height, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight; fixed_t x, y, z, dist, distxy, distz, height, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
fixed_t pan, xpan, ypan; fixed_t pan, xpan, ypan;
INT32 camrotate; INT32 camrotate;
boolean camstill, lookback; boolean camstill, lookback, lookbackdown;
UINT8 timeover; UINT8 timeover;
mobj_t *mo; mobj_t *mo;
fixed_t f1, f2; fixed_t f1, f2;
@ -7343,15 +7344,19 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camstill = true; camstill = true;
else if (lookback || lookbackdelay[num]) // SRB2kart - Camera flipper else if (lookback || lookbackdelay[num]) // SRB2kart - Camera flipper
{ {
#define MAXLOOKBACKDELAY 2
camspeed = FRACUNIT; camspeed = FRACUNIT;
if (lookback) if (lookback)
{ {
camrotate += 180; camrotate += 180;
lookbackdelay[num] = 2; lookbackdelay[num] = MAXLOOKBACKDELAY;
} }
else else
lookbackdelay[num]--; lookbackdelay[num]--;
} }
lookbackdown = (lookbackdelay[num] == MAXLOOKBACKDELAY) != lookbackactive[num];
lookbackactive[num] = (lookbackdelay[num] == MAXLOOKBACKDELAY);
#undef MAXLOOKBACKDELAY
if (mo->eflags & MFE_VERTICALFLIP) if (mo->eflags & MFE_VERTICALFLIP)
camheight += thiscam->height; camheight += thiscam->height;
@ -7434,8 +7439,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
else else
distxy = dist; distxy = dist;
distz = -FixedMul(dist, FINESINE((pitch>>ANGLETOFINESHIFT) & FINEMASK)); distz = -FixedMul(dist, FINESINE((pitch>>ANGLETOFINESHIFT) & FINEMASK));
//if (r_splitscreen == 1) // 2 player is weird, this helps keep players on screen
//distz = 3*distz/5;
x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy); x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy);
y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy); y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy);
@ -7779,6 +7782,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->aiming = ANGLE_22h; thiscam->aiming = ANGLE_22h;
} }
if (lookbackdown)
P_MoveChaseCamera(player, thiscam, false);
return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming);
} }