add comments, spaces and better fn naming

This commit is contained in:
Mylloon 2023-04-01 16:20:46 +02:00
parent ff150a39ac
commit 342b07e6ea
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
8 changed files with 38 additions and 13 deletions

View file

@ -1,7 +1,7 @@
from win32api import GetAsyncKeyState
from hack import Hack
from utils import Vec, angle_fixer, hypot
from utils import Vec, angle_normalizer, hypot
class Aimbot(Hack):
@ -67,7 +67,8 @@ class Aimbot(Hack):
local_player + offset["m_aimPunchAngle"] + offset["float"])
).times(2.) # server multiple punch by 2
best_fov = self.__fov_range
# Will hold info about the closest ennemy
best_distance = self.__fov_range
best_angle = Vec()
# Loop all entities
@ -103,7 +104,6 @@ class Aimbot(Hack):
# Find head
boneMatrix = mem.read_uint(entity + offset["m_dwBoneMatrix"])
ennemy_head = Vec(
mem.read_float(
boneMatrix + offset["head_idx"] + offset["head_x"]),
@ -113,26 +113,31 @@ class Aimbot(Hack):
boneMatrix + offset["head_idx"] + offset["head_z"])
)
# Angle to ennemy's head
angle = calculate_angle(
local_eye_pos, ennemy_head, view_angles.plus(aim_punch))
# Current FOV
fov = hypot(angle.x, angle.y)
distance = hypot(angle.x, angle.y)
if (fov < best_fov):
best_fov = fov
# If an ennemy is close
if (distance < best_distance):
best_distance = distance
best_angle = angle
# We found an ennemy to aim at
if not best_angle.is_zero():
# Apply the smoothing if needed
if self.__smoothing > 0.:
best_angle = best_angle.div(self.__smoothing)
# Angle from player to ennemy's head
final_angle = view_angles.plus(best_angle)
# Fix angle if needed
final_angle = angle_fixer(final_angle)
final_angle = angle_normalizer(final_angle)
# Move player's view angle
mem.write_float(
client_state + offset["dwClientState_ViewAngles"], final_angle.x)
mem.write_float(

View file

@ -59,6 +59,8 @@ class Chams(Hack):
mem.write_uint(
entity + offset["m_clrRender"] + offset["render_B"], self.__color.b)
# Override the brightness of models by increasing
# the minimal brightness value
brightness = 5.
mem.write_int(
engine + offset["model_ambient_min"],

View file

@ -43,6 +43,7 @@ class Fov(Hack):
# If modified
if fov != self.__fov:
# Override the FOV value
mem.write_int(
local_player + offset["m_iDefaultFOV"], self.__fov)

View file

@ -19,7 +19,9 @@ class Noflash(Hack):
local_player = self.find_uint(client, offset["dwLocalPlayer"])
def cheat():
mem.write_float(local_player + offset["m_flFlashMaxAlpha"], self.__brightness)
# Override the brightness value
mem.write_float(
local_player + offset["m_flFlashMaxAlpha"], self.__brightness)
# Value only overrided on first flash or when server fullupdate
sleep(10)

View file

@ -1,5 +1,5 @@
from hack import Hack
from utils import Vec, angle_fixer
from utils import Vec, angle_normalizer
class Norecoil(Hack):
@ -36,6 +36,7 @@ class Norecoil(Hack):
client_state + offset["dwClientState_ViewAngles"] + offset["float"])
)
# Bullet shift
aim_punch = Vec(
mem.read_float(
local_player + offset["m_aimPunchAngle"]),
@ -44,15 +45,16 @@ class Norecoil(Hack):
).times(2.) # server multiple punch by 2
# New angles
new_angle = angle_fixer(view_angles.plus(
new_angle = angle_normalizer(view_angles.plus(
self.nr__old_punch).minus(aim_punch))
# Cancel recoil
# Cancel recoil by moving the player view angle
mem.write_float(
client_state + offset["dwClientState_ViewAngles"], new_angle.x)
mem.write_float(
client_state + offset["dwClientState_ViewAngles"] + offset["float"], new_angle.y)
# Save the current spray value for the next bullet
self.nr__old_punch = aim_punch
else:

View file

@ -38,6 +38,7 @@ class Radarhack(Hack):
if mem.read_int(entity + offset["m_lifeState"]):
continue
# Mark ennemy as spotted
mem.write_bool(entity + offset["m_bSpotted"], True)
self.hack_loop(cheat)

View file

@ -11,14 +11,18 @@ class Hack():
def __init__(self, offline: bool = False) -> None:
# Loading offsets
self.offsets = self._find_offsets(offline)
# Load virtual mapping of keys
self.vmap = self._find_keys()
# Load process
self.pm = self._find_process(True)
self.wait_time = 0.01
self.timeout = self.wait_time * 50
def _find_offsets(self, offline: bool = False) -> dict[str, int]:
def _find_offsets(self, offline: bool) -> dict[str, int]:
"""Load CSGO offset from online repository or local file"""
if offline:
with open("hazedumper/csgo.min.json", "r") as f:
serial_data = load(f)

View file

@ -2,6 +2,8 @@ from math import atan2, hypot, pi
class Vec:
"""Support : `Vec2i | Vec2f | Vec3i | Vec3f`"""
def __init__(self, x: int | float | None = None, y: int | float | None = None, z: int | float | None = None) -> None:
if x != None:
self.new(x, y, z)
@ -42,6 +44,7 @@ class Vec:
return f"{self.__class__.__name__}({x}, {y}{'' if z == None else f', {z}'})"
def plus(self, other: 'Vec') -> 'Vec':
"""Add 2 vectors"""
x = self.x + other.x
y = self.y + other.y
@ -51,6 +54,7 @@ class Vec:
return Vec(x, y, self.z + other.z)
def minus(self, other: 'Vec') -> 'Vec':
"""Subtracts 2 vectors"""
x = self.x - other.x
y = self.y - other.y
@ -60,6 +64,7 @@ class Vec:
return Vec(x, y, self.z - other.z)
def times(self, factor: float) -> 'Vec':
"""Multiplies 2 vectors"""
x = self.x * factor
y = self.y * factor
@ -69,6 +74,7 @@ class Vec:
return Vec(x, y, self.z * factor)
def div(self, factor: float) -> 'Vec':
"""Divides 2 vectors"""
x = self.x / factor
y = self.y / factor
@ -78,6 +84,7 @@ class Vec:
return Vec(x, y, self.z / factor)
def to_angle(self):
"""Transforms a Vec3 into a Vec2 angle"""
if self.z == None:
raise TypeError
@ -89,6 +96,7 @@ class Vec:
)
def is_zero(self):
"""Check if the vector is zero"""
xy = (float(self.x) == 0.) and (float(self.y) == 0.)
if self.z == None:
return xy
@ -96,7 +104,7 @@ class Vec:
return xy and float(self.z) == 0.
def angle_fixer(angle: Vec) -> Vec:
def angle_normalizer(angle: Vec) -> Vec:
"""Force the angle to respect game limitation"""
# Limit of pitch in game is ]-89; 180[
if angle.x > 89.: