Author: husserlTW
Original Thread: About STARTPOS.ESF file

About STARTPOS.ESF fileDecoding” crucial files like startpos.esf that are needed for minor or major modifications is a long proses due to lack of CA's modding tools. I've decided to make this tutorial with all the informations I've found so far. These informations comes from my involvement with several issues that had to do mainly with added building slots to cities and many of them were provided by demis14 . Also there are many pieces of informations in several posts around. I've included just some of these but there more that need to be gathered. And that is the ambitious objective of this tutorial: to become a place where will be gathered several already known futures of these files and to be provoked further improvement in modding them. Any contributions in theoretical or practical ideas, successful tests experiments and modifications are needed. In the other hand questions are added about changes in startpos. In this case a guide is needed and this tutorial/research will try to help in this direction, revealing some of the roots in startpos.esf labyrinth.


THEORY

Startpos.esf:
As it's name says startpos is the starting position of the game. It's database includes all the elements of the game and the way they are connected. Maps, theatres, factions, regions, armies, trading roots and posts, governments, families, even the roots of the horse wagons that carry commodities are included.
Regions.esf:
This file includes the positions and the roots on the campaign. Demis14 connects it also with the positions of buildings in battle map.

TOOLS

EsfEditor (l.v. 1.4.3.0)


Thanks to Just there is EsfEditor that has been improved by koras31 and alpaca. It can handle multiply .esf files like startpos, regions and saved_games. This is the basic interface:








Here you can see the database tree and the informations that can be displayed. Except Values and Types has also 2 very helpful columns. In Description can be noted by the user general descriptions of the values which are known. When you change a value -and until save it- the original remains in Original Value until you save it.


Links for more info:


Esf Editor


Esf Editor1.4.3


startpos.esf catelog


Grid_spreadsheet


Erasmus777 based on the relations among the basic coordinates of a settlement and the coordinates of her building slots and made a very useful spreadsheet that calculates new coordinates when building slots are added or disabled.


Link: spreadsheet


TUTORIALS BASED ON STARTPOS.ESF CHANGES




IN PRACTICE




Trying to present known elements of startpos.esf and regions.esf, I am going to follow the root of the known connections inside these files. To do that I will follow Portugal in the labyrinth of the vanilla startpos.esf. Although this presentation follows linear the database tree, as it is shown in the left window of the editor, working in startpos.esf usually it is not like this. Searching or heading to a record following the shortest root through the connections among them is often the quicker way. Since starting points often is a name (faction, region, etc.) and the long lists of the records are not in alphabetical order, it is helpful to be advised by lists that are made in the forum, with useful connections. Some of them are included in the tutorial. Especially entering CAI_INTERFACE most common way is through CAI_BUILDING_SLOTS ID's using the BUILDING_SLOT ID.




Faction:Portugal


Status: minor, not playable


Regions: portugal, curacao.


Capitol: Lisbon


Government: Absolute monarchy

startpos.esf/
CAMPAIGN_STARTPOS/
CAMPAIGN_PREOPEN_MAP_INFO:
The first data about Portugal are met in CAMPAIGN_PLAYERS_SETUP/PLAYERS_ARRAY/PLAYERS_ARRAY/:

Spoiler Alert, click show to read: 


Here are the factions with the relations to the player. In the table above there is a list with all the players_array and their position in the list:


[LEFT]

The 27th record that belongs to portugal:
CAMPAIGN_PREOPEN_MAP_INFO/CAMPAIGN_PLAYERS_SETUP:

Spoiler Alert, click show to read: 

The second false value tells if portugal is playble (True) or non (False). There are other fields need to be changed for activating a non playable factions in next records.
CAMPAIGN_PLAYERS_SETUP/CAMPAIGN_VICTORY_CONDITIONS:
Spoiler Alert, click show to read: 


These values are the same for all factions in PLAYERS_ARRΑY (factions) as those in CAMPAIGN_PLAYERS_SETUP_MODIFIABLES.

CAMPAIGN_PREOPEN_MAP_INFO/VICTORY_CONDITION_OPTIONS:
There is a list of the faction is in a different order. Portugal's VICTORY_CONDITION_OPTIONS:
Spoiler Alert, click show to read: 

VICTORY_CONDITION_OPTIONS of Portugal is divided by 4 VICTORY_CONDITION_BLOCK which include the preconditions for victory in every campaign scenario.
Spoiler Alert, click show to read: 

The CAMPAIGN_VICTORY_CONDITION of the first VICTORY_CONDITION_BLOCK is for campaign mod 0 (short), which ends in 1750 and the player must own 10 provinces:
Spoiler Alert, click show to read: 

Among them must be the regions that included in the the REGION_KEYS under VICTORY_CONDITION_BLOCK:
Spoiler Alert, click show to read: 

The rest three blocks has the preconditions for the campaign mod 1-long, 2-prestige, 3 - world domination.

CAMPAIGN_PREOPEN_MAP_INFO/FACTION_INFOS:
Here are the factions in the same order as in PLAYERS_ARRAY with basic informations.
Spoiler Alert, click show to read: 


