# HG changeset patch # User Adam Kaminski # Date 1631543703 14400 # Mon Sep 13 10:35:03 2021 -0400 # Node ID 3e1cc88ef49569eed082b3c97c5aae9420c34181 # Parent 96ae55abf5e2f1896c9b91394a029e3df0080583 Weapon sprites now sway on the screen based on how much the player's angle and pitch changes, instead of using their inputs directly. This means the local player can now see other player's weapons sway properly. diff -r 96ae55abf5e2 -r 3e1cc88ef495 src/cl_main.cpp --- a/src/cl_main.cpp Mon Sep 13 09:53:09 2021 -0400 +++ b/src/cl_main.cpp Mon Sep 13 10:35:03 2021 -0400 @@ -3816,6 +3816,9 @@ // [BB] But don't just set the position, but also properly set floorz and ceilingz, etc. CLIENT_MoveThing( player->mo, x, y, z ); + // [AK] Calculate how much this player's angle changed. + player->mo->AngleDelta = angle - player->mo->angle; + // Set the player's angle. player->mo->angle = angle; @@ -4445,6 +4448,10 @@ if (pitch > ANGLE_1*56) pitch = ANGLE_1*56; } + + // [AK] Calculate how much this player's pitch changed. + player->mo->PitchDelta = pitch - player->mo->pitch; + player->mo->pitch = pitch; player->mo->waterlevel = waterLevel; // [BB] The attack buttons are now already set in *_MovePlayer, so additionally setting diff -r 96ae55abf5e2 -r 3e1cc88ef495 src/d_player.h --- a/src/d_player.h Mon Sep 13 09:53:09 2021 -0400 +++ b/src/d_player.h Mon Sep 13 10:35:03 2021 -0400 @@ -168,6 +168,11 @@ // [CW] Fades for when you are being damaged. PalEntry DamageFade; + // [AK] How much the player's angle and pitch changed across a single tic. These are + // used to control how much weapon sprites sway on the local player's screen. + fixed_t AngleDelta; + fixed_t PitchDelta; + bool UpdateWaterLevel (fixed_t oldz, bool splash); bool ResetAirSupply (bool playgasp = true); diff -r 96ae55abf5e2 -r 3e1cc88ef495 src/p_pspr.cpp --- a/src/p_pspr.cpp Mon Sep 13 09:53:09 2021 -0400 +++ b/src/p_pspr.cpp Mon Sep 13 10:35:03 2021 -0400 @@ -591,8 +591,8 @@ if ((paused == false) && (P_CheckTickerPaused() == false)) { fixed_t nswaypos[2]; - nswaypos[0] = FLOAT2FIXED(static_cast(player->cmd.ucmd.yaw) / 128.0f / cl_swayspeed); - nswaypos[1] = FLOAT2FIXED(static_cast(player->cmd.ucmd.pitch) / 128.0f / cl_swayspeed); + nswaypos[0] = FLOAT2FIXED(FIXED2FLOAT(player->mo->AngleDelta) * cl_swayspeed / 128.0f); + nswaypos[1] = FLOAT2FIXED(FIXED2FLOAT(player->mo->PitchDelta) * cl_swayspeed / 128.0f); for (int i = 0; i <= 1; i++) { diff -r 96ae55abf5e2 -r 3e1cc88ef495 src/p_user.cpp --- a/src/p_user.cpp Mon Sep 13 09:53:09 2021 -0400 +++ b/src/p_user.cpp Mon Sep 13 10:35:03 2021 -0400 @@ -2840,6 +2840,9 @@ // [Leo] cl_spectatormove is now applied here to avoid code duplication. fixed_t spectatormove = FLOAT2FIXED(cl_spectatormove); + // [AK] Save the player's angle before we update it. + fixed_t oldAngle = mo->angle; + // [RH] 180-degree turn overrides all other yaws if (player->turnticks) { @@ -2851,6 +2854,9 @@ mo->angle += cmd->ucmd.yaw << 16; } + // [AK] Calculate how much the player's angle changed. + mo->AngleDelta = mo->angle - oldAngle; + // [TP] Allow spectators to move freely even if the game is suspended. if ( GAME_GetEndLevelDelay( ) && ( player->bSpectating == false )) memset( cmd, 0, sizeof( ticcmd_t )); @@ -3664,6 +3670,9 @@ player->mo->MorphPlayerThink (); } + // [AK] Save the player's pitch before we update it. + fixed_t oldPlayerPitch = player->mo->pitch; + // [Leo] Spectators shouldn't be limited by the server settings. // [RH] Look up/down stuff if (!level.IsFreelookAllowed() && player->bSpectating == false) @@ -3732,6 +3741,9 @@ } } + // [AK] Calculate how much the player's pitch changed. + player->mo->PitchDelta = player->mo->pitch - oldPlayerPitch; + // [RH] Check for fast turn around if (cmd->ucmd.buttons & BT_TURN180 && !(player->oldbuttons & BT_TURN180)) {