63 lines
2 KiB
Python
63 lines
2 KiB
Python
from hack import Hack
|
|
from utils import Vec, angle_fixer
|
|
|
|
|
|
class Norecoil(Hack):
|
|
def __init__(self) -> None:
|
|
super().__init__()
|
|
|
|
|
|
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"])
|
|
|
|
# Get client state
|
|
client_state = mem.read_uint(engine + offset["dwClientState"])
|
|
|
|
# Control variable
|
|
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 = Vec(
|
|
mem.read_float(
|
|
client_state + offset["dwClientState_ViewAngles"]),
|
|
mem.read_float(
|
|
client_state + offset["dwClientState_ViewAngles"] + offset["float"])
|
|
)
|
|
|
|
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 = 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)
|
|
mem.write_float(
|
|
client_state + offset["dwClientState_ViewAngles"] + offset["float"], new_angle.y)
|
|
|
|
self.nr__old_punch = aim_punch
|
|
|
|
else:
|
|
# Not spraying
|
|
self.nr__old_punch = Vec()
|
|
|
|
self.hack_loop(cheat)
|