optimize
This commit is contained in:
parent
44d19f15a3
commit
dcb53ae52f
1 changed files with 17 additions and 25 deletions
42
main.py
42
main.py
|
@ -55,10 +55,11 @@ class Hack():
|
||||||
raise MemoryError
|
raise MemoryError
|
||||||
|
|
||||||
def find_int(self, base, offset: int) -> int:
|
def find_int(self, base, offset: int) -> int:
|
||||||
"""Find integer in memory"""
|
"""Find integer in memory for sure"""
|
||||||
local_element = None
|
local_element = None
|
||||||
while not local_element:
|
while not local_element:
|
||||||
local_element = self.pm.read_uint(base + offset)
|
local_element = self.pm.read_uint(base + offset)
|
||||||
|
|
||||||
sleep(self.timeout)
|
sleep(self.timeout)
|
||||||
|
|
||||||
return local_element
|
return local_element
|
||||||
|
@ -97,7 +98,7 @@ class Cheat(Hack):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check if player is alive
|
# Check if player is alive
|
||||||
if not mem.read_int(local_player + offset["m_iHealth"]):
|
if not mem.read_uint(local_player + offset["m_iHealth"]):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Check if player on ground
|
# Check if player on ground
|
||||||
|
@ -115,42 +116,33 @@ class Cheat(Hack):
|
||||||
client = self.find_module("client")
|
client = self.find_module("client")
|
||||||
|
|
||||||
# Get local player
|
# Get local player
|
||||||
print("Looking for player...")
|
|
||||||
local_player = self.find_int(client, offset["dwLocalPlayer"])
|
local_player = self.find_int(client, offset["dwLocalPlayer"])
|
||||||
|
|
||||||
# Get local team
|
# Get local team
|
||||||
print("Looking for team...")
|
|
||||||
local_team = self.find_int(local_player, offset["m_iTeamNum"])
|
local_team = self.find_int(local_player, offset["m_iTeamNum"])
|
||||||
|
|
||||||
print("Looking for entities...")
|
|
||||||
# idx 0 == world
|
|
||||||
ennemies = []
|
|
||||||
for i in range(1, 64):
|
|
||||||
entity = self.find_int(
|
|
||||||
client, offset["dwEntityList"] + i * 0x10)
|
|
||||||
|
|
||||||
# Ignore allies
|
|
||||||
print("Check entity team...", end=" ")
|
|
||||||
if self.find_int(entity, offset["m_iTeamNum"] == local_team):
|
|
||||||
print("ally found...")
|
|
||||||
continue
|
|
||||||
|
|
||||||
print("ennemy found...")
|
|
||||||
ennemies.append(entity)
|
|
||||||
|
|
||||||
# Hack loop
|
# Hack loop
|
||||||
print("Running...")
|
|
||||||
while True:
|
while True:
|
||||||
# Reduce CPU usage
|
# Reduce CPU usage
|
||||||
sleep(self.wait_time)
|
sleep(self.wait_time)
|
||||||
|
|
||||||
# Show ennemies
|
# Show ennemies
|
||||||
for ennemy in ennemies:
|
for i in range(1, 64): # 0 is world
|
||||||
# Check if ennemy is alive
|
entity = mem.read_uint(
|
||||||
if not self.find_int(ennemy, offset["m_iHealth"]):
|
client + offset["dwEntityList"] + i * 0x10)
|
||||||
|
|
||||||
|
if not entity:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
mem.write_bool(ennemy + offset["m_bSpotted"], True)
|
# Ignore allies
|
||||||
|
if mem.read_uint(entity + offset["m_iTeamNum"]) == local_team:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Check if ennemy is alive
|
||||||
|
if not mem.read_uint(entity + offset["m_iHealth"]):
|
||||||
|
continue
|
||||||
|
|
||||||
|
mem.write_bool(entity + offset["m_bSpotted"], True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Reference in a new issue