summaryrefslogtreecommitdiffstats
path: root/src/hl2h.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/hl2h.cpp54
1 files changed, 51 insertions, 3 deletions
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) {
169 cmd->sidemove = (dx * rx + dy * ry) * 450.0f; 169 cmd->sidemove = (dx * rx + dy * ry) * 450.0f;
170} 170}
171 171
172// True while the player stands on (or just left) a physics prop. m_hGroundEntity
173// is latched briefly because it clears during each hop.
174static bool stucklaunch_prop_ok(void *ent, int tick) {
175 if (g_net.groundentity < 0)
176 return true; // no netvar: the bind is the only safeguard
177 static int last_prop_tick = -100000;
178 uint32_t h = *(uint32_t *)((uintptr_t)ent + g_net.groundentity);
179 int gi = (h == 0xFFFFFFFFu) ? 0 : (int)(h & 0xFFFF);
180 bool on = gi > 0 && gi <= 4096 && entity_is_physics_prop(gi);
181 if (on)
182 last_prop_tick = tick;
183 return tick - last_prop_tick < 32; // ~0.5 s at 66 tick
184}
185
186// Stucklaunch assist. The player supplies the physics prop and a little
187// initial speed; this holds jump, alternates +use (and optionally the gravity
188// gun's +attack) to keep regrabbing the prop, and air-strafes the hops.
189static void stucklaunch_apply(CUserCmd *cmd, void *local_ent, bool onground,
190 const float *vel) {
191 cmd->buttons |= IN_JUMP;
192 int phase = (cmd->tick_count / 2) & 1;
193 if (stucklaunch_use_spam_enabled()) {
194 if (phase == 0)
195 cmd->buttons |= IN_USE;
196 else
197 cmd->buttons &= ~IN_USE;
198 }
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)
207 apply_autostrafe(cmd, vel);
208}
209
172// --------------------------------------------------------------------------- 210// ---------------------------------------------------------------------------
173// jumpbug 211// jumpbug
174// --------------------------------------------------------------------------- 212// ---------------------------------------------------------------------------
@@ -576,8 +614,15 @@ static void do_move(int seq, float frametime) {
576 return; 614 return;
577 } 615 }
578 616
579 bool bhop_on = feature_active(FEAT_BHOP); 617 bool stuck_on = feature_active(FEAT_STUCKLAUNCH);
580 bool abh_on = feature_active(FEAT_ABH); 618 bool stuck_engaged = stuck_on && stucklaunch_prop_ok(ent, cmd->tick_count);
619 if (stuck_engaged) {
620 stucklaunch_apply(cmd, ent, onground, vel);
621 note_modified(cmd, flags, vel);
622 }
623
624 bool bhop_on = !stuck_engaged && feature_active(FEAT_BHOP);
625 bool abh_on = !stuck_engaged && feature_active(FEAT_ABH);
581 626
582 static bool lastground = false; 627 static bool lastground = false;
583 628
@@ -628,7 +673,8 @@ static void do_move(int seq, float frametime) {
628 } 673 }
629 } 674 }
630 675
631 if (jumpbug_apply(cmd, localIdx, ent, flags, vel, frametime)) 676 if (!stuck_engaged &&
677 jumpbug_apply(cmd, localIdx, ent, flags, vel, frametime))
632 note_modified(cmd, flags, vel); 678 note_modified(cmd, flags, vel);
633 679
634 bool melee = feature_active(FEAT_MELEE) && melee_weapon_active(ent); 680 bool melee = feature_active(FEAT_MELEE) && melee_weapon_active(ent);
@@ -866,6 +912,8 @@ static void *setup_thread(void *) {
866 toastf(TOAST_ERROR, "Netvars incomplete; features may be disabled"); 912 toastf(TOAST_ERROR, "Netvars incomplete; features may be disabled");
867 else if (g_net.absvelocity < 0) 913 else if (g_net.absvelocity < 0)
868 toastf(TOAST_WARN, "Jumpbug assist disabled: velocity netvar missing"); 914 toastf(TOAST_WARN, "Jumpbug assist disabled: velocity netvar missing");
915 if (g_net.groundentity < 0)
916 toastf(TOAST_WARN, "Stucklaunch prop detection unavailable; bind it");
869 if (!g_iface.engineserver) 917 if (!g_iface.engineserver)
870 toastf(TOAST_WARN, "Server interfaces missing; jumpbug/spread limited"); 918 toastf(TOAST_WARN, "Server interfaces missing; jumpbug/spread limited");
871 if (!g_iface.debugoverlay) 919 if (!g_iface.debugoverlay)