The nfo/grf Technical Reference

Action 2 for houses and industry tiles

Defining set-IDs for houses, industry tiles, objects and airport tiles (OpenTTD only)


Introduction

For houses, industry tiles, objects and airport tiles, the action 2 data defines a spritelayout for a tile. There are two formats available:

Basic format for tiles with a single building sprite

<sprite-number> * <length> 02 07/09/0F <set-id> 00 <groundsprite> <buildingsprite> <xoffset> <yoffset> <xextent> <yextent> <zextent>

ElementSizeDescription
<sprite-number>decA sequential sprite number
<length>decThe total number of bytes used in this action
02BDefines action 02
07/09/0FBfeature 7 (town buildings), 9 (industry tiles) or 0F (objects)
set-idBID for this definition
00BLiteral 0 (to distinguish this definition from random/variational lists)
groundspriteDGround sprite for the building (see format below)
buildingspriteDThe sprite of the building (see format below), can be zero to indicate that no building sprite should be displayed (useful for early building stages)
xofsBx-offset from northern tile corner (as a signed byte)
yofsBy-offset from northern tile corner (as a signed byte)
xextentBsize of sprite in x direction
yextentBsize of sprite in y direction
zextentBsize of sprite in z direction

In the above, xofs, yofs, xextent, yextent and zextent define the 3D bounding box of the building sprite not including the ground sprite. The z-offset is always zero for buildings (TTD doesn't support floating buildings). Please note that xofs/xextent and yofs/yextent pairs that place the bounding box off the tile are not recommended.


Extended format using multiple combined sprites

Since 2.0.1 alpha 55 vcs 3, houses, industry (and object) tiles support an extended syntax as well, which looks as follows:

<sprite-number> * <length> 02 07/09/0F <set-id> <num-sprites> <groundsprite> [<buildingsprite> (<xoffset> <yoffset> <zoffset> <xextent> <yextent> <zextent>) | (<xpixeloffset> <ypixeloffset> 80)]...

ElementSizeDescription
<sprite-number>decA sequential sprite number
<length>decThe total number of bytes used in this action
02BDefines action 02
07/09/0FBfeature 7 (town buildings), 9 (industry tiles) or 0F (objects)
set-idBID for this definition
num-spritesBNumber of following building sprites (the groundsprite mustn't be counted). Allowed range: 1 to 63 (0x01 to 0x3F). Adding 0x40 makes the layout an Advanced Spritelayout with register modifiers (since OpenTTD r22518; to be documented).
groundspriteDGround sprite for the building (see format below)
buildingspriteDThe sprite to be drawn. Unlike the basic format, zero isn't allowed here.
-- for sprites defining a new bounding box --
xofsBx-offset from northern tile corner (as a signed byte)
yofsBy-offset from northern tile corner (as a signed byte)
zofsBz-offset from the ground
xextentBsize of sprite in x direction
yextentBsize of sprite in y direction
zextentBsize of sprite in z direction
-- for sprites sharing their bounding box with the previous sprite
xpixeloffsetBx offset from the top left corner of the previous sprite
ypixeloffsetBy offset from the top left corner of the previous sprite
80Ba literal 80h byte to distinguish from new-bounding-box definitions

Note: restrictions for sprites sharing their bounding box are the same as explained for station tiles.

Since OpenTTD r18959 you can draw multiple ground sprites for a tile, which is useful if you want to use the usual grass/water/concrete groundtile, but still need to add features to it without using a new bounding box. To do so use the syntax of sprites sharing the previous bounding box, but use it before the first bounding box definition.

Please note that x- and y pixel offsets refer to different spots of the "parent" sprite when using for ground or building tiles. See picture.

The same feature is also partially supported in TTDPatch since 2.6 r2313: TTDPatch ignores the xpixeloffset and ypixeloffset fields and always uses (0,0) for the offset. If you are developing a GRF that needs to be compatible with both OpenTTD and TTDPatch, you should always keep xpixeloffset and ypixeloffset zero to get the same effect in both games.


Description

Sprite definition


The ground and building sprite fields have the following format:

BitsContent
0 .. 13Sprite number, exact meaning specified by bit 31
14 .. 150: draw sprite normally, 1: draw sprite in transparent mode, 2: recolor sprite
16 .. 29Color translation special sprite number, see below
30If set, sprite is drawn normally even in transparent buildings mode (for building sprites only; supported in 2.0.1 alpha 57 or later)
31Sprite type, see below

Since 2.0.1 alpha 57, the groundsprite value can be zero if no ground sprite is needed (this is useful if you need to draw custom foundations, see example). Ground sprites are always drawn normally, so bit 30 is ignored for them. Bit 30 may get a different meaning for ground sprites in a later version of TTDPatch, so please leave it zero for now. This does not apply to additional groundsprites using the "<xpixeloffset> <ypixeloffset> 80"-syntax (see above); for these bit 30 has the same meaning as for building sprites.

Colour translation special sprite number


This is used only if bits 14 or 15 are nonzero. Bits 16-29 must be the number of a regular TTD sprite containing a colour translation table (see below for available translation tables). For transparent mode, a suitable translation table is needed, e.g. that of TTDĀ“s sprite number 802 (s.b.). See RecolorSprites for more information on the usage of transparent and recolouring sprites.

For houses, if no recolour sprite is given but recolouring is turned on in bits 14-15, there are two possibilities:

See RecolorSprites for a list of available colour translations.

For industry tiles, if this field is zero, but recolouring is turned on in bits 14 or 15, the colour of the containing industry will automatically be applied.

The ground sprite should be exactly the same size and shape as TTD's flat tile. In general, it shouldn't contain anything that has a z-dimension because any non-ground sprite will cover it.

Useful values for ground sprites:

Sprite number
(decimal)
Contents
3924bare land
3981grass
4061water
4550snow or desert (depending on climate)
1420concrete

Please note that all the ground sprites become visible in "transparent buildings" mode, so you should draw parts that seem to be hidden as well.

Sprite type


If bit 31 is clear, the bottom 14 bits contain a regular TTD sprite number.

If bit 31 is set, the bottom 14 bits contain a number of a sprite set in the most recent action 1, and the used sprite is decided according to the current construction state and the number of sprites in the set: