summaryrefslogtreecommitdiffstats
path: root/src/esp.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-26 16:41:54 +0100
committersalmonik <salmonik@tuta.io>2026-10-26 16:42:19 +0100
commit4357a9dc269a2fb7297acaf9ba5ad1bb2a48c6dd (patch)
treecb1d0e878734926b717b8a9c683f353aaf3eed39 /src/esp.cpp
parentAimbot: head-only nearest-to-crosshair with bounded smoothing (diff)
downloadhl2h-4357a9dc269a2fb7297acaf9ba5ad1bb2a48c6dd.tar.gz
hl2h-4357a9dc269a2fb7297acaf9ba5ad1bb2a48c6dd.zip
Aimbot: push smoothed angles to engine view + diagnostics
Diffstat (limited to '')
-rw-r--r--src/esp.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/esp.cpp b/src/esp.cpp
index 1cb8b70..bd3fbdb 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -397,8 +397,24 @@ bool aimbot_apply(CUserCmd *cmd) {
397 best_head = approx; 397 best_head = approx;
398 } 398 }
399 399
400 if (best_idx < 0) 400 if (best_idx < 0) {
401 static double last_none = 0.0;
402 double now = esp_now();
403 if (now - last_none >= 2.0) {
404 last_none = now;
405 logf("aimbot: no hostile target within %.0f deg", MAX_FOV);
406 }
401 return false; 407 return false;
408 }
409
410 static int sel_logs = 0;
411 if (sel_logs < 5) {
412 sel_logs++;
413 logf("aimbot: target idx=%d fov=%.2f eye=(%.1f %.1f %.1f) "
414 "approx_head=(%.1f %.1f %.1f)",
415 best_idx, best_fov, g_cam_eye.x, g_cam_eye.y, g_cam_eye.z,
416 best_head.x, best_head.y, best_head.z);
417 }
402 418
403 // Refine to the actual head hitbox/bone for the chosen target only. 419 // Refine to the actual head hitbox/bone for the chosen target only.
404 void *best_ent = entitylist_get(best_idx); 420 void *best_ent = entitylist_get(best_idx);
@@ -422,6 +438,8 @@ bool aimbot_apply(CUserCmd *cmd) {
422 return false; 438 return false;
423 439
424 float scale = (maxd > MAX_STEP) ? (MAX_STEP / maxd) : 1.0f; 440 float scale = (maxd > MAX_STEP) ? (MAX_STEP / maxd) : 1.0f;
441 float old_pitch = cmd->viewangles[0];
442 float old_yaw = cmd->viewangles[1];
425 float np = cmd->viewangles[0] + dp * scale; 443 float np = cmd->viewangles[0] + dp * scale;
426 float ny = cmd->viewangles[1] + dy * scale; 444 float ny = cmd->viewangles[1] + dy * scale;
427 if (np > 89.0f) np = 89.0f; 445 if (np > 89.0f) np = 89.0f;
@@ -430,6 +448,21 @@ bool aimbot_apply(CUserCmd *cmd) {
430 while (ny < -180.0f) ny += 360.0f; 448 while (ny < -180.0f) ny += 360.0f;
431 cmd->viewangles[0] = np; 449 cmd->viewangles[0] = np;
432 cmd->viewangles[1] = ny; 450 cmd->viewangles[1] = ny;
451
452 // cmd->viewangles drives usercmd/prediction, but the rendered camera can
453 // stay on the pre-hook angles. Also push the smoothed angles into the
454 // engine's view (IVEngineClient013 slot 20 = SetViewAngles).
455 if (g_iface.engine) {
456 QAngle out{np, ny, 0.0f};
457 using SetViewFn = void (*)(void *, QAngle *);
458 vfunc<SetViewFn>(g_iface.engine, 20)(g_iface.engine, &out);
459 }
460
461 static int mod_logs = 0;
462 if (mod_logs < 10) {
463 mod_logs++;
464 logf("aimbot: view %.2f/%.2f -> %.2f/%.2f", old_pitch, old_yaw, np, ny);
465 }
433 return true; 466 return true;
434} 467}
435 468