-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
65 lines (55 loc) · 2.14 KB
/
main.py
File metadata and controls
65 lines (55 loc) · 2.14 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
from os import environ
environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"
import os
import signal
from time import sleep
import pygame
from pymem import Pymem
from pymem.exception import MemoryReadError, ProcessError, ProcessNotFound
from rich import print
from rich.console import Console
pygame.mixer.init(frequency=48000, buffer=2048)
base_address = 0x072F2088
offset = [0x1B8, 0x268, 0x378]
def main() -> None:
Console().clear()
print("Starting ...")
print("BACK UP YOUR SAVES, THIS WILL DELETE YOUR SAVE(Save1.sav) INSTANTLY IF A SAVE IS LOADED WITH FAILED PARCELS IN IT.")
check_fails()
if input("Hit 'Enter' to Exit. Y to restart.").lower() == "y":
main()
def check_fails() -> None:
try:
global game_mem, fail_count_address
game_mem = Pymem("parcel-Win64-Shipping.exe")
while game_mem:
fail_count_address = game_mem.resolve_offsets(base_address, offset)
fails = int(game_mem.read_int(fail_count_address))
if fails > 0 and game_mem.process_id:
print(f"[bold red]{fails} Fails detected![/bold red]")
audio = pygame.mixer.Sound("Failed.mp3").play()
while audio.get_busy():
sleep(0.1)
sleep(1)
savepath = os.path.join((os.getenv("LOCALAPPDATA")) or "", "\\parcel\\Saved\\SaveGames\\Save1.sav")
os.kill(game_mem.process_id, signal.SIGTERM)
## Delete the first save file ALWAYS
os.remove(savepath) # This will NOT look for what save you are playing.
print("[bold red]Save file deleted.[/bold red]")
break
else:
print("[bold green]No fails detected.[/bold green]", end="\r")
sleep(1)
sleep(1)
except (ProcessNotFound, ProcessError):
print("Parcel Simulator not running.")
except FileNotFoundError:
print("Save file not found.")
except MemoryReadError:
print("Failed to read memory.")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\nExiting ...")
pygame.mixer.quit()