Skip to content

Metatile Attributes

grunt-lucas edited this page Jul 15, 2024 · 5 revisions

Table Of Contents

Basic Setup

Metatile attributes are a key part of any good tileset. As such, Porytiles supports seamless attribute management via an easy-to-use CSV file. Simply create a file called attributes.csv in your source tileset folder, right next to your layer PNGs.

The first line of the attribute file is the column key. For the default target base game, pokeemerald, it should look like this:

id,behavior

On subsequent lines, you can then specify a metatile ID followed by the desired behavior for that metatile. The behavior can be either a raw integral value, or a metatile behavior label as defined in the given include/constants/metatile_behaviors.h. Porytiles recommends that you use the label as opposed to the integral value, as it is more flexible and less error prone. For example:

11,MB_TALL_GRASS

This line specifies that the metatile with ID 11 should have the behavior value associated with label MB_TALL_GRASS. After compiling and refreshing Porymap, you should see the behaviors you specified in the CSV file appear in the tileset editor window.

Any metatile you don't explicitly specify in attributes.csv will receive the default value of 0 for all attributes. You can change this with the various -default-* options detailed below.

Attributes For pokeruby And pokeemerald

For target base games pokeruby and pokeemerald, the attribute column format should be id,behavior as indicated above. Any deviation from this format will present a compilation error.

Attributes For pokefirered

For target base game pokefirered, the attribute column format should be id,behavior,terrainType,encounterType. Any deviation from this format will present a compilation error.

Attribute Options

Attribute generation can be tweaked via the following command options. These options should be supplied after the compilation command, i.e. after compile-primary or compile-secondary.

-disable-attribute-generation

Ignore the contents of attributes.csv and skip generation of metatile_attributes.bin. Enable this option if you want to manage attributes via Porymap instead of the CSV file. Otherwise, Porytiles will write metatile_attributes.bin to your output location, which will overwrite anything you have edited in Porymap.

-default-behavior

Select the default metatile behavior for metatiles that do not have an entry in the attributes.csv file. You may use either a raw integral value or a metatile behavior label defined in the provided include/constants/metatile_behaviors.h header file. If unspecified, defaults to 0.

-default-encounter-type

Select the default encounter type for metatiles that do not have an entry in the attributes.csv file. You may use either a raw integral value or an EncounterType label defined in the include/global.fieldmap.h file. If unspecified, defaults to 0.

-default-terrain-type

Select the default terrain type for metatiles that do not have an entry in the attributes.csv file. You may use either a raw integral value or a TerrainType label defined in the include/global.fieldmap.h file. If unspecified, defaults to 0.

Attribute Warnings

There are a few compilation warnings that can be enabled to help catch common attributes.csv problems.

-Wattribute-format-mismatch

This warning alerts you when the attributes specified in the header of attributes.csv do not match the target base game. Base games pokeemerald/pokeruby and pokefirered have different attribute formats. Specifically, pokefirered metatiles contain the same id and behavior attributes as pokeemerald/pokeruby, but they additionally contain terrain_type and encounter_type attributes. This warning will display if attributes.csv is missing these extra attributes while the target base game is set to pokefirered. It will also display if you specify fields beyond id and behavior for target base games pokeemerald/pokeruby. Defaults to off.

-Wmissing-attributes-csv

This warning alerts you when attributes.csv is missing. When there is no attributes.csv in the source folder, Porytiles will apply the default values to all metatile attributes. Defaults to off.

-Wunused-attribute

This warning alerts you when attributes.csv specifies an attribute for a metatile ID that does not exist in the layer sheet. Defaults to off.

Future Improvements

As tracked here, Porytiles plans to eventually support completely customized attributes via custom masks and shifts à la Porymap. Look out for the feature in a future Porytiles release. Once the feature is implemented, I will explain how to use it in an updated version of this tutorial page.