First of all a huge thanks to PowerWizard, MrThib and The Phenom for their tutorials on how to create units. Their tutorials can be found here, here and here respectively. My tutorial is just a small addition to what they have already achieved.
For the sake of this tutorial I am going to make Prussian Line Infantry only recruitable in East Prussia and only 10 are available at any one time.
1. Extract the region_unit_resources table from main.pack with Pack File Manager.
2. Then create a new pack and add the db directory to the pack.
3. Then add east_prussia to the region_unit_resourcestable. Save the pack as a mod, in my case I saved it as mod_regions. Don't forget to add it to your scripts file. This table does not include the actual regions on the campaign map, but instead 'umbrella' regions that can control AOR over many regions on the map. For example if you give your unit (in the unit_tables) the 'europe' region that will allow you to recruit that unit anywhere in Europe assuming you have the correct tech and buildings.
4. Then set the Prussian line infantry to only be recruited in east_prussia in the units_tables and a maximum of 10 units from that region. (I am editing the slow mod pack file but the table to edit will still be under units_tables).
5. Now that means nothing yet as it has not been tied to the actual region on the map. Here is how to do that:
Open the startpos.esf with the esf editor. Navigate to main\startps.esf\CAMPAIGN_STARTPOS\CAMPAIGN_ENV\CAMPAIGN_MODEL\WORLD\REGION_MANAGER\REGIONS_ARRAY
Now you will see a series of entries for each region. Expand the entry on level and click REGION to find out what region this refers to on the campaign map. In my case I found prussia (see what I mean - CA is not very good at naming so this confused me at first - Prussia is actually East Prussia in game).
6. Now expand REGION\RESOURCES_ARRAY\
Clone one of the entries and rename the value to the region you created in the region_unit_resources. I should also mention that you can add your 'region' to any number or regions in the .esf and the unit will be recruitable there too. An example here again is 'europe' in the region_unit_resources. You will notice that every 'european' province will have a 'europe' entry.
Save the .esf and you are done. The Prussian line infantry will now only be available in East Prussia and only 10 at once. AOR units
I was look for this because I want to limit how many units of each type can be recruited in a region. The only problem I can see is if you want to limit a specific unit on a regional basis you would have to create a new unit for every region.