UNIT
The units placed on the map, 36 bytes each. Start locations are units too, of type 214.
A unit record can set the unit's hit points, shields, energy, resources and hangar as percentages or amounts, and states such as cloaked or burrowed. Each of these is used only when its bit is set in the record's fields-set or special-states word, so a record can set the hit points alone.
The units of a human player slot nobody takes are removed when the game starts; Neutral units stay. (Found playing StarCraft: Remastered.)
| Name | UNIT (55 4E 49 54) |
|---|---|
| Size | 36 bytes per unit. |
| Read by | The game. |
| Required | Yes. The game does not load a map without it. |
| More than one copy | Every copy counts: the records of all of them, in file order. |
| In scmJS | Read, and written again when you change what it holds. |
Each unit:
| Offset | Type | Holds |
|---|---|---|
| 0 | u32 | The unit's serial number, unique in the map; add-ons and nydus canals are linked by it |
| 4 | u16 | X position in pixels |
| 6 | u16 | Y position in pixels |
| 8 | u16 | Unit type |
| 10 | u16 | How the unit is linked to another (relations, below) |
| 12 | u16 | Which special states the record sets (below) |
| 14 | u16 | Which of the following fields the record sets (fields set, below) |
| 16 | u8 | Owner, 0 for Player 1 |
| 17 | u8 | Hit points, per cent of the maximum |
| 18 | u8 | Shields, per cent |
| 19 | u8 | Energy, per cent |
| 20 | u32 | Resources, for a mineral field or geyser |
| 24 | u16 | Units in the hangar: interceptors or scarabs |
| 26 | u16 | The special states themselves |
| 28 | u32 | Unused |
| 32 | u32 | Serial number of the linked unit |
Relations:
| Bit | Meaning |
|---|---|
| 0x0200 | Nydus link |
| 0x0400 | Add-on |
Special states:
| Bit | Meaning |
|---|---|
| 0x01 | Cloaked |
| 0x02 | Burrowed |
| 0x04 | In transit |
| 0x08 | Hallucinated |
| 0x10 | Invincible |
Fields set:
| Bit | Meaning |
|---|---|
| 0x01 | Owner |
| 0x02 | Hit points |
| 0x04 | Shields |
| 0x08 | Energy |
| 0x10 | Resources |
| 0x20 | Hangar |
| 0x40 | State |
Example#
A Protoss Carrier for Player 2 with half its hit points, full shields and four interceptors. The record sets the owner, hit points, shields and hangar, so the game uses those four fields and ignores energy and resources:
0 11 00 00 00 serial number 17
4 50 06 x 1616 px (tile 50)
6 50 03 y 848 px (tile 26)
8 48 00 unit type 72, Protoss Carrier
10 00 00 not linked
12 00 00 sets no special states
14 27 00 sets: owner, hit points, shields, hangar
16 01 owner: Player 2
17 32 hit points 50%
18 64 shields 100%
19 00 energy 0% (not set, so not used)
20 00 00 00 00 resources 0 (not set)
24 04 00 4 in the hangar
26 00 00 no special states
28 00 00 00 00 unused
32 00 00 00 00 no linked unit