This repository has been archived on 2023-09-02. You can view files and clone it, but cannot push or open issues or pull requests.
csh/cheats/trigger.py

59 lines
1.7 KiB
Python
Raw Normal View History

2023-03-31 18:52:22 +02:00
from win32api import GetAsyncKeyState
from hack import Hack, sleep
class Trigger(Hack):
def __init__(self) -> None:
super().__init__()
def trigger(self) -> None:
# Aliases
mem = self.pm
offset = self.offsets
# Get module address
client = self.find_module("client")
# Get local player
local_player = self.find_uint(client, offset["dwLocalPlayer"])
# Get local team
local_team = self.find_uint(local_player, offset["m_iTeamNum"])
def cheat():
# Pressing trigger key
if not GetAsyncKeyState(self.vmap["+"]):
return
# Check if player is alive
if not mem.read_int(local_player + offset["m_iHealth"]):
return
# Get crosshair info about what we aiming at
crosshair_id = mem.read_int(
local_player + offset["m_iCrosshairId"])
# 0 is wall, +64 isn't a player
if (crosshair_id == 0) or (crosshair_id > 64):
return
# Get ennemy under crosshair
ennemy = mem.read_uint(
client + offset["dwEntityList"] + (crosshair_id - 1) * offset["entity_size"])
# Check if ennemy is alive
if mem.read_int(ennemy + offset["m_lifeState"]):
return
# Ignore allies
if mem.read_int(ennemy + offset["m_iTeamNum"]) == local_team:
return
# Shoot
mem.write_uint(client + offset["dwForceAttack"], 6)
sleep(0.2)
mem.write_uint(client + offset["dwForceAttack"], 4)
self.hack_loop(cheat)