From 0fdb740ac76ef991b4094d8bd5def620c9a5ab41 Mon Sep 17 00:00:00 2001 From: CandiceJoy Date: Fri, 16 Dec 2022 17:12:03 -0600 Subject: [PATCH] Added toggle control for weapon bob while flying --- src/d_netinfo.cpp | 2 ++ src/namedef_custom.h | 1 + src/playsim/d_player.h | 4 ++++ src/playsim/p_acs.cpp | 2 ++ src/playsim/p_mobj.cpp | 5 ++++- src/playsim/p_user.cpp | 6 ++++++ wadsrc/static/language.csv | 1 + wadsrc/static/menudef.txt | 1 + wadsrc/static/zscript/actors/player/player.zs | 8 +++++++- 9 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/d_netinfo.cpp b/src/d_netinfo.cpp index 6c31fbe736..8dc10fa11d 100644 --- a/src/d_netinfo.cpp +++ b/src/d_netinfo.cpp @@ -63,6 +63,7 @@ CVAR (Int, team, TEAM_NONE, CVAR_USERINFO | CVAR_ARCHIVE); CVAR (String, gender, "male", CVAR_USERINFO | CVAR_ARCHIVE); CVAR (Bool, neverswitchonpickup, false, CVAR_USERINFO | CVAR_ARCHIVE); CVAR (Float, movebob, 0.25f, CVAR_USERINFO | CVAR_ARCHIVE); +CVAR (Bool, fviewbob, true, CVAR_USERINFO | CVAR_ARCHIVE); CVAR (Float, stillbob, 0.f, CVAR_USERINFO | CVAR_ARCHIVE); CVAR (Float, wbobspeed, 1.f, CVAR_USERINFO | CVAR_ARCHIVE); CVAR (Float, wbobfire, 0.f, CVAR_USERINFO | CVAR_ARCHIVE); @@ -80,6 +81,7 @@ enum INFO_Gender, INFO_NeverSwitchOnPickup, INFO_MoveBob, + INFO_FViewBob, INFO_StillBob, INFO_WBobSpeed, INFO_WBobFire, diff --git a/src/namedef_custom.h b/src/namedef_custom.h index e55d5cb079..e6f6c6e9d6 100644 --- a/src/namedef_custom.h +++ b/src/namedef_custom.h @@ -450,6 +450,7 @@ xx(Playermenu) xx(ColorSet) xx(NeverSwitchOnPickup) xx(MoveBob) +xx(FViewBob) xx(StillBob) xx(ClassicFlight) xx(WBobSpeed) diff --git a/src/playsim/d_player.h b/src/playsim/d_player.h index 5497480706..5363a36876 100644 --- a/src/playsim/d_player.h +++ b/src/playsim/d_player.h @@ -226,6 +226,10 @@ struct userinfo_t : TMap { return *static_cast(*CheckKey(NAME_MoveBob)); } + double GetFViewBob() const + { + return *static_cast(*CheckKey(NAME_FViewBob)); + } double GetStillBob() const { return *static_cast(*CheckKey(NAME_StillBob)); diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index 01def47586..8d3873386b 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -531,6 +531,7 @@ PLAYERINFO_GENDER, PLAYERINFO_NEVERSWITCH, PLAYERINFO_MOVEBOB, + PLAYERINFO_FVIEWBOB, PLAYERINFO_STILLBOB, PLAYERINFO_PLAYERCLASS, PLAYERINFO_FOV, @@ -9954,6 +9955,7 @@ scriptwait: case PLAYERINFO_GENDER: STACK(2) = userinfo->GetGender(); break; case PLAYERINFO_NEVERSWITCH: STACK(2) = userinfo->GetNeverSwitch(); break; case PLAYERINFO_MOVEBOB: STACK(2) = DoubleToACS(userinfo->GetMoveBob()); break; + case PLAYERINFO_FVIEWBOB: STACK(2) = DoubleToACS(userinfo->GetFViewBob()); break; case PLAYERINFO_STILLBOB: STACK(2) = DoubleToACS(userinfo->GetStillBob()); break; case PLAYERINFO_PLAYERCLASS: STACK(2) = userinfo->GetPlayerClassNum(); break; case PLAYERINFO_DESIREDFOV: STACK(2) = (int)pl->DesiredFOV; break; diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index bcc825e0da..6908a9b95e 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -2410,7 +2410,10 @@ static void P_ZMovement (AActor *mo, double oldfloorz) } if (mo->player && (mo->flags & MF_NOGRAVITY) && (mo->Z() > mo->floorz)) { - if (!mo->IsNoClip2()) + FBaseCVar* const fViewBobCvar = G_GetUserCVar(int(mo->player - players),"FViewBob"); + bool const fViewBob = fViewBobCvar->GetGenericRep(fViewBobCvar->GetRealType()).Bool; + + if (!mo->IsNoClip2() && fViewBob) { mo->AddZ(DAngle::fromDeg(360 / 80.f * mo->Level->maptime).Sin() / 8); } diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index 0fa33a90ef..8f5e7e5a12 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -796,6 +796,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetMoveBob) ACTION_RETURN_FLOAT(self->userinfo.GetMoveBob()); } +DEFINE_ACTION_FUNCTION(_PlayerInfo, GetFViewBob) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_t); + ACTION_RETURN_BOOL(self->userinfo.GetFViewBob()); +} + DEFINE_ACTION_FUNCTION(_PlayerInfo, GetStillBob) { PARAM_SELF_STRUCT_PROLOGUE(player_t); diff --git a/wadsrc/static/language.csv b/wadsrc/static/language.csv index 18e6a6d8fa..5026999c0f 100644 --- a/wadsrc/static/language.csv +++ b/wadsrc/static/language.csv @@ -2762,6 +2762,7 @@ Interpolate monster movement,DSPLYMNU_NOMONSTERINTERPOLATION,,,,Interpolovat poh Menu dim,DSPLYMNU_MENUDIM,,,,Síla barvy pozadí v menu,Menüabdunklung,,Menuo-malheleco,Atenuación del menú,,Valikon himmennys,Assombrissement menu,Menü homályosítása,Offuscamento menu,メニュー背景,메뉴 배경색 강도,Donkere menuachtergrond,Mgła w menu,Atenuação do menu,,Întunecare meniu,Затемнение фона меню,Пригушивање менија Dim color,DSPLYMNU_DIMCOLOR,,,Dim colour,Barva pozadí v menu,Abdunklungsfarbe,,Malheleca koloro,Color de la atenuación,,Himmennysväri,Couleur de l'assombrissement,Homályosítás színe,Colore offuscamento,背景色,배경색 설정,Donkere kleur,Kolor mgły,Cor da atenuação,,Culoare întunecare,Цвет затемнения,Боја пригушивања View bob amount while moving,DSPLYMNU_MOVEBOB,,,,Pohupování pohledu při pohybu,Waffenpendeln beim Bewegen,,Vidi kvanton de kapo-balanciĝo dum movado,Cantidad de balanceo al moverse,,Aseen heilumisvoimakkuus liikkeessä,Chaloupage arme en movement,Fegyver mozgása lépés közben,Ammontare di bob di movimento,視点揺れする移動値,이동 시 화면 흔들림 강도,,Dygaj kiedy się ruszasz,Quantidade de balanço durante movimento,,Mișcare cameră în timpul deplasării,Покачивание камеры при движении,Тресење камере током кретања +View bobbing while flying,DSPLYMNU_FVIEWBOB,,,,,,,,,,,,,,,,,,,,,, View bob amount while not moving,DSPLYMNU_STILLBOB,,,,Pohupování pohledu v klidu,Waffenpendeln bei Nichtbewegen,,Vidi kvanton de kapo-balanciĝo dum ne movado,Cantidad de balanceo al no moverse,,Aseen heilumisvoimakkuus levossa,Chaloupage arme statique,Fegyver mozgása egy helyben,Ammontare di bob di movimento da fermo,視点揺れしない移動値,정지 시 화면 움직임 강도,,Dygaj kiedy się nie ruszasz,Quantidade de balanço parado,,Mișcare cameră în timpul staționării,Покачивание камеры при бездействии,Тресење камере током неактивности Weapon bob speed,DSPLYMNU_BOBSPEED,,,,Rychlost pohupování zbraně,Waffenpendelgeschwindigkeit,,Rapido de armilo-balanciĝo,Velocidad de balanceo de Arma,,Aseen heilumisnopeus,Vitesse du chaloupage,Fegyver mozgás sebesség,Velocità di bob dell'arma,武器揺れ速度,무기 흔들림 속도,Snelheid wapenzwaaieffect,Szybkość ruchu broni,Velocidade de balanço de arma,,Viteză mișcare arme,Скорость покачивания оружия,Брзина трсења оружја ,,Scaling,,,,,,,,,,,,,,,,,,,,, diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 8167ae5e40..57064bb061 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1053,6 +1053,7 @@ OptionMenu "HUDOptions" protected Option "$HUDMNU_OLDOUCH", "st_oldouch", "OnOff" StaticText " " Slider "$DSPLYMNU_MOVEBOB", "movebob", 0, 1.0, 0.05, 2 + Option "$DSPLYMNU_FVIEWBOB", "fviewbob", "OnOff" Slider "$DSPLYMNU_STILLBOB", "stillbob", 0, 1.0, 0.05, 2 Slider "$DSPLYMNU_BOBSPEED", "wbobspeed", 0, 2.0, 0.1 Slider "$DSPLYMNU_BOBFIRE", "wbobfire", 0, 1.0, 0.1 diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index ad7ffdd792..deb16ef20a 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -590,7 +590,11 @@ class PlayerPawn : Actor return; } - if (still) + if (bFly && !GetCVar("FViewBob")) + { + bob = 0; + } + else if (still) { if (player.health > 0) { @@ -638,6 +642,7 @@ class PlayerPawn : Actor bob = 0; } player.viewz = pos.Z + player.viewheight + (bob * clamp(ViewBob, 0. , 1.5)); // [SP] Allow DECORATE changes to view bobbing speed. + if (Floorclip && player.playerstate != PST_DEAD && pos.Z <= floorz) { @@ -2800,6 +2805,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native double GetWBobSpeed() const; native double GetWBobFire() const; native double GetMoveBob() const; + native bool GetFViewBob() const; native double GetStillBob() const; native void SetFOV(float fov); native clearscope bool GetClassicFlight() const;