-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.py
More file actions
93 lines (84 loc) · 3.4 KB
/
mod.py
File metadata and controls
93 lines (84 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import time
import threading
from pymem import Pymem
from pymem.process import module_from_name
import psutil
def is_process_running(process_name):
for proc in psutil.process_iter(['pid', 'name']):
if proc.info['name'] == process_name:
return True
return False
class AssultCubeMod:
def __init__(self):
if not is_process_running("ac_client.exe"):
print("Assault Cube is not running. Please start the game first.")
exit()
try:
self.pm = Pymem("ac_client.exe")
self.module = module_from_name(self.pm.process_handle, "ac_client.exe").lpBaseOfDll
self.id_and_address = f"Process ID: {self.pm.process_id} , Base Address: {hex(self.module)}"
self.health_address = self.module + 0x0017E0A8 # health ptr chain,, 0xEC
self.ammo_address = self.module + 0x0018AC00 # ammo ptr chain,, 0x140
self.health_offset = 0xEC
self.ammo_offset = 0x140
self.god_mode = False
self.god_mode_thread = None
except Exception as e:
print(f"Error initializing Pymem:: {e}")
exit()
def GetHealthPTR(self):
try:
base_pointer = self.pm.read_int(self.health_address)
if not base_pointer:
print("Health Base pointer is null.")
return None
health_address = base_pointer + self.health_offset
return health_address
except Exception as e:
print(f"Error reading health memory: {e}")
return None
def GetAmmoPTR(self):
try:
base_pointer = self.pm.read_int(self.ammo_address)
if not base_pointer:
print("Ammo base pointer is null.")
return None
ammo_address = base_pointer + self.ammo_offset
return ammo_address
except Exception as e:
print(f"Error reading ammo memory: {e}")
return None
def set_health(self, value, log=True):
health_address = self.GetHealthPTR()
if health_address:
try:
self.pm.write_int(health_address, value)
if log:
print(f"Health set to {value}")
except Exception as e:
if log:
print(f"Failed to set health: {e}")
def set_ammo(self, value, log=True):
ammo_address = self.GetAmmoPTR()
if ammo_address:
try:
self.pm.write_int(ammo_address, value)
if log:
print(f"Ammo set to {value}")
except Exception as e:
if log:
print(f"Failed to set ammo: {e}")
def toggle_god_mode(self):
self.god_mode = not self.god_mode
print(f"God Mode: {'ON' if self.god_mode else 'OFF'}")
if self.god_mode:
self.god_mode_thread = threading.Thread(target=self.god_mode_loop, daemon=True)
self.god_mode_thread.start()
else:
if self.god_mode_thread:
self.god_mode_thread.join()
def god_mode_loop(self):
while self.god_mode:
self.set_health(9999, log=False) #"log=False" is used to prevent logging repeated messages.
self.set_ammo(999, log=False)
time.sleep(0.1)