diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-26 17:35:13 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-26 17:35:13 +0100 |
| commit | 849d205a3afb553eb49296393fad44671cc03494 (patch) | |
| tree | 6ae394857d7ba71f8a03e1a9ef7056e9d4557a6c /src/esp.cpp | |
| parent | Silent aim: exact usercmd angle + fire, restore rendered view (diff) | |
| download | hl2h-849d205a3afb553eb49296393fad44671cc03494.tar.gz hl2h-849d205a3afb553eb49296393fad44671cc03494.zip | |
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
Diffstat (limited to '')
| -rw-r--r-- | src/esp.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
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) { | |||
| 526 | return true; | 526 | return true; |
| 527 | } | 527 | } |
| 528 | 528 | ||
| 529 | // Keep the world-space movement wish direction unchanged when the usercmd | ||
| 530 | // view angles are temporarily replaced by the silent-aim angles. | ||
| 531 | static void preserve_movement(CUserCmd *cmd, float old_yaw, float new_yaw) { | ||
| 532 | float oy = old_yaw * PI_F / 180.0f; | ||
| 533 | float ay = new_yaw * PI_F / 180.0f; | ||
| 534 | float ofx = cosf(oy), ofy = sinf(oy); | ||
| 535 | float orx = sinf(oy), ory = -cosf(oy); | ||
| 536 | float afx = cosf(ay), afy = sinf(ay); | ||
| 537 | float arx = sinf(ay), ary = -cosf(ay); | ||
| 538 | float wx = ofx * cmd->forwardmove + orx * cmd->sidemove; | ||
| 539 | float wy = ofy * cmd->forwardmove + ory * cmd->sidemove; | ||
| 540 | cmd->forwardmove = wx * afx + wy * afy; | ||
| 541 | cmd->sidemove = wx * arx + wy * ary; | ||
| 542 | } | ||
| 543 | |||
| 529 | bool silent_aim_apply(CUserCmd *cmd) { | 544 | bool silent_aim_apply(CUserCmd *cmd) { |
| 530 | unsigned bone_mask = aimbot_bone_mask(); | 545 | unsigned bone_mask = aimbot_bone_mask(); |
| 531 | if (!bone_mask) | 546 | if (!bone_mask) |
| @@ -546,12 +561,15 @@ bool silent_aim_apply(CUserCmd *cmd) { | |||
| 546 | while (ny > 180.0f) ny -= 360.0f; | 561 | while (ny > 180.0f) ny -= 360.0f; |
| 547 | while (ny < -180.0f) ny += 360.0f; | 562 | while (ny < -180.0f) ny += 360.0f; |
| 548 | 563 | ||
| 564 | preserve_movement(cmd, orig.y, ny); | ||
| 565 | |||
| 549 | cmd->viewangles[0] = np; | 566 | cmd->viewangles[0] = np; |
| 550 | cmd->viewangles[1] = ny; | 567 | cmd->viewangles[1] = ny; |
| 551 | cmd->viewangles[2] = orig.z; | 568 | cmd->viewangles[2] = orig.z; |
| 552 | 569 | ||
| 553 | // The usercmd keeps the aim angles (shot/prediction); the rendered camera | 570 | // Restore now and again at FRAME_RENDER_START (after the engine consumed |
| 554 | // is restored to where the player was actually looking. | 571 | // the aimed usercmd); the frame-stage restore is the one that sticks. |
| 572 | set_silent_restore(orig); | ||
| 555 | if (g_iface.engine) { | 573 | if (g_iface.engine) { |
| 556 | QAngle restore{orig.x, orig.y, orig.z}; | 574 | QAngle restore{orig.x, orig.y, orig.z}; |
| 557 | using SetViewFn = void (*)(void *, QAngle *); | 575 | using SetViewFn = void (*)(void *, QAngle *); |
