From 59432708a4ae926e4be2959dfbb2b4eb80be3fd6 Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 27 Oct 2026 20:17:07 +0100 Subject: Stucklaunch: alternate attack/use and expose spam rate - Gravity-gun spam now alternates +attack (grab) and +use (drop) instead of pressing both together, which would punt the prop. - Add a Spam rate slider (1..16 ticks, default 2) so the pickup/drop cycle can be tuned; it persists as spam_ticks in [stucklaunch]. - Log the prop index the first few times a stucklaunch engages to aid testing. --- src/hl2h.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'src/hl2h.cpp') diff --git a/src/hl2h.cpp b/src/hl2h.cpp index 63fdcdc..84de815 100644 --- a/src/hl2h.cpp +++ b/src/hl2h.cpp @@ -178,8 +178,14 @@ static bool stucklaunch_prop_ok(void *ent, int tick) { 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) + if (on) { + static int prop_logs = 0; + if (prop_logs < 4) { + prop_logs++; + logf("stucklaunch: prop idx=%d", gi); + } last_prop_tick = tick; + } return tick - last_prop_tick < 32; // ~0.5 s at 66 tick } @@ -189,20 +195,28 @@ static bool stucklaunch_prop_ok(void *ent, int tick) { 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()) { + int period = stucklaunch_spam_ticks(); + if (period < 1) + period = 1; + int phase = (cmd->tick_count / period) & 1; + bool gravity = stucklaunch_gravspam_enabled() && + active_weapon_is_gravity_gun(local_ent); + if (gravity) { + // Pick up with +attack, drop with +use on the next half-cycle. Pressing + // both together would punt instead of regrabbing. + if (phase == 0) { + cmd->buttons |= IN_ATTACK; + cmd->buttons &= ~IN_USE; + } else { + cmd->buttons |= IN_USE; + cmd->buttons &= ~IN_ATTACK; + } + } else 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); } -- cgit v1.2.3