diff options
Diffstat (limited to 'src/esp.cpp')
| -rw-r--r-- | src/esp.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/esp.cpp b/src/esp.cpp index 2987508..fbeb234 100644 --- a/src/esp.cpp +++ b/src/esp.cpp | |||
| @@ -337,6 +337,9 @@ static QAngle angle_to(const Vector &from, const Vector &to) { | |||
| 337 | bool aimbot_apply(CUserCmd *cmd) { | 337 | bool aimbot_apply(CUserCmd *cmd) { |
| 338 | if (!g_iface.entitylist || g_net.origin < 0 || g_net.maxs < 0) | 338 | if (!g_iface.entitylist || g_net.origin < 0 || g_net.maxs < 0) |
| 339 | return false; | 339 | return false; |
| 340 | unsigned bone_mask = aimbot_bone_mask(); | ||
| 341 | if (!bone_mask) | ||
| 342 | return false; | ||
| 340 | int local = engine_get_local_player(); | 343 | int local = engine_get_local_player(); |
| 341 | if (local <= 0) | 344 | if (local <= 0) |
| 342 | return false; | 345 | return false; |
| @@ -388,7 +391,8 @@ bool aimbot_apply(CUserCmd *cmd) { | |||
| 388 | Vector origin{*(float *)(e + g_net.origin), | 391 | Vector origin{*(float *)(e + g_net.origin), |
| 389 | *(float *)(e + g_net.origin + 4), | 392 | *(float *)(e + g_net.origin + 4), |
| 390 | *(float *)(e + g_net.origin + 8)}; | 393 | *(float *)(e + g_net.origin + 8)}; |
| 391 | Vector approx{origin.x, origin.y, origin.z + maxz * 0.9f}; | 394 | Vector approx{origin.x, origin.y, |
| 395 | origin.z + maxz * ((bone_mask & (1u << 1)) ? 0.9f : 0.55f)}; | ||
| 392 | float fov = getfov(view, angle_to(g_cam_eye, approx)); | 396 | float fov = getfov(view, angle_to(g_cam_eye, approx)); |
| 393 | if (fov >= best_fov) | 397 | if (fov >= best_fov) |
| 394 | continue; | 398 | continue; |
| @@ -416,24 +420,33 @@ bool aimbot_apply(CUserCmd *cmd) { | |||
| 416 | best_head.x, best_head.y, best_head.z); | 420 | best_head.x, best_head.y, best_head.z); |
| 417 | } | 421 | } |
| 418 | 422 | ||
| 419 | // Refine to the actual head hitbox/bone for the chosen target only. | 423 | // Refine to the nearest selected hitbox/bone point on the chosen target. |
| 420 | bool exact_head = false; | 424 | Vector pts[32]; |
| 425 | int npoints = 0; | ||
| 421 | void *best_ent = entitylist_get(best_idx); | 426 | void *best_ent = entitylist_get(best_idx); |
| 422 | if (best_ent && bones_update(best_idx, best_ent)) { | 427 | if (best_ent && bones_update(best_idx, best_ent)) |
| 423 | Vector head; | 428 | npoints = aim_points(best_idx, bone_mask, pts, 32); |
| 424 | if (head_position(best_idx, head) && | 429 | if (npoints <= 0) |
| 425 | getfov(view, angle_to(g_cam_eye, head)) <= MAX_FOV) { | 430 | return false; |
| 426 | best_head = head; | 431 | float aim_fov = 1e9f; |
| 427 | exact_head = true; | 432 | Vector aim_pt{}; |
| 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; | ||
| 437 | aim_pt = pts[i]; | ||
| 428 | } | 438 | } |
| 429 | } | 439 | } |
| 440 | if (aim_fov > MAX_FOV) | ||
| 441 | return false; | ||
| 442 | best_head = aim_pt; | ||
| 430 | 443 | ||
| 431 | QAngle desired = angle_to(g_cam_eye, best_head); | 444 | QAngle desired = angle_to(g_cam_eye, best_head); |
| 432 | static int want_logs = 0; | 445 | static int want_logs = 0; |
| 433 | if (want_logs < 10) { | 446 | if (want_logs < 10) { |
| 434 | want_logs++; | 447 | want_logs++; |
| 435 | logf("aimbot: head=(%.1f %.1f %.1f) exact=%d want=%.2f/%.2f", | 448 | logf("aimbot: aim=(%.1f %.1f %.1f) points=%d fov=%.2f want=%.2f/%.2f", |
| 436 | best_head.x, best_head.y, best_head.z, (int)exact_head, desired.x, | 449 | best_head.x, best_head.y, best_head.z, npoints, aim_fov, desired.x, |
| 437 | desired.y); | 450 | desired.y); |
| 438 | } | 451 | } |
| 439 | float dp = desired.x - cmd->viewangles[0]; | 452 | float dp = desired.x - cmd->viewangles[0]; |
| @@ -442,12 +455,13 @@ bool aimbot_apply(CUserCmd *cmd) { | |||
| 442 | while (dy < -180.0f) dy += 360.0f; | 455 | while (dy < -180.0f) dy += 360.0f; |
| 443 | 456 | ||
| 444 | constexpr float DEADZONE = 0.05f; | 457 | constexpr float DEADZONE = 0.05f; |
| 445 | constexpr float MAX_STEP = 5.0f; | 458 | float max_step = (float)aimbot_smooth_step(); |
| 459 | if (max_step < 1.0f) max_step = 1.0f; | ||
| 446 | float maxd = fmaxf(fabsf(dp), fabsf(dy)); | 460 | float maxd = fmaxf(fabsf(dp), fabsf(dy)); |
| 447 | if (maxd <= DEADZONE) | 461 | if (maxd <= DEADZONE) |
| 448 | return false; | 462 | return false; |
| 449 | 463 | ||
| 450 | float scale = (maxd > MAX_STEP) ? (MAX_STEP / maxd) : 1.0f; | 464 | float scale = (maxd > max_step) ? (max_step / maxd) : 1.0f; |
| 451 | float old_pitch = cmd->viewangles[0]; | 465 | float old_pitch = cmd->viewangles[0]; |
| 452 | float old_yaw = cmd->viewangles[1]; | 466 | float old_yaw = cmd->viewangles[1]; |
| 453 | float np = cmd->viewangles[0] + dp * scale; | 467 | float np = cmd->viewangles[0] + dp * scale; |