Portugal is the 27th record with infos about portrait, description and the region that the faction owns. The entries in 3rd and 4th line are True/True for playable faction, False/False for unplayable and True/False in Mughal and US.

CAMPAIGN_PREOPEN_MAP_INFO/REGION_OWNERS_BY_THEATRE:
All the regions with the owner faction are grouped in the 3 theatres, europe, america, india.
Spoiler Alert, click show to read: 

Above the REGION_OWNERSHIPS malaba-portugal in indian theatre.

startpos.esf/
CAMPAIGN_STARTPOS/CAMPAIGN_ENV:
Spoiler Alert, click show to read: 

CAMPAIGN_ENV/CAMPAIGN_SETUP includes the same records as startpos.esf/CAMPAIGN_STARTPOS/CAMPAIGN_PREOPEN_MAP_INFO/CAMPAIGN_PLAYERS_SETUP:
Spoiler Alert, click show to read: 

CAMPAIGN_SETUP/CAMPAIGN_SETUP_OPTIONS:
Spoiler Alert, click show to read: 


Unknown entries with 6th and 7th lines matching with 7th and 8th entry of next table.

CAMPAIGN_ENV/CAMPAIGN_MODEL:
Spoiler Alert, click show to read: 


CAMPAIGN_MODEL/
CAMPAIGN_MAP_DATA:
Spoiler Alert, click show to read: 



CAMPAIGN_MODEL/WORLD/
Here is one of the most interesting fields of startpos.esf -and area of many modifications-. where detailed settings and unique ID's are given to game elements.
WORLD/FACTION_ARRAY:
Spoiler Alert, click show to read: 

In FACTION_ARRAY/FACTION we can see informations about Portugal. Some interesting are in line:
1st faction's ID.
6th False for minor, True for major.
8th, 10th True playable, False non. If True is placed here for a minor faction, even it is playable by modding, the game crashes.
11th , 12th Capitol region ID. Regions ID's are in a later record of WORLD.
13th Demis14 connects True/False with emergent/non emergent.
17th , 18th Usually is 0. Some of the major factions have numbers like France 4960/2150, Ottomans 3690/730, Austria 4570/0, etc.
19th The following strategy during the game. All the minor nations have MAINTANANCE and majors FULL.
20th Is something like special ability. Portugal's is maritime_repressive. The minors have usually default. Some of them like Morocco have no_europe but most of non europe factions have default. The values of the major factions are variable. Brtain maritime_progressive, France mixed_progressive, Austria continental_progressive, Netherlands trader, Spain maritime_repressive, etc. There are also major with default like Sweden and no_europe like Ottomans or Maratha.
23th - 26th All values are 0 for minor factions. Major have numbers (like 8, 10, 15, etc.).

FACTION/ANCILLARY_UNIQUENESS_MONITOR:
Spoiler Alert, click show to read: 

As in all minor factions, ENTRIES in Portugal are empty. In the above image is Britain with two ENTRIES: Ancillary_Government_Comptroller and Ancillary_Army_Merc_Artilleryman.

FACTION/CAMPAIGN_PLAYERS_SETUP:
Spoiler Alert, click show to read: 

Same records as in CAMPAIGN_PREOPEN_MAP_INFO.

FACTION/FACTION_ECONOMICS:
Spoiler Alert, click show to read: 

Staring money of Portugal.

FACTION/DIPLOMACY_MANAGER:
Spoiler Alert, click show to read: 

Here are the relations between Portugal and the other factions. Above in DIPLOMACY_RELATIONSHIP Portugal is neutral to faction with ID 351568752 which is new_spain.
Spoiler Alert, click show to read: 

For the relation between Portugal and New Spain there are 22 DIPLOMACY_RELATIONSHIPS_ATTITUDES_ARRAY. Most of them have 0 values in 1, 2, 3, and 5th line. If a number appears in one of 1, 2, 3, then False in 4th line turns to True. Same thing happens in 5th and 6th line.

FACTION/GOVERNMENT:
Spoiler Alert, click show to read: 

ID an type of Portugal's government.

GOVERNMENT/POSTS_ARRAY/CHARACTER_POST:
Spoiler Alert, click show to read: 

In Portugal's GOVERNMENT there are 9 CHARACTER_POST's. 7 are for the ministers and 2 governors for Europe and India. In every record are noted the government post ID, the type, the character ID and the government ID of Portugal.

GOVERNMENT/GOV_IMP
Spoiler Alert, click show to read: 

Probably when the first revolution is occurred. Above, after 10 turns or years (?) a CONSTITUTIONAL_MONARCHY will be attempted (?).

FACTION/FAMILY:
Spoiler Alert, click show to read: 

In FAMILY are included the Monarch and his successors. The 5t line maybe is the turns or years that he will be replaced by his successor. CAMPAIN_LOCALISATION and PORTRAIT_DETAILS link to descriptions and details (loc files). The records of successors have 0/False values.
Spoiler Alert, click show to read: 

Every MONARCH_INFO_CHARACTER seems to have a NAME_ALLOCATION_DETAILS record. One of them has in 1stline 0 (the others have numbers) and in second the number 4245029912. These type of 10 digit numbers are met also in the other records.
Comment:
We have also meet CAMPAIGN_MODEL with 10 digit number and CAMPAIGN_MODEL/RandSeed with 11th digit number.

