summaryrefslogtreecommitdiffstats
path: root/src/bones.cpp
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 /src/bones.cpp
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, ...)
Diffstat (limited to '')
-rw-r--r--src/bones.cpp13
1 files changed, 11 insertions, 2 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)