summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/esp.cpp38
-rw-r--r--src/hl2h.h3
-rw-r--r--src/menu.cpp10
3 files changed, 46 insertions, 5 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);
diff --git a/src/hl2h.h b/src/hl2h.h
index 68d5d55..1eaee10 100644
--- a/src/hl2h.h
+++ b/src/hl2h.h
@@ -141,7 +141,8 @@ enum EspOption {
141 ESP_OPT_SHOW_HEALTHBAR = 1, 141 ESP_OPT_SHOW_HEALTHBAR = 1,
142 ESP_OPT_SHOW_HEALTHNUM = 2, 142 ESP_OPT_SHOW_HEALTHNUM = 2,
143 ESP_OPT_SHOW_NAME = 3, 143 ESP_OPT_SHOW_NAME = 3,
144 ESP_OPT_COUNT = 4 144 ESP_OPT_SHOW_SKELETON = 4,
145 ESP_OPT_COUNT = 5
145}; 146};
146 147
147// --------------------------------------------------------------------------- 148// ---------------------------------------------------------------------------
diff --git a/src/menu.cpp b/src/menu.cpp
index 6244002..6474d69 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -59,7 +59,7 @@ static FeatureState g_esp{true, 0};
59 59
60// ESP sub-options (menu "ESP" children). Defaults match the pre-option 60// ESP sub-options (menu "ESP" children). Defaults match the pre-option
61// behaviour: everything on. 61// behaviour: everything on.
62static bool g_esp_opt[ESP_OPT_COUNT] = {true, true, true, true}; 62static bool g_esp_opt[ESP_OPT_COUNT] = {true, true, true, true, true};
63 63
64// tree 64// tree
65static MenuNode g_root{NODE_ROOT, "HL2hake", false, 0, {}, nullptr, nullptr, nullptr}; 65static MenuNode g_root{NODE_ROOT, "HL2hake", false, 0, {}, nullptr, nullptr, nullptr};
@@ -75,6 +75,7 @@ static MenuNode g_esp_opt_nodes[ESP_OPT_COUNT] = {
75 {NODE_TOGGLE, "Show healthbar", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_HEALTHBAR], nullptr, nullptr}, 75 {NODE_TOGGLE, "Show healthbar", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_HEALTHBAR], nullptr, nullptr},
76 {NODE_TOGGLE, "Show healthnum", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], nullptr, nullptr}, 76 {NODE_TOGGLE, "Show healthnum", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], nullptr, nullptr},
77 {NODE_TOGGLE, "Show name", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_NAME], nullptr, nullptr}, 77 {NODE_TOGGLE, "Show name", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_NAME], nullptr, nullptr},
78 {NODE_TOGGLE, "Show skeleton", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_SKELETON], nullptr, nullptr},
78}; 79};
79 80
80static MenuNode *g_visible[32]; // flattened visible nodes for arrow navigation 81static MenuNode *g_visible[32]; // flattened visible nodes for arrow navigation
@@ -159,10 +160,11 @@ static void config_save() {
159 g_bhop.bind, g_bhop_autostrafe); 160 g_bhop.bind, g_bhop_autostrafe);
160 fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind); 161 fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind);
161 fprintf(f, "[esp]\nactive=%d\nbind=%d\nneutral=%d\nhealthbar=%d\n" 162 fprintf(f, "[esp]\nactive=%d\nbind=%d\nneutral=%d\nhealthbar=%d\n"
162 "healthnum=%d\nname=%d\n", 163 "healthnum=%d\nname=%d\nskeleton=%d\n",
163 g_esp.active, g_esp.bind, g_esp_opt[ESP_OPT_SHOW_NEUTRAL], 164 g_esp.active, g_esp.bind, g_esp_opt[ESP_OPT_SHOW_NEUTRAL],
164 g_esp_opt[ESP_OPT_SHOW_HEALTHBAR], 165 g_esp_opt[ESP_OPT_SHOW_HEALTHBAR],
165 g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], g_esp_opt[ESP_OPT_SHOW_NAME]); 166 g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], g_esp_opt[ESP_OPT_SHOW_NAME],
167 g_esp_opt[ESP_OPT_SHOW_SKELETON]);
166 fclose(f); 168 fclose(f);
167} 169}
168 170
@@ -204,6 +206,8 @@ static void config_load() {
204 g_esp_opt[ESP_OPT_SHOW_HEALTHNUM] = atoi(val) != 0; 206 g_esp_opt[ESP_OPT_SHOW_HEALTHNUM] = atoi(val) != 0;
205 else if (strcmp(key, "name") == 0) 207 else if (strcmp(key, "name") == 0)
206 g_esp_opt[ESP_OPT_SHOW_NAME] = atoi(val) != 0; 208 g_esp_opt[ESP_OPT_SHOW_NAME] = atoi(val) != 0;
209 else if (strcmp(key, "skeleton") == 0)
210 g_esp_opt[ESP_OPT_SHOW_SKELETON] = atoi(val) != 0;
207 } 211 }
208 if (strcmp(key, "active") == 0) 212 if (strcmp(key, "active") == 0)
209 cur->active = atoi(val) != 0; 213 cur->active = atoi(val) != 0;