Even Dragons Get Second Chances: Coding Morale & Luck | Heroes of Might & Magic Rebuild [Episode 67]

In this episode of rebuilding the Heroes of Might and Magic 1 engine from scratch, we look at how morale and luck work in battle — what they actually do mechanically, how they're animated, and how to bring them to life in a modern reimplementation. We start by examining the original game's assets: the sprite frames, ICN animation files, and audio clips for good luck, good morale, bad morale, and even bad luck (a sound effect that exists in the files but never triggers in the original game). From there, we work out the probability tables — sourced from the Acid Cave fansite, with some healthy skepticism about a few values — and wire up the logic: good morale giving creatures a chance at a second action, bad morale causing a lost turn, and luck rolling before attacks to potentially double damage (including on retaliations). The implementation involves loading the new animations and sounds into battle resources, hooking them into both melee and ranged attack paths, and syncing the 9-frame animation to the 3-second audio clip. We also catch a compiler bug from a double XOR-shift and discover that the morale animation offset is slightly off relative to the creature — likely needing to be anchored to the hex tile rather than the creature's head position. We finish by playtesting with a dragon-only Knight army to trigger high morale and confirm it's working in-game — animation and all.