remove automatically incompatible cheats

This commit is contained in:
Mylloon 2023-04-06 12:38:10 +02:00
parent 18f3a9ca43
commit 8442ed67de
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 22 additions and 2 deletions

View file

@ -38,6 +38,11 @@ class Mycheat(Hack):
5. For more examples, see [the cheats already done](./cheats/)
6. If your cheat logic modifies the same memory of another cheat at the same
time, then add that cheat to the list of incompatibilities in [cheat](./cheat.py)
after the `Incompatible cheats` comment. Add only one entry for your cheat,
it will automatically propagate to the other ones
## Extra infos
- `self.pm` is used to read/write memory

View file

@ -23,3 +23,15 @@ class Cheat(*[child for child in Hack.__subclasses__()]): # type: ignore
if not func.endswith("_unload")
# Utils
if not func.startswith("find_")]
self.incompatible = dict.fromkeys(self.cheats_list, [])
# Incompatible cheats
self.incompatible["aimbot"] = ["norecoil"]
# Builds the implicit list
for cheat, incompatible_cheat_list in self.incompatible.items():
for incompatible_cheat in incompatible_cheat_list:
if not cheat in self.incompatible[incompatible_cheat]:
self.incompatible[incompatible_cheat] = self.incompatible[incompatible_cheat] + [
cheat]

View file

@ -60,10 +60,13 @@ if __name__ == "__main__":
c_id = []
print("Invalid ID.")
# Instanciate and run threads
for fn in [c.cheats_list[i] for i in c_id]:
# Instanciate and run threads, removing incompatibilites
running = []
for fn in [c.cheats_list[i] for i in c_id
if any(map(lambda v: v in c.incompatible[fn], running))]:
print(f"Running {fn}...")
t = Thread(target=getattr(c, fn))
running.append(fn)
t.daemon = True
t.start()