EDCT and EDA region label converter download
As part of EBII planning to revise the map, I was made aware of a problem with traits and ancillaries. Conditions testing which region a character is in (IsRegionOneOf), unlike the campaign script, needs to reference a region ID. This ID is volatile, it can change when the map boundaries change for any reason - breaking these conditions. Depending on how widespread you are using region conditions, this can mean a lot of work fixing each time you change the map.
The region label you define in descr_regions.txt is a constant, and therefore more suitable to reference. I have made a small conversion tool that when run, will convert region label references in EDCT and EDA to region ID using the current map.
Java source included. Anyone can use it however you like, except copyrighting it.
-------------
How does it work
I read map_regions.tga, descr_regions.txt and imperial_campaign_regions_and_settlement_names.txt in order to make a mapping of region label to region ID and province name.
It uses Withwnar's logic for assigning region ID, IE traverse map_regions.tga from left to right, top to bottom, and assign an incrementing ID as each new colour is encountered.
Reading the files export_descr_character_traits_regionlabels.txt and export_descr_ancillaries_regionlabels.txt, I look for references to region labels within straight brackets. Any of these are converted to the region ID, while the rest of the file contents are kept as is. The tool then writes export_descr_character_traits.txt and export_descr_ancillaries.txt with the converted region IDs. The source files remain untouched.
The mapping of region label to region ID is also printed to the console output, to aid making the files use labels in the first place.
-------------
Benefits
EDCT and EDA will no longer be impacted by any map changes short of removing a referenced region, or changing the region labels. This means map changes are less costly.
Drawbacks
EDCT and EDA editing can no longer happen directly in EDCT and EDA, but will need to be done in two other files as described above. These have identical structure as the original files. The tool must be run each time you have made any edit to either of those files, to make it readable by the game engine. This means another step in the workflow.
-------------
Setup
1. Make a backup of EDCT and EDA. Keep these until you are certain the tool works for you.
2. Ensure you have Java.
3. Download the zip file at the top of this post. Unpack to anywhere you like.
4. Edit the runConversion.bat file. You need to tell it where your mod data folder is, and which map folder to read map_regions.tga from (base, imperial_campaign or similar). The default works for EBII and looks like this:
5. Copy your export_descr_character_traits.txt to export_descr_character_traits_regionlabels.txtCode:set DATAFOLDER=../../../mods/EBII/data set MAPFOLDER=world/maps/base
6. Copy your export_descr_ancillaries.txt to export_descr_ancillaries_regionlabels.txt
7. Run the conversion tool. It should not find any region labels to convert, but will output the mapping of region label and ID, aiding you in the one-time task of changing the IDs to labels.
8. Change the current region IDs to region labels using the format detailed below.
9. Run the conversion tool. Verify that the outputted EDCT and EDA becomes the same as the original files were.
-------------
Regular use
After any edit of EDCT or EDA, double click runConversion.bat. Wait some seconds until complete.
-------------
Format of region labels
You can find the labels for your own regions in descr_regions.txt. The bolded line contains the important bit for this tool.
The basic format to use in EDCT/EDA is flat braces with the region label inside. You can add an optional description using the equals sign after the region label, and anything from there is ignored. The description is meant to make the code more human readable than a numeric label (or ID!) can be. Valid ways to write it thus include:Originally Posted by descr_regions.txt
[region_090] - only the region label
[region_090=Lakonike] - region label and province name
[region_090=Spartan krypteia after agoge requires staying in the Lakonike region] - region label and freeform text description
[region_148=Sakasthane] [region_065=Kushi-Yapoy] [region_150=Sakanu Kshaharae] - a set of three regions, all part of the same condition and each with their description
An example from EBII's EDCT:
After conversion, this turns intoCode:;------------------------------------------ Trigger Spartan_Krypteia_Progress WhenToTest CharacterTurnEnd Condition IsRegionOneOf [region_090=Lakonike] and Trait AgogeKrypteia = 1 Affects AgogeProgressCounter 1 Chance 100
Code:;------------------------------------------ Trigger Spartan_Krypteia_Progress WhenToTest CharacterTurnEnd Condition IsRegionOneOf 164 and Trait AgogeKrypteia = 1 Affects AgogeProgressCounter 1 Chance 100