diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-26 16:04:18 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-26 16:04:18 +0100 |
| commit | 7101b7955071485a9bff33d55fc9f83f117b8f58 (patch) | |
| tree | 3351eca32146d6f88f740ff73da7c84045942a55 /src/esp.cpp | |
| parent | Menu: start fully collapsed on first open (diff) | |
| download | hl2h-7101b7955071485a9bff33d55fc9f83f117b8f58.tar.gz hl2h-7101b7955071485a9bff33d55fc9f83f117b8f58.zip | |
Bones: client-side SetupBones/studiohdr groundwork
- bones.cpp: resolve IClientRenderable via IClientUnknown slot 6, validate it
against IVModelInfo GetModel, call SetupBones (slot 16) with engine Time()
(slot 14), and parse the studio header (GetStudiomodel, slot 29) for
bones/bone names/parents and hitboxes
- cache up to 64 entity bone snapshots, refreshed at ~30 Hz
- helpers: bone_find/parent/pos, hitbox_center (e.g. "head")
- debug probe: HL2H_BONE_DEBUG=1 draws a white marker at each NPC's head
hitbox center and logs bone count/head position once
Diffstat (limited to '')
| -rw-r--r-- | src/esp.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/esp.cpp b/src/esp.cpp index 4462f07..b384bc4 100644 --- a/src/esp.cpp +++ b/src/esp.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <cmath> | 3 | #include <cmath> |
| 4 | #include <cstring> | 4 | #include <cstring> |
| 5 | #include <cstddef> | 5 | #include <cstddef> |
| 6 | #include <cstdlib> | ||
| 6 | #include <ctime> | 7 | #include <ctime> |
| 7 | 8 | ||
| 8 | static constexpr float PI_F = 3.14159265358979323846f; | 9 | static constexpr float PI_F = 3.14159265358979323846f; |
| @@ -16,6 +17,7 @@ enum SurfSlot { | |||
| 16 | enum { LIFE_ALIVE = 0 }; | 17 | enum { LIFE_ALIVE = 0 }; |
| 17 | 18 | ||
| 18 | struct EspTarget { | 19 | struct EspTarget { |
| 20 | int idx; | ||
| 19 | float sx, sy; // screen pos of feet | 21 | float sx, sy; // screen pos of feet |
| 20 | float h; // box height px | 22 | float h; // box height px |
| 21 | float health, maxhealth; | 23 | float health, maxhealth; |
| @@ -242,6 +244,7 @@ static void esp_collect(int local_idx) { | |||
| 242 | if (sx < -(float)g_scr_w || sx > 2.0f * (float)g_scr_w) continue; | 244 | if (sx < -(float)g_scr_w || sx > 2.0f * (float)g_scr_w) continue; |
| 243 | 245 | ||
| 244 | EspTarget &t = g_targets[g_ntargets++]; | 246 | EspTarget &t = g_targets[g_ntargets++]; |
| 247 | t.idx = idx; | ||
| 245 | t.sx = sx; t.sy = sy; t.h = h; | 248 | t.sx = sx; t.sy = sy; t.h = h; |
| 246 | t.health = hp > 0 ? (float)hp : 0.0f; | 249 | t.health = hp > 0 ? (float)hp : 0.0f; |
| 247 | t.maxhealth = maxhp > 0 ? (float)maxhp : 100.0f; | 250 | t.maxhealth = maxhp > 0 ? (float)maxhp : 100.0f; |
| @@ -319,4 +322,30 @@ void esp_draw() { | |||
| 319 | if (esp_option(ESP_OPT_SHOW_NAME)) | 322 | if (esp_option(ESP_OPT_SHOW_NAME)) |
| 320 | draw_text_col(left, top - 14, t.name, 255, 255, 255); | 323 | draw_text_col(left, top - 14, t.name, 255, 255, 255); |
| 321 | } | 324 | } |
| 325 | |||
| 326 | // Groundwork probe: HL2H_BONE_DEBUG=1 draws a white marker at each NPC's | ||
| 327 | // "head" hitbox center (from SetupBones + studio hitboxes). | ||
| 328 | static bool bone_debug = getenv("HL2H_BONE_DEBUG") != nullptr; | ||
| 329 | if (bone_debug) { | ||
| 330 | static bool head_logged = false; | ||
| 331 | for (int i = 0; i < g_ntargets; i++) { | ||
| 332 | const EspTarget &t = g_targets[i]; | ||
| 333 | void *ent = entitylist_get(t.idx); | ||
| 334 | if (!ent || !bones_update(t.idx, ent)) | ||
| 335 | continue; | ||
| 336 | Vector head; | ||
| 337 | if (!hitbox_center(t.idx, "head", head)) | ||
| 338 | continue; | ||
| 339 | float hx, hy; | ||
| 340 | if (!world_to_screen(head, hx, hy)) | ||
| 341 | continue; | ||
| 342 | surf_color(255, 255, 255, 255); | ||
| 343 | surf_rect(1, (int)hx - 2, (int)hy - 2, (int)hx + 3, (int)hy + 3); | ||
| 344 | if (!head_logged) { | ||
| 345 | head_logged = true; | ||
| 346 | logf("bone debug: idx=%d bones=%d head=(%.1f %.1f %.1f)", t.idx, | ||
| 347 | bones_count(t.idx), head.x, head.y, head.z); | ||
| 348 | } | ||
| 349 | } | ||
| 350 | } | ||
| 322 | } | 351 | } |
