Skip to main content

GAT

This document describes the GAT file format used in the Ragnarok Online client.

Contents

GAT files contain the following information:

  • Altitude data, encoded as height vectors, for each tile of a map
  • Terrain type flags to identify the terrain on a given tile

The file contents can be interpreted as a 2-dimensional navigation map, similar to 3D navigation meshes in concept.

Layout

Version 1.2

The vast majority of maps in the RO client use this version, including those found in alpha clients (and even Arcturus)1.

FieldOffsetLengthTypeDescription
Header04string"GRAT" as an ASCII-encoded, fixed-size string
MajorVersion41byteVersioning information
MinorVersion51byteVersioning information
Width64intThe horizontal size of the map, given in tiles
Height104intThe vertical size of the map, given in tiles
Tiles14+20arrayContains the navigation properties for Width * Height tiles

Tile Properties

Each entry in the Tiles array represents a surface block ("tile") of the given map's terrain, and is structured as follows:

FieldOffsetLengthTypeDescription
SouthWestAltitude04floatAltitude at the bottom left corner, i.e., at (0, 0) relative coordinates
SouthEastAltitude44floatAltitude at the bottom right corner, i.e., at (1, 0) relative coordinates
NorthWestAltitude84floatAltitude at the top left corner, i.e., at (0, 1) relative coordinates
NorthEastAltitude124floatAltitude at the top right corner, i.e., at (1, 1) relative coordinates
TerrainType164uintIdentifier for the tile's terrain type

Terrain Types

info

More research is needed. If you know anything about the topic, please help fill in the blanks!

The following terrain types are known to have practical applications:

ValueWalkableInterpretation
0YESRegular (walkable) terrain
1NOObstructed (impassable) terrain
5NOImpassable snipeable terrain ("cliff")

There are several other terrain types, but it's unclear whether they affect clientside collision checks at all.

Version 1.3

info

More research is needed. If you know anything about the topic, please help fill in the blanks!

This version adds a twist to the TerrainType values: A special flag marks water tiles, though the layout itself hasn't changed. Effectively, two flags are seemingly embedded in the existing terrain type field. Consider the following example:

  • A water tile might use a TerrainType of 1 (obstructed), which in GAT 1.2 would be encoded as 0x01000000 (LE int, value is 1)
  • In GAT 1.3, the sameTerrainType property would however be encoded as 0x01000080 (LE int, value is now -2147483647)
  • The IsWaterTile flag can then be extracted by masking the TerrainType, leaving only the 0x08 component (binary: 0000 1000)

What exactly should be done with that information is unclear, but all water tiles in GAT 1.3 files have been assigned such a flag.

References

Footnotes

  1. Technically, old versions have a zero-byte prefix shifting the layout. It's still GAT 1.2 otherwise.