-
Notifications
You must be signed in to change notification settings - Fork 19
2. Sprites
All the visuals for Fields of Mistria are small individual images known as "sprites". Whether it's a piece of clothing, a character walking around or a building they all refer to these sprite images in the game and they're all stored in the assets.zip file inside Fields of Mistria. If you want to see the sprites individually, you can unzip the file to see how they're structured. (It will take a while, since there are many, many individual files for your computer to unpack.) Sprites are located in the animations folder of the assets.zip.
Sprites can have many parts, but the most basic ones will at least have an image file, a .meta.toml file, and a poly .meta.toml file. Animated sprites are stored as a sprite sheet, with each frame stitched into a long horizontal image. (For those reading who modded under the original game engine, the sprite sheet format is new since the maybe engine update, and is one of the major differences in formatting.)
Every sprite in FoM comes with its own .meta.toml file, which gives it a unique ID, along with other key information (metadata) about the file. Here's the .meta.toml file for the tortie cat's east action sprite sheet:
[meta_properties]
id = "5f591756f29e1c0d"
asset_kind = "Animation"
[asset_properties]
frame_size = [48, 40]
frame_len = 13
duration = [0.15, 0.15, 0.3, 0.4, 0.3, 0.25, 0.15, 0.25, 0.25, 0.25, 0.25, 0.25, 0.8]
atlas = "Default"
[asset_properties.offset]
horizontal = 24.0
vertical = 31.0For more information on sprite TOML files, see the devs' official docs here.
Assets in Mistria are given unique IDs, each a 16 character hexadecimal number. These are what is referenced by the game internally when trying to find your sprite. For MOMI mods, this ID is not required. While some mods may provide their own IDs, this is not recommended as it creates another possible point of error.
To reiterate, in your MOMI mods, it is recommended to not include the line that provides an ID.
All sprites have asset_kind "Animation". This is just the term they have used for this data format.
Texture atlases are an optimization that many games use to speed up performance by packing many images into one large image that only needs to be loaded once. In Mistria's case, every sprite has its whitespace trimmed and packed into atlases by their in-house engine, maybe. As of version 0.16.4, there are only 3 atlases: one for UI, one for NPCs, and the rest go into Default.
When the game loads, it doesn't actually load every individual small image in the animations folder, only the atlases. If you were to only replace an image directly in the animations folder, the game would not display your change because it remains unchanged in the atlas. This is why MOMI needs to recognize your images so it can pack them into the atlas for the game to load.
For more info on atlases, you can read the devs' official documentation here.
The example given above is an animated sprite, with variable frame durations. However, if the sprite you are working with is not animated, it will have a frame length of 1 and duration of 0.0.
Under the assets folder, there is another relevant folder called shapes. This folder contains additional data for every sprite in the game. Here is the corresponding poly file for the tortie cat's east action sprite sheet:
[meta_properties]
id = "49b8253b75d04820"
asset_kind = "Shape"
required_assets = ["5f591756f29e1c0d"]
[asset_properties]
kind = "box"
offset = [-9, -16]
dimensions = [20, 18]You'll notice that required_assets points back to the sprite id, and that the data has a different format, "Shape". This information seems to be mostly generated by Mistria's engine. The devs use the data in the game's physics engine, and potentially also to trim the whitespace for atlases. For the devs' official documentation on shape files, read more here.
As with the sprite toml ID, MOMI will handle the ID and the required_assets key for you. We recommend not including these lines in your mod files.
MOMI has a unique framework for sprite replacement, since it's a common type of mod. This section covers how to make your own sprite replacement mod.
The file should be located somewhere in assets/animations. You can use the vanilla file organization to help guide your search, but know that the folders are only there for organization, since the game uses the unique ID's to fetch the assets themselves. Once you find the file, make note of its name as well as the associated TOML file, as you will need this later.
Because MOMI needs to pack your changes into the games atlases, your sprite must be located in a folder in your mod directory called images. For sprite replacement mods, your replacement files should be located in a subfolder within images called replace.
Place your replacement files into the images/replace folder, making sure the name is the exact same as the vanilla files. You do not need to worry about replicating the folder system of the game's assets.zip, as MOMI will search through the directory to find the file by the filename you provided.
At this point, your mod folder should look something like this:
example_mod/
├── manifest.toml
└── images/
└── replace/
├── spr_vanilla_sprite_name.png
└── spr_vanilla_sprite_name.meta.toml (optional, if edited)
At this point, most replacement mods are done. Some, however, also need to edit the meta TOML files and the shape TOML files. As of the current version of MOMI (0.13.3), sprite TOML files can go in the images/replace file like the image file. However, if you need to modify the shape file, you'll need to locate the shape file and replicate the folder structure of the shapes folder to overwrite it using MOMI's normal functionality. The folder structure in the shapes folder exactly mirrors the animations folder, so you can use the same path you used to find the sprite originally.
Because MOMI needs to handle atlas packing, you will need to create a folder called images in your mod directory so MOMI can find what needs to be packed. This is the case for both the sprite image and the meta TOML file.
Your sprite should be named according to the naming convention: spr_[your_sprite_name].png.
Your TOML file should be named according to the naming convention: spr_[your_sprite_name].meta.toml, and contain the relevant asset_properties. If you're confused, take a look at the example at the start of this page as well as similar sprites found in the animations folder. You do not have to worry about the meta_properties as MOMI will know that this is asset_kind "Animation" from its location in the images folder, and it will generate an ID for you.
When defining a new shape file, you only need to worry about the [asset_properties] section, as MOMI should generate an ID for you and link the file to the associated sprite. MOMI does this by following the naming convention, where your shape file should be poly_[your_sprite_name].meta.toml, like your other files spr_[your_sprite_name].png and spr_[your_sprite_name].meta.toml.
The file should be placed in a folder called shapes under your mod directory (just like in the vanilla assets folder). You don't need to worry about sorting into a relevant subfolder because shape files are referenced by ID, not by folder location.