diff options
| -rw-r--r-- | src/esp.cpp | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/src/esp.cpp b/src/esp.cpp index 945b234..c0edd2e 100644 --- a/src/esp.cpp +++ b/src/esp.cpp | |||
| @@ -276,6 +276,15 @@ static void surf_line(int x0, int y0, int x1, int y1) { | |||
| 276 | 276 | ||
| 277 | // Screen projection of the aimbot FOV cone boundary, using the engine's own | 277 | // Screen projection of the aimbot FOV cone boundary, using the engine's own |
| 278 | // world->screen transform so it follows the actual aspect/fov. | 278 | // world->screen transform so it follows the actual aspect/fov. |
| 279 | static QAngle engine_view_angles() { | ||
| 280 | QAngle v{g_cam_view.x, g_cam_view.y, g_cam_view.z}; | ||
| 281 | if (g_iface.engine) { | ||
| 282 | using Fn = void (*)(void *, QAngle *); | ||
| 283 | vfunc<Fn>(g_iface.engine, 19)(g_iface.engine, &v); | ||
| 284 | } | ||
| 285 | return v; | ||
| 286 | } | ||
| 287 | |||
| 279 | static void draw_fov_circle() { | 288 | static void draw_fov_circle() { |
| 280 | if (!aimbot_fov_circle()) | 289 | if (!aimbot_fov_circle()) |
| 281 | return; | 290 | return; |
| @@ -283,33 +292,43 @@ static void draw_fov_circle() { | |||
| 283 | if (fov < 1.0f || fov >= 89.0f) // beyond this the "circle" is behind the eye | 292 | if (fov < 1.0f || fov >= 89.0f) // beyond this the "circle" is behind the eye |
| 284 | return; | 293 | return; |
| 285 | float alpha = fov * PI_F / 180.0f; | 294 | float alpha = fov * PI_F / 180.0f; |
| 286 | float yaw = g_cam_view.y * PI_F / 180.0f; | 295 | QAngle view = engine_view_angles(); |
| 287 | float pitch = g_cam_view.x * PI_F / 180.0f; | 296 | float yaw = view.y * PI_F / 180.0f; |
| 297 | float pitch = view.x * PI_F / 180.0f; | ||
| 288 | Vector fwd{cosf(pitch) * cosf(yaw), cosf(pitch) * sinf(yaw), -sinf(pitch)}; | 298 | Vector fwd{cosf(pitch) * cosf(yaw), cosf(pitch) * sinf(yaw), -sinf(pitch)}; |
| 289 | Vector right{sinf(yaw), -cosf(yaw), 0.0f}; | 299 | Vector right{sinf(yaw), -cosf(yaw), 0.0f}; |
| 290 | Vector up{right.y * fwd.z - right.z * fwd.y, | 300 | Vector up{right.y * fwd.z - right.z * fwd.y, |
| 291 | right.z * fwd.x - right.x * fwd.z, | 301 | right.z * fwd.x - right.x * fwd.z, |
| 292 | right.x * fwd.y - right.y * fwd.x}; | 302 | right.x * fwd.y - right.y * fwd.x}; |
| 293 | constexpr int N = 48; | 303 | |
| 294 | float xs[N], ys[N]; | 304 | constexpr float D = 1024.0f; |
| 295 | bool ok[N]; | ||
| 296 | float ca = cosf(alpha), sa = sinf(alpha); | 305 | float ca = cosf(alpha), sa = sinf(alpha); |
| 297 | for (int i = 0; i < N; i++) { | 306 | Vector eh{g_cam_eye.x + (fwd.x * ca + right.x * sa) * D, |
| 298 | float phi = (2.0f * PI_F * i) / N; | 307 | g_cam_eye.y + (fwd.y * ca + right.y * sa) * D, |
| 299 | float cp = cosf(phi), sp = sinf(phi); | 308 | g_cam_eye.z + (fwd.z * ca + right.z * sa) * D}; |
| 300 | Vector d{fwd.x * ca + (right.x * cp + up.x * sp) * sa, | 309 | Vector ev{g_cam_eye.x + (fwd.x * ca + up.x * sa) * D, |
| 301 | fwd.y * ca + (right.y * cp + up.y * sp) * sa, | 310 | g_cam_eye.y + (fwd.y * ca + up.y * sa) * D, |
| 302 | fwd.z * ca + (right.z * cp + up.z * sp) * sa}; | 311 | g_cam_eye.z + (fwd.z * ca + up.z * sa) * D}; |
| 303 | Vector p{g_cam_eye.x + d.x * 1024.0f, g_cam_eye.y + d.y * 1024.0f, | 312 | float hsx, hsy, vsx, vsy; |
| 304 | g_cam_eye.z + d.z * 1024.0f}; | 313 | if (!world_to_screen(eh, hsx, hsy) || !world_to_screen(ev, vsx, vsy)) |
| 305 | ok[i] = world_to_screen(p, xs[i], ys[i]) && std::isfinite(xs[i]) && | 314 | return; |
| 306 | std::isfinite(ys[i]); | 315 | |
| 307 | } | 316 | float cx = (float)g_scr_w * 0.5f, cy = (float)g_scr_h * 0.5f; |
| 317 | float rx = fabsf(hsx - cx), ry = fabsf(vsy - cy); | ||
| 318 | if (!(rx > 1.0f && ry > 1.0f) || rx > 1e5f || ry > 1e5f) | ||
| 319 | return; | ||
| 320 | |||
| 321 | constexpr int N = 64; | ||
| 322 | int px = 0, py = 0; | ||
| 308 | surf_color(255, 255, 255, 160); | 323 | surf_color(255, 255, 255, 160); |
| 309 | for (int i = 0; i < N; i++) { | 324 | for (int i = 0; i <= N; i++) { |
| 310 | int j = (i + 1) % N; | 325 | float phi = (2.0f * PI_F * i) / N; |
| 311 | if (ok[i] && ok[j]) | 326 | int x = (int)(cx + rx * cosf(phi)); |
| 312 | surf_line((int)xs[i], (int)ys[i], (int)xs[j], (int)ys[j]); | 327 | int y = (int)(cy + ry * sinf(phi)); |
| 328 | if (i > 0) | ||
| 329 | surf_line(px, py, x, y); | ||
| 330 | px = x; | ||
| 331 | py = y; | ||
| 313 | } | 332 | } |
| 314 | } | 333 | } |
| 315 | 334 | ||
