Scripts - Tkachov/ALERT GitHub Wiki

Quick overview of scripts available in repo. In general, running those without arguments should prompt with a usage message. For example:

Usage:
$ animclip_to_gltf.py <.model filename> <.animclip filename> [output .gltf filename]

Tells that animclip_to_gltf.py script has two required arguments, first being .model filename and second being .animclip. Third argument is optional, and determines custom .gltf filename for output file.

Some of the scripts are built into server.exe that is available in Releases. In this case, they could be run from command line like server.exe animclip_to_gltf path-to.model path-to.animclip. But overall, it's expected that scripts users are researchers or experienced mod makers, know how to run a Python script and can read the code to fix it if it doesn't work the way they want.

.ascii

model_to_ascii.py

$ model_to_ascii.py <.model filename> [output .ascii filename] [output materials.txt filename]

Extracts .model data to .ascii. Only writes 'materials.txt' if filename is specified. 'materials.txt' is formatted the same way as ID-Daemon's spiderman_pc_model.exe formats it.

ascii_to_model.py

$ ascii_to_model.py <.ascii filename> <source .model filename> [materials.txt filename] [output .model filename]

Injects .ascii data (vertexes, faces, weights) into .model, writing the result as a new .model file. If given, reads materials.txt to update lookgroups and materials.

spiderman_pc_model.py

$ spiderman_pc_model.py <.model filename>

Imitates the behavior of ID-Daemon's spiderman_pc_model.exe. Is simply a wrapper around model_to_ascii.py.

spiderman_pc_mi.py

$ spiderman_pc_mi.py <.model filename> <.ascii filename> [_materials.txt filename]

Imitates the behavior of ID-Daemon's spiderman_pc_mi.exe. Is simply a wrapper around ascii_to_model.py.

diff_ascii.py

$ diff_ascii.py <filename1> <filename2>

Compares two .ascii files. Could be useful while debugging the above scripts. Return code is 0 if files are the same and 1 if they are not. If they are different, prints a message describing the difference.

Epsilon for comparing floats, as well as booleans controlling which parts to diff, are at the top of the scripts. Some can be overriden using environment variables.

GLTF

model_to_gltf.py

$ model_to_gltf.py <.model filename> [output .gltf filename]

Similarly to model_to_ascii.py, extracts .model data. In this case, to GLTF. Has a ADD_SHAPEKEYS variable at the top of the script, which allows to enable or disable extraction of shapekeys. Shapekeys support is not perfect, and bloats file size. Doesn't write 'materials.txt'.

gltf_to_model.py

$ gltf_to_model.py <.gltf filename> <source .model filename> [materials.txt filename] [output .model filename]

Similarly to ascii_to_model.py, injects data (vertexes, faces, weights) into .model. In this case, from GLTF. Optionally, can read a 'materials.txt' to change lookgroups and materials. Doesn't inject shapekeys.

animclip_to_gltf.py

$ animclip_to_gltf.py <.model filename> <.animclip filename> [output .gltf filename]

Writes GLTF for .model with default pose (first frame) from .animclip applied. .animclip support is poor, so poses usually don't look correct. Writes shapekeys (but doesn't have ADD_SHAPEKEYS variable to disable that).

Other assets

reconstruct_nodegraph.py

$ reconstruct_nodegraph.py <filename>

Reconstructs built .nodegraph into .json representation. Is used in Assets Browser .nodegraph viewer. Doesn't support subgraphs.

change_soundbank.py

$ change_soundbank.py <.soundbank filename> <.bnk filename>

Injects .bnk as corresponding section of .soundbank, writing the result as a .soundbank.edited file.

config2json.py

$ config2json.py <filename>

Extracts main section of .config as .json. Prints .config type to stdout.

json2config.py

$ json2config.py <filename> <config type>

Makes .config with main section matching .json given, and type set to type given.

DSAR

dsar_codec.py

$ dsar_codec.py <filename>

If '<filename>' is DSAR archive, uncompresses it to '<filename>.dec'. Otherwise, compresses it into DSAR archive to '<filename>.dsar'.

Only supports LZ4 (DSAR compression type = 3).

Assets Browser

editor.py

$ editor.py [arg]

Runs Assets Browser.

arg could be "so" to run in Sunset Overdrive mode (all asset IDs are 32-bit), "msmr" to force MSMR mode (in some cases it can think passed 'toc' is for RCRA) or "-try-second-magic" to try to detect asset type not by first magic, but by magic that comes after DAT1.

Passing anything else as argument(s) causes main.py to work instead of launching Assets Browser.

main.py

$ main.py [script] [args]

Runs one of the supported scripts. Passing unknown script name or no arguments shows the list of possible scripts and their brief description.

Other scripts

extract_assets.py

$ extract_assets.py <asset_archive path>

Interactive assets extractor. Opens 'toc' file and asks user to enter asset IDs to extract. If no ID is given, stops.

extract_section.py

$ extract_section.py <filename> <section index or tag>

Reads a DAT1 asset and extracts specified section into a separate file.

info.py

$ info.py <filename>

Reads a DAT1 asset and tries to print as much information about it as possible. Basically a command line version of Assets Browser section view.

short_diff.py

$ short_diff.py <filename> <filename>

Compares two DAT1 files, printing which sections differ.

⚠️ **GitHub.com Fallback** ⚠️