From 12fde50efc7e1f1d123f9fc34ffef53d4387de2d Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 13:53:45 +0100 Subject: Add ESP, aim, view and movement batch - ESP: alert state (IDLE/ALERT/COMBAT/SCRIPT), enemy weapon labels, hostile/ neutral/friendly colour pickers, off-screen direction arrows, and trigger_changelevel volumes with next/previous map labels. - Aim: silent aim reuses the Aimbot FOV, vischeck and bone settings; add optional aim-punch compensation for aimbot, silent aim, triggerbot and melee (server bullets add m_vecPunchAngle to the usercmd angles). - View: always-on Camera / display card with camera FOV (writes the client m_iDefaultFOV netvar), viewmodel FOV and monitor gamma (client cvars). - Movement: Jump assist card with auto crouch-jump and edge jump (point ground probe 0.12 s ahead). - Spread: Engine spread override toggle gates the direct RandomFloat zeroing; off leaves only the seed search. - Server: entity count/base/classname helpers, trigger_changelevel map name and world bounds via IServerUnknown/ICollideable. - Netvars: m_vecPunchAngle and m_iDefaultFOV. --- src/hl2h.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 2 deletions(-) (limited to 'src/hl2h.cpp') diff --git a/src/hl2h.cpp b/src/hl2h.cpp index 8ab1a3e..74a8c6c 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp @@ -503,7 +503,7 @@ static void hkdSrvRandomSeed(int seed) { (uintptr_t)self == g_local_server_player; if (local && g_server.contains(ret) && feature_active(FEAT_SPREAD) && - spread_no_spread_enabled()) { + spread_no_spread_enabled() && spread_engine_enabled()) { g_spread_rand_left = 8; int pellets = g_spread_pellets; if (pellets < 1) @@ -599,7 +599,7 @@ static bool g_uniform_hook_installed = false; static float hkdUniformRandomFloat(void *self, float mn, float mx) { bool enabled = g_local_server_player && feature_active(FEAT_SPREAD) && - spread_no_spread_enabled(); + spread_no_spread_enabled() && spread_engine_enabled(); bool hit = false; void *who = nullptr; if (enabled) { @@ -654,6 +654,90 @@ static void install_uniform_random_hook() { (void *)g_orig_uniform_float, (void *)&hkdUniformRandomFloat); } +// --------------------------------------------------------------------------- +// camera / viewmodel FOV and gamma +// --------------------------------------------------------------------------- +// +// The rendered camera FOV is derived from C_BasePlayer::m_iDefaultFOV every +// frame (CViewRender::OnRenderStart copies it into default_fov), so writing +// the client netvar is enough and needs no server command. The viewmodel FOV +// and monitor gamma are plain client cvars. + +static void view_settings_apply(void *ent) { + if (g_net.default_fov >= 0 && ent) { + static int last = -2; + int want = g_fov_camera > 0 ? g_fov_camera : 0; + if (want != last || g_fov_camera > 0) { + *(int *)((uintptr_t)ent + g_net.default_fov) = want; + last = want; + } + } + // 0 means "leave the game's value alone": only send a command once the + // slider is non-zero, then restore the stock value when it returns to 0. + static int last_vm = 0; + if (g_fov_viewmodel > 0 && g_fov_viewmodel != last_vm) { + char cmd[48]; + snprintf(cmd, sizeof(cmd), "viewmodel_fov %d", g_fov_viewmodel); + console_cmd(cmd); + last_vm = g_fov_viewmodel; + } else if (g_fov_viewmodel == 0 && last_vm > 0) { + console_cmd("viewmodel_fov 54"); + last_vm = 0; + } + static int last_gamma = 22; + if (g_gamma != last_gamma) { + char cmd[48]; + snprintf(cmd, sizeof(cmd), "mat_monitorgamma %d.%d", g_gamma / 10, + g_gamma % 10); + console_cmd(cmd); + last_gamma = g_gamma; + } +} + +// --------------------------------------------------------------------------- +// jump assist: crouch-jump and edge jump +// --------------------------------------------------------------------------- + +static bool g_cj_added = false; + +static bool crouch_jump_apply(CUserCmd *cmd, int flags, const float *vel) { + bool user_duck = (cmd->buttons & IN_DUCK) != 0; + bool onground = (flags & FL_ONGROUND) != 0; + bool want = g_auto_crouchjump && !onground && !user_duck && + (cmd->buttons & IN_JUMP) && vel[2] > 20.0f; + int old = cmd->buttons; + if (want) { + cmd->buttons |= IN_DUCK; + g_cj_added = true; + } else if (g_cj_added && !user_duck) { + cmd->buttons &= ~IN_DUCK; + g_cj_added = false; + } + return cmd->buttons != old; +} + +static bool edge_jump_apply(CUserCmd *cmd, void *ent, int flags, + const float *vel) { + if (!g_edge_jump || g_net.origin < 0 || !(flags & FL_ONGROUND) || + (flags & FL_INWATER)) + return false; + if (cmd->buttons & (IN_JUMP | IN_DUCK)) + return false; + float speed2d = sqrtf(vel[0] * vel[0] + vel[1] * vel[1]); + if (speed2d < 120.0f) + return false; + uintptr_t e = (uintptr_t)ent; + Vector origin{*(float *)(e + g_net.origin), *(float *)(e + g_net.origin + 4), + *(float *)(e + g_net.origin + 8)}; + // Probe the ground a fraction of a second ahead. No hit within 64 units + // means a real ledge; slopes and stairs still find a floor and are skipped. + Vector ahead{origin.x + vel[0] * 0.12f, origin.y + vel[1] * 0.12f, origin.z}; + if (!g_iface.enginetrace || point_ground(ahead, ent)) + return false; + cmd->buttons |= IN_JUMP; + return true; +} + static void do_move(int seq, float frametime) { install_seed_hook(); install_uniform_random_hook(); @@ -683,6 +767,8 @@ static void do_move(int seq, float frametime) { if (!ent) return; + view_settings_apply(ent); + // New map / respawn: drop stale bone caches and target locks. static void *last_local_ent = nullptr; if (ent != last_local_ent) { @@ -803,6 +889,12 @@ static void do_move(int seq, float frametime) { } } + bool jump_assist = crouch_jump_apply(cmd, flags, vel); + if (edge_jump_apply(cmd, ent, flags, vel)) + jump_assist = true; + if (jump_assist) + note_modified(cmd, flags, vel); + if (jumpbug_apply(cmd, localIdx, ent, flags, vel, frametime)) note_modified(cmd, flags, vel); -- cgit v1.2.3