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/chams.py

70 lines
2.3 KiB
Python
Raw Normal View History

2023-03-31 20:34:04 +02:00
from struct import pack
2023-03-31 18:52:22 +02:00
2023-03-31 21:58:07 +02:00
from hack import Hack
from utils import Color3i
2023-03-31 18:52:22 +02:00
class Chams(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
self.__color = Color3i(255, 255, 0)
2023-03-31 18:52:22 +02:00
def chams(self) -> None:
# Aliases
mem = self.pm
offset = self.offsets
# Get module addresses
client = self.find_module("client")
2023-03-31 20:34:04 +02:00
engine = self.find_module("engine")
2023-03-31 18:52:22 +02:00
# Get local player
local_player = self.find_uint(client, offset["dwLocalPlayer"])
def cheat():
# 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
2023-03-31 18:56:02 +02:00
if mem.read_int(entity + offset["m_iTeamNum"]) == 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
# Space between values
i = mem.read_int(
entity + offset["m_iGlowIndex"]) * offset["glow_obj_size"]
# Change color
2023-03-31 21:58:07 +02:00
if self.__color.r > 0:
mem.write_uint(
entity + offset["m_clrRender"] + offset["render_R"], self.__color.r)
if self.__color.g > 0:
mem.write_uint(
entity + offset["m_clrRender"] + offset["render_G"], self.__color.g)
if self.__color.b > 0:
mem.write_uint(
entity + offset["m_clrRender"] + offset["render_B"], self.__color.b)
2023-03-31 20:34:04 +02:00
brightness = 5.
mem.write_int(
engine + offset["model_ambient_min"],
int.from_bytes(pack("f", brightness), byteorder='little') ^ (
engine + offset["model_ambient_min"] - 0x2C)
)
2023-03-31 18:52:22 +02:00
self.hack_loop(cheat)