From c947570ddba5f2da3cd4c60e18b408872f3e3f13 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 30 Mar 2023 15:55:36 +0200 Subject: [PATCH] WIP: add no_recoil --- main.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/main.py b/main.py index 7152bf4..99e209a 100644 --- a/main.py +++ b/main.py @@ -267,6 +267,74 @@ class Cheat(Hack): self.hack_loop(cheat) + def no_recoil(self) -> None: + # Aliases + mem = self.pm + offset = self.offsets + + # Get module addresses + client = self.find_module("client") + engine = self.find_module("engine") + + # Get local player + local_player = self.find_uint(client, offset["dwLocalPlayer"]) + + old_punch_x = 0. + old_punch_y = 0. + + def cheat(): + # TODO: Reduce read/write call + + # Check if player is shooting + if mem.read_int(local_player + offset["m_iShotsFired"]): + client_state = mem.read_uint(engine + offset["dwClientState"]) + + # 4 = offset of integer + + # view angle + view_angles_x = mem.read_float( + client_state + offset["dwClientState_ViewAngles"]) + view_angles_y = mem.read_float( + client_state + offset["dwClientState_ViewAngles"] + 4) + + server_mult = 2. + + # recoil + aim_punch_x = mem.read_float( + client_state + offset["m_aimPunchAngle"]) * server_mult + aim_punch_y = mem.read_float( + client_state + offset["m_aimPunchAngle"] + 4) * server_mult + + # New angles + new_angle_x = view_angles_x + old_punch_x - aim_punch_x + new_angle_y = view_angles_y + old_punch_y - aim_punch_y + + # Sanity check + if new_angle_x > 89.: + new_angle_x = 89. + if new_angle_x < -89.: + new_angle_x = -89 + while (new_angle_y > 180.): + new_angle_y -= 360. + while (new_angle_y < -180.): + new_angle_y += 360. + + # Cancel recoil + mem.write_float( + client_state + offset["dwClientState_ViewAngles"], new_angle_x) + mem.write_float( + client_state + offset["dwClientState_ViewAngles"] + 4, new_angle_y) + + old_punch_x = aim_punch_x + old_punch_y = aim_punch_y + + else: + # Not spraying + old_punch_x = 0. + old_punch_y = 0. + + self.hack_loop(cheat) + if __name__ == "__main__": # Cheat