remove automatically incompatible cheats
This commit is contained in:
parent
18f3a9ca43
commit
8442ed67de
3 changed files with 22 additions and 2 deletions
5
GUIDE.md
5
GUIDE.md
|
@ -38,6 +38,11 @@ class Mycheat(Hack):
|
||||||
|
|
||||||
5. For more examples, see [the cheats already done](./cheats/)
|
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
|
## Extra infos
|
||||||
|
|
||||||
- `self.pm` is used to read/write memory
|
- `self.pm` is used to read/write memory
|
||||||
|
|
12
cheat.py
12
cheat.py
|
@ -23,3 +23,15 @@ class Cheat(*[child for child in Hack.__subclasses__()]): # type: ignore
|
||||||
if not func.endswith("_unload")
|
if not func.endswith("_unload")
|
||||||
# Utils
|
# Utils
|
||||||
if not func.startswith("find_")]
|
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]
|
||||||
|
|
7
main.py
7
main.py
|
@ -60,10 +60,13 @@ if __name__ == "__main__":
|
||||||
c_id = []
|
c_id = []
|
||||||
print("Invalid ID.")
|
print("Invalid ID.")
|
||||||
|
|
||||||
# Instanciate and run threads
|
# Instanciate and run threads, removing incompatibilites
|
||||||
for fn in [c.cheats_list[i] for i in c_id]:
|
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}...")
|
print(f"Running {fn}...")
|
||||||
t = Thread(target=getattr(c, fn))
|
t = Thread(target=getattr(c, fn))
|
||||||
|
running.append(fn)
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
|
|
Reference in a new issue