diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-27 20:17:07 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-27 20:17:07 +0100 |
| commit | 59432708a4ae926e4be2959dfbb2b4eb80be3fd6 (patch) | |
| tree | 3233f49d2c9b3affbb97d832b4afdccbfb5f43b6 /src/hl2h.cpp | |
| parent | Fix tooltip truncation; add Stucklaunch assist (diff) | |
| download | hl2h-59432708a4ae926e4be2959dfbb2b4eb80be3fd6.tar.gz hl2h-59432708a4ae926e4be2959dfbb2b4eb80be3fd6.zip | |
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.
Diffstat (limited to 'src/hl2h.cpp')
| -rw-r--r-- | src/hl2h.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
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) { | |||
| 178 | uint32_t h = *(uint32_t *)((uintptr_t)ent + g_net.groundentity); | 178 | uint32_t h = *(uint32_t *)((uintptr_t)ent + g_net.groundentity); |
| 179 | int gi = (h == 0xFFFFFFFFu) ? 0 : (int)(h & 0xFFFF); | 179 | int gi = (h == 0xFFFFFFFFu) ? 0 : (int)(h & 0xFFFF); |
| 180 | bool on = gi > 0 && gi <= 4096 && entity_is_physics_prop(gi); | 180 | bool on = gi > 0 && gi <= 4096 && entity_is_physics_prop(gi); |
| 181 | if (on) | 181 | if (on) { |
| 182 | static int prop_logs = 0; | ||
| 183 | if (prop_logs < 4) { | ||
| 184 | prop_logs++; | ||
| 185 | logf("stucklaunch: prop idx=%d", gi); | ||
| 186 | } | ||
| 182 | last_prop_tick = tick; | 187 | last_prop_tick = tick; |
| 188 | } | ||
| 183 | return tick - last_prop_tick < 32; // ~0.5 s at 66 tick | 189 | return tick - last_prop_tick < 32; // ~0.5 s at 66 tick |
| 184 | } | 190 | } |
| 185 | 191 | ||
| @@ -189,20 +195,28 @@ static bool stucklaunch_prop_ok(void *ent, int tick) { | |||
| 189 | static void stucklaunch_apply(CUserCmd *cmd, void *local_ent, bool onground, | 195 | static void stucklaunch_apply(CUserCmd *cmd, void *local_ent, bool onground, |
| 190 | const float *vel) { | 196 | const float *vel) { |
| 191 | cmd->buttons |= IN_JUMP; | 197 | cmd->buttons |= IN_JUMP; |
| 192 | int phase = (cmd->tick_count / 2) & 1; | 198 | int period = stucklaunch_spam_ticks(); |
| 193 | if (stucklaunch_use_spam_enabled()) { | 199 | if (period < 1) |
| 200 | period = 1; | ||
| 201 | int phase = (cmd->tick_count / period) & 1; | ||
| 202 | bool gravity = stucklaunch_gravspam_enabled() && | ||
| 203 | active_weapon_is_gravity_gun(local_ent); | ||
| 204 | if (gravity) { | ||
| 205 | // Pick up with +attack, drop with +use on the next half-cycle. Pressing | ||
| 206 | // both together would punt instead of regrabbing. | ||
| 207 | if (phase == 0) { | ||
| 208 | cmd->buttons |= IN_ATTACK; | ||
| 209 | cmd->buttons &= ~IN_USE; | ||
| 210 | } else { | ||
| 211 | cmd->buttons |= IN_USE; | ||
| 212 | cmd->buttons &= ~IN_ATTACK; | ||
| 213 | } | ||
| 214 | } else if (stucklaunch_use_spam_enabled()) { | ||
| 194 | if (phase == 0) | 215 | if (phase == 0) |
| 195 | cmd->buttons |= IN_USE; | 216 | cmd->buttons |= IN_USE; |
| 196 | else | 217 | else |
| 197 | cmd->buttons &= ~IN_USE; | 218 | cmd->buttons &= ~IN_USE; |
| 198 | } | 219 | } |
| 199 | if (stucklaunch_gravspam_enabled() && | ||
| 200 | active_weapon_is_gravity_gun(local_ent)) { | ||
| 201 | if (phase == 0) | ||
| 202 | cmd->buttons |= IN_ATTACK; | ||
| 203 | else | ||
| 204 | cmd->buttons &= ~IN_ATTACK; | ||
| 205 | } | ||
| 206 | if (stucklaunch_autostrafe_enabled() && !onground) | 220 | if (stucklaunch_autostrafe_enabled() && !onground) |
| 207 | apply_autostrafe(cmd, vel); | 221 | apply_autostrafe(cmd, vel); |
| 208 | } | 222 | } |
