summaryrefslogtreecommitdiffstats
path: root/src/esp.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-26 16:15:22 +0100
committersalmonik <salmonik@tuta.io>2026-10-26 16:15:22 +0100
commitea163c157bd30e4c54fa917ffe0465f5a6d1c663 (patch)
treeb7466203f533dadb04532df4ff2fade4cd90590b /src/esp.cpp
parentBones: refresh snapshots every frame (head marker no longer lags) (diff)
downloadhl2h-ea163c157bd30e4c54fa917ffe0465f5a6d1c663.tar.gz
hl2h-ea163c157bd30e4c54fa917ffe0465f5a6d1c663.zip
ESP: skeleton ESP
- render parent->child bone links from the SetupBones world matrices (ISurface DrawLine, projected once per bone) - menu option "Show skeleton" under ESP, persisted as skeleton=1 - skeletons use the same hostile/friendly/neutral colours as the boxes
Diffstat (limited to 'src/esp.cpp')
-rw-r--r--src/esp.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/esp.cpp b/src/esp.cpp
index 996a886..b75a7a9 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -11,7 +11,7 @@ static constexpr float PI_F = 3.14159265358979323846f;
11// ISurface slots (binary = SDK header + 4, disassembly-confirmed) 11// ISurface slots (binary = SDK header + 4, disassembly-confirmed)
12enum SurfSlot { 12enum SurfSlot {
13 SURF_DrawSetColor = 10, SURF_FilledRect = 12, SURF_OutlinedRect = 14, 13 SURF_DrawSetColor = 10, SURF_FilledRect = 12, SURF_OutlinedRect = 14,
14 SURF_GetScreenSize = 38, 14 SURF_DrawLine = 15, SURF_GetScreenSize = 38,
15}; 15};
16 16
17enum { LIFE_ALIVE = 0 }; 17enum { LIFE_ALIVE = 0 };
@@ -271,6 +271,37 @@ static void surf_color(int r, int g, int b, int a) {
271 using Fn = void (*)(void *, int, int, int, int); 271 using Fn = void (*)(void *, int, int, int, int);
272 vfunc<Fn>(g_surface, SURF_DrawSetColor)(g_surface, r, g, b, a); 272 vfunc<Fn>(g_surface, SURF_DrawSetColor)(g_surface, r, g, b, a);
273} 273}
274static void surf_line(int x0, int y0, int x1, int y1) {
275 using Fn = void (*)(void *, int, int, int, int);
276 vfunc<Fn>(g_surface, SURF_DrawLine)(g_surface, x0, y0, x1, y1);
277}
278
279// Draw the parent->child bone links. Bone snapshots are world-space matrices
280// from SetupBones; project each bone once and reuse for both endpoints.
281static void draw_skeleton(const EspTarget &t) {
282 int n = bones_count(t.idx);
283 if (n <= 0 || n > 256)
284 return;
285 Vector wp[256];
286 float xs[256], ys[256];
287 bool ok[256];
288 for (int i = 0; i < n; i++) {
289 ok[i] = bone_pos(t.idx, i, wp[i]) &&
290 world_to_screen(wp[i], xs[i], ys[i]) && std::isfinite(xs[i]) &&
291 std::isfinite(ys[i]);
292 }
293 if (t.friendly)
294 surf_color(60, 255, 60, 255);
295 else if (t.neutral)
296 surf_color(220, 220, 220, 255);
297 else
298 surf_color(255, 60, 60, 255);
299 for (int i = 0; i < n; i++) {
300 int p = bone_parent(t.idx, i);
301 if (p >= 0 && p < n && ok[i] && ok[p])
302 surf_line((int)xs[p], (int)ys[p], (int)xs[i], (int)ys[i]);
303 }
304}
274 305
275void esp_draw() { 306void esp_draw() {
276 if (!g_surface || !g_iface.entitylist || !g_net.esp_ok()) return; 307 if (!g_surface || !g_iface.entitylist || !g_net.esp_ok()) return;
@@ -285,6 +316,11 @@ void esp_draw() {
285 const EspTarget &t = g_targets[i]; 316 const EspTarget &t = g_targets[i];
286 if (t.neutral && !esp_option(ESP_OPT_SHOW_NEUTRAL)) 317 if (t.neutral && !esp_option(ESP_OPT_SHOW_NEUTRAL))
287 continue; 318 continue;
319 if (esp_option(ESP_OPT_SHOW_SKELETON)) {
320 void *ent = entitylist_get(t.idx);
321 if (ent && bones_update(t.idx, ent))
322 draw_skeleton(t);
323 }
288 if (t.friendly) surf_color(60, 255, 60, 255); 324 if (t.friendly) surf_color(60, 255, 60, 255);
289 else if (t.neutral) surf_color(220, 220, 220, 255); 325 else if (t.neutral) surf_color(220, 220, 220, 255);
290 else surf_color(255, 60, 60, 255); 326 else surf_color(255, 60, 60, 255);