From 15e4d33220bedb62beac635580fa4d222a7f5863 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 26 Oct 2026 15:44:45 +0100 Subject: ESP: menu toggles for neutral/healthbar/healthnum/name --- src/esp.cpp | 15 ++++++++++++--- src/hl2h.h | 8 ++++++++ src/menu.cpp | 44 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 59 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/esp.cpp b/src/esp.cpp index 3914342..4462f07 100644 --- a/src/esp.cpp +++ b/src/esp.cpp @@ -280,6 +280,8 @@ void esp_draw() { esp_collect(engine_get_local_player()); for (int i = 0; i < g_ntargets; i++) { const EspTarget &t = g_targets[i]; + if (t.neutral && !esp_option(ESP_OPT_SHOW_NEUTRAL)) + continue; if (t.friendly) surf_color(60, 255, 60, 255); else if (t.neutral) surf_color(220, 220, 220, 255); else surf_color(255, 60, 60, 255); @@ -289,7 +291,10 @@ void esp_draw() { int top = (int)(t.sy - t.h); int bot = (int)t.sy; surf_rect(0, left, top, right, bot); - if (t.show_health) { + bool draw_bar = t.show_health && esp_option(ESP_OPT_SHOW_HEALTHBAR); + bool draw_num = t.show_health && esp_option(ESP_OPT_SHOW_HEALTHNUM); + int num_x = right + 3; + if (draw_bar) { float frac = t.health / (t.maxhealth > 1.0f ? t.maxhealth : 100.0f); if (frac > 1) frac = 1; if (frac < 0) frac = 0; @@ -304,10 +309,14 @@ void esp_draw() { else surf_color(255, 40, 40, 255); if (fill_top < bot) surf_rect(1, bx0, fill_top, bx1, bot); + num_x = bx1 + 3; + } + if (draw_num) { char hptext[16]; snprintf(hptext, sizeof(hptext), "%d", (int)t.health); - draw_text_col(bx1 + 3, top, hptext, 255, 255, 255); + draw_text_col(num_x, top, hptext, 255, 255, 255); } - draw_text_col(left, top - 14, t.name, 255, 255, 255); + if (esp_option(ESP_OPT_SHOW_NAME)) + draw_text_col(left, top - 14, t.name, 255, 255, 255); } } diff --git a/src/hl2h.h b/src/hl2h.h index b693617..50b5525 100644 --- a/src/hl2h.h +++ b/src/hl2h.h @@ -136,6 +136,13 @@ extern Vector g_cam_eye; extern Vector g_cam_view; QAngle vector_angles(const Vector &forward); enum FeatureId { FEAT_BHOP = 0, FEAT_ABH = 1, FEAT_ESP = 2 }; +enum EspOption { + ESP_OPT_SHOW_NEUTRAL = 0, + ESP_OPT_SHOW_HEALTHBAR = 1, + ESP_OPT_SHOW_HEALTHNUM = 2, + ESP_OPT_SHOW_NAME = 3, + ESP_OPT_COUNT = 4 +}; // --------------------------------------------------------------------------- // cross-file declarations @@ -153,6 +160,7 @@ int server_model_index(void *base); void find_modules(); void init_conmsg(); bool feature_active(int feature); +bool esp_option(int opt); void *entitylist_get(int idx); int engine_get_local_player(); void draw_text_col(int x, int y, const char *s, int r, int g, int b); diff --git a/src/menu.cpp b/src/menu.cpp index 302eab3..2caf0aa 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -37,7 +37,7 @@ struct MenuNode { const char *label; bool expanded; // for root/feature: whether children are visible int child_count; - MenuNode *children[4]; // max children per node + MenuNode *children[8]; // max children per node // leaf data bool *active_ptr; // NODE_TOGGLE: pointer to the active flag @@ -55,6 +55,11 @@ static FeatureState g_bhop{true, 0}; static FeatureState g_abh{true, 0}; static FeatureState g_esp{true, 0}; + +// ESP sub-options (menu "ESP" children). Defaults match the pre-option +// behaviour: everything on. +static bool g_esp_opt[ESP_OPT_COUNT] = {true, true, true, true}; + // tree static MenuNode g_root{NODE_ROOT, "HL2hake", true, 0, {}, nullptr, nullptr, nullptr}; static MenuNode g_bhop_feat{NODE_FEATURE, "Bunnyhop", true, 1, {}, nullptr, nullptr, nullptr}; @@ -63,8 +68,14 @@ static MenuNode g_abh_feat{NODE_FEATURE, "ABH", true, 1, {}, nullptr, nullptr, n static MenuNode g_abh_active{NODE_TOGGLE, "Active", false, 0, {}, &g_abh.active, nullptr, nullptr}; static MenuNode g_esp_feat{NODE_FEATURE, "ESP", true, 1, {}, nullptr, nullptr, nullptr}; static MenuNode g_esp_active{NODE_TOGGLE, "Active", false, 0, {}, &g_esp.active, nullptr, nullptr}; +static MenuNode g_esp_opt_nodes[ESP_OPT_COUNT] = { + {NODE_TOGGLE, "Show neutral", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_NEUTRAL], nullptr, nullptr}, + {NODE_TOGGLE, "Show healthbar", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_HEALTHBAR], nullptr, nullptr}, + {NODE_TOGGLE, "Show healthnum", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], nullptr, nullptr}, + {NODE_TOGGLE, "Show name", false, 0, {}, &g_esp_opt[ESP_OPT_SHOW_NAME], nullptr, nullptr}, +}; -static MenuNode *g_visible[16]; // flattened visible nodes for arrow navigation +static MenuNode *g_visible[32]; // flattened visible nodes for arrow navigation static int g_visible_count = 0; static int g_selected = 0; bool g_menu_open = false; @@ -74,16 +85,19 @@ static void build_tree() { g_bhop_feat.children[0] = &g_bhop_active; g_abh_feat.children[0] = &g_abh_active; g_esp_feat.children[0] = &g_esp_active; + for (int i = 0; i < ESP_OPT_COUNT; i++) + g_esp_feat.children[i + 1] = &g_esp_opt_nodes[i]; + g_esp_feat.child_count = ESP_OPT_COUNT + 1; g_root.children[0] = &g_bhop_feat; g_root.children[1] = &g_abh_feat; g_root.children[2] = &g_esp_feat; g_root.child_count = 3; } -static int g_depth[16]; // depth of each visible row (for indentation) +static int g_depth[32]; // depth of each visible row (for indentation) static void flatten(MenuNode *node, int depth) { - if (g_visible_count >= 16) + if (g_visible_count >= 32) return; node->type = (depth == 0) ? NODE_ROOT : (node->child_count > 0) ? NODE_FEATURE @@ -139,7 +153,11 @@ static void config_save() { return; fprintf(f, "[bhop]\nactive=%d\nbind=%d\n", g_bhop.active, g_bhop.bind); fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind); - fprintf(f, "[esp]\nactive=%d\nbind=%d\n", g_esp.active, g_esp.bind); + fprintf(f, "[esp]\nactive=%d\nbind=%d\nneutral=%d\nhealthbar=%d\n" + "healthnum=%d\nname=%d\n", + g_esp.active, g_esp.bind, g_esp_opt[ESP_OPT_SHOW_NEUTRAL], + g_esp_opt[ESP_OPT_SHOW_HEALTHBAR], + g_esp_opt[ESP_OPT_SHOW_HEALTHNUM], g_esp_opt[ESP_OPT_SHOW_NAME]); fclose(f); } @@ -149,6 +167,7 @@ static void config_load() { return; char line[256]; FeatureState *cur = nullptr; + bool in_esp = false; while (fgets(line, sizeof(line), f)) { line[strcspn(line, "\r\n")] = 0; if (line[0] == '[') { @@ -160,12 +179,23 @@ static void config_load() { cur = &g_esp; else cur = nullptr; + in_esp = (cur == &g_esp); } else if (cur) { char *eq = strchr(line, '='); if (!eq) continue; *eq = 0; const char *key = line, *val = eq + 1; + if (in_esp) { + if (strcmp(key, "neutral") == 0) + g_esp_opt[ESP_OPT_SHOW_NEUTRAL] = atoi(val) != 0; + else if (strcmp(key, "healthbar") == 0) + g_esp_opt[ESP_OPT_SHOW_HEALTHBAR] = atoi(val) != 0; + else if (strcmp(key, "healthnum") == 0) + g_esp_opt[ESP_OPT_SHOW_HEALTHNUM] = atoi(val) != 0; + else if (strcmp(key, "name") == 0) + g_esp_opt[ESP_OPT_SHOW_NAME] = atoi(val) != 0; + } if (strcmp(key, "active") == 0) cur->active = atoi(val) != 0; else if (strcmp(key, "bind") == 0) @@ -285,6 +315,10 @@ bool feature_active(int feature) { return f->bind == 0 || key_held(f->bind); } +bool esp_option(int opt) { + return opt >= 0 && opt < ESP_OPT_COUNT && g_esp_opt[opt]; +} + static void menu_handle_input() { poll_keyboard(); -- cgit v1.2.3