summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/esp.cpp22
-rw-r--r--src/hl2h.cpp33
-rw-r--r--src/hl2h.h1
3 files changed, 52 insertions, 4 deletions
diff --git a/src/esp.cpp b/src/esp.cpp
index f7c24ce..cd0ff36 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -526,6 +526,21 @@ bool aimbot_apply(CUserCmd *cmd) {
526 return true; 526 return true;
527} 527}
528 528
529// Keep the world-space movement wish direction unchanged when the usercmd
530// view angles are temporarily replaced by the silent-aim angles.
531static void preserve_movement(CUserCmd *cmd, float old_yaw, float new_yaw) {
532 float oy = old_yaw * PI_F / 180.0f;
533 float ay = new_yaw * PI_F / 180.0f;
534 float ofx = cosf(oy), ofy = sinf(oy);
535 float orx = sinf(oy), ory = -cosf(oy);
536 float afx = cosf(ay), afy = sinf(ay);
537 float arx = sinf(ay), ary = -cosf(ay);
538 float wx = ofx * cmd->forwardmove + orx * cmd->sidemove;
539 float wy = ofy * cmd->forwardmove + ory * cmd->sidemove;
540 cmd->forwardmove = wx * afx + wy * afy;
541 cmd->sidemove = wx * arx + wy * ary;
542}
543
529bool silent_aim_apply(CUserCmd *cmd) { 544bool silent_aim_apply(CUserCmd *cmd) {
530 unsigned bone_mask = aimbot_bone_mask(); 545 unsigned bone_mask = aimbot_bone_mask();
531 if (!bone_mask) 546 if (!bone_mask)
@@ -546,12 +561,15 @@ bool silent_aim_apply(CUserCmd *cmd) {
546 while (ny > 180.0f) ny -= 360.0f; 561 while (ny > 180.0f) ny -= 360.0f;
547 while (ny < -180.0f) ny += 360.0f; 562 while (ny < -180.0f) ny += 360.0f;
548 563
564 preserve_movement(cmd, orig.y, ny);
565
549 cmd->viewangles[0] = np; 566 cmd->viewangles[0] = np;
550 cmd->viewangles[1] = ny; 567 cmd->viewangles[1] = ny;
551 cmd->viewangles[2] = orig.z; 568 cmd->viewangles[2] = orig.z;
552 569
553 // The usercmd keeps the aim angles (shot/prediction); the rendered camera 570 // Restore now and again at FRAME_RENDER_START (after the engine consumed
554 // is restored to where the player was actually looking. 571 // the aimed usercmd); the frame-stage restore is the one that sticks.
572 set_silent_restore(orig);
555 if (g_iface.engine) { 573 if (g_iface.engine) {
556 QAngle restore{orig.x, orig.y, orig.z}; 574 QAngle restore{orig.x, orig.y, orig.z};
557 using SetViewFn = void (*)(void *, QAngle *); 575 using SetViewFn = void (*)(void *, QAngle *);
diff --git a/src/hl2h.cpp b/src/hl2h.cpp
index 89d6b89..0491fd9 100644
--- a/src/hl2h.cpp
+++ b/src/hl2h.cpp
@@ -278,6 +278,31 @@ static void do_move(int seq) {
278using CreateMoveFn = bool (*)(void *, int, float, bool); 278using CreateMoveFn = bool (*)(void *, int, float, bool);
279static CreateMoveFn oCreateMove = nullptr; 279static CreateMoveFn oCreateMove = nullptr;
280 280
281using FrameStageFn = void (*)(void *, int);
282static FrameStageFn oFrameStageNotify = nullptr;
283static QAngle g_silent_restore_angles{};
284static bool g_silent_restore_pending = false;
285
286void set_silent_restore(const QAngle &angles) {
287 g_silent_restore_angles = angles;
288 g_silent_restore_pending = true;
289}
290
291// FRAME_RENDER_START (ClientFrameStage_t: -1 undefined, 0 START, ...,
292// 4 NET_UPDATE_END, 5 RENDER_START).
293static void hkdFrameStageNotify(void *self, int stage) {
294 if (oFrameStageNotify)
295 oFrameStageNotify(self, stage);
296 if (stage == 5 && g_silent_restore_pending) {
297 g_silent_restore_pending = false;
298 if (g_iface.engine) {
299 QAngle a = g_silent_restore_angles;
300 using SetViewFn = void (*)(void *, QAngle *);
301 vfunc<SetViewFn>(g_iface.engine, 20)(g_iface.engine, &a);
302 }
303 }
304}
305
281using DrawPrintTextFn = void (*)(void *self, const wchar_t *text, int len, int drawType); 306using DrawPrintTextFn = void (*)(void *self, const wchar_t *text, int len, int drawType);
282static DrawPrintTextFn oDrawPrintText = nullptr; 307static DrawPrintTextFn oDrawPrintText = nullptr;
283using PaintTraverseExFn = void (*)(void *, long, bool); 308using PaintTraverseExFn = void (*)(void *, long, bool);
@@ -345,9 +370,13 @@ static void install_hook() {
345 memcpy(newvt, vt, SLOTS * sizeof(void *)); 370 memcpy(newvt, vt, SLOTS * sizeof(void *));
346 oCreateMove = (CreateMoveFn)vt[21]; 371 oCreateMove = (CreateMoveFn)vt[21];
347 newvt[21] = (void *)&hkdCreateMove; 372 newvt[21] = (void *)&hkdCreateMove;
373 oFrameStageNotify = (FrameStageFn)vt[35];
374 newvt[35] = (void *)&hkdFrameStageNotify;
348 VTABLE(g_iface.client) = newvt; 375 VTABLE(g_iface.client) = newvt;
349 logf("hook installed: CreateMove %p -> %p (orig %p)", vt[21], 376 logf("hook installed: CreateMove %p -> %p (orig %p), FrameStageNotify %p "
350 (void *)&hkdCreateMove, (void *)oCreateMove); 377 "-> %p (orig %p)",
378 vt[21], (void *)&hkdCreateMove, (void *)oCreateMove, vt[35],
379 (void *)&hkdFrameStageNotify, (void *)oFrameStageNotify);
351} 380}
352 381
353// --------------------------------------------------------------------------- 382// ---------------------------------------------------------------------------
diff --git a/src/hl2h.h b/src/hl2h.h
index 02be393..a08f029 100644
--- a/src/hl2h.h
+++ b/src/hl2h.h
@@ -185,6 +185,7 @@ int engine_get_local_player();
185void draw_text_col(int x, int y, const char *s, int r, int g, int b); 185void draw_text_col(int x, int y, const char *s, int r, int g, int b);
186void esp_draw(); 186void esp_draw();
187bool world_to_screen(const Vector &w, float &sx, float &sy); 187bool world_to_screen(const Vector &w, float &sx, float &sy);
188void set_silent_restore(const QAngle &angles);
188bool is_visible(const Vector &eye, const Vector &point); 189bool is_visible(const Vector &eye, const Vector &point);
189void *trace_entity(const Vector &start, const Vector &end, void *ignore); 190void *trace_entity(const Vector &start, const Vector &end, void *ignore);
190 191