UGRD Format
UGRD holds the data for the upgrades and spells in WarCraft II: how long each one takes to research, what it costs, its icon, and what it gives. The layout is the same in all versions. UGRD data is found in three places:
- The default copy: entry 1 of MAINDAT.WAR in the DOS versions (1.3, 1.33 and 1.5), and the file rez\upgrades.dat in War2Dat.mpq in the Battle.net Edition (2.00 and 2.02), holds the 780 bytes in the layout below, with nothing in front of them. It is the same in all five versions, and the game uses it whenever a map does not give its own upgrade data.
- PUD files (maps): a PUD can have a UGRD section, but it does not need one. In a PUD the section starts with 2 bytes in front of the data (not counted in the offsets here), so the section is 782 bytes. If both bytes are 0, the game reads the data that follows and uses it instead of the default copy. Otherwise the game skips the data, even though it is there, and uses the default copy. A PUD without a UGRD section also gets the default copy. In the Battle.net Edition, the game skips the UGRD section of the map in a multiplayer game unless the game type is Use Map Settings; with the other game types that come with it (Melee, Free For All, One on One, Top vs. Bottom, Ladder and Iron Man Ladder) the default copy is used.
- Saved games (.SAV files): when the game is saved, the 780 bytes in use at that moment are written to the save file, and when the save is loaded they replace the upgrade data from the map.
Every field in this section has one entry per upgrade, 52 in all (see Appendix: Upgrade and Spell types). The game handles the entries in two ways. Entries 0 to 31 are upgrades: when one is finished, the game adds one to the player's level counter chosen by Group, and that counter is what gives the bonus. Entries 32 to 51 are spells (and the Paladin and Ogre Mage upgrades): when one is finished, its Flags are added to the spells the player knows. Which way an entry is handled is decided by the command button that starts the research, not by this data.
Upgrade Time
- Offset
- 0x0000
- Length
- 52 bytes (1 byte / Upgrade)
- Description
- Time it takes to research this upgrade. It uses the same unit as Cost: Build Time in the UDTA section: the game doubles both, and the building's progress goes up by one each step until it reaches that.
- Values
- Integer value between 0 and 255. Entries 34 (Holy Vision), 38 (Fireball) and 43 (Eye of Kilrogg) are 0 in the default data. These three and Death Coil (46) have no research button in the game.
Cost: Gold
- Offset
- 0x0034
- Length
- 104 bytes (2 bytes / Upgrade)
- Description
- Gold it costs to research this upgrade. Unlike the costs in the UDTA section, this is the actual amount; it is not multiplied by 10. The cost is taken when the research starts and given back if it is cancelled.
- Values
- Integer value between 0 and 65535.
Cost: Lumber
- Offset
- 0x009C
- Length
- 104 bytes (2 bytes / Upgrade)
- Description
- Lumber it costs to research this upgrade. This is the actual amount; it is not multiplied by 10.
- Values
- Integer value between 0 and 65535.
Cost: Oil
- Offset
- 0x0104
- Length
- 104 bytes (2 bytes / Upgrade)
- Description
- Oil it costs to research this upgrade. This is the actual amount; it is not multiplied by 10. Only the ship cannon upgrades (12 to 15) cost oil in the default data.
- Values
- Integer value between 0 and 65535.
Icon
- Offset
- 0x016C
- Length
- 104 bytes (2 bytes / Upgrade)
- Description
- Icon shown in the panel of the selected building while it is researching this upgrade. The research button itself has its own icon in the command data of the game's executable, so this does not change the button. The Battle.net Edition shows icon 108 as icon 103, so in the default data Death and Decay (108) is shown with the Death Coil icon while it is being researched.
- Values
- Icon number, the same numbering as the icons of units and command buttons. For example 6 and 7 are the Ranger and Berserker, 10 and 11 the Paladin and Ogre Mage.
Group
- Offset
- 0x01D4
- Length
- 104 bytes (2 bytes / Upgrade)
- Description
- Only used by upgrades 0 to 31: the level counter that goes up by one for the player when the upgrade is finished. Each counter is shared by all upgrades with the same group, so for example Swords 1 and 2 both use group 1, and the research buttons show level 1 or 2 depending on the counter. The upgrade data holds no bonus amounts. When an upgrade is finished, the counter is the only thing the game changes (apart from the unit changes described under Flags); the bonus amounts are built into the game's executable, which reads the counter wherever it needs them. So what an upgrade gives depends only on its Group, not on its name, icon or place in the list: if Swords 1 had Group 2, researching it would raise the Shields counter and give the Shields bonus. Version 2.02 adds a check when upgrades 0 to 23 are started, using a counter chosen by the upgrade's place in the list rather than by its Group (0 to 3 Swords and Axes, 4 to 7 Arrows and Throwing Axes, 8 to 11 Shields, 12 to 15 Ship Cannons, 16 to 19 Ship Armor, 20 to 23 Catapults and Ballistas): the even-numbered entries can only be started while that counter is 0, and the odd-numbered ones while it is 1. So in 2.02, in the example above, Swords 2 could never be started, and neither could Human Shield 1 once Swords 1 is finished. For entries 32 to 51 the game never reads this field; in the default data it holds the number of the spell's bit in Flags.
- Values
- Integer value between 0 and 10 for upgrades 0 to 31. The game has only 11 counters and does not check the value, so a higher value reads past the end of its list of counters.
- Bits
- 0x00
- Arrows and Throwing Axes (upgrades 4 to 7).
- 0x01
- Swords and Axes (upgrades 0 to 3).
- 0x02
- Shields (upgrades 8 to 11).
- 0x03
- Ship Cannons (upgrades 12 to 15).
- 0x04
- Ship Armor (upgrades 16 to 19).
- 0x05
- Not used by any upgrade in the default data. The game reads this counter in one place only: the "Level" number in the panel of a selected ship. Each level of this counter adds 1 to the Level shown for Transports, and for Oil Tankers, Destroyers, Battleships, Juggernaughts, Submarines and Turtles if they have the Sea Unit flag (Unit Flags bit 0x03 in UDTA). Nothing else reads it, so it gives no bonus in play. The game's executable does have a bonus amount of 10 per level for this counter in its list of upgrade bonuses, but nothing uses that amount.
- 0x06
- Catapults and Ballistas (upgrades 20 to 23).
- 0x07
- Ranger and Berserker Training (upgrades 24 and 28). Longbow, Scouting and Marksmanship (and the Troll equivalents) can only be researched once this counter is not 0.
- 0x08
- Longbow and Lighter Axes (upgrades 25 and 29).
- 0x09
- Ranger and Berserker Scouting (upgrades 26 and 30).
- 0x0A
- Ranger Marksmanship and Berserker Regeneration (upgrades 27 and 31).
Flags
- Offset
- 0x023C
- Length
- 208 bytes (4 bytes / Upgrade)
- Description
- The bit (or bits) this upgrade uses in the player's upgrade or spell bits, which are the same bits as in the ALOW section of PUDs: upgrades 0 to 31 use the upgrade bits, entries 32 to 51 the spell bits. When research starts, the flags are marked as being researched for the player; when it finishes or is cancelled, the mark is removed. If the mark is already gone when the research finishes, nothing happens (no level and no refund). For upgrades 0 to 31 the flags give nothing by themselves (the bonus comes from Group). The research buttons are hidden while the bit they check is being researched, but each button checks a fixed bit, not this field; in the default data upgrade 5 (Arrows 2) has 0x01 instead of 0x02, so Arrows 2 can be started in a second Lumber Mill while the first is still researching it, and the second one to finish has no effect and its cost is lost. For entries 32 to 51 the flags are added to the spells the player knows when the research finishes; a spell's cast button is only shown when its bit is known. Two values do more when the research finishes, and only when the flags are exactly that value: 0x10000 turns all the player's Archers into Rangers and Axe Throwers into Berserkers (also those being trained), and 0x100000 turns Knights into Paladins and Ogres into Ogre Mages (also those being trained) and gives the player Holy Vision and Eye of Kilrogg if those spells are allowed.
- Bits
- 0x00
- Upgrades: Arrows and Throwing Axes level 1. Spells: Holy Vision.
- 0x01
- Upgrades: Arrows and Throwing Axes level 2. Spells: Healing.
- 0x02
- Upgrades: Swords and Axes level 1. Spells: not used by any entry in the default data.
- 0x03
- Upgrades: Swords and Axes level 2. Spells: Exorcism.
- 0x04
- Upgrades: Shields level 1. Spells: Flame Shield.
- 0x05
- Upgrades: Shields level 2. Spells: Fireball.
- 0x06
- Upgrades: Ship Cannons level 1. Spells: Slow.
- 0x07
- Upgrades: Ship Cannons level 2. Spells: Invisibility.
- 0x08
- Upgrades: Ship Armor level 1. Spells: Polymorph.
- 0x09
- Upgrades: Ship Armor level 2. Spells: Blizzard.
- 0x0A
- Upgrades: not checked by any research button. Spells: Eye of Kilrogg.
- 0x0B
- Upgrades: not checked by any research button. Spells: Bloodlust.
- 0x0C
- Upgrades: Catapults and Ballistas level 1. Spells: not used by any entry in the default data.
- 0x0D
- Upgrades: Catapults and Ballistas level 2. Spells: Raise Dead.
- 0x0E
- Upgrades: not checked by any research button. Spells: Death Coil.
- 0x0F
- Upgrades: not checked by any research button. Spells: Whirlwind.
- 0x10
- Upgrades: Ranger and Berserker Training (exactly 0x10000 also turns Archers and Axe Throwers into Rangers and Berserkers). Spells: Haste.
- 0x11
- Upgrades: Longbow and Lighter Axes. Spells: Unholy Armor.
- 0x12
- Upgrades: Ranger and Berserker Scouting. Spells: Runes.
- 0x13
- Upgrades: Ranger Marksmanship and Berserker Regeneration. Spells: Death and Decay.
- 0x14
- Upgrades: not checked by any research button. Spells: Knights to Paladins and Ogres to Ogre Mages (exactly 0x100000 also turns the units and gives Holy Vision and Eye of Kilrogg).
- 0x15
- Unused 0x15. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x16
- Unused 0x16. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x17
- Unused 0x17. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x18
- Unused 0x18. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x19
- Unused 0x19. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x1A
- Unused 0x1A. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x1B
- Unused 0x1B. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x1C
- Unused 0x1C. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x1D
- Unused 0x1D. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x1E
- Unused 0x1E. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
- 0x1F
- Unused 0x1F. The game never tests this bit. If it is set, it is copied into the player's upgrade or spell bits like the other bits, but nothing checks it there.
Appendix: Upgrade and Spell types
- Description
- The upgrade and spell list. Every field in this section has one entry per upgrade, in this order. The order is the same as the upgrade names in STRDAT.WAR (rez\stat_txt.tbl in the Battle.net Edition) and the numbers in the Research command buttons of the game's executable. Entries 0x00 to 0x1F are handled as upgrades and 0x20 to 0x33 as spells (see the description of this section).
- Bits
- 0x00
- Sword 1
- 0x01
- Sword 2
- 0x02
- Axe 1
- 0x03
- Axe 2
- 0x04
- Arrow 1
- 0x05
- Arrow 2
- 0x06
- Throwing Axes 1 (Spear 1)
- 0x07
- Throwing Axes 2 (Spear 2)
- 0x08
- Human Shield 1
- 0x09
- Human Shield 2
- 0x0A
- Orc Shield 1
- 0x0B
- Orc Shield 2
- 0x0C
- Human Ship Cannon 1
- 0x0D
- Human Ship Cannon 2
- 0x0E
- Orc Ship Cannon 1
- 0x0F
- Orc Ship Cannon 2
- 0x10
- Human Ship Armor 1
- 0x11
- Human Ship Armor 2
- 0x12
- Orc Ship Armor 1
- 0x13
- Orc Ship Armor 2
- 0x14
- Catapult 1
- 0x15
- Catapult 2
- 0x16
- Ballista 1
- 0x17
- Ballista 2
- 0x18
- Elven Ranger Training
- 0x19
- Longbow
- 0x1A
- Ranger Scouting
- 0x1B
- Ranger Marksmanship
- 0x1C
- Troll Berserker Training
- 0x1D
- Lighter Axes
- 0x1E
- Berserker Scouting
- 0x1F
- Berserker Regeneration
- 0x20
- Upgrade Ogres to Ogre-Mages
- 0x21
- Upgrade Knights to Paladins
- 0x22
- Holy Vision
- 0x23
- Healing
- 0x24
- Exorcism
- 0x25
- Flame Shield
- 0x26
- Fireball
- 0x27
- Slow
- 0x28
- Invisibility
- 0x29
- Polymorph
- 0x2A
- Blizzard
- 0x2B
- Eye of Kilrogg
- 0x2C
- Bloodlust
- 0x2D
- Raise Dead
- 0x2E
- Death Coil
- 0x2F
- Whirlwind
- 0x30
- Haste
- 0x31
- Unholy Armor
- 0x32
- Runes
- 0x33
- Death and Decay
