summaryrefslogtreecommitdiffstats
path: root/src/hl2h.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-26 17:50:04 +0100
committersalmonik <salmonik@tuta.io>2026-10-26 17:50:04 +0100
commitd44d75991ae24146df535a91a7d0446fcda21f5d (patch)
tree21ed2dcf17aba43604dd35f69b3a210fc72efc0f /src/hl2h.cpp
parentSilent aim: restore view at FRAME_RENDER_START; preserve movement (diff)
downloadhl2h-d44d75991ae24146df535a91a7d0446fcda21f5d.tar.gz
hl2h-d44d75991ae24146df535a91a7d0446fcda21f5d.zip
ABH: silent auto-ABH on the jump tick
- on landing with jump held, face opposite the horizontal velocity and zero forward/side movement for that tick; the HL2 jump speed-bound subtraction then accelerates along the velocity (the classic no-input ABH exploit) - works standalone or with bhop; bhop's auto-strafe still applies in air when enabled - rendered view is restored at FRAME_RENDER_START via the existing hook, so the camera does not flip around
Diffstat (limited to '')
-rw-r--r--src/hl2h.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/hl2h.cpp b/src/hl2h.cpp
index 0491fd9..f3aa26f 100644
--- a/src/hl2h.cpp
+++ b/src/hl2h.cpp
@@ -210,10 +210,11 @@ static void do_move(int seq) {
210 bool inwater = (flags & FL_INWATER) != 0; 210 bool inwater = (flags & FL_INWATER) != 0;
211 211
212 bool bhop_on = feature_active(FEAT_BHOP); 212 bool bhop_on = feature_active(FEAT_BHOP);
213 bool abh_on = feature_active(FEAT_ABH);
213 214
214 static bool lastground = false; 215 static bool lastground = false;
215 216
216 if (bhop_on && (cmd->buttons & IN_JUMP)) { 217 if ((bhop_on || abh_on) && (cmd->buttons & IN_JUMP)) {
217 if (inwater && (cmd->buttons & IN_DUCK)) { 218 if (inwater && (cmd->buttons & IN_DUCK)) {
218 lastground = onground; 219 lastground = onground;
219 return; 220 return;
@@ -233,13 +234,30 @@ static void do_move(int seq) {
233 if (!onground) { 234 if (!onground) {
234 lastground = false; 235 lastground = false;
235 cmd->buttons &= ~IN_JUMP; 236 cmd->buttons &= ~IN_JUMP;
236 if (!inwater && bhop_autostrafe_enabled()) 237 if (bhop_on && !inwater && bhop_autostrafe_enabled())
237 apply_autostrafe(cmd, vel); 238 apply_autostrafe(cmd, vel);
238 note_modified(cmd, flags, vel); 239 note_modified(cmd, flags, vel);
239 } else if (!lastground) { 240 } else if (!lastground) {
240 lastground = true; 241 lastground = true;
241 if (!backmove) 242 if (abh_on) {
243 // ABH jump tick: face opposite the horizontal velocity, hold no
244 // directional keys. The jump speed-bound subtraction then flips into
245 // acceleration along the velocity. The rendered view is restored at
246 // FRAME_RENDER_START so the camera does not spin around.
247 float speed2d = sqrtf(vel[0] * vel[0] + vel[1] * vel[1]);
248 if (speed2d > 1.0f) {
249 float vyaw = atan2f(vel[1], vel[0]) * 180.0f / PI_F;
250 float fake = vyaw + 180.0f;
251 while (fake > 180.0f) fake -= 360.0f;
252 while (fake < -180.0f) fake += 360.0f;
253 cmd->viewangles[1] = fake;
254 cmd->forwardmove = 0.0f;
255 cmd->sidemove = 0.0f;
256 set_silent_restore(QAngle{g_cam_view.x, g_cam_view.y, g_cam_view.z});
257 }
258 } else if (!backmove) {
242 cmd->forwardmove = -0.1f; 259 cmd->forwardmove = -0.1f;
260 }
243 note_modified(cmd, flags, vel); 261 note_modified(cmd, flags, vel);
244 } 262 }
245 } 263 }