From d354d7332fdba73f094085c7fe962da175977739 Mon Sep 17 00:00:00 2001 From: jekyllgrim Date: Fri, 15 Sep 2023 22:58:35 +0300 Subject: [PATCH] Allow viewbob speed adjustment through properties This adds ViewBobSpeed to PlayerPawn that is passed in CalcHeight() instead of the value of 20 and can be adjusted with the Player.ViewBobSpeed variable. This will let modders dynamically adjust how to only how far the camera bobs up and down, but also how *quickly* it does that, which allows to easily convey a feeling of a heavy, slow-moving character whose view might bob a lot but would do it slowly. --- wadsrc/static/zscript/actors/player/player.zs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index e103bcd5f7..aca1c4bca1 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -48,6 +48,7 @@ class PlayerPawn : Actor color DamageFade; // [CW] Fades for when you are being damaged. double FlyBob; // [B] Fly bobbing mulitplier double ViewBob; // [SP] ViewBob Multiplier + double ViewBobSpeed; // [AA] ViewBob speed multiplier double WaterClimbSpeed; // [B] Speed when climbing up walls in water double FullHeight; double curBob; @@ -79,6 +80,7 @@ class PlayerPawn : Actor property TeleportFreezeTime: TeleportFreezeTime; property FlyBob: FlyBob; property ViewBob: ViewBob; + property ViewBobSpeed: ViewBobSpeed; property WaterClimbSpeed : WaterClimbSpeed; flagdef NoThrustWhenInvul: PlayerFlags, 0; @@ -128,6 +130,7 @@ class PlayerPawn : Actor Player.AirCapacity 1; Player.FlyBob 1; Player.ViewBob 1; + Player.ViewBobSpeed 20; Player.WaterClimbSpeed 3.5; Player.TeleportFreezeTime 18; Obituary "$OB_MPDEFAULT"; @@ -619,7 +622,7 @@ class PlayerPawn : Actor } else { - angle = Level.maptime / (20 * TICRATE / 35.) * 360.; + angle = Level.maptime / (ViewBobSpeed * TICRATE / 35.) * 360.; bob = player.bob * sin(angle) * (waterlevel > 1 ? 0.25f : 0.5f); }