Action2/Sprite Layout

From GRFSpecs
< Action2
Revision as of 08:56, 24 June 2008 by Mb (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Defining an action 2 for houses and industry tiles

Action 2 for houses and industry tiles

Defining an action 2 for houses and industry tiles

-=Format=-

For houses and industry tiles, the action 2 data looks as follows:

(basic format)

 -+<Sprite-number> * <Length> 02 07/09 <set-id> 00 <groundsprite> <buildingsprite> <xoffset> <yoffset> <xextent> <yextent> <zextent>+-

||Element|Size|Description

<Sprite-number>|dec|A sequential sprite number

<length>|dec|The total number of bytes used in this action

02|B|Defines action 02

07/09|B|feature 7=town buildings or 9=industry tiles

set-id|B|ID for this definition

00|B|Literal 0 (to distinguish this definition from random/variational lists)

groundsprite|D|Ground sprite for the building (see format below)

buildingsprite|D|The sprite of the building (see format below), can be zero to indicate that no building sprite should be displayed (useful for early building stages)

xofs|B|x-offset from northern tile corner (as a signed byte)

yofs|B|y-offset from northern tile corner (as a signed byte)

xextent|B|size of sprite in x direction

yextent|B|size of sprite in y direction

zextent|B|size 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).

xofs/xextent and yofs/yextent pairs that place the bounding box off the tile are not recommended.

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

 -+<nowiki><Sprite-number> * <Length> 02 07/09 <set-id> <num-sprites> <groundsprite> [<buildingsprite> (<xoffset> <yoffset> <zoffset> <xextent> <yextent> <zextent>) | (<xpixeloffset> <ypixeloffset> 80)]...</nowiki>+-

||Element|Size|Description

<Sprite-number>|dec|A sequential sprite number

<length>|dec|The total number of bytes used in this action

02|B|Defines action 02

07/09|B|feature 7=town buildings or 9=industry tiles

set-id|B|ID for this definition

num-sprites|B|Number of following building sprites (the groundsprite mustn't be counted). Must not be zero.

groundsprite|D|Ground sprite for the building (see format below)

buildingsprite|D|The sprite to be drawn. Unlike the basic format, zero isn't allowed here.

-- for sprites defining a new bounding box --

xofs|B|x-offset from northern tile corner (as a signed byte)

yofs|B|y-offset from northern tile corner (as a signed byte)

zofs|B|z-offset from the ground

xextent|B|size of sprite in x direction

yextent|B|size of sprite in y direction

zextent|B|size of sprite in z direction

-- for sprites sharing their bounding box with the previous sprite

xpixeloffset|B|x offset from the top left corner of the previous sprite

ypixeloffset|B|y offset from the top left corner of the previous sprite

80|B|a 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.

-=Details=-

Sprite definition

The ground and building sprite fields have the following format:

||Bits|Content

0-13|Sprite number, exact meaning specified by bit 31

14-15|0: draw sprite normally, 1: draw sprite in transparent mode, 2: recolor sprite

16-29|Color translation special sprite number, see below

30|If set, sprite is drawn normally even in transparent buildings mode (for building sprites only; supported in 2.0.1 alpha 57 or later)

31|Sprite 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). 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.

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 possiblities:

  • If you have callback 1E enabled, it is called to determine the colour mapping.
  • If callback 1E is disabled or fails, one of the colours specified in property 17 will be chosen randomly.

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.

For the colour translation, you can use the following sprite numbers:

||Sprite number (decimal)|Translated colour

translations for "player colour"

775|dark blue

776|pale green

777|pink

778|yellow

779|red

780|light blue

781|green

782|dark green

783|blue

784|cream

785|mauve

786|purple

787|orange

788|brown

789|grey

790|white

translations for "brownish red" colour

795|blue

796|brown

797|white (ignoring original intensity)

798|red

799|green

800|white (darker parts are blueish)

801|yellow

special colour translations

802|makes the whole sprite darker

803|maps the sprite to grey tones (for the newspaper)

804|maps the sprite to even darker grey tones (crash debris?)||

In the above table, "blue" means the "magic blue" color used, for example, on the vehicles, while "brownish red" means the "magic" color used on some town buildings ( on the tall office block, for example). Mapping 775 is an identity function (maps each color to itself), so you can use it in cases where a remapping is needed, but you don't want to recolor anything.

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

3924|bare land

3981|grass

4550|snow or desert (depending on climate)

1420|concrete||

Please note that all the ground sprite becomes 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:

  • if there's only one sprite, it's used always
  • if there are two sprites, the first is used during construction (stages 0-2), and the second is used for the finished building (stage 3)
  • if there are three sprites, the first will be used in the beginning of the construction (stage 0), the second will be used during the rest of the construction (stages 1 and 2) and the third will be used for the complete building (stage 3)
  • if there are four or more sprites, the first four will be used for the four construction stages. Sprites after the first four are always ignored.