Hacking HoMM IV saved game


For the five of you who have a copy of Heroes of Might and Magic IV, Mac edition (and still play it on occasion), here’s something you might not know.

The .h4s saved game files are gzipped data files, with what appears to be a straight-up serialized form of in-memory data structures representing your heroes, their stats, creatures, etc. The implication is, then, this guide to in-memory editing on the PC edition also applies (mostly) to the saved games on the Mac.

There is a bug in Campaign mode, where certain skills are never offered to your heroes even when they are able to receive them natively. For example, if you played on the Might campaign, even if you hired a Mage from the external tavern (say, on Map 2), you will never be offered Life Magic or Death Magic for this mage at level-up time, even though these skills are within the allowable set for Mages. Instead, your Mage will actually get offered Nature Magic, Tactics, etc, which aren’t normally in the set of offerable skills. A Cleric would never be offered Order Magic, etc. It appears that campaign skill restrictions on your primary hero are also inadvertently applied to secondary carry-over heroes.

Since 3DO is dead, I don’t expect this to ever be patched. To workaround this bug, however, you can edit the saved games yourself.

You’ll first need to gunzip the saved game. The incantation is gunzip -S .h4s foo.h4s.

With a hex editor, find your hero’s name. There may be several instances of it, but the correct one has your hero’s description following. If you’ve done this correctly, you should see a block of hexes consisting of bytes such as FF FF FF FF, 00 00 00 00, etc. Each 4-byte signed integer represent one of your hero’s skills. They are, in order:

tactics, combat, scouting, nobility,
life, order, death, chaos,
nature, offense, defense, leadership,
melee, archery, resistance, pathfinding,
ships, stealth, estate, mining,
diplomacy, heal, spirituality, resurrection,
enchantment, wizardry, charm, occult,
daemonology, necromancy, conjuration, pyromancy,
sorcery, herbalism, meditation, summoning

The skills are represented by signed, 4-byte integers. On big-endian PowerPC machines, this would be:

FF FF FF FF == -1 == no skill
00 00 00 00 == 0 == basic
00 00 00 01 == 1 == advanced
00 00 00 02 == 2 == expert
00 00 00 03 == 3 == master
00 00 00 04 == 4 == grandmaster

Hypothetically, an Intel version would be little-endian. Since there isn’t HoMM IV Mac edition for Intel processors (not Universal binary, and not likely ever to be), however, the issue is kind of moot.

Change the various skill levels as you wish. I use this to workaround the aforementioned skills bug, so I decrement one skill and then take up the one I should have gotten, but you can also, of course, cheat like mad.

There are other values around that I haven’t really played with, but all the values are in here, including your amount of gold, resources, etc. One easy way to find them is to convert their values (well, if they’re reasonably unique values) to hex and search the file.

Once you’re done, don’t forget to use gzip to zip the file back up into a .h4s file and plop it back into your games directory. Fire up HoMM IV, and you’re ready to go.

Update
check out the comment section for additional notes on other data values