Having developed an interest in modding masters of magic, I've been working on understanding the data file format. The eljay links were a good start, but I rapidly hit their limits, so I thought I'd share stuff I've found so far (other modders may know this stuff, but I don't see it). Starting from eljay's description, and also requires understanding save game format, further notes (some of this stuff is not tested in game, it's just by inspection):
Byte 0x15 is in fact a byte determining the type of the spell, and also controls the interpretation of bytes 0x20-0x23. Codes are as follows:
Byte 0x15 is in fact a byte determining the type of the spell, and also controls the interpretation of bytes 0x20-0x23. Codes are as follows:
- 0x00: normal summoning spell (all but hero/champion/torin). Byte 0x20 contains the creature summoned, 21-23 are blank.
- 0x01: enchantment that can be cast on a friendly unit. Bytes 0x20-0x23 contain the mask for the enchantment applied (same as bytes 0x18-0x1B in the unit data structure in the save file). While no current spells do this, it is possible to set more than one bit; doing so will apply both spells, and will also prevent casting if either spell is already on the unit.
- 0x02: enchantment hits a friendly city. Byte 0x20 contains the code for the city enchantment, in the same order as for city enchantments in the save file, but starts at 0 (0x00 is wall of fire, 0x18 is altar of battle).
- 0x03: enchantment hits a hostile city. Byte 0x20 is the same as above.
- 0x04: non-moddable damaging spell. Byte 0x20 is the magnitude, 0x21 is the immunity flags that apply (same as for monsters), 0x22 and 0x23 are attack flags (same as for monsters, but for byte 0x23, 0x80, listed as no effect for monsters, makes it act like warp lightning, and 0x10 makes it act like fireball. Neither flag seems to apply to critter attacks, though I haven't tried all possible combinations. Not all attack flags work for spells).
- 0x05: unusual spells. I haven't been able to determine how they're parsed, and there are a lot of them.
- 0x6: spells that target one wizard. 0x20 appears to be the effect (there are only four spells in this category: spell blast, cruel unminding, drain power, subversion).
- 0x09: global enchantment. Byte 0x20 contains the code for the global enchantment, in the same order as for global enchantments in the save file, but starts at 0 (0x00 is eternal night, 0x17 is awareness).
- 0x0a: combat globals (affect all units). Mostly, it's twice the number of the enchantment (if you want, you can add +1, and apply spells to the other side), but the instants (Call Chaos, Death Spell, Holy Word, Mass Healing, Flame Strike) would appear to be special case coded. If byte 0x21 is set, it seems to just make the spell not work in most cases (cloning flame strike does not work). Enchantment codes are:
- 00: true light
- 02: darkness
- 04: warp reality
- 06: black prayer
- 08: wrack
- 0a: metal fires
- 0c: prayer
- 0e: high prayer
- 10: terror
- 12: call lightning
- 14: counter magic (which is a different bit; probably says moddable/not moddable)
- 16: mass invisibility
- 18: entangle
- 1a: mana leak
- 1c: blur
- 00: true light
- 0x0b: enchant item and create artifact.
- 0x0c: spells that destroy a unit. Byte 0x21 looks like it may be a normal immunity byte, as it's 0x22 for petrify, 0x20 for disintegrate, but there's missing information here.
- 0x0d: hostile (resisted) combat enchantments. Bytes 0x20-0x21 are a mask for what effect is created:
- 0x0001: Warp Creature (Defense)
- 0x0002: Warp Creature (Resistance)
- 0x0004: Mind Twist, which is a status effect that uses the text for Mana Leak. The actual effect is apparently -1 to hit, -1 resistance (either won't reduce below 0, or the UI doesn't show negative attack modifiers).
- 0x0008: Haste (yeah, it's not a negative effect). It looks like combat-only enchantments use a different set of bits.
- 0x0010: Web. Applies the debuff, but either does nothing, or only removes flight (cannot determine on my test monster).
- 0x0020: Creature Binding. Puts a counter on the unit, but doesn't actually change allegiance.
- 0x0040: Possession. Puts a counter on the unit, but doesn't actually change allegiance.
- 0x0080: No Apparent Effect
- 0x0100: Vertigo
- 0x0200: Confusion
- 0x0400: Whirlwind (???) Puts a whirlwind counter on the unit, no apparent effect (may be related to magic vortex)
- 0x0800: Mind Storm
- 0x1000: Shatter
- 0x2000: Weakness
- 0x4000: Black Sleep
- 0x8000: Warp Creature (-50% attack)
- 0x0001: Warp Creature (Defense)
- 0x0e: hostile (un-resisted) combat enchantments. Otherwise as 0x0d
- 0x0f: friendly unit enchantment that only works on mundane units. Otherwise identical to 0x01.
- 0x10: hostile (resisted) combat enchantments that only work on mundane units.
- 0x12: dispel magic, dispel magic true. Max cost = base cost * 5.
- 0x13: disenchant area, disenchant true. Max cost = base cost * 5.
- 0x14: disjunction, disjunction true. Max cost = base cost * 5.
- 0x15: counter magic. Max cost = base cost * 5. Functions otherwise like 0x0a, so it's likely that other area spells could be modded, though effects would likely be undefined.
- 0x16: variable cost damage spells; max cost = base cost * 5. Otherwise identical to 0x04. The extra effect per extra mana spent is probably determined by the flags, it isn't coded here.