From f512a080513669e15e36dc5c00122f87a102e643 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 19:33:43 +0100 Subject: [PATCH 1/2] dont do this while not in replay this is kinda awkward tbh, but its useful for replay stuff --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 03cf054d9..e5c1c86b2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3370,8 +3370,8 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num) } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") - // well this only really works in replays for us, since we still move our spec player around which causes displayplayer to be the spec player - if (cam->freecam && cmd->buttons & BT_ATTACK) + // this feels kinda pointless for ingame freecam so keep it for replays only + if (demo.playback && 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. From 2f4a113685bea06fbe512bd4dd0a757f15e7715b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 19:37:52 +0100 Subject: [PATCH 2/2] more hAx: dont move player during freecam state besides hop and honk useful if you wanna take pics and dont feel like driving away --- src/g_game.c | 38 +++++++++++++++++++++++++------------- src/p_user.c | 11 +++++++---- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index cd96729fc..861c09497 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -842,34 +842,45 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn -// this is absolutely awful -// but we need this if we dont want spectators to move but be able to go to freecam from watching someone -static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer) +// +// G_BuildLocalTiccmd +// extremely basic cut down ticcmd builder +// for spectator and freecam +// this does not make the player move at all but keeps important things working +// +static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) { boolean moveinput = false; INT32 axis = 0; const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value); - moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) - || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || - (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); - // check for inputs and return button commands - // for stuff like joining with item button, etc. + // for stuff like joining with item button, saltyhop, honking, etc. #define CHECKINPUT(button, AXIS, buttflag) \ axis = JoyAxis(AXIS, ssplayer); \ if (InputDown(button, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= buttflag; - CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); - CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); CHECKINPUT(gc_fire, AXISFIRE, BT_ATTACK); CHECKINPUT(gc_drift, AXISDRIFT, BT_DRIFT); CHECKINPUT(gc_custom1, AXISCUSTOM1, BT_CUSTOM1); CHECKINPUT(gc_custom2, AXISCUSTOM2, BT_CUSTOM2); CHECKINPUT(gc_custom3, AXISCUSTOM3, BT_CUSTOM3); + // we dont need the rest of this if were in freecam state + if (freecam) + { + return; + } + + CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); + CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); + #undef CHECKINPUT + moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) + || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || + (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); + axis = JoyAxis(AXISLOOKBACK, ssplayer); camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); @@ -954,11 +965,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - // lmfao this is beyond hellish - if (player->spectator) + // dumbass thing so we can use a few buttons but dont accidentally drive away + if (player->spectator || camera[forplayer].freecam) { - G_BuildLocalTiccmd(cmd, ssplayer); + G_BuildLocalTiccmd(cmd, ssplayer, !player->spectator); + // let lua override everything if (gamestate == GS_LEVEL) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); diff --git a/src/p_user.c b/src/p_user.c index e5c1c86b2..ca2616461 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3155,6 +3155,12 @@ void P_ToggleDemoCamera(UINT8 viewnum) cam->freecam = true; cam->button_a_held = 2; cam->reset_aiming = true; + + // get rid of some hud elements + if (displayplayers[0] != consoleplayer) + { + displayplayers[0] = consoleplayer; + } } else // toggle off { @@ -3255,13 +3261,10 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) if (InputDown(gc_aimbackward, forplayer) || (usejoystick && axis > 0)) forward -= forwardmove[1]; - // fire with any button/key axis = JoyAxis(AXISFIRE, forplayer); - if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) + if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; - // spectator aiming shit, ahhhh... - // looking up/down laim += (mlooky<<19);