This is an old revision of the document!
Loggy's Morale check and Fear reverse engineering notes
Morale Check
(dom v5.53) This is done on a nation by nation basis.
Rout undead if there is no friendly undead leadership left
Rout magic beings if there is no friendly magic leadership
If this is a check for special indies with nation ID 3, jump further down to actual unit morale check time
Keep a count of units (and commander) with orders matching unknown criteria. This doesn't seem to be used for anything much, though…
If there is no friendly commander not retreating (so all friendly commanders are retreating), val1 = 125. If there isn't, it's 0.
If the current field HP is 25% or less than what it started with:
Otherwise, val1 is set to something large and negative if either of the following are entirely true:
Nobody or a different nation have routed
Friendly current HP is 50% or less than what it started with, AND the other side has routed
If the nation is on side 1 [the left; attacker]
val1 is then messed with further based on the turn timer:
If it's round 91+, it's set to 130.
If it's round 101+, it's set to 140.
If val1 is 100+…
If val1 is 50+:
If nation is on battlefield side 2 [right; defender]:
If val1 is 100+, every friendly unit is immediately forced to rout, no questions asked
If val1 is 50-99 inclusive:
If you are the attacker, and the province ID the battle is taking place in > 0 [not another plane], commanders rout without any checks so long as they are not mindless or immortal.
If you are defending a fort storming, every non-mindless non-immortal friendly commander with hp > 0 rolls morale + DRN vs 10 + DRN. Losing (not in the case of a tie) routs the commander. [This is "autobreak" in the debug log]
If you are defending and not in a fort, you rout without any checks.
If val1 is 25-49, all friendly units have 1 added to their morale problems value
Morale Problems
(v5.53) The things that alter morale problems (besides those in the morale checking function itself) are as follows:
Being hit directly with fear type 2 (LA TC howling bows) adds 1 to the unit hit and 1 to all members of the squad.
Being hit directly with fear type 1 (spells, fear auras) adds 1000 to all members of the squad and then SETS the problems of the unit hit to 1000.
After being damaged, if the unit's current hitpoints are less than 80% (rounded down) of its maximum, it gets +1 morale problems
If a unit dies, add 100 to morale problems of all still living squad members
Fear and Temporary Morale decrease
Fear effects (and the unused but functional temporary positive morale effect) provide unit-by-unit modification of morale values. This can go no further than 5 in either direction. The modifier is halved (rounding down) every combat round.