add aimbot

This commit is contained in:
Mylloon 2023-03-31 04:08:21 +02:00
parent cfaef4f2c2
commit 28b89557e9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

123
cheat.py
View file

@ -1,7 +1,8 @@
from win32api import GetAsyncKeyState
from win32con import EM_LINEINDEX, VK_SPACE
from win32con import EM_LINEINDEX, LOCKF_PHYSICAL_LOCK, VK_SPACE
from hack import Hack, sleep
from utils import Vec, angle_fixer, calculate_angle, hypot
class Cheat(Hack):
@ -266,9 +267,125 @@ class Cheat(Hack):
self.hack_loop(cheat)
def aimbot(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 local team
local_team = self.find_uint(local_player, offset["m_iTeamNum"])
# Get client state
client_state = self.find_uint(engine, offset["dwClientState"])
def cheat():
print("WIP")
exit(2)
# Pressing left click
if not GetAsyncKeyState(LOCKF_PHYSICAL_LOCK):
return
# Where are the eyes
local_eye_pos = Vec(
mem.read_float(
local_player + offset["m_vecOrigin"]),
mem.read_float(
local_player + offset["m_vecOrigin"] + offset["float"]),
mem.read_float(
local_player + offset["m_vecOrigin"] + offset["float"] * 2)
).plus(Vec(
mem.read_float(
local_player + offset["m_vecViewOffset"]),
mem.read_float(
local_player + offset["m_vecViewOffset"] + offset["float"]),
mem.read_float(
local_player + offset["m_vecViewOffset"] + offset["float"] * 2)
))
# 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"])
)
# How much the view is modified
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
# AimBot FOV
best_fov = 5.
best_angle = Vec()
# Loop all entities
for i in range(1, 32): # 0 is world
entity = mem.read_uint(
client + offset["dwEntityList"] + i * offset["entity_size"])
# Ignore if entity doesn't exist
if not entity:
continue
# Ignore allies
if mem.read_int(entity + offset["m_iTeamNum"]) == local_team:
continue
# Ignore dormant
if mem.read_bool(entity + offset["m_bDormant"]):
continue
# Check if ennemy is alive
if mem.read_int(entity + offset["m_lifeState"]):
continue
# TODO: Ignore ennemies behind wall
# Find head
boneMatrix = mem.read_uint(entity + offset["m_dwBoneMatrix"])
ennemy_head = Vec(
mem.read_float(
boneMatrix + offset["head_idx"] + offset["head_x"]),
mem.read_float(
boneMatrix + offset["head_idx"] + offset["head_y"]),
mem.read_float(
boneMatrix + offset["head_idx"] + offset["head_z"])
)
angle = calculate_angle(
local_eye_pos, ennemy_head, view_angles.plus(aim_punch))
# Current FOV
fov = hypot(angle.x, angle.y)
if (fov < best_fov):
best_fov = fov
best_angle = angle
# We found an ennemy to aim at
if not best_angle.is_zero():
# Smoothing
best_angle = best_angle.div(3.)
final_angle = view_angles.plus(best_angle)
# Fix angle if needed
final_angle = angle_fixer(final_angle)
# Some sub to adujst the final position
mem.write_float(
client_state + offset["dwClientState_ViewAngles"], final_angle.x - .2)
mem.write_float(
client_state + offset["dwClientState_ViewAngles"] + offset["float"], final_angle.y - .1)
self.hack_loop(cheat)