From 7101b7955071485a9bff33d55fc9f83f117b8f58 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 26 Oct 2026 16:04:18 +0100 Subject: 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 --- src/esp.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/esp.cpp') 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 @@ #include #include #include +#include #include static constexpr float PI_F = 3.14159265358979323846f; @@ -16,6 +17,7 @@ enum SurfSlot { enum { LIFE_ALIVE = 0 }; struct EspTarget { + int idx; float sx, sy; // screen pos of feet float h; // box height px float health, maxhealth; @@ -242,6 +244,7 @@ static void esp_collect(int local_idx) { if (sx < -(float)g_scr_w || sx > 2.0f * (float)g_scr_w) continue; EspTarget &t = g_targets[g_ntargets++]; + t.idx = idx; t.sx = sx; t.sy = sy; t.h = h; t.health = hp > 0 ? (float)hp : 0.0f; t.maxhealth = maxhp > 0 ? (float)maxhp : 100.0f; @@ -319,4 +322,30 @@ void esp_draw() { if (esp_option(ESP_OPT_SHOW_NAME)) draw_text_col(left, top - 14, t.name, 255, 255, 255); } + + // Groundwork probe: HL2H_BONE_DEBUG=1 draws a white marker at each NPC's + // "head" hitbox center (from SetupBones + studio hitboxes). + static bool bone_debug = getenv("HL2H_BONE_DEBUG") != nullptr; + if (bone_debug) { + static bool head_logged = false; + for (int i = 0; i < g_ntargets; i++) { + const EspTarget &t = g_targets[i]; + void *ent = entitylist_get(t.idx); + if (!ent || !bones_update(t.idx, ent)) + continue; + Vector head; + if (!hitbox_center(t.idx, "head", head)) + continue; + float hx, hy; + if (!world_to_screen(head, hx, hy)) + continue; + surf_color(255, 255, 255, 255); + surf_rect(1, (int)hx - 2, (int)hy - 2, (int)hx + 3, (int)hy + 3); + if (!head_logged) { + head_logged = true; + logf("bone debug: idx=%d bones=%d head=(%.1f %.1f %.1f)", t.idx, + bones_count(t.idx), head.x, head.y, head.z); + } + } + } } -- cgit v1.2.3