summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-26 16:31:44 +0100
committersalmonik <salmonik@tuta.io>2026-10-26 16:31:44 +0100
commitd74e4900f8247f2fb20ede70bea4c65c12fd0b55 (patch)
treeca538916d78fbe8835ac1cde095474c6e9072371
parentESP: include zombie head (headcrab body/head) in humanoid skeleton (diff)
downloadhl2h-d74e4900f8247f2fb20ede70bea4c65c12fd0b55.tar.gz
hl2h-d74e4900f8247f2fb20ede70bea4c65c12fd0b55.zip
ESP: generic full-bone skeleton for non-humanoid NPCs (headcrabs, crows, ...)
-rw-r--r--src/bones.cpp13
-rw-r--r--src/esp.cpp3
-rw-r--r--src/hl2h.h1
3 files changed, 14 insertions, 3 deletions
diff --git a/src/bones.cpp b/src/bones.cpp
index d1e25cb..f33a4b2 100644
--- a/src/bones.cpp
+++ b/src/bones.cpp
@@ -371,16 +371,20 @@ int bone_parent(int idx, int bone) {
371 371
372bool bone_is_skeleton_core(int idx, int bone) { 372bool bone_is_skeleton_core(int idx, int bone) {
373 BoneEntry *e = find_entry(idx); 373 BoneEntry *e = find_entry(idx);
374 if (!e || !e->valid || !e->humanoid || bone < 0 || bone >= e->count) 374 if (!e || !e->valid || bone < 0 || bone >= e->count)
375 return false; 375 return false;
376 if (!e->humanoid)
377 return true; // non-humanoid: draw its full bone tree
376 return e->core[bone]; 378 return e->core[bone];
377} 379}
378 380
379int bone_nearest_core_parent(int idx, int bone) { 381int bone_nearest_core_parent(int idx, int bone) {
380 BoneEntry *e = find_entry(idx); 382 BoneEntry *e = find_entry(idx);
381 if (!e || !e->valid || !e->humanoid || bone < 0 || bone >= e->count) 383 if (!e || !e->valid || bone < 0 || bone >= e->count)
382 return -1; 384 return -1;
383 int p = bone_at(e->hdr, bone)->parent; 385 int p = bone_at(e->hdr, bone)->parent;
386 if (!e->humanoid)
387 return (p >= 0 && p < e->count) ? p : -1;
384 for (int guard = 0; p >= 0 && p < e->count && guard < 64; guard++) { 388 for (int guard = 0; p >= 0 && p < e->count && guard < 64; guard++) {
385 if (e->core[p]) 389 if (e->core[p])
386 return p; 390 return p;
@@ -389,6 +393,11 @@ int bone_nearest_core_parent(int idx, int bone) {
389 return -1; 393 return -1;
390} 394}
391 395
396bool bones_is_humanoid(int idx) {
397 BoneEntry *e = find_entry(idx);
398 return e && e->valid && e->humanoid;
399}
400
392bool bone_pos(int idx, int bone, Vector &out) { 401bool bone_pos(int idx, int bone, Vector &out) {
393 BoneEntry *e = find_entry(idx); 402 BoneEntry *e = find_entry(idx);
394 if (!e || !e->valid || bone < 0 || bone >= e->count) 403 if (!e || !e->valid || bone < 0 || bone >= e->count)
diff --git a/src/esp.cpp b/src/esp.cpp
index b5cb9b0..34a702a 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -298,7 +298,8 @@ static void draw_skeleton(const EspTarget &t) {
298 static int logged = 0; 298 static int logged = 0;
299 if (core_count > 0 && logged < 4) { 299 if (core_count > 0 && logged < 4) {
300 logged++; 300 logged++;
301 logf("skeleton: idx=%d bones=%d core=%d", t.idx, n, core_count); 301 logf("skeleton: idx=%d bones=%d core=%d humanoid=%d", t.idx, n, core_count,
302 (int)bones_is_humanoid(t.idx));
302 } 303 }
303 if (t.friendly) 304 if (t.friendly)
304 surf_color(60, 255, 60, 255); 305 surf_color(60, 255, 60, 255);
diff --git a/src/hl2h.h b/src/hl2h.h
index c0d4cdd..289e4e6 100644
--- a/src/hl2h.h
+++ b/src/hl2h.h
@@ -177,6 +177,7 @@ int bone_parent(int idx, int bone);
177bool bone_pos(int idx, int bone, Vector &out); 177bool bone_pos(int idx, int bone, Vector &out);
178bool bone_is_skeleton_core(int idx, int bone); 178bool bone_is_skeleton_core(int idx, int bone);
179int bone_nearest_core_parent(int idx, int bone); 179int bone_nearest_core_parent(int idx, int bone);
180bool bones_is_humanoid(int idx);
180bool hitbox_center(int idx, const char *hitbox_name, Vector &out); 181bool hitbox_center(int idx, const char *hitbox_name, Vector &out);
181bool head_position(int idx, Vector &out); 182bool head_position(int idx, Vector &out);
182 183