From ba500fef7fbf94725f18541b0e23a45591379dba Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 27 Oct 2026 20:15:51 +0100 Subject: Fix tooltip truncation; add Stucklaunch assist Tooltips: text_in() shifted the x position to fit the full string before truncating, which drew the tooltip text outside its box. Truncate to the available width first, then clamp inside the clip. Stucklaunch (Movement): - opt-in feature (Active off by default) with its own bind; - holds jump, alternates +use every 2 ticks to regrab a physics prop, optionally +attack while the gravity gun is active, and air-strafes; - engagement uses m_hGroundEntity (client netvar) latched for ~0.5 s so the prop stays active while airborne; falls back to running whenever active if the netvar is unavailable, with a startup warning to bind it; - does not spawn or place props; the player supplies the prop and initial speed. Config gets [stucklaunch] active/bind/use_spam/gravspam/autostrafe; Reset restores those defaults. CONTEXT documents the assist and its limits. --- src/hl2h.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'src/hl2h.cpp') diff --git a/src/hl2h.cpp b/src/hl2h.cpp index c51d35e..63fdcdc 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp @@ -169,6 +169,44 @@ static void apply_autostrafe(CUserCmd *cmd, const float *vel) { cmd->sidemove = (dx * rx + dy * ry) * 450.0f; } +// True while the player stands on (or just left) a physics prop. m_hGroundEntity +// is latched briefly because it clears during each hop. +static bool stucklaunch_prop_ok(void *ent, int tick) { + if (g_net.groundentity < 0) + return true; // no netvar: the bind is the only safeguard + static int last_prop_tick = -100000; + uint32_t h = *(uint32_t *)((uintptr_t)ent + g_net.groundentity); + int gi = (h == 0xFFFFFFFFu) ? 0 : (int)(h & 0xFFFF); + bool on = gi > 0 && gi <= 4096 && entity_is_physics_prop(gi); + if (on) + last_prop_tick = tick; + return tick - last_prop_tick < 32; // ~0.5 s at 66 tick +} + +// Stucklaunch assist. The player supplies the physics prop and a little +// initial speed; this holds jump, alternates +use (and optionally the gravity +// gun's +attack) to keep regrabbing the prop, and air-strafes the hops. +static void stucklaunch_apply(CUserCmd *cmd, void *local_ent, bool onground, + const float *vel) { + cmd->buttons |= IN_JUMP; + int phase = (cmd->tick_count / 2) & 1; + if (stucklaunch_use_spam_enabled()) { + if (phase == 0) + cmd->buttons |= IN_USE; + else + cmd->buttons &= ~IN_USE; + } + if (stucklaunch_gravspam_enabled() && + active_weapon_is_gravity_gun(local_ent)) { + if (phase == 0) + cmd->buttons |= IN_ATTACK; + else + cmd->buttons &= ~IN_ATTACK; + } + if (stucklaunch_autostrafe_enabled() && !onground) + apply_autostrafe(cmd, vel); +} + // --------------------------------------------------------------------------- // jumpbug // --------------------------------------------------------------------------- @@ -576,8 +614,15 @@ static void do_move(int seq, float frametime) { return; } - bool bhop_on = feature_active(FEAT_BHOP); - bool abh_on = feature_active(FEAT_ABH); + bool stuck_on = feature_active(FEAT_STUCKLAUNCH); + bool stuck_engaged = stuck_on && stucklaunch_prop_ok(ent, cmd->tick_count); + if (stuck_engaged) { + stucklaunch_apply(cmd, ent, onground, vel); + note_modified(cmd, flags, vel); + } + + bool bhop_on = !stuck_engaged && feature_active(FEAT_BHOP); + bool abh_on = !stuck_engaged && feature_active(FEAT_ABH); static bool lastground = false; @@ -628,7 +673,8 @@ static void do_move(int seq, float frametime) { } } - if (jumpbug_apply(cmd, localIdx, ent, flags, vel, frametime)) + if (!stuck_engaged && + jumpbug_apply(cmd, localIdx, ent, flags, vel, frametime)) note_modified(cmd, flags, vel); bool melee = feature_active(FEAT_MELEE) && melee_weapon_active(ent); @@ -866,6 +912,8 @@ static void *setup_thread(void *) { toastf(TOAST_ERROR, "Netvars incomplete; features may be disabled"); else if (g_net.absvelocity < 0) toastf(TOAST_WARN, "Jumpbug assist disabled: velocity netvar missing"); + if (g_net.groundentity < 0) + toastf(TOAST_WARN, "Stucklaunch prop detection unavailable; bind it"); if (!g_iface.engineserver) toastf(TOAST_WARN, "Server interfaces missing; jumpbug/spread limited"); if (!g_iface.debugoverlay) -- cgit v1.2.3