Morrowind Mod:Mod File Format/PGRD

Mod / Morrowind: Morrowind Mod: Modding: Mod File Format

PGRD records contain information about path grids.

C Field Type/Size Info
+ DATA struct
(12 bytes)
Path grid data
int32 - Grid X (exterior only)
int32 - Grid Y (exterior only)
uint16 - Flags. The values below are the only ones accessible via the TESCS; other values exist between the range of 0x1 and 0x4000 (with the exception of 0x4) but appear to be deprecated outside of cell [0, 0].
0x80 = 128 granularity
0x100 = 256 granularity
0x200 = 512 granularity
0x400 = 1024 granularity (Appears to be the default)
0x800 = 2048 granularity
0x1000 = 4096 granularity
uint16 - Path point count (see PGRP)

Note: the Construction Set allows for a 44-byte version of the structure where NAME is a 32-byte null-terminated string immediately after Grid Y, rather than a field of its own. Only the 12-byte version is currently in use; the 44-byte version appears to be an older version.

+ NAME zstring The cell name the path grid belongs to.
- PGRP PathPoint[Count]
(16 bytes each)
A sequential list of PathPoints:
int32 - X
int32 - Y
int32 - Z
uint8 - Flags
0x01 = Autogenerated
uint8 - Connection count (number of entries in PGRC)
uint16 - Unknown
- PGRC uint32[TotalConnCount] Connection list (also known as edges), where TotalConnCount is the sum of all Connection count values in the PGRP node.

For each path point listed in PGRP, there are Connection count edges in this list, each an index into PGRP. Using Azura's Coast (12, 20) as an example, the first entry in the PGRP (index 0) the Connection count value is 1, so you would read one uint32 from this list. That has a value of 1, so index 0 connects to index 1. For the second entry (index = 1), Connection count is 4, so you would read the next four uint32 values: 0, 6, 3, and 2, meaning that the point at index 1 connects to the points at indices 0, 6, 3, and 2.