MegaMek Tilesets and Tileincs - MegaMek/megamek GitHub Wiki

MegaMek Tilesets and Tileincs – Adding Fluff Graphics

This documentation is at a fairly basic level – I don’t have a full grip on, and haven’t tried, some elements, especially buildings. User beware, but don’t be afraid to experiment and try things out if you have a hankering to add new hex art. – Ulysses

MegaMek Board Graphics – A Primer

MegaMek presents board graphics to you using three types of files:

  • .tileset
  • .tileinc
  • .board files you will see in your \data\boards folder.

These files are text-based and editable with tools like Notepad, Notepad++, IDEs, etc. They do not require coding knowledge to understand, but if you want to make edits to tilesets and tileincs, you will need to be familiar with the MegaMek board editor and how it interprets a hex.

  • The tileset files are the ‘masters’ – they hold all the information required to draw a MegaMek board. The default used by MegaMek is Saxarba.
  • Tileincs are subsets of tilesets – they can be referenced in multiple tilesets, and are where the most ‘modding’ is possible by a user.
  • The board files tell MegaMek what graphics it should pull from the selected tileset based on the attributes assigned to a hex.

What makes a board?

Each hex in a board file is made up of a line like this. Here are some simple examples:

image

This board file is telling MegaMek three things:

  • The hex this applies to is 0603
  • It should display graphics for a Rough hex, of type 1 (standard rough)
  • It should use the Desert theme.

A more complex set of hexes with buildings: image

The empty quotes at the end are important to remember when we get to tilesets/tileincs: this is telling MegaMek to draw whatever the default theme is.

So, you want to add some fluff

The most common edits people want to make to tilesets are adding new fluff types for graphical flair.

Fluff is the hex attribute used in MegaMek when we want to display graphics that don’t necessarily have a gameplay effect.

Thanks to the magic of tileincs, we can overwrite existing graphics without disturbing the original tileset file, or we can add entirely new types.

Modifying a Tileset - Includes

Using the Saxarba tileset as an example, after some brief documentation notes at the top (which I’ll reproduce here), you’ll see a set of ‘includes’: image

When editing tileset/tileinc files, # is used to mark comments; comments are not read by MegaMek. Any time you want human-readable information, use this format.

An ‘include’ statement tells MegaMek when loading the tileset to also read the information in the .tileinc file mentioned. Unless you are trying to make an entirely brand-new tileset for MegaMek from scratch, this is as far as you’ll want to go with these.

The directory that is searched is: data\images\hexes – this is the directory in which you should put any subfolders you want to use.

For example, the full path to my UlyssesSprites/UlyssesSprites.tileinc file is:

Setting up a Tileinc to Show Fluff Graphics

image

This is what my folder looks like for the fluff sprites I added. I have subfolders to keep the hex art neat and tidy, and then the .tileinc file.

Before you set up your .tileinc, you will need to know what your hex art filenames are. You can create a test one if you just want to check your understanding by making an all-black 84x72 pixel image and adding it to a folder.

Here’s an example from my .tileinc for adding in different fluff graphics for Rough type hexes: image

Let’s break the statement down:

  • super – this command tells MegaMek to replace the old graphic with a new one
  • * – I’m not sure what this does, but it’s needed
  • "rough:*;fluff:1" – this statement is telling MegaMek when it should draw the graphic. In this case, it’s for a hex with a type of Rough of ANY ‘elevation’ (represented by the *) AND (the semi-colon) a fluff elevation of 1.
  • "" – the empty quotes tell MegaMek that this can be applied to any theme. If a type of fluff was meant to show only in a specific theme, this would be something like "desert". The graphics would then only show in that theme.
  • "UlyssesSprites/Rough/Rough-Fluff-DragonsTeeth.png" – this is the part that tells MegaMek exactly which image to display when the previous conditions are met.

It’s also possible for MegaMek to cycle through/randomize different graphics to add more variety. This is useful for natural features (trees, rough terrain, etc.) to prevent boards from being too visually repetitive. To do so, separate each image path with a semi-colon, like so:

The MegaMek Team thanks UlyssesSockdrawer for writing this summary. October 2024