summaryrefslogtreecommitdiffstats
path: root/src/esp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/esp.cpp')
-rw-r--r--src/esp.cpp22
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.
531static 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
529bool silent_aim_apply(CUserCmd *cmd) { 544bool 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 *);