Loggy's Freespawn reverse engineering notes
Yomi, "natural" spawns
Friendly dominion and a temple is required.
"Terrains" is true in any combination of caves/mountains/highlands, otherwise false.
"Your cap" also technically includes Shinuyama's cap, both of them have the flag used for this for some reason.
Number of spawn attempts is Turmoil + 1.
If End of Culture is up, add Turmoil again (so it becomes 2*Turmoil + 1).
While the number of spawn attempts > 0:
66% to just flat out fail (-1 spawn attempt).
If (terrains or your cap) and a 2% chance: Amanojaku (-2 spawn attempts)
If (terrains or your cap) and a 80% chance: Kuro-Oni (-2 spawn attempts)
If (terrains or your cap) and a 70% chance: Oni (-2 spawn attempts)
30% chance per cold scale: Ao-Oni (-1 spawn attempt)
30% chance per heat scale: Aka-Oni (-1 spawn attempt)
Otherwise: 1d4 (non-exploding) Ko-Oni (-1 spawn attempt)
(Once a single check succeeds, go spawn the units, subtract the spawn attempts, and then go back to the top of the bullets)
Yomi, Oni Summoner
Local value = (turmoil * 10) + unrest, capped at 100
If End of culture, double this (and cap at 150).
Doesn't function underwater.
Final % to spawn is (local value * oni summoner ability value)/100
Unknown criteria can also prevent spawning
You get a non-exploding d6 number of Ko-Oni.
Therodos
first it checks to see if you have candles, if you don't it does nothing
then it checks something else I don't understand, if you don't have that it does nothing
then it checks for a fort in the province, if there isn't one it does nothing
then it checks something else I don't understand, if you don't have that it does nothing
then it does (candles + [random number 0-2 incl] + death scale)
then it divides this number by 3 and rounds down
if that number is less than 1, it does nothing
This number is the number of spawn attempts.
For each spawn attempt:
pick a random number 0-8. If you rolled 8 and there is no temple in the province, set this to 0 instead
roll another random number 0-99. If it's less than 5, set the previous number to a random number 0-3 + 10
Spawn units based on the first number in this section:
0-3 incl: 1d4 exploding units with ID 0xb1a [spectral hoplite]
4 or 5: 1d4 exploding units with ID 0xb18 [spectral archer]
6 or 7: 1d4 exploding units with ID 0xb19 [spectral peltast]
8: 1 unit with ID 0xb1b [spectral kourete]
9: do nothing
10 or 11: 1 commander with ID 0xb1c [spectral commander]
12: 1 commander with ID 0xb1d [ephor 2845]
13: 1 commander with ID 0xb1e [spectral philosopher]
LA Rlyeh
If you don't have candles, don't do any of this.
Void critter component:
Scale component: 2 * candles + magic scale
If a random number 0-499 inclusive is less than (scale component * 5):
Roll 2d(candles/3 + 4, rounded down). These are closed die rolls. You get the void encounter that corresponds to this result:
If 1-5: 6x lesser otherness
If 6: 4x vile thing
If 7: 3x thing of many eyes
If 8: 3x thing from the void
If 9: 5x elder thing
If 10: 4x formless spawn
If 11: 4x otherness
If 12: 3x thing from the beyond
If 13: 2x dweller in the deep
If 14: 4x: greater otherness
If 15: 5x thing that should not be
If 16: 1x vastness
If 17+: 2x greater otherness
Cultist component:
If the province has no temple, get number of candles. If (province pop/10) < the number of candles, use that instead.
If the province has a temple, instead:
If a random number 0-74 is less than the value above, you're geting cultists.
If underwater, always get Cultist#1639
If coastal, always get Hybrid Cultist
If not coastal, 50% for Hybrid Cultist, 25% for Cultist#1640, 25% for Mad Cultist
Madman component:
Calculate 10 * number of candles.
If (province pop/20) is less than this, use that value instead.
If a random number 0-99 is less than the above value, you get madmen.
If this is a non-coastal land province, you get Madman
If this is a coastal land province, you get Mad Hybrids
If this is underwater, equal chances of Peasant [which is weird because they'll instantly drown], Mad Merman#1568, and Mad Ones.
No matter what type, you get 2d8 exploding.
Dreamer component:
Take (province pop/20) or (sloth + 5*candles), whichever is smaller.
If random number 0-99 is less than this value, you get dreamers.
If on land, it's always Human Dreamers.
Otherwise, equal chances for Deep One Dreamer, Triton Dreamer, and Merman Dreamer#1572
No matter which type, get 2d8 exploding.
MA Ermor
If you don't have candles, you get nothing.
If you don't own the province, you get nothing.
Candle value = (candles / 2) + 2
If you have a temple, add (8 * game setting's gold multiple)/100, rounded down.
Number of spawns = candle value * 175/100, rounded down
If the number of spawns is 0 or negative, you get nothing.
For each spawn attempt:
If this is your capital (90% chance of success) OR any other fort with ((1 + commander point bonus) * 30)% chance of success:
Roll a closed d(candles)-1, and spawn accordingly:
If 0 and the province is not UW: 50% for 1 ghoul
If 1 or 3: 1x soulless#197
If 2 4 6 7 9 10:
If 5 or 8:
Any other value [TODO: how does this fit in with the stuff below?]:
If 90 or 91, 1 longdead velite
If 92-94 inclusive, 1 in 3 chance for either a longdead triarius or principe (equal weighting). Otherwise, longdead legionnaire. Additionally, 1% chance for a Censor#260 regardless of the stuff before.
Asphodel
first it checks to see if you have candles, if you don't it does nothing
then it checks something else I don't understand, if you don't have that it does nothing
Number of spawns = 3, or 4 if you have a temple in the province
For each spawn attempt:
if this is not a UW province, and a random number 0-9 < (number of candles + growth):
25% chance, if there are armed corpses, or always if there armed corpses but no unarmed corpses:
If there are only civilian corpses:
If any corpses were removed:
if this is not a UW province, and a random number 0-9 < (number of candles + growth), and something to do with the presence of a forest (I assume, if province is a forest, but sign flags are doing my head in right now):
There is a (2 + Growth + Magic)% chance to get a high quality spawn:
Equal chances for Mandragora, Carrion Beast#718, Minotaur Manikin, Carrion Beast#1006, Sagittarian Carcass
Otherwise, a low quality spawn:
Equal chances for Manikin, Satyr Manikin, Harpy Manikin, Carrion Beast#715, Carrion Beast#716, Carrion Beast#717
If you rolled a (regular) manikin or mandragora (unit ID - 313 < 2), you instead get Carrion Beast#715 or Carrion Beast#716, chosen at random
Spawn 1 of the selected creature type
Regardless of spawn attempts, spawn (closed) 1d2 Sagittarian Carcasses if all of the following are true:
(5 + Growth) * 2 + Candles * 3 > a random number 0-99
The province is not underwater
The province is a forest
The province has a temple
LA Lemuria
Getting this was difficult because the compiler tied this in knots. There might be mistakes somewhere along the lines…
Requires friendly dom
Requires something else to do with province ownership
Something = (closed d2 - 1 + candles)/2 rounded down
If you have a temple, something = (closed d4 - 1 + candles) / 4 rounded down
If there is a fort, add a closed d4 to the something
The something is the number of spawn attempts, if 0 or negative then don't do anything.
For each spawn attempt:
If there is a temple
If there is no temple, always use index 0
If index = 0: Turns up to 1 corpse into a dispossessed spirit. Has a 25% chance to use armed corpses in preference to unarmed
If index is 1 or 2: On land, spawns a Shadow Soldier. Underwater, gives a Shadow Triton or an atlantean Shadow Soldier at equal chances
If index is 3: 60% Shade, 40% Shade Beast
If index is 4: Ghost
If index is 5: If 0 population, nothing happens. Otherwise, make 1 apparition, and kill 100 population
If index is 20 or 21:
If index is 22, openended d6 Spectral Velites
If index is 40, 50% chance if there is a lab for a Lemur Acolyte, otherwise a Shadow Tribune
If index is any other value (which in theory is impossible), the spawn attempt fails
LA and MA R'lyeh, coastal land forts only (nation attribute 157)
(For LA R'lyeh, this is in addition to their normal stuff)
This happens only in coastal on-land provinces where the R'lyeh owns the fort and has dominion there.
"Random hybrid" in this context is units 967-970, chosen at equal weighting.
If R'lyeh is the full owner (IE: fort is not under siege), there is one guaranteed random hybrid unit
Then, roll two closed d10s. For each that ⇐ the number of candles, you get another random hybrid