From 584f09ec624a3e422e75a24084861cd9c938acc3 Mon Sep 17 00:00:00 2001 From: Alaux <73968015+MrAlaux@users.noreply.github.com> Date: Mon, 26 Feb 2024 15:56:37 -0300 Subject: [PATCH] View/weapon bobbing percentages (#1535) * Move bobbing thermos to "Weapons" * Switch "Cosmetic"/"Preferences" pages in "Weapons" --------- Co-authored-by: Roman Fomin --- src/d_player.h | 3 --- src/doomstat.c | 3 ++- src/doomstat.h | 3 ++- src/m_menu.c | 62 ++++++++++++++++++++++++++------------------------ src/m_misc.c | 21 +++++++++++------ src/p_pspr.c | 9 ++++---- src/p_saveg.c | 1 - src/p_user.c | 10 +++----- 8 files changed, 57 insertions(+), 55 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index d7723f96..570048df 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -205,9 +205,6 @@ typedef struct player_s // [crispy] weapon recoil pitch fixed_t recoilpitch, oldrecoilpitch; - // [crispy] variable player view bob - fixed_t bob2; - weapswitch_t switching; // DSDA UV Max category requirements diff --git a/src/doomstat.c b/src/doomstat.c index 4e9e0f93..de5fd24c 100644 --- a/src/doomstat.c +++ b/src/doomstat.c @@ -120,7 +120,8 @@ boolean hide_weapon; // [FG] centered weapon sprite int center_weapon; -int cosmetic_bobbing; +int view_bobbing_pct; +int weapon_bobbing_pct; char *MAPNAME(int e, int m) { diff --git a/src/doomstat.h b/src/doomstat.h index 448d6671..6a74049c 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -439,7 +439,8 @@ extern boolean hide_weapon; // [FG] centered weapon sprite extern int center_weapon; -extern int cosmetic_bobbing; +extern int view_bobbing_pct; +extern int weapon_bobbing_pct; // Doom-style printf diff --git a/src/m_menu.c b/src/m_menu.c index db69d7b4..1f61427f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1996,7 +1996,6 @@ enum str_layout, str_curve, str_center_weapon, - str_bobfactor, str_screensize, str_hudtype, str_hudmode, @@ -2022,6 +2021,7 @@ enum str_death_use_action, str_menu_backdrop, str_widescreen, + str_bobbing_pct, }; static const char **GetStrings(int id); @@ -3087,8 +3087,8 @@ static setup_menu_t* weap_settings[] = static setup_tab_t weap_tabs[] = { - { "preferences", weap_settings1 }, - { "cosmetic", weap_settings2 }, + { "cosmetic", weap_settings1 }, + { "preferences", weap_settings2 }, { NULL } }; @@ -3097,16 +3097,37 @@ static const char *center_weapon_strings[] = { "Off", "Centered", "Bobbing" }; -static const char *bobfactor_strings[] = { - "Off", "Full", "75%" -}; - static void M_UpdateCenteredWeaponItem(void) { - DisableItem(!cosmetic_bobbing, weap_settings2, "center_weapon"); + DisableItem(!weapon_bobbing_pct, weap_settings1, "center_weapon"); } -setup_menu_t weap_settings1[] = // Weapons Settings screen +static const char *bobbing_pct_strings[] = { + "0%", "25%", "50%", "75%", "100%" +}; + +setup_menu_t weap_settings1[] = +{ + {"View Bob", S_THERMO|S_THRM_SIZE4, m_null, M_X_THRM4, M_Y, + {"view_bobbing_pct"}, 0, NULL, str_bobbing_pct}, + + {"Weapon Bob", S_THERMO|S_THRM_SIZE4, m_null, M_X_THRM4, M_THRM_SPC, + {"weapon_bobbing_pct"}, 0, M_UpdateCenteredWeaponItem, str_bobbing_pct}, + + // [FG] centered or bobbing weapon sprite + {"Weapon Alignment", S_CHOICE|S_STRICT, m_null, M_X, M_THRM_SPC, + {"center_weapon"}, 0, NULL, str_center_weapon}, + + {"Hide Weapon", S_ONOFF|S_STRICT, m_null, M_X, M_SPC, {"hide_weapon"}}, + + {"Weapon Recoil", S_ONOFF, m_null, M_X, M_SPC, {"weapon_recoilpitch"}}, + + MI_RESET, + + MI_END +}; + +setup_menu_t weap_settings2[] = // Weapons Settings screen { {"1St Choice Weapon", S_WEAP|S_BOOM, m_null, M_X, M_Y, {"weapon_choice_1"}}, {"2Nd Choice Weapon", S_WEAP|S_BOOM, m_null, M_X, M_SPC, {"weapon_choice_2"}}, @@ -3128,25 +3149,6 @@ setup_menu_t weap_settings1[] = // Weapons Settings screen {"Pre-Beta BFG", S_ONOFF, m_null, M_X, // killough 8/8/98 M_SPC, {"classic_bfg"}}, - // Button for resetting to defaults - MI_RESET, - - MI_END -}; - -setup_menu_t weap_settings2[] = -{ - {"View/Weapon Bobbing", S_CHOICE, m_null, M_X, M_Y, - {"cosmetic_bobbing"}, 0, M_UpdateCenteredWeaponItem, str_bobfactor}, - - {"Hide Weapon", S_ONOFF|S_STRICT, m_null, M_X, M_SPC, {"hide_weapon"}}, - - // [FG] centered or bobbing weapon sprite - {"Weapon Alignment", S_CHOICE|S_STRICT, m_null, M_X, M_SPC, - {"center_weapon"}, 0, NULL, str_center_weapon}, - - {"Weapon Recoil", S_ONOFF, m_null, M_X, M_SPC, {"weapon_recoilpitch"}}, - MI_END }; @@ -4243,7 +4245,7 @@ setup_menu_t gen_settings6[] = { {"Organize save files", S_ONOFF|S_PRGWARN, m_null, M_X, M_THRM_SPC, {"organize_savefiles"}}, - {"", S_SKIP, m_null, M_X, M_SPC}, + {"", S_SKIP, m_null, M_X, M_THRM_SPC}, {"Miscellaneous", S_SKIP|S_TITLE, m_null, M_X, M_SPC}, @@ -6877,7 +6879,6 @@ static const char **selectstrings[] = { layout_strings, curve_strings, center_weapon_strings, - bobfactor_strings, screensize_strings, hudtype_strings, NULL, // str_hudmode @@ -6899,6 +6900,7 @@ static const char **selectstrings[] = { death_use_action_strings, menu_backdrop_strings, widescreen_strings, + bobbing_pct_strings, }; static const char **GetStrings(int id) diff --git a/src/m_misc.c b/src/m_misc.c index f783df42..1a91a205 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -709,13 +709,6 @@ default_t defaults[] = { "1 to enable player bobbing (view moving up/down slightly)" }, - { - "cosmetic_bobbing", - (config_t *) &cosmetic_bobbing, NULL, - {1}, {0,2}, number, ss_weap, wad_no, - "Player View/Weapon Bobbing (0 = off, 1 = full, 2 = 75%)" - }, - { "hide_weapon", (config_t *) &hide_weapon, NULL, @@ -723,6 +716,20 @@ default_t defaults[] = { "1 to hide weapon" }, + { + "view_bobbing_pct", + (config_t *) &view_bobbing_pct, NULL, + {4}, {0,4}, number, ss_weap, wad_no, + "Player View Bobbing (0 - 0%, 1 - 25% ... 4 - 100%)" + }, + + { + "weapon_bobbing_pct", + (config_t *) &weapon_bobbing_pct, NULL, + {4}, {0,4}, number, ss_weap, wad_no, + "Player Weapon Bobbing (0 - 0%, 1 - 25% ... 4 - 100%)" + }, + // [FG] centered or bobbing weapon sprite { "center_weapon", diff --git a/src/p_pspr.c b/src/p_pspr.c index 20d0dc20..4214b89a 100644 --- a/src/p_pspr.c +++ b/src/p_pspr.c @@ -1089,8 +1089,6 @@ void P_SetupPsprites(player_t *player) // Called every tic by player thinking routine. // -#define BOBBING_75 2 - #define WEAPON_CENTERED 1 #define WEAPON_BOBBING 2 @@ -1118,7 +1116,7 @@ void P_MovePsprites(player_t *player) if (psp->state) { - if (!cosmetic_bobbing) + if (!weapon_bobbing_pct) { static fixed_t last_sy = WEAPONTOP; @@ -1135,7 +1133,7 @@ void P_MovePsprites(player_t *player) psp->sy2 -= (last_sy - WEAPONTOP); } } - else if (cosmetic_bobbing == BOBBING_75 || center_weapon_strict || uncapped) + else if (center_weapon_strict || uncapped) { // [FG] don't center during lowering and raising states if (psp->state->misc1 || player->switching) @@ -1144,7 +1142,8 @@ void P_MovePsprites(player_t *player) // [FG] not attacking means idle else if (!player->attackdown || center_weapon_strict == WEAPON_BOBBING) { - P_ApplyBobbing(&psp->sx2, &psp->sy2, player->bob2); + fixed_t bob = player->bob * weapon_bobbing_pct / 4; + P_ApplyBobbing(&psp->sx2, &psp->sy2, bob); } // [FG] center the weapon sprite horizontally and push up vertically else if (center_weapon_strict == WEAPON_CENTERED) diff --git a/src/p_saveg.c b/src/p_saveg.c index f0dba018..2b8fec4e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -826,7 +826,6 @@ static void saveg_read_player_t(player_t *str) // fixed_t bob; str->bob = saveg_read32(); - str->bob2 = str->bob; // fixed_t momx; str->momx = saveg_read32(); diff --git a/src/p_user.c b/src/p_user.c index e6abd448..a80a3340 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -105,9 +105,6 @@ void P_Bob(player_t *player, angle_t angle, fixed_t move) // Calculate the walking / running height adjustment // -// [crispy] variable player view bob -static const int bobfactors[3] = {0, 4, 3}; - void P_CalcHeight (player_t* player) { int angle; @@ -147,9 +144,6 @@ void P_CalcHeight (player_t* player) player->bob = MAXBOB; } - // [crispy] variable player view bob - player->bob2 = bobfactors[cosmetic_bobbing] * player->bob / 4; - if (!onground || player->cheats & CF_NOMOMENTUM) { player->viewz = player->mo->z + VIEWHEIGHT; @@ -168,7 +162,9 @@ void P_CalcHeight (player_t* player) } angle = (FINEANGLES/20*leveltime)&FINEMASK; - bob = FixedMul(player->bob2/2,finesine[angle]); + + bob = player->bob * view_bobbing_pct / 4; + bob = FixedMul(bob/2,finesine[angle]); // move viewheight