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

66 lines
1.9 KiB
Python
Raw Permalink Normal View History

2023-03-31 18:52:22 +02:00
from win32api import GetAsyncKeyState
from hack import Hack, sleep
class Trigger(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
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"])
def cheat():
# Pressing trigger key
if not GetAsyncKeyState(self.vmap["+"]):
return
# Check if player is alive
2023-03-31 19:22:19 +02:00
if mem.read_int(local_player + offset["m_lifeState"]):
2023-03-31 18:52:22 +02:00
return
# Get crosshair info about what we aiming at
2023-05-05 16:04:06 +02:00
crosshair_id = int(mem.read_int(local_player + offset["m_iCrosshairId"]))
2023-03-31 18:52:22 +02:00
# 0 is wall, +64 isn't a player
if (crosshair_id == 0) or (crosshair_id > 64):
return
# Get ennemy under crosshair
2023-05-05 16:04:06 +02:00
ennemy = int(
mem.read_uint(
client
+ offset["dwEntityList"]
+ (crosshair_id - 1) * offset["entity_size"]
)
)
2023-03-31 18:52:22 +02:00
2023-03-31 19:45:59 +02:00
# Ignore dormant
if mem.read_bool(ennemy + offset["m_bDormant"]):
return
2023-03-31 18:52:22 +02:00
# Check if ennemy is alive
if mem.read_int(ennemy + offset["m_lifeState"]):
return
# Ignore allies
2023-05-05 16:04:06 +02:00
if mem.read_int(ennemy + offset["m_iTeamNum"]) == mem.read_int(
local_player + offset["m_iTeamNum"]
):
2023-03-31 18:52:22 +02:00
return
# Shoot
mem.write_uint(client + offset["dwForceAttack"], 6)
sleep(0.2)
mem.write_uint(client + offset["dwForceAttack"], 4)
self.hack_loop(cheat)