diff options
Diffstat (limited to '')
| -rw-r--r-- | src/esp.cpp | 96 |
1 files changed, 61 insertions, 35 deletions
diff --git a/src/esp.cpp b/src/esp.cpp index 57f67ae..2c033ea 100644 --- a/src/esp.cpp +++ b/src/esp.cpp | |||
| @@ -358,9 +358,13 @@ bool aimbot_apply(CUserCmd *cmd) { | |||
| 358 | hi = 4096; | 358 | hi = 4096; |
| 359 | 359 | ||
| 360 | constexpr float MAX_FOV = 60.0f; // only things near the crosshair | 360 | constexpr float MAX_FOV = 60.0f; // only things near the crosshair |
| 361 | float best_fov = MAX_FOV; | 361 | struct Candidate { |
| 362 | int best_idx = -1; | 362 | int idx; |
| 363 | Vector best_head{}; | 363 | float fov; |
| 364 | Vector approx; | ||
| 365 | }; | ||
| 366 | Candidate cands[16]; | ||
| 367 | int ncands = 0; | ||
| 364 | 368 | ||
| 365 | for (int idx = 1; idx <= hi; idx++) { | 369 | for (int idx = 1; idx <= hi; idx++) { |
| 366 | if (idx == local) | 370 | if (idx == local) |
| @@ -394,14 +398,22 @@ bool aimbot_apply(CUserCmd *cmd) { | |||
| 394 | Vector approx{origin.x, origin.y, | 398 | Vector approx{origin.x, origin.y, |
| 395 | origin.z + maxz * ((bone_mask & (1u << 1)) ? 0.9f : 0.55f)}; | 399 | origin.z + maxz * ((bone_mask & (1u << 1)) ? 0.9f : 0.55f)}; |
| 396 | float fov = getfov(view, angle_to(g_cam_eye, approx)); | 400 | float fov = getfov(view, angle_to(g_cam_eye, approx)); |
| 397 | if (fov >= best_fov) | 401 | if (fov >= MAX_FOV) |
| 398 | continue; | 402 | continue; |
| 399 | best_fov = fov; | 403 | |
| 400 | best_idx = idx; | 404 | // keep candidates sorted by approximate angle, nearest first |
| 401 | best_head = approx; | 405 | int pos = ncands; |
| 406 | while (pos > 0 && cands[pos - 1].fov > fov) | ||
| 407 | pos--; | ||
| 408 | if (ncands < 16) | ||
| 409 | ncands++; | ||
| 410 | for (int j = ncands - 1; j > pos; j--) | ||
| 411 | cands[j] = cands[j - 1]; | ||
| 412 | if (pos < 16) | ||
| 413 | cands[pos] = {idx, fov, approx}; | ||
| 402 | } | 414 | } |
| 403 | 415 | ||
| 404 | if (best_idx < 0) { | 416 | if (ncands == 0) { |
| 405 | static double last_none = 0.0; | 417 | static double last_none = 0.0; |
| 406 | double now = esp_now(); | 418 | double now = esp_now(); |
| 407 | if (now - last_none >= 2.0) { | 419 | if (now - last_none >= 2.0) { |
| @@ -411,43 +423,57 @@ bool aimbot_apply(CUserCmd *cmd) { | |||
| 411 | return false; | 423 | return false; |
| 412 | } | 424 | } |
| 413 | 425 | ||
| 414 | static int sel_logs = 0; | 426 | // Walk targets nearest-first. On each, pick the nearest selected hitbox |
| 415 | if (sel_logs < 5) { | 427 | // point that passes vischeck; skip to the next target if all are blocked. |
| 416 | sel_logs++; | 428 | int best_idx = -1; |
| 417 | logf("aimbot: target idx=%d fov=%.2f eye=(%.1f %.1f %.1f) " | 429 | Vector best_head{}; |
| 418 | "approx_head=(%.1f %.1f %.1f)", | 430 | for (int ci = 0; ci < ncands && best_idx < 0; ci++) { |
| 419 | best_idx, best_fov, g_cam_eye.x, g_cam_eye.y, g_cam_eye.z, | 431 | int idx = cands[ci].idx; |
| 420 | best_head.x, best_head.y, best_head.z); | 432 | void *ent = entitylist_get(idx); |
| 421 | } | 433 | if (!ent || !bones_update(idx, ent)) |
| 422 | 434 | continue; | |
| 423 | // Refine to the nearest selected hitbox/bone point on the chosen target. | 435 | Vector pts[32]; |
| 424 | Vector pts[32]; | 436 | int npoints = aim_points(idx, bone_mask, pts, 32); |
| 425 | int npoints = 0; | 437 | float aim_fov = 1e9f; |
| 426 | void *best_ent = entitylist_get(best_idx); | 438 | Vector aim_pt{}; |
| 427 | if (best_ent && bones_update(best_idx, best_ent)) | 439 | for (int i = 0; i < npoints; i++) { |
| 428 | npoints = aim_points(best_idx, bone_mask, pts, 32); | 440 | float f = getfov(view, angle_to(g_cam_eye, pts[i])); |
| 429 | if (npoints <= 0) | 441 | if (f >= aim_fov) |
| 430 | return false; | 442 | continue; |
| 431 | float aim_fov = 1e9f; | 443 | if (aimbot_vischeck_enabled() && !is_visible(g_cam_eye, pts[i])) |
| 432 | Vector aim_pt{}; | 444 | continue; |
| 433 | for (int i = 0; i < npoints; i++) { | ||
| 434 | float f = getfov(view, angle_to(g_cam_eye, pts[i])); | ||
| 435 | if (f < aim_fov) { | ||
| 436 | aim_fov = f; | 445 | aim_fov = f; |
| 437 | aim_pt = pts[i]; | 446 | aim_pt = pts[i]; |
| 438 | } | 447 | } |
| 448 | if (aim_fov <= MAX_FOV && aim_fov < 1e8f) { | ||
| 449 | best_idx = idx; | ||
| 450 | best_head = aim_pt; | ||
| 451 | static int sel_logs = 0; | ||
| 452 | if (sel_logs < 5) { | ||
| 453 | sel_logs++; | ||
| 454 | logf("aimbot: target idx=%d points=%d fov=%.2f vischeck=%d", idx, | ||
| 455 | npoints, aim_fov, (int)aimbot_vischeck_enabled()); | ||
| 456 | } | ||
| 457 | } | ||
| 439 | } | 458 | } |
| 440 | if (aim_fov > MAX_FOV) | 459 | |
| 460 | if (best_idx < 0) { | ||
| 461 | static double last_vis = 0.0; | ||
| 462 | double now = esp_now(); | ||
| 463 | if (now - last_vis >= 2.0) { | ||
| 464 | last_vis = now; | ||
| 465 | logf("aimbot: no visible aim point (vischeck=%d)", | ||
| 466 | (int)aimbot_vischeck_enabled()); | ||
| 467 | } | ||
| 441 | return false; | 468 | return false; |
| 442 | best_head = aim_pt; | 469 | } |
| 443 | 470 | ||
| 444 | QAngle desired = angle_to(g_cam_eye, best_head); | 471 | QAngle desired = angle_to(g_cam_eye, best_head); |
| 445 | static int want_logs = 0; | 472 | static int want_logs = 0; |
| 446 | if (want_logs < 10) { | 473 | if (want_logs < 10) { |
| 447 | want_logs++; | 474 | want_logs++; |
| 448 | logf("aimbot: aim=(%.1f %.1f %.1f) points=%d fov=%.2f want=%.2f/%.2f", | 475 | logf("aimbot: aim=(%.1f %.1f %.1f) want=%.2f/%.2f", best_head.x, |
| 449 | best_head.x, best_head.y, best_head.z, npoints, aim_fov, desired.x, | 476 | best_head.y, best_head.z, desired.x, desired.y); |
| 450 | desired.y); | ||
| 451 | } | 477 | } |
| 452 | float dp = desired.x - cmd->viewangles[0]; | 478 | float dp = desired.x - cmd->viewangles[0]; |
| 453 | float dy = desired.y - cmd->viewangles[1]; | 479 | float dy = desired.y - cmd->viewangles[1]; |
