2023-03-31 18:52:22 +02:00
|
|
|
from win32api import GetAsyncKeyState
|
|
|
|
|
|
|
|
from hack import Hack
|
2023-04-01 16:20:46 +02:00
|
|
|
from utils import Vec, angle_normalizer, hypot
|
2023-03-31 18:52:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Aimbot(Hack):
|
2023-04-01 16:11:56 +02:00
|
|
|
def __init__(self, **kwargs) -> None:
|
|
|
|
super().__init__(**kwargs)
|
2023-03-31 18:52:22 +02:00
|
|
|
|
2023-03-31 21:58:07 +02:00
|
|
|
# AimBot FOV, higher = more aggressive
|
2023-05-05 16:04:06 +02:00
|
|
|
self.__fov_range = 4.0
|
2023-03-31 21:58:07 +02:00
|
|
|
|
|
|
|
# Smoothing, more = less efficient
|
2023-05-05 16:04:06 +02:00
|
|
|
self.__smoothing = 6.0
|
2023-03-31 21:58:07 +02:00
|
|
|
|
2023-03-31 18:52:22 +02:00
|
|
|
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 client state
|
|
|
|
client_state = self.find_uint(engine, offset["dwClientState"])
|
|
|
|
|
|
|
|
def cheat():
|
|
|
|
# Pressing left click
|
|
|
|
if not GetAsyncKeyState(self.vmap["LBUTTON"]):
|
|
|
|
return
|
|
|
|
|
|
|
|
# Where are the eyes
|
|
|
|
local_eye_pos = Vec(
|
2023-05-05 16:04:06 +02:00
|
|
|
float(mem.read_float(local_player + offset["m_vecOrigin"])),
|
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
local_player + offset["m_vecOrigin"] + offset["float"]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
local_player + offset["m_vecOrigin"] + offset["float"] * 2
|
|
|
|
)
|
|
|
|
),
|
|
|
|
).plus(
|
|
|
|
Vec(
|
|
|
|
float(mem.read_float(local_player + offset["m_vecViewOffset"])),
|
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
local_player + offset["m_vecViewOffset"] + offset["float"]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
local_player
|
|
|
|
+ offset["m_vecViewOffset"]
|
|
|
|
+ offset["float"] * 2
|
|
|
|
)
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
2023-03-31 18:52:22 +02:00
|
|
|
|
|
|
|
# Where player is looking
|
|
|
|
view_angles = Vec(
|
2023-05-05 16:04:06 +02:00
|
|
|
float(
|
|
|
|
mem.read_float(client_state + offset["dwClientState_ViewAngles"])
|
|
|
|
),
|
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
client_state
|
|
|
|
+ offset["dwClientState_ViewAngles"]
|
|
|
|
+ offset["float"]
|
|
|
|
)
|
|
|
|
),
|
2023-03-31 18:52:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# How much the view is modified
|
|
|
|
aim_punch = Vec(
|
2023-05-05 16:04:06 +02:00
|
|
|
float(mem.read_float(local_player + offset["m_aimPunchAngle"])),
|
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
local_player + offset["m_aimPunchAngle"] + offset["float"]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
).times(
|
|
|
|
2.0
|
|
|
|
) # server multiple punch by 2
|
2023-03-31 18:52:22 +02:00
|
|
|
|
2023-04-01 16:20:46 +02:00
|
|
|
# Will hold info about the closest ennemy
|
|
|
|
best_distance = self.__fov_range
|
2023-03-31 18:52:22 +02:00
|
|
|
best_angle = Vec()
|
|
|
|
|
|
|
|
# Loop all entities
|
|
|
|
for i in range(1, 32): # 0 is world
|
2023-05-05 16:04:06 +02:00
|
|
|
entity = int(
|
|
|
|
mem.read_uint(
|
|
|
|
client + offset["dwEntityList"] + i * offset["entity_size"]
|
|
|
|
)
|
|
|
|
)
|
2023-03-31 18:52:22 +02:00
|
|
|
|
|
|
|
# Ignore if entity doesn't exist
|
|
|
|
if not entity:
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Ignore allies
|
2023-04-01 15:22:13 +02:00
|
|
|
if mem.read_int(entity + offset["m_iTeamNum"]) == (
|
2023-05-05 16:04:06 +02:00
|
|
|
mem.read_int(local_player + offset["m_iTeamNum"])
|
|
|
|
):
|
2023-03-31 18:52:22 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
# Don't aim at ennemy behind a wall
|
|
|
|
if not (
|
2023-05-05 16:04:06 +02:00
|
|
|
int(mem.read_int(entity + offset["m_bSpottedByMask"]))
|
|
|
|
& (
|
|
|
|
1
|
|
|
|
<< int(
|
|
|
|
mem.read_int(
|
|
|
|
client_state + offset["dwClientState_GetLocalPlayer"]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2023-03-31 18:52:22 +02:00
|
|
|
):
|
|
|
|
continue
|
|
|
|
|
|
|
|
# Find head
|
2023-05-05 16:04:06 +02:00
|
|
|
boneMatrix = int(mem.read_uint(entity + offset["m_dwBoneMatrix"]))
|
2023-03-31 18:52:22 +02:00
|
|
|
ennemy_head = Vec(
|
2023-05-05 16:04:06 +02:00
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
boneMatrix + offset["head_idx"] + offset["head_x"]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
boneMatrix + offset["head_idx"] + offset["head_y"]
|
|
|
|
)
|
|
|
|
),
|
|
|
|
float(
|
|
|
|
mem.read_float(
|
|
|
|
boneMatrix + offset["head_idx"] + offset["head_z"]
|
|
|
|
)
|
|
|
|
),
|
2023-03-31 18:52:22 +02:00
|
|
|
)
|
|
|
|
|
2023-04-01 16:20:46 +02:00
|
|
|
# Angle to ennemy's head
|
2023-03-31 18:52:22 +02:00
|
|
|
angle = calculate_angle(
|
2023-05-05 16:04:06 +02:00
|
|
|
local_eye_pos, ennemy_head, view_angles.plus(aim_punch)
|
|
|
|
)
|
2023-03-31 18:52:22 +02:00
|
|
|
|
|
|
|
# Current FOV
|
2023-04-01 16:20:46 +02:00
|
|
|
distance = hypot(angle.x, angle.y)
|
2023-03-31 18:52:22 +02:00
|
|
|
|
2023-04-01 16:20:46 +02:00
|
|
|
# If an ennemy is close
|
2023-05-05 16:04:06 +02:00
|
|
|
if distance < best_distance:
|
2023-04-01 16:20:46 +02:00
|
|
|
best_distance = distance
|
2023-03-31 18:52:22 +02:00
|
|
|
best_angle = angle
|
|
|
|
|
|
|
|
# We found an ennemy to aim at
|
|
|
|
if not best_angle.is_zero():
|
2023-04-01 16:20:46 +02:00
|
|
|
# Apply the smoothing if needed
|
2023-05-05 16:04:06 +02:00
|
|
|
if self.__smoothing > 0.0:
|
2023-03-31 21:58:07 +02:00
|
|
|
best_angle = best_angle.div(self.__smoothing)
|
2023-03-31 18:52:22 +02:00
|
|
|
|
2023-04-01 16:20:46 +02:00
|
|
|
# Angle from player to ennemy's head
|
2023-03-31 18:52:22 +02:00
|
|
|
final_angle = view_angles.plus(best_angle)
|
|
|
|
|
|
|
|
# Fix angle if needed
|
2023-04-01 16:20:46 +02:00
|
|
|
final_angle = angle_normalizer(final_angle)
|
2023-03-31 18:52:22 +02:00
|
|
|
|
2023-04-01 16:20:46 +02:00
|
|
|
# Move player's view angle
|
2023-03-31 18:52:22 +02:00
|
|
|
mem.write_float(
|
2023-05-05 16:04:06 +02:00
|
|
|
client_state + offset["dwClientState_ViewAngles"], final_angle.x
|
|
|
|
)
|
2023-03-31 18:52:22 +02:00
|
|
|
mem.write_float(
|
2023-05-05 16:04:06 +02:00
|
|
|
client_state + offset["dwClientState_ViewAngles"] + offset["float"],
|
|
|
|
final_angle.y,
|
|
|
|
)
|
2023-03-31 18:52:22 +02:00
|
|
|
|
|
|
|
self.hack_loop(cheat)
|
2023-03-31 19:48:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
def calculate_angle(local_pos: Vec, ennemy_pos: Vec, angles: Vec) -> Vec:
|
|
|
|
"""Angle calculation for aimbot"""
|
2023-05-05 16:04:06 +02:00
|
|
|
return ennemy_pos.minus(local_pos).to_angle().minus(angles)
|