FACTION/CHARACTER_ARRAY/CHARACTER:
Spoiler Alert, click show to read: 

In this CHARACTER table of a Portugal minister there are in line:
1st Character ID
2nd Type of character. Except ministers here are the generals, admirals, captains, gentlemen and rakes.
7th The government post ID for this minister. It is GOVERNMENT/POSTS_ARRAY/CHARACTER_POST ID for finance we've met already. So this character is the minister of treasury.
14th Number 10 is met on land CHARACTERS and 15 on sea CHR's (admirals, etc.)

CHARACTER_ARRAY/CHARACTER/LOCOMOTABLE:
Spoiler Alert, click show to read: 

1st and 2nd line are the location of finance minister. These are the basic coordination's of Lisbon settlement (we'll meet the entries later), where the government is settled. The coordinates varies from character to character depending on his location on campaign map.
Comment:
I've noticed many remaining entries like settlements coordination's, which are connected with several records, in attempts of changing region ownership.

FACTION/ARMY_ARRAY:
Spoiler Alert, click show to read: 


Here are registered the armies and navies of Portugal. Every army has it's ID, settlement ID (if it is inside settlement as in Lisbon). In MILITARY_FORCE the character leader's ID (general or captain) and in UNITS_ARRAY the units that this army has in the beginning of the game.

WORLD/REGION_MANAGER
That's the place in the list of all regions. In the table below the position of the faction records in the list:


Spoiler Alert, click show to read: 

This is the REGION portugal and in line:
1 Region name.
2 Region ID
6-11 Demis14 connects these numbers with economic figures like starting wealth of productive facilities.
17 Controlling faction ID
18 Governorship ID
19 Theatre
20 Emerging nation
21 Region rebels
22 Region group. Bournoutfigshas moded this line so New Orleans get europe civilian buildings around city and not native american's(sc_european_americans).

REGION/LINE_OF_SIGHT:
Spoiler Alert, click show to read: 

Most of the regions have that record just after SETTLEMENT. All the QAD_TREE_BIT_ARRAY_NODE sub-records have no values.

REGION/POPULATION:
Spoiler Alert, click show to read: 

These three numbers of population have nothing to do with the 3 classes. 1st and 3rd is very close to staring population.
Spoiler Alert, click show to read: 

In REGION_FACTORS 2nd line is the population number that you can see in the Lists of in game interface, regions tab, in Lisbon city. Maybe the fourth line is the population of all region.
REGION_FACTORS contains 3 population records for the 3 classes with the same values (0 most cases). RELIGION_BREAKTROUGH determines the religion of Portugal.
Spoiler Alert, click show to read: 

Above in rel_catholic table 2nd line is 1 and in all others religions 0.

REGION/REGION_SLOT_MANAGER
Here are placed all the building slots of buildings, towns, ports, farms and mines for region portugal. Minor cities have only 1 building (minor_government), major 4 or 5.
Spoiler Alert, click show to read: 

Above is the table of Lisbon's army building:
1 REGION_ SLOT ID for army building.
2 Type of slot, settlement:'portugal':lisbon:settlement_army-admin(minus quotations around portugal).

5, 6 The coordinates of its location in Lisbon settlement major city.
8 Type of civilian small buildings. Can be between 1-5 depending on the city growing. Here there are images of the 5 levels.
10, 11 Are connected with the type of slot as well as 7, 8.
12 The 10 digit number 4294967295 is shown in many occasions. Amazing coincidence (?) that is the same with highest value of turns per year in Just's tool.
REGION_ SLOT/SIEGABLE_GARRISON_RESIDENCE must have the REGION_ SLOT ID, and GARISSON_RESIDENCE the FACTION ID
REGION_ SLOT/BUILDING_MANAGER is True/False if the slot exists in the beginning and False/False if it is going to be spawned later in the campaign:
Spoiler Alert, click show to read: 

If the slot is occupied by a building (True/False) then the sub-record BUILDING appears with the specific type and level of slot.
Spoiler Alert, click show to read: 

Above the army building of Lisbon in army_encampment level.

REGION_SLOT_MANAGER/SETTLEMENT
This record has to do with the city of Lisbon:
Spoiler Alert, click show to read: 

First line's value must be the same with 8th line of city's building slots. In 2nd and 4th the status of settlement:'portugal':lisbon(minus quotations)
and in 3rd the owner faction.

SETTLEMENT/ SIEGABLE_GARRISON_RESIDENCE table is almost the same as REGION_SLOTS,
Spoiler Alert, click show to read: 


plus the basic coordinates of the settlement in lines 10, 11 and the ARMY ID that is stationed there in the beginning of the game. The same coordinates were met in the CHARACTERS that are in city. Also this ARMY ID is connected with the ARMY and the it's leader records in FACTION/ARMY_ARRAY and FACTION/CHARACTER_ARRAY.

REGION_SLOT_MANAGER/REGION_RECRUITMENT_MANAGER:
Spoiler Alert, click show to read: 



Portugal owns a second region, Goa in India, which has it's own REGION records.