From aad2401ba59cb2bf0b2656a287f8b9736399607e Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 28 Apr 2020 23:24:48 +0200 Subject: [PATCH] Cam lockon, allow viewpoint change during freecam --- src/g_game.c | 2 +- src/p_user.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index a7ad1e68..bf0557d0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1871,7 +1871,7 @@ boolean G_Responder(event_t *ev) // allow spy mode changes even during the demo if (gamestate == GS_LEVEL && ev->type == ev_keydown - && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1]) && !demo.freecam) + && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) { if (!demo.playback && (splitscreen || !netgame)) displayplayers[0] = consoleplayer; diff --git a/src/p_user.c b/src/p_user.c index e0fb6fb4..03f8f0fb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7314,6 +7314,10 @@ static ticcmd_t *P_CameraCmd(camera_t *cam) if (InputDown(gc_aimbackward, 1) || (usejoystick && axis > 0)) forward -= forwardmove[1]; + // fire with any button/key + axis = JoyAxis(AXISFIRE, 1); + if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ATTACK; // spectator aiming shit, ahhhh... player_invert = invertmouse ? -1 : 1; @@ -7380,6 +7384,7 @@ void P_DemoCameraMovement(camera_t *cam) ticcmd_t *cmd; angle_t thrustangle; mobj_t *awayviewmobj_hack; + player_t *lastp; // update democam stuff with what we got here: democam.cam = cam; @@ -7399,6 +7404,14 @@ void P_DemoCameraMovement(camera_t *cam) else if (cmd->buttons & BT_BRAKE) cam->z -= 32*mapobjectscale; + // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") + if (cmd->buttons & BT_ATTACK) + { + lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. + cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); + cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + } + cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0)