diff --git a/src/common/engine/namedef.h b/src/common/engine/namedef.h index 7c70e1867..02f4c6d7c 100644 --- a/src/common/engine/namedef.h +++ b/src/common/engine/namedef.h @@ -809,6 +809,7 @@ xx(MoveBob) xx(StillBob) xx(ClassicFlight) xx(WBobSpeed) +xx(WBobFire) xx(PlayerClass) xx(MonsterClass) xx(MorphedMonster) diff --git a/src/d_netinfo.cpp b/src/d_netinfo.cpp index 00ad7e62c..a68b1c3dc 100644 --- a/src/d_netinfo.cpp +++ b/src/d_netinfo.cpp @@ -65,6 +65,7 @@ CVAR (Bool, neverswitchonpickup, false, CVAR_USERINFO | CVAR_ARCHIVE); CVAR (Float, movebob, 0.25f, 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); CVAR (String, playerclass, "Fighter", CVAR_USERINFO | CVAR_ARCHIVE); CVAR (Bool, classicflight, false, CVAR_USERINFO | CVAR_ARCHIVE); @@ -80,6 +81,7 @@ enum INFO_MoveBob, INFO_StillBob, INFO_WBobSpeed, + INFO_WBobFire, INFO_PlayerClass, INFO_ColorSet, INFO_ClassicFlight, diff --git a/src/playsim/d_player.h b/src/playsim/d_player.h index 21b20c2ee..102b2e01a 100644 --- a/src/playsim/d_player.h +++ b/src/playsim/d_player.h @@ -232,6 +232,10 @@ struct userinfo_t : TMap { return *static_cast(*CheckKey(NAME_WBobSpeed)); } + double GetWBobFire() const + { + return *static_cast(*CheckKey(NAME_WBobFire)); + } int GetPlayerClassNum() const { return *static_cast(*CheckKey(NAME_PlayerClass)); diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index 47241679b..86bbfdb47 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -789,6 +789,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetWBobSpeed) ACTION_RETURN_FLOAT(self->userinfo.GetWBobSpeed()); } +DEFINE_ACTION_FUNCTION(_PlayerInfo, GetWBobFire) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_t); + ACTION_RETURN_FLOAT(self->userinfo.GetWBobFire()); +} + DEFINE_ACTION_FUNCTION(_PlayerInfo, GetMoveBob) { PARAM_SELF_STRUCT_PROLOGUE(player_t); diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 102d9ca11..da6b48d07 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1045,6 +1045,7 @@ OptionMenu "HUDOptions" protected Slider "$DSPLYMNU_MOVEBOB", "movebob", 0, 1.0, 0.05, 2 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 StaticText " " Slider "$DSPLYMNU_MENUDIM", "dimamount", 0, 1.0, 0.05, 2 ColorPicker "$DSPLYMNU_DIMCOLOR", "dimcolor" diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index 3a5727739..d47b09182 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -2301,8 +2301,6 @@ class PlayerPawn : Actor Vector2 p1, p2, r; Vector2 result; - float bobtarget; - let player = self.player; if (!player) return (0, 0); let weapon = player.ReadyWeapon; @@ -2326,17 +2324,16 @@ class PlayerPawn : Actor // [RH] Smooth transitions between bobbing and not-bobbing frames. // This also fixes the bug where you can "stick" a weapon off-center by // shooting it when it's at the peak of its swing. - bobtarget = double((player.WeaponState & WF_WEAPONBOBBING) ? player.bob : 0.); - if (curbob != bobtarget) + if (curbob != player.bob) { - if (abs(bobtarget - curbob) <= 1) + if (abs(player.bob - curbob) <= 1) { - curbob = bobtarget; + curbob = player.bob; } else { - double zoom = MAX(1., abs(curbob - bobtarget) / 40); - if (curbob > bobtarget) + double zoom = MAX(1., abs(curbob - player.bob) / 40); + if (curbob > player.bob) { curbob -= zoom; } @@ -2347,11 +2344,14 @@ class PlayerPawn : Actor } } + // The weapon bobbing intensity while firing can be adjusted by the player. + double BobIntensity = (player.WeaponState & WF_WEAPONBOBBING) ? 1. : player.GetWBobFire(); + if (curbob != 0) { //[SP] Added in decorate player.viewbob checks - double bobx = (player.bob * Rangex * ViewBob); - double boby = (player.bob * Rangey * ViewBob); + double bobx = (player.bob * BobIntensity * Rangex * ViewBob); + double boby = (player.bob * BobIntensity * Rangey * ViewBob); switch (bobstyle) { case Bob_Normal: @@ -2710,6 +2710,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native float GetAutoaim() const; native bool GetNoAutostartMap() const; native double GetWBobSpeed() const; + native double GetWBobFire() const; native double GetMoveBob() const; native double GetStillBob() const; native void SetFOV(float fov);