Hello,
In this tutorial I will show you how you can give a region to another faction as well as making an emergent playable in the same process.
First make a backup of your startpos.esf in the data/campaigns/main/ folder
Next you will need to download this program http://www.twcenter.net/forums/showthread.php?t=242353 and open up your startpos.esf with it.
I will start with making a emergent faction playable because it will in the end have the same process that is gone through as you would with adding a region to any faction whether it was already in the game.
The first section we will be editing is known as the CAMPAIGN_PREOPEN_MAP_INFO as the name suggests this is what the game reads in when you are at the grand campaign start area so it can populate the menu with who can be played and what regions they own.
We first want to edit CAMPAIGN_PLAYERS_SETUP. Find the emergent faction you wish to play.
Under its CAMPAIGN_PLAYER_SETUP section you will see the faction's name and then three booleans. By setting the second boolean to True you will allow that faction to be chosen at the menu.
Next find your faction in FACTION_INFOS and set the last integer to 1 or if you plan to give your faction multiple regions, then just put the number of regions you plan to give. This step may not be completely necessary because I notice for the faction I stole the regions from they automatically updated to reflect correctly in the start game screen.
Next we have REGION_OWNERSHIPS_BY_THEATRE. Each subsection is for a specific theatre, India, America, Europe. So find the theater for your region and then find the specific region entry and change the faction name to the name of the Emergent faction you want to play.
Now we are moving on to the CAMPAIGN_ENV section. This defines the bulk of the campaign state at the start of the first turn.
Under CAMPAIGN_PLAYERS_SETUP you will do the same process as in the prior section where the second boolean needs to be set to True.
Next we will move to CAMPAIGN_MODEL/WORLD.
Under this section you will see a FACTION_ARRAY and a REGION_MANAGER. These are the two final areas we will be editing.
Firstly go into the FACTION_ARRAY and find the Faction you want to be emergent or the faction you want to give a region to.
When you have found him you will see a lot of data variables for the faction at its FACTION section level. Here is what some of them do:
- faction_id - int
- faction_db_name - uft16
- faction_display_name - utf16
- unknown - Boolean
- unknown - Boolean
- Is Major Faction? - Boolean
- unknown - Binary Data
- Official Religion - utf16
- unknown - Boolean
- capitol_region_id - Int
- capitol_region_id - Int
- unknown - Boolean
- Is Emergent? - Boolean
- unknown -Uint
- unknown - Binary Data
- unknown - int
- unknown - int
- Main AI mode - utf16 (FULL or MAINTAINANCE)
- AI Personality - utf16
- protector faction_id - int
For Emergent factions to be playable you need to set Is Emergent? to False. (sorry forgot this step )
So I suggest to write down the Faction ID# for your faction.
Next we will go into the REGION_MANAGER and you will need to find the entry for your Region which may take some time as there are 205 regions to find it through.
At the REGION section level you will see a large set of data for each region here is explained some of what they are:
- region_db_name - utf16
- region_id - int
- (skip past 13 unknowns)
- owner faction_id - uint
- owner theater_id - uint
- theater_name - utf16
- main_rebels - uft16 (Can be any Faction or just a rebels type)
- base rebels type - utf16 (This can only be a rebels type of faction)
- coastal climate? - utf16
So first we want to take the faction_id of our faction and set the owner faction_id to this value.
If you are using an emergent faction we will also need to go back to our faction section and change the capitol_region_ids to point to this region.
Next we must proceed further into the region and edit parts of the REGION_SLOT_MANAGER and the SETTLEMENT sections.
Proceed as far in as you can for each element in REGION_SLOT_MANAGER to if you can reach a BUILDING section which inside will have who owns the building and also the gov_type. You must edit each building to have your faction's name and government type.
Furthermore for each REGION_SLOT you need to edit SEIGABLE_GARRISON_RESIDENCE/GARRISON_RESIDENCE. In there is a single Uint that holds the ID to the owner faction of this region. (These same things also get done for the region_slots inside of the Road and Fort Slots.
Also do the same thing under SETTLEMENT for the SEIGABLE_GARRISON_RESIDENCE/GARRISON_RESIDENCE.
If you followed all the steps correctly this region should now be properly owned by the faction you chose.
If you were unlocking a emergent faction please note that you can only play as that emergent faction because the AI definitions for the emergent probably are not there so other factions crash on load.
Update: How to decouple an enemy army from the settlement of a region they no longer own
Next we will be looking at how you can get those pesky armies that start in a settlement out of the settlement. I found after so much turns the army eventually vanished. What typically happens to this army is it will exhibit behavior similar to trade fleets on trade nodes when the game first came out where they were trapped there. When you load up the game with this fix to your region you will see the army sits in the center of your settlement but is no longer in the settlement. I think soon the AI will realize that unit is borked and will destroy it on its own.
So to do this step we will now be looking at the ARMY under the FACTION of the FACTION_ARRAY of the original owner of the region.
So you see here that the first step will be to find what the army we want to edit is. To do this we need to go back to our Region we gave to the other faction.
At the SETTLEMENT/SIEGEABLE_GARRISON_RESIDENCE level of our region we will see this data:
- settlement_id - int
- 8 unknowns
- some ai ID - int
- some ai ID - int
- garrisoned_army_id - int
So here you see that we will want to make note of our settlement_id and to also change the garrisoned_army_id to 0 so that the settlement no longer has a garrison to it.
We then take our settlement_id and we find the ARMY in the ARMY_ARRAY for the old owner of the region
At the ARMY section level is some set of data which is explained thus:
- unknown Binary Data
- unknown Binary Data
- army_id - int
- settlement_id -int (for the settlement they are garrisoning, 0 if no settlement)
- unknown - boolean
- unknown - int
So we change that settlement_id to be 0 so that the army no longer will think it is to be garrisoning that settlement. If all goes well you will find the army standing outside the settlement right at its center and after you save the game it should check validity of each armies position on the campaign and these bad armies will be sent to the nearest region. When I did Greece from the Ottomans this resulted in the army getting stuck on one of the little islands of Anatolia.
Also for emergent faction if you want to get all your government people to generate you will need to capture a region and then instantly the game will generate a Faction Leader and ministers for your faction. (It is hard with some factions who cannot build stuff like Scotland, but with USA I tested this).
Here are two esfs as an example. (You can only play the specific emergent faction for each esf since AI setups have not been developed into them for the emergents so playing anybody else caused crashes)
startpos_us.esf gives the USA Virginia to start off. Once you capture another region everything should be working as normal, till then you cannot manage taxes you will have no faction leader or ministers. When I tested I just made 4 Minutemen and quickly attacked the region above me and then it was business as usual. Also in this file I made Portugal a Major faction with FULL AI just as a test.
scotty_startpos.esf is a Scotland version. This one is near useless because as Scotland it would not let me build any building or any units so I was stuck with a city with just the garrison I think something in the db files could fix this maybe.
http://rapidshare.com/files/213902506/main.zip.html