At the moment of the attack (movement), a random number is selected. This number is divided by 24.
As an alternative, when the author was examining the executable file, could he have encountered morale with neutral units and stopped his research there, without assuming that there is a second formula for morale in battles with heroes?