Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- from os.path import isfile
- from getpass import getuser
- from json import loads, dumps
- KEY = b"CHANGE ME TO YOUR OWN RANDOM STRING"
- SAVE_PATH = fr"C:\Users\{getuser()}\AppData\LocalLow\Kinetic Games\Phasmophobia\saveData.txt"
- def read_file(filename: str) -> bytes:
- with open(filename, "rb") as f:
- data = f.read()
- return data
- def write_file(filename: str, data: (str, bytes, bytearray)) -> None:
- with open(filename, "w" if type(data) == str else "wb") as f:
- f.write(data)
- def scramble(data: (str, bytes, bytearray)) -> bytearray:
- if type(data) == str:
- data = bytearray(data.encode("UTF8"))
- elif type(data) == bytes:
- data = bytearray(data)
- for i in range(len(data)):
- data[i] ^= KEY[i % len(KEY)]
- return data
- unscramble = lambda d: scramble(d)
- def main() -> None:
- if not isfile("saveData.json") and isfile(SAVE_PATH):
- save_data_enc = read_file(SAVE_PATH)
- save_data_dec = unscramble(save_data_enc)
- save_data_json = loads(save_data_dec)
- write_file("saveData.json", dumps(save_data_json, indent=4))
- print("Dumped save file to \"saveData.json\"!")
- print("Edit this file and run again to create a modified save file.")
- else:
- save_data_dec = read_file("saveData.json")
- save_data_json = loads(save_data_dec)
- i = 0
- for entry in save_data_json["IntData"]:
- (key, value) = entry.values()
- if key == "myTotalExp": # experience
- save_data_json["IntData"][i]["Value"] = 999999
- elif key == "PlayersMoney": # money
- save_data_json["IntData"][i]["Value"] = 999999
- elif key.endswith("Inventory"): # items
- save_data_json["IntData"][i]["Value"] = 999
- elif key == "PlayerDied" and value > 0: # death count
- save_data_json["IntData"][i]["Value"] = 0
- elif key == "completedTraining" and value == 0: # tutorial finished
- save_data_json["IntData"][i]["Value"] = 1
- i += 1
- save_data_enc = scramble(dumps(save_data_json, separators=(",", ":")))
- write_file(SAVE_PATH, save_data_enc)
- print("Wrote modified save file!")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement