use new vec class in no recoil

This commit is contained in:
Mylloon 2023-03-31 04:13:23 +02:00
parent 28b89557e9
commit 2973f0a8ba
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -212,57 +212,42 @@ class Cheat(Hack):
client_state = mem.read_uint(engine + offset["dwClientState"])
# Control variable
self.nr__old_punch_x = 0.
self.nr__old_punch_y = 0.
self.nr__old_punch = Vec()
def cheat():
# Check if player is shooting
if mem.read_int(local_player + offset["m_iShotsFired"]):
# Where player is looking
view_angles_x = mem.read_float(
client_state + offset["dwClientState_ViewAngles"])
view_angles_y = mem.read_float(
client_state + offset["dwClientState_ViewAngles"] + offset["float"])
view_angles = Vec(
mem.read_float(
client_state + offset["dwClientState_ViewAngles"]),
mem.read_float(
client_state + offset["dwClientState_ViewAngles"] + offset["float"])
)
# Server multiple punch by 2
server_mult = 2.
# How much the view is modified
aim_punch_x = mem.read_float(
local_player + offset["m_aimPunchAngle"]) * server_mult
aim_punch_y = mem.read_float(
local_player + offset["m_aimPunchAngle"] + offset["float"]) * server_mult
aim_punch = Vec(
mem.read_float(
local_player + offset["m_aimPunchAngle"]),
mem.read_float(
local_player + offset["m_aimPunchAngle"] + offset["float"])
).times(2.) # server multiple punch by 2
# New angles
new_angle_x = view_angles_x + self.nr__old_punch_x - aim_punch_x
new_angle_y = view_angles_y + self.nr__old_punch_y - aim_punch_y
# Limit of pitch in game is ]-89; 180[
if new_angle_x > 89.:
new_angle_x = 89.
if new_angle_x < -89.:
new_angle_x = -89
# Limit of yaw in game is ]-180; 360[
while (new_angle_y > 180.):
new_angle_y -= 360.
while (new_angle_y < -180.):
new_angle_y += 360.
new_angle = angle_fixer(view_angles.plus(
self.nr__old_punch).minus(aim_punch))
# Cancel recoil
mem.write_float(
client_state + offset["dwClientState_ViewAngles"], new_angle_x)
client_state + offset["dwClientState_ViewAngles"], new_angle.x)
mem.write_float(
client_state + offset["dwClientState_ViewAngles"] + offset["float"], new_angle_y)
client_state + offset["dwClientState_ViewAngles"] + offset["float"], new_angle.y)
self.nr__old_punch_x = aim_punch_x
self.nr__old_punch_y = aim_punch_y
self.nr__old_punch = aim_punch
else:
# Not spraying
self.nr__old_punch_x = 0.
self.nr__old_punch_y = 0.
self.nr__old_punch = Vec()
self.hack_loop(cheat)