From 164bdcbf3e8ed2b7377351b619150586012e1007 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 26 Oct 2026 15:56:03 +0100 Subject: Bhop: uni-directional auto-strafe for all movement directions - derive the desired air direction from the raw W/S/A/D input (view-relative) - pick the velocity perpendicular that rotates toward that target, so S/A/D work instead of only forward and A/D no longer spin in circles - no keys: accelerate along the crosshair - menu label now "Uni-directional auto-strafe"; state column moved to x=270 --- src/menu.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/menu.cpp') diff --git a/src/menu.cpp b/src/menu.cpp index 2caf0aa..c8dffc9 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -52,6 +52,7 @@ struct FeatureState { }; static FeatureState g_bhop{true, 0}; +static bool g_bhop_autostrafe = true; static FeatureState g_abh{true, 0}; static FeatureState g_esp{true, 0}; @@ -64,6 +65,7 @@ static bool g_esp_opt[ESP_OPT_COUNT] = {true, true, true, true}; 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}; static MenuNode g_bhop_active{NODE_TOGGLE, "Active", false, 0, {}, &g_bhop.active, nullptr, nullptr}; +static MenuNode g_bhop_autostrafe_node{NODE_TOGGLE, "Uni-directional auto-strafe", false, 0, {}, &g_bhop_autostrafe, nullptr, nullptr}; static MenuNode g_abh_feat{NODE_FEATURE, "ABH", true, 1, {}, nullptr, nullptr, nullptr}; 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}; @@ -83,6 +85,8 @@ bool g_menu_open = false; static bool g_bind_mode = false; static void build_tree() { g_bhop_feat.children[0] = &g_bhop_active; + g_bhop_feat.children[1] = &g_bhop_autostrafe_node; + g_bhop_feat.child_count = 2; 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++) @@ -151,7 +155,8 @@ static void config_save() { FILE *f = fopen(config_path().c_str(), "w"); if (!f) return; - fprintf(f, "[bhop]\nactive=%d\nbind=%d\n", g_bhop.active, g_bhop.bind); + fprintf(f, "[bhop]\nactive=%d\nbind=%d\nautostrafe=%d\n", g_bhop.active, + g_bhop.bind, g_bhop_autostrafe); fprintf(f, "[abh]\nactive=%d\nbind=%d\n", g_abh.active, g_abh.bind); fprintf(f, "[esp]\nactive=%d\nbind=%d\nneutral=%d\nhealthbar=%d\n" "healthnum=%d\nname=%d\n", @@ -167,7 +172,7 @@ static void config_load() { return; char line[256]; FeatureState *cur = nullptr; - bool in_esp = false; + bool in_esp = false, in_bhop = false; while (fgets(line, sizeof(line), f)) { line[strcspn(line, "\r\n")] = 0; if (line[0] == '[') { @@ -180,12 +185,16 @@ static void config_load() { else cur = nullptr; in_esp = (cur == &g_esp); + in_bhop = (cur == &g_bhop); } else if (cur) { char *eq = strchr(line, '='); if (!eq) continue; *eq = 0; const char *key = line, *val = eq + 1; + if (in_bhop && strcmp(key, "autostrafe") == 0) { + g_bhop_autostrafe = atoi(val) != 0; + } if (in_esp) { if (strcmp(key, "neutral") == 0) g_esp_opt[ESP_OPT_SHOW_NEUTRAL] = atoi(val) != 0; @@ -319,6 +328,8 @@ bool esp_option(int opt) { return opt >= 0 && opt < ESP_OPT_COUNT && g_esp_opt[opt]; } +bool bhop_autostrafe_enabled() { return g_bhop_autostrafe; } + static void menu_handle_input() { poll_keyboard(); @@ -557,10 +568,10 @@ void outer_draw() { draw_text(x, 10 + i * 20, line); // right-aligned state if (n->type == NODE_TOGGLE) { - draw_text(200, 10 + i * 20, *n->active_ptr ? "[on]" : "[off]"); + draw_text(270, 10 + i * 20, *n->active_ptr ? "[on]" : "[off]"); } else if (n->type == NODE_BIND) { if (g_bind_mode && i == g_selected) - draw_text(200, 10 + i * 20, "[press key]"); + draw_text(270, 10 + i * 20, "[press key]"); else { /* stable name for current bind */ static char bn[2][32]; @@ -570,7 +581,7 @@ void outer_draw() { if (n->bind_ptr == &feats[k]->bind) fi = k; snprintf(bn[fi], 32, "[%s]", scancode_name(*n->bind_ptr)); - draw_text(200, 10 + i * 20, bn[fi]); + draw_text(270, 10 + i * 20, bn[fi]); } } } -- cgit v1.2.3