Count the number of units there are in the province. If the player has spirit sight in the province, count invisible units as well, otherwise omit them.
Add all sources of obfuscate/false army (and the negative magnitude that hides things) to that count.
If there is an inaccuracy percentage, add ((closed d200 - 101) * inaccuracy percentage * unit count) to the unit count. If the result is greater than 10, it is set to ((old value + 5)/10)*10 rounding down after the division
If Fata Morgana is active for the province owner, there's a 50% chance to hide everything, otherwise multiply by (closed d500 - 1), divide by 100 and round down.
If there are no units, your message is simply "The province is free from %s military units." [in these, %s should be one of "allied" or "enemy", with enemy being the normal one and allied shown for allies in disciples only]
If there is no besieging going on in the province…
If there is no inaccuracy, you see the real value. "The province contains %d %s units. "
If the above unit calculation resulted in exactly 1, "The province seems to contain only one %s unit. "
Otherwise, "The province contains about %d %s units. "
If there IS besieging going on in the province…
Count all the different unit types. Different unit types with the same names get their counts merged. In the case of two different unit types with the same name, the unit type ID recorded is whichever one is checked first (which is the with the lower ingame unit IDs). Invisible units are ignored unless the person doing the scouting has spirit sight in the province.
Find the largest commander chassis value. On top of the normal chassis value calculation, add 10x all the commander's magic skills, including holy magic skill. Invisible commanders are ignored unless the scouter has spirit sight in the province.
Work out what the six most common of the above found unit types are. Sort them, with most numerous first.
If Fata Morgana is active:
If there are 4 or more unit types found, there's a 50% chance to swap the 3rd and 4th.
If there are 3 or more unit types found, there's a 50% chance to swap the 2nd and 3rd.
If there are 2 or more unit types found, there's a 50% chance to swap the 2nd and 1st.
[These are done in sequence, and each is rolled independently]
Go through these most common unit types in order. If any are size 4 or larger, there is a 15% chance per base unit size (not modified by things like enlargement) to "notice" the larger size. Record the highest size "noticed" this way, as well as which unit type this was.
Go through them again, this time looking for some kind of "power score". This is calculated as:
Hitpoints
Add hitpoints again if innately ethereal
Add (fear * 10) + (awe * 5)
If a commander, add (sum of all non-holy path levels) * 15
As with the fear, only scores above 100 are noticed, and the chance to notice a new score is (score/2)%. Remember the unit type of the highest noticed score again.
Go through them again. This time, looking for units that can fly (respecting things like perpetual storm). In order to be noticed, the unit…
Needs to have a higher power score than the last unit noticed, or 2+ if none were noticed by this check before
Must not be the unit type noticed by either the power score or size checks
Any unit type also has only a (power score)% chance to be noticed
In the presence of the fool scouts ability:
If there are 2+ unit types found in the province, erase all data for the second unit type.
This will stop subsequent checks finding anything except the first unit type
If Fata Morgana is or fool scouts is active: