User Tools

Site Tools


user:loggy:morale

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
  • 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, val1 = 125. If there isn't, it's 0.
  • If the current field HP is 25% or less than what it started with:
    • If val1 was zero from the above, it's set to 50.
  • 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+:
      • It doesn't matter, both end with the "The armies of X are routed" message and the nation being marked as routed
  • If nation is on battlefield side 2 [right; defender]:
    • If the current field HP is 25% or less than what it started with:
      • If it's round 111+, val1 is set to 130
      • If it's round 122+, val1 is set to 140
      • If val1 is 100+, rout everything.
      • If it's 50+, rout everything if the nation is not defending a fort siege. Otherwise, display "The armies of X are mostly routed".
  • 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], you rout without any checks.
    • If you are defending a fort storming, every friendly commander with hp > 0 that is not immortal, not mindless 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
  • Actual unit morale check time. For each unit on the map:
    • If the unit's HP is less than 1, they are not in the current province, they are already routing, they are not owned by the nation being considered, or their morale problems are 0 or negative, do nothing.
    • If the unit has no squad (squad ID of -1), they are considered to be on their own with a squad size of 1 and average morale as would be expected.
    • Otherwise:
      • Add up the total morale of all units in the squad with greater than 0 HP. Units with morale greater than 30 (mindless and berserk) are considered to have 30 for this purpose.
      • Calculate the average morale by dividing that by the number of units that have greater than 0 HP, rounding down.
      • Find the squad's highest morale problems value (of all members with greater than 0 HP).
      • Calculate half the number of surviving units in the squad, rounded down. If the halved result is greater than 100 (with 200+ surviving units), consider it as if it were 100.
      • The morale problems value above is ignored and considered to be 10000 if any of the following are true:
        • The squad has less than or equal to 80% of its original members alive (rounded down) AND the squad's average morale is 8 or lower AND the half squad size is less than the number of morale problems
        • The squad has less than or equal to 75% of its original members alive (rounded down) AND the squad's average morale is 10 or lower AND the half squad size is less than the number of morale problems
        • The squad has less than or equal to 70% of its original members alive (rounded down) AND the squad's average morale is 11 or lower AND the half squad size is less than the number of morale problems
        • The squad has less than or equal to 60% of its original members alive (rounded down) AND the half squad size is less than the number of morale problems
        • The squad has less than or equal to 30% of its original members alive (rounded down) AND any unit in the squad has morale problems greater than 0
      • If any of the previous were true, the base morale bonus is 0. Otherwise, it is 4.
      • The squad takes a morale check if morale problems are greater than 10000 [does NOT set base morale bonus to 0 if failed], and neither of the following are true:
        • The squad has less alive units than a rolled d4 (nonexploding) die [sets base morale to 0 if failed]
        • The highest morale problems value is less than half the surviving squad size [sets base morale to 0 if failed]
      • The actual morale check is [base morale bonus] + [average unit morale] + ([original squad size / 2] + [surviving squad size * 5])/original squad size + DRN vs 14 + DRN. Only losing causes a rout, not a tie. Rounding down occurs after each division.
      • Regardless of whether or not a morale check was made, set the morale problems value of all units in the squad to 0.

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.

user/loggy/morale.1622810983.txt.gz · Last modified: 2021/06/04 12:49 by loggy