From 33e2de70a210f6eac8c82840efd2beff775755eb Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 6 Nov 2022 21:34:07 +1100 Subject: [PATCH] - Duke: Pitch-adjusted velocity for `shootrpg()` when free-aiming. --- source/core/gamefuncs.h | 6 ++++++ source/games/duke/src/player_d.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 6b659a4bb..b1d531905 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -523,4 +523,10 @@ inline DAngle ClampViewPitch(const DAngle pitch) return clamp(pitch, GetMaxPitch(), GetMinPitch()); } +inline void setFreeAimVelocity(double& vel, double& zvel, const DAngle pitch, const double zvspeed) +{ + vel *= pitch.Cos(); + zvel = pitch.Sin() * zvspeed; +} + #include "updatesector.h" diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index b4ea750c7..0a6fc550f 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -683,7 +683,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw ang = (aimed->spr.pos.XY() - pos.XY()).Angle(); } else - zvel = ps[p].horizon.sum().Tan() * 40.5; + setFreeAimVelocity(vel, zvel, ps[p].horizon.sum(), 40.5); if (atwith == RPG) S_PlayActorSound(RPG_SHOOT, actor);