A set of tools for The Coffin of Andy and Leyley (tested with version 2.0.10, the latest as of writing), written in TypeScript for Deno.
source- Extracts the "main code" of the game.deobfuscate- Applies modifications to the "main code" to make it human-readable.decrypt- Decrypt game files (JSON, audio, images).
If you use this project for anything, please give credit! :) Also, do not share the output of this tool anywhere. This is intended to help modders and those curious about the game, not proliferate piracy.
Scripts
Various scripts are included to run various common operations. Values like <path to input folder> should be substituted with the value they describe, i.e. out.
If you clone this repo and want to run the local scripts, remove the https://codeberg.org/basil/grimoire/raw/branch/main/ from each command before running them.
You may also pass the following arguments (must be after the .ts script location, otherwise Deno will interpret them as flags passed to Deno itself and not the script):
--game-path <path to game folder>- The script will use this value instead of prompting you for the path to the game folder.--out <path to output>- Will replace the default write output of any of the scripts.- For
deobfuscate/main.ts, it will change which file it writes to instead of the defaultclean.js. - For
decrypt/main.ts, it will change the output folder to which it will write to instead of the defaultout/.
- For
Deobfuscating Main Code
To get the deobfuscated code for the game, run deno run --allow-read --allow-write=clean.js --allow-env https://codeberg.org/basil/grimoire/raw/branch/main/deobfuscate/main.ts.
--allow-read: Used for reading files in the game directory. You can limit it to only allow reading from the game directory by using--allow-read=<path to game>.--allow-write=clean.js: The script will make one write call at the end to write the output to a file.--allow-env: A deobfuscation library called webcrack, used for making one final pass on the code to improve readability, makes several reads to the ENV variablebrowserto see if it's running in the browser. Deno does not seem to allow for granularly allowing certain ENV variables (given that theprocess.envobject has all environment variables in it) for npm packages.- You may also be asked for
--allow-sys, which seems to be from thesupports-colornpm package.
Decrypting Assets
To get the decrypted assets for the game, run deno run --allow-read --allow-write=out/ --allow-env https://codeberg.org/basil/grimoire/raw/branch/main/decrypt/main.ts.
The permissions are the same as those for the deobfuscator, except:
--allow-write=out/: The script will write all of the decrypted files to theout/directory.
Explanations
Explanations have been moved to the modding wiki: https://coffin-wiki.basil.cafe/modding/game