How to add a new faction replacing an existing one
After some requests I've decided to make this tutorial on " How to add a new faction replacing an existing one". As you might know it is not possible yet to add new elements such as factions, regions, cities, etc. But we can replace them making some more interesting starting positions.
As an example I am going to use Finland that was replaced Saxony in my mod Sturm und Drang. The necessary tools for the modifications are:
1. EsfEditor 1.4.5
2. PFM
3. OpenOficce spreadsheet
4. Gimp
Other needed modifications that are included and more references about startpos.esf can be found here . Since changes in startpos are always dangerous for errors I don't type the changes but I copy/paste them from a spread sheet that I have opened side by side with the editor, but that's me...
1. Preparing startpos.esf
First you have to choose which faction is going to be replaced by the new one. Some good choices are minor factions which will not be so unhistorical if their regions are given to the proper nearby major faction. Here I choose Saxony and first thing is give to it the region of Finland. This can be done in two ways:
a. The hard one is to edit the startpos and change Finland's region ownership from Sweden to Saxony following the proper modification (see STARTPOS ESF thread).
b. The easy one is making hybrid startpos which I'll follow. To make hybrid we need the original startpos and a saved game. For more details see in STARTPOS ESF thread. Here are the steps: Start the game as Sweden (owner of Finland), offer Finland to Saxony, save, exit, make hybrid. This is going to be the new startpos until a new hybrid is made.
c. Whatever way you choose open (new or modded) startpos with the editor go to REGION Saxony, note the region's Id then go in FACTION Saxony and make it faction's capital (see how to in STARTPOS ESF thread).
d. Saxony has a starting army and two characters (gentleman and rake), all stationed in city capital. We have to remove them in Finland region. See "how to" in STARTPOS ESF thread. Here I'll repeat some important things about it, since I often receive messages about it. Moving an army to a new place means that we have to change the coordinates for the army and the leading character (general or colonel, sometimes both). The same stands for gentlemen and rakes who have an army record too. Character's position is found in startpos [...]CAMPAIGN_ENV/CAMPAIN_MODEL/WORLD/FACTION_ARRAY/FACTION/CAHARCTER_ARRAY/CHARACTER/LOCOMOTABLE where there are two pairs of grids in the first 4 lines. Armies position is in [...]CAMPAIGN_ENV/CAMPAIN_MODEL/CAI_INTERFACE/CAI_WORLD/CAI_WORLD_RESOURCE_MOBILES/CAI_SITUATED where in two first lines are the coordination and in third the CAI_REGION id. So if we want to change an army's position we have to enter new coordinates in the places I've noted above and the new CAI_REGION Id. Note that every sea has a CAI_REGION Id so removing navies is exactly the same. Another important thing is that if a character or army is stationed in a city there are some other entries that need to be changed in WORLD and CAI_WORLD fields but we shall avoid these to make things easier. There is one more serious reason that I will do this, which is that I've never managed to remove stationed characters like gentlemen or rakes in a new place.
So let's put all things together: in order to move the army plus general, gentleman and rake from Saxony to Finland I have to have available 3 new pairs of coordinates. Then I'll need to make the changes to startpos. Here is how I am doing these:
d1. I start the game (using your new startpos) as Saxony and I move the army, character and rake out of the city. I save the game giving the name "hybrid" to saved_game but do not exit. I go in Finland (it already belongs to Saxony) and I recruit three units. Play the turn and move the new units in three deferent positions near the city. I save the game giving the name" grids" and exit. The hybrid saved game is going to be used for making hybrid startpos and grids saved_game to take the needed new coordinates.
Important Note: If gentleman and rake were not present I could simply disband the army here and save my time (and my nerves) from the next complex d2 step and d3. But since there is not a way to disband this kind of characters I have to go on d2, d3.
EDIT: After I've finished this tutorial I saw some new ideas about deleting characters. So if next steps are too complex for you take a look here and here. If these ideas are working go straight to e. When you are in game delete army and characters and continue the tutorial. If you want to keep starting army and characters then proceed to next step d2.
d2. Before go on I need to have available the three CAI_ARMY Id's (CAI_WORLD_RESOURCE_MOBILES). This is a little tricky so here it is in details. I go first in [...]WORLD/FACTION_ARRAY/FACTION/CAHARCTER_ARRAY/CHARACTER and note the Id (first line) for every character. Then I go in CAI_WORLD/ CAI_WORLD_REGIONS to find Saxony's and Finland's record. The only tip I can give for an easy spotting of these CAI records is to open regions.esf (!!!) and count in what place in root/region_data/region list are these regions. Then count the list CAI_WORLD/ CAI_WORLD_REGIONS and spot them checking the name in CAI_WORLD_REGIONS/CAI_REGION. From Finland I need the CAI_REGION Id which is the number of the record and I note it down. From Saxony I want something else. I go in CAI_WORLD_REGIONS/CAI_REGION and I note the CAI_SETTLEMENT Id in 3rd line. Then I use it to find Saxony's CAI_SETTLEMENT record in CAI_WORLD_ SETTLEMENTS and go further in CAI_WORLD_ SETTLEMENTS/CAI_GARISSONABLE. In first line there is CAI_ARMY Id! This is the first sight of Ithaca but the Odyssey is not over yet. Using this I spot the CAI_WORLD_RESOURCE_MOBILES record of the army. I go there and in CAI_WORLD_RESOURCE_MOBILES/ CAI_RESOURCE_MOBILE I note the CAI_CHARACTER's Id in 1st line (this is for general). Although the nearby records are the other two cai armies needed there is only one way to be sure, since characters like gentlemen and rakes have not simple army Id to confirm it. Go in CAI_WORLD_ CHARACTERS/CAI_ CHARACTERS using the Id found for the general and spot it. Checking the nearby records using the characters Id's I've noted down from [...]WORLD/FACTION_ARRAY/FACTION/CAHARCTER_ARRAY/CHARACTER (9 digits, it should appear in CAI_WORLD_ CHARACTERS/CAI_ CHARACTERS 4th line) I can spot the records for gentleman and rake. In CAI_WORLD_ CHARACTERS/CAI_ CHARACTERS 1st line is the CAI_ARMY I am looking for so I note them down making sure to also note which cai army Id belongs to whom.
d3. Now the last thing I have to note are the new coordinates. I open the grids saved_game, go on WORLD/FACTION_ARRAY/FACTION(saxony)/CAHARCTER_ARRAY/CHARACTER and I spot the three colonels records which belong to the three new units I've made in the game at Finland region. In LOCOMOTABLE I find the new coordinates and note them down deciding which I'll give to whom.
d4. Using startpos and hybrid saved game I make a new hybrid startpos. I open it and go in Saxony's [...]WORLD/FACTION_ARRAY/FACTION/CAHARCTER_ARRAY/CHARACTER and I enter the new coordinates I've noted before (double enter in the first four lines). Then I go in CAI_WORLD_RESOURCE_MOBILES record for every character using the CAI_RESOURCE_MOBILE Id I've already found and in CAI_SITUATED I enter the new coordinates (checking to be the same that I've entered in CHARACTER's record) in the first 2 lines and in third the CAI_REGION Id for Finland which I've already found in step d2. Save and exit.
e. Start the game as Saxony and if everything is o.k. now I should have: Saxony faction owning two regions (Saxony and Finland), Finland as capital region, characters and army placed in Finland. I give Saxony region to Prussia, save and exit. I make the last hybrid startpos and I open it for the last couple but easy modifications. I go in [...]CAMPAIGN_PREOPEN_MAP_INFO/REGION_OWNERSHIP_BY_THEATRE and I change the owner for Finland from Sweden to Saxony, and for Saxony from Saxony to Prussia. Then I go in [...]WORLD/FACTION_ARRAY/FACTION(saxony)/FACTION_FLAG_AND_COLOURS and I change the R,G,B colors which the game will use on the map, in tooltips, e.t.c. You can open a program like paint.net (free) and in colors select the color that suits to your new faction and copy the R,G,B numbers. I picked a light blue (86, 173, 255). These numbers will be used also in mod.pack/db/faction_tables.
2. Preparing mod pack file.
Make a new folder and name it as you like e.g. mymod. Open patch.pack with PFM and extract db/factions_table and after that export as a TSV, pointing as destination for both mymod folder. Do the same for units_to_exclusive_faction_permissions, warscape_rigid_lod_tables and warscape_rigid_tables, extracting and exporting as TSV each table. Then open models.pack and extract rigidmodels/ campaignbuildings/campaignagenticons, flags/textures and naval/textures. Last open ui.pack and extract flags/saxony (in my case the old faction).
a. Open factions.TSV using a spreadsheet and go in the row with the faction. Live first two cells unchanged where the faction name and code are (Faction Id and Id2). In Category enter the proper entry using one of another faction with the same or similar culture with the new one. Here I use some of the entries for Sweden. In Type, Nation, Nationality enter the proper entries. Not all of these entries affect the game and many of them are just for info use. In Names enter the name_group for your new faction. If your new faction has names that there are not available (as it happened with me for Finland) then you have to make major changes in localisation.loc. Anyway here you should enter an existing group name since I haven't find a way to mod names_group table and add new groups. But in most case you'll find a suitable one. Change also Sounds with an appropriate entry, Icons for the units, in R1, G1, B1, ..., repeat the color numbers you've already used for startpos. In Group is determined the type of units the new faction will have. Names 1 live it as names_english and in Names 2 repeat the entry of Names. When you've done delete all factions rows except the one you've modded. Exit and save changes in TSV.
b. units_to_exclusive_faction_permissions.TSV. For Finland I've entered in faction table to use sweden_denmark_group units. But in Swedish army there are units that only Sweden can use. Also there is one that is Finnish. So in Unit Id ref column I keep only the specific Swedish units (e.g euro_dragoons_sweden, euro_heavy_cavalry_sweden, etc.) and the Swedish unit hakkapeliitat and delete all the rest. Using saxony/true I assign these units to be available also for Saxony. For hakkapelitat I make a second row using sweden/false so only Finland(Saxony) will have this unit. Exit and save changes in TSV.
c. warscape_rigid_lod_tables.TSV . Open it and short it in alphabetical order for easy control. Delete all rows and keep only the one that will have your old faction's agent model, in my case RigidModels/CampaignBuildings/CampaignAgentIcons/agent_ID_saxony.rigid_model. Exit and save changes in TSV.
d. warscape_rigid_tables.TSV. Repeat the same keeping only the agent texture, in my case agent_ID_saxony.
e. There are two ways making the flags files. One is to make new one, the second that I'll follow is changing the existing one. In mymod folder go in ui/flags and delete all folders except the old faction, in my case saxony. Here are all the flags that are used in game (campaign map, hud, menu, etc.). You have to make new tga's in the same dimensions and names as the existing, for your new faction's flag, using a program like gimp (free). All the animation flags (11 pieces) can be the same just with deferent name. This is made for the effect of the waving flag in faction selection menu and in Ai turn. There is no point to waste your time make it like this (if you can) just use the same 200 X 100 tga. On campaign and battle map flags will be waving in the wind. The only difficult are the these for hud and portraits. All the other are the same in deferent dimensions and names. So make first large.tga in 512X256 from an image of the flag you should have already and proceed with the rest.
g. In rigidmodels/ campaignbuildings/campaignagenticons folder delete all but the old faction agent model, in my case agent_id_saxony.rigid_model. In texture folder keep only the agent's dds, in my case agent_id_saxony_diffuse.dds. Open it with gimp and change the flag colors (copy a circle from one of your flags you've made already). This is for the flag on top of the agent on campaign map. In flags/textures keep only the files flags.tai, flags0.dds, 1,2,3, naval_id.tai and naval_id0.dds. Find in which flagsX.dds is the old faction's flag. Then copy over it the latge.tga (512X256) you've already made. In naval_id0.dds replace the circle flag that will be shown on top of the ships. In naval/textures keep only faction's dds in my case ensign_saxony_diffuse.dds. Change this also using the large.tga and remaking the side long triangle flags.
h. Now we have everything we need to make the mod.pack file. Open PFM and make new pack file, pointing mymod folder. Choose a Pack Action/Change pack type and mark mod. Save the file as the name you like but you have to save it in mymod folder and do not exit. Right click on pack file and add directory. Add all folders that there are in mymod folder. Save. Expand db and go in db/factions table, import TSV and point factions.TSV file. Repeat with all db tables. Save. Open again db and rename every table. For example call my_factions, factions table, etc. Do this for all (and only) db tables. Save the file.
3. Preparing localisation.loc
Open patch_en.pack with PFM extract localisation_loc in mymod folder and also export as TSV. Close PFM and open localisation.TSV. Sort it in alphabetical order. Then find the entries factions_screen_adjective_xxxxxx and factions_screen_name_xxxxxx and enter in column B the appropriate names for your new faction. Exit and save TSV. Open PFM and make a new pack file of type movie this time. Save it is as the name you like but in mymod folder. Then add directory text and then import localisation.TSV in text/localisation_loc table..
Now you are ready to see your new faction. Place the two pack files you make in ETW/data folder. Start the game with Mod Manager marking your new mod to be activated. Enjoy your new faction with the proper name, flag and colors.
Other changes.
There are some other changes that have to be done in some cases. If your new faction uses deferent group names than the old then the existing characters will still have the old names. To correct that you have to edit startpos and change all names in FAMILY and CHARACTERS using new names from localisation.loc. Another element might be religion. Here you have to change the religion in FACTION record, in FAMILY records and in the REGION/POPULATION record of the new faction. Also the same maybe is needed to be done about type of government, diplomatic relations, etc. Most of these changes are in startpos FACTION record. In my mod Sturm und Drang you can see in the pack file the structure of it. There I've added three new faction until now and I've just changed some elements of three existing Italian faction as well.
If you successfully make your mod introducing a new faction. please compress the mod files and upload them here. It will be made a good data base with the new factions playable.
CREDITS
Lt Chabers for PFM
Just for EsfEditor
Koras321, alpaca, erasmus777 for later development of these tools.