Im going to use Mongols as example.
STEP 1: In descr_strat.txt, you need this:
The bold line is actually the only mandatory one, you can edit the other ones the way you want
Make sure there is no settlement or characters/armies in the section of this faction in this file, just the lines above, nothing more.
Code:
faction mongols, balanced henry
ai_label default
dead_until_resurrected
denari 10000
denari_kings_purse 3000
STEP 2: In descr_sm_factions.txt you need this:
You need at least one horde_unit here, otherwise the game will keep showing a "faction destroyed" pop up every turn. If you dont want any unit to be spawed via the descr_events.txt (as explained in the next steps), set the values above in red to 1 at least, if you use 0 the log.txt file will warn you (though I dont know what are the real consequences of this).
Code:
faction mongols, spawned_on_event
culture middle_eastern
religion islam
........
custom_battle_availability yes
horde_min_units 10
horde_max_units 20
horde_max_units_reduction_every_horde 10
horde_unit_per_settlement_population 250
horde_min_named_characters 2
horde_max_percent_army_stack 80
horde_disband_percent_on_settlement_capture 0
horde_unit Mongol Infantry
horde_unit Mongol Foot Archers
horde_unit Mongol Heavy Archers
horde_unit Mongol Heavy Lancers
can_sap yes
prefers_naval_invasions no
can_have_princess no
has_family_tree yes
WARNING: THE NEXT STEPS (3 AND 4) ARE NOT REALLY NECESSARY, AFTER STEPS 1 AND 2 ARE DONE YOU CAN SIMPLY SPAWN THE FACTION'S UNITS VIA CAMPAIGN_SCRIPT.TXT AND THIS WILL MAKE THE FACTION ALIVE. THE FOLLOWING STEPS ARE JUST ANOTHER WAY.
STEP 3: In descr_events.txt you need this:
Here you can edit the date freely and you need to choose a region from your mod.
What the emergent_faction event does is to spawn several randomly named characters with some specific units in the target region. The number and unit types are determined by the entries in descr_sm_factions.txt (see next step).
Code:
event emergent_faction mongols
date 1 3
region Name_Of_Province
STEP 4: In historic_events.txt you need this:
Code:
{THE_MONGOLS_EMERGE_TITLE} Place any text you want here
{THE_MONGOLS_EMERGE_BODY} Place any text you want here
------------------------------------------ THE END ---------------------------------------------
Bonus info:
You can now spawn units for this horde faction normally via campaign_script.
If you want to spawn an unique character as the faction leader when the horde faction emerges (e.g. You want to spawn Timur as the faction leader of the Timurids), you shouldn't use the emergent_faction event since the first randomly named character spawned in the event will become the faction leader. See this
PS: If the faction leader dies and there is no heir, the faction will be destroyed.