From 849d205a3afb553eb49296393fad44671cc03494 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 26 Oct 2026 17:35:13 +0100 Subject: Silent aim: restore view at FRAME_RENDER_START; preserve movement - hook CHLClient::FrameStageNotify (vtable slot 35) and at FRAME_RENDER_START re-apply the player's original view angles after the engine has consumed the aimed usercmd; this fixes the slow pull with high-RPM weapons and the revolver leaving the view on the target - silent aim also rewrites forwardmove/sidemove so the world-space movement wish vector is unchanged by the temporary aim angles --- src/esp.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/esp.cpp') diff --git a/src/esp.cpp b/src/esp.cpp index f7c24ce..cd0ff36 100644 --- a/src/esp.cpp +++ b/src/esp.cpp @@ -526,6 +526,21 @@ bool aimbot_apply(CUserCmd *cmd) { return true; } +// Keep the world-space movement wish direction unchanged when the usercmd +// view angles are temporarily replaced by the silent-aim angles. +static void preserve_movement(CUserCmd *cmd, float old_yaw, float new_yaw) { + float oy = old_yaw * PI_F / 180.0f; + float ay = new_yaw * PI_F / 180.0f; + float ofx = cosf(oy), ofy = sinf(oy); + float orx = sinf(oy), ory = -cosf(oy); + float afx = cosf(ay), afy = sinf(ay); + float arx = sinf(ay), ary = -cosf(ay); + float wx = ofx * cmd->forwardmove + orx * cmd->sidemove; + float wy = ofy * cmd->forwardmove + ory * cmd->sidemove; + cmd->forwardmove = wx * afx + wy * afy; + cmd->sidemove = wx * arx + wy * ary; +} + bool silent_aim_apply(CUserCmd *cmd) { unsigned bone_mask = aimbot_bone_mask(); if (!bone_mask) @@ -546,12 +561,15 @@ bool silent_aim_apply(CUserCmd *cmd) { while (ny > 180.0f) ny -= 360.0f; while (ny < -180.0f) ny += 360.0f; + preserve_movement(cmd, orig.y, ny); + cmd->viewangles[0] = np; cmd->viewangles[1] = ny; cmd->viewangles[2] = orig.z; - // The usercmd keeps the aim angles (shot/prediction); the rendered camera - // is restored to where the player was actually looking. + // Restore now and again at FRAME_RENDER_START (after the engine consumed + // the aimed usercmd); the frame-stage restore is the one that sticks. + set_silent_restore(orig); if (g_iface.engine) { QAngle restore{orig.x, orig.y, orig.z}; using SetViewFn = void (*)(void *, QAngle *); -- cgit v1.2.3