• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Loc_n_lol

Second Lieutenant
41 Badges
May 30, 2016
165
44
  • Crusader Kings II
  • Stellaris: Galaxy Edition
  • Stellaris - Path to Destruction bundle
  • Stellaris: Nemesis
  • Stellaris: Necroids
  • Crusader Kings III
  • Stellaris: Federations
  • Stellaris: Lithoids
  • Stellaris: Ancient Relics
  • Imperator: Rome Sign Up
  • Crusader Kings II: Holy Fury
  • Stellaris: Megacorp
  • Stellaris: Distant Stars
  • Cities: Skylines - Parklife
  • Stellaris: Apocalypse
  • Stellaris: Humanoids Species Pack
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Monks and Mystics
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Crusader Kings II: Reapers Due
  • Stellaris: Galaxy Edition
  • Stellaris
  • Crusader Kings II: Conclave
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Cities: Skylines
  • Warlock 2: The Exiled
  • Europa Universalis IV
Hi fellow CK2 modders.

A few months back I posted a thread with these tools, but I seem to have misplaced it. I have been working on this project on and off since then and I feel it is ready for a new release.

Download
http://lvisse.free.fr/CK2MapTools/CK2MapTools-V2.0.5.zip

Older Version

http://lvisse.free.fr/CK2MapTools/CK2MapTools-v1.1.0.zip

In-game Screenshots

oRc3AM8.jpg

TQQ9pWE.jpg

P3pAw9k.jpg

1NXVfMp.jpg

WODqmaa.jpg

nRQdCyx.jpg

JoBFgxg.jpg

qStdpYZ.jpg

bBpDzl9.jpg

TLddCNm.jpg

What is this ?


A few bits of java code I have made to automate some parts of the map modding process. It is primarily intended for people who want to start a new map from scratch, as this can be quite a soul-crushing experience, with seemingly random, unexplainable CTDs, and lots of menial, repetitive or redundant work.

This is not a random map generator, the idea is you put in the work and draw the map yourself, but don't have to worry about image format, adhering to strict color palettes, and hand writing a thousand text files. Well, you still need to follow some color codes and write some text, but I think it's much easier this way.

How does it work ?

First you need a Java Runtime Environment installed on your machine. The code was compiled using version 1.8.0.121, so you need at least that.

You also need an image editing tool and a text editor, but you probably already have that. I like GIMP and notepad++ myself, though mspaint and notepad would work too. I find it very useful to be able to use layers and transparency when working on map files.

Supplied are a handful of batch files. These are shortcuts to launch the various bits of code with some preset parameters in some cases, so you don't have to type command lines. There is no graphic UI here.

In the same folder as the batch fles, there is an input folder, this is where you will place all the files needed by the tools to generate the map and associated files. Some of these you will have to make yourself from scratch. Others, you will get a basic template generated that you can then fill in. The tools will also create an output folder in the same directory, the content of this output folder can then be entirely copied straight into a mod folder to run into CK2.

How does it work, in-depth

1.Generating Terrain
2.Generating Rivers
3.Generating Provinces and First look in-game
4.Assigning Cultures and Religions
5.Assigning DeJure / DeFacto titles
6.Assigning Governments, Technology and more
7.Naming things
8.Making Trade Routes


Features

Currently supports generating the following files :

map/adjacencies.csv (automatically creates straits and major river crossings)
map/climate.txt (assigns winter severity based on user-defined climate map and terrain height)
map/default.map
map/definition.csv (matches province colors from provinces.bmp)
map/geographical_region.txt (generates one region for each dejure empire)
map/island_region.txt (detects regions that are isolated from each other, and which one is the mainland)
map/positions.txt (automatically positions ports, shields, armies, etc... it's not perfect but it mostly works)
map/provinces.bmp (draws province borders and sea zones, ensures colors are unique. Some manual work still required to fix sea zones, make wastelands and impassable mountains)
map/rivers.bmp (most of the work still needs to be handmade, but it gives you some lenciency and a few shortcuts)
map/terrain.bmp (auto-assigned based on various factors and your own input, smoothes transitions and adds random noise to make it look more natural)
map/topology.bmp (auto-assigned, smoothed, with random noise to get convincing-looking terrain as much as possible)
map/trees.bmp (auto-assigned based on user-defined terrain and climate)
map/world_normal_height.bmp (derived from topology. Please don't look up the source code for this)

map/terrain/colormap.dds (derived from terrain and climate, with some random noise)
map/terrain/colormap_water.dds

localisation/ (associates titles and provinces with names supplied by you. You can name places precisely, or put a list of names to randomly assign, and you can mix both methods at the same time)

history/characters/ (generates count-tier rulers of local culture and religion for every province, as well as a small 10-character dynasty for all the playable ones.)
history/provinces/ (auto-assigns culture, religion, title, number of holding slots, existing holdings...)
history/technology (based on your own input, rudimentary, but a good starting point)
history/titles (assigns a ruler and his/her ancestors to every county, also creates duchies, kingdoms and empires if you will it. Generates patrician houses for merchant republics if applicable)

common/dynasties (done as part of character history, but the dynasties can also used by courtiers or by the ruler designer)
common/landed_titles (generates the main file with all dejure titles, also generates some mercenary band titles : 1 for each dejure kingdom)
common/province_setup
common/trade_routes (a recent addition, lets you draw trade routes on a map and generates text files based on that)

Changelog
V1.1
  • All files used in the "tutorial" are included in this release.
  • Wastelands are no longer color-based, instead they require a new type of "settlement" to be identified as wastelands : a pure green dot.
  • info.csv has been divided into 3 different files : config.csv contains the generic properties, which have been greatly expanded. cultures.csv and religions.csv contain the color definitions for cultures and religions. For those 2 files, the first column has been dropped.
  • It is no longer necessary to have a culture map before you can launch make province setup.
  • You can now define the following properties in config.csv : hills_height, mountains_height, snow_height, peak_height, input_map_scale, tree_map_scale, noise_patch_size, noise_factor_max, noise_baseline, smooth_radius.
  • Added a new input terrain : forested hills. It combines the height of the plateau type and the trees of the forest type. Color 0;64;64.
  • Added support for the 2 unused terrain types in vanilla. Added properties in config.csv to customize them.
  • Added a reverse engineering batch : takes the terrain.bmp, topology.bmp and provinces.bmp and tries to create an input.bmp, climate.bmp and settlements.bmp in a new folder. The input and climate don't work very well, but the settlements should be mostly usable as is. As it is it can only distinguish btween land provinces and sea provinces, not rivers and wastelands.
  • Fixed straits not appearing in-game. Unfortunately this just shows the tools generate far too many, so some manual editting is required to make it look good.
  • Merchant republics start with a trade post in the capital province, owned by the doge.

Known Issues

Nomads are currently not supported. Mostly because I don't understand how to automatically turn tribals into nomads, and also because I didn't like them enough to bother. This doesn't mean your map can't have nomads, but it won't be automatic.

All seas are currently always considered as part of one big ocean. This could cause issues if it is not the case on your map with some seas being unreachable from other seas, such as the red sea and mediterranean in vanilla CK2.
 
Last edited:
To explain a little more about how this works and what it can do, I'm going to make a "quick" example mod, and show step-by-step how it's done.
In this example I'm making a Horses vs Bears vs Cats mod. Because I can.


Getting started : Terrain

The first and most important file to make in the input.bmp. This is basically your terrain and heights rolled into one and will define much of the setting for your world. It should be a regular 24-bits bitmap file, such as one that can be made with mspaint. 32-bit files (with transparency) don't seem to always work, so if the program unexpectedly hangs, double check your file format when you export in GIMP for example.

Important : this file is, by default, at half the scale of the final map.
So if you wanted to make a map just as large as the default CK2 map (3072x2048), your input file would have to be 1536x1024 pixels large.
This can be changed in config.csv, see below.

Here is a list of the colors codes it understands, these are not the same ones as for the CK2 terrain.bmp.
But at least they are a bit easier to remember because all values are multiples of 64. Also if you get the color wrong, or accidentally applied some blending, the program will automatically try to match to the nearest valid color.
hYAKDvF.png

+New terrain with V1.1 : FOREST_HILL 64 64 0
Don't get too excited about the volcano, it's not a real one.
Plateau can be used to make hills. "Semi-desert" is just what the game calls coastal desert, a mix of sand and grass.


So for my example mod, I want to create a fairly small map : 256x256 for the input, with a final map size of 512x512.
Horses will be best suited to vast steppes. The bears will stay confined to their bear island in the north (where have I heard this before ?). Finally, the cats will inhabit warmer lands, some desertic regions as well as a river valley where they can put their human slaves to work the farmlands.
I'm adding some mountains to separate the various lands and make things a bit more interesting, as well as some forests.

8EjtviH.png

This is very basic and undetailed, but it will do.
Note that I used the wrong color for the desert and farmlands, but it won't matter, because it's close enough.
I then save this as a new file in the input folder and call it input.bmp


Assigning Climate

Now that I've painted my basic terrain, it's a good idea to make the climate map. I find it easiest to just paint it over the input terrain, with a new layer.
The climate.bmp is used at most steps and has a lot of effects but I will only list here those that are immediately relevant.
Here is a list of the colors codes for the climates, it's very simple. Just like input.bmp, if you don't get the exact color, it will match to the nearest one.
ZiateTZ.png

"Hot" will turn mountains into desert mountains and forests into jungles.
"Warm" aka mediterranean will be associated with cypress trees.
"Temperate" will have default deciduous trees.
"Cold" will have pine trees.
"Polar" will generate arctic terrain and also use pine trees, but fewer.

Painting over the input.bmp, I create this picture, and save it as climate.bmp :
oaaaSZs.png


Generally I found it's better to avoid having a climate change over a forest. In the case of the hot climate, it's also better to avoid having it transition over a mountain range, which is exactly what I did here because the map is too small to contain that many different climates. It will probably look a little weird but it will do.


CONFIG.CSV

This file contains important constants that are necessary for the remainder of the tools. They are defined like this : name in the first column, value in the second column. A few of them are colors, in that case it's R,G,B in columns 2,3 and 4.
An example file is provided with comments that explain everything, but here are some outlines :

  • mod_folder. If your mod uses custom cultures then this should be a path to the root folder of your mod. If using vanilla cultures, then make this point to the CK2 directory, for example :
mod_folder;D:\Program Files (x86)\Steam\steamapps\common\Crusader Kings II

  • start_date. This tells the program for what target year it should generate living, adult rulers. Currently only one start date at a time is fully supported, but you can choose it... although very small start dates are likely to cause problems as ancestors to the present rulers will not have time to be born, preferably give it at least a start year of 200 to be safe. So :
start_year;1066

  • hills_height, mountains_height, snow_height, peak_height. These 4 properties determine the base height that will be assigned to every pixel on the map, before smoothing and random noise are added. It also determines at which height terrain should be replaced by hills, mountains or snowy mountains.
  • input_map_scale This is the scale of the input map compared to the final map. A higher value means a smaller input map. I use the value 2 as a default, which means half size, but you can change it to 1 if you want to add finer detail to your input map.
  • tree_map_scale This is the scale of the tree map. Vanilla is around 1/6th the size of provinces.bmp, so I set the default value to 6. A lower value means more trees in-game.
  • noise_patch_size, noise_factor_max, noise_baseline : controls the quantity of random noise applied to terrain height.
  • smooth_radius Controls the amount of smoothing that is applied to terrain height. A higher value will impact performance very negatively. Anywhere between 6 and 9 seems good to me.


With those 3 files, it's time to get started with the tools.
I execute "1 - Make Terrain Maps.bat" and it generates the following files in my output/map folder :
aQOXBZz.png



A word about performance
These programs aren't very well optimized. They're not horrible either, but the terrain maps one is especially slow. It's not multi-threaded, and it's entirely CPU-dependent. For such a small map, my AMD FX-6300 (a realtively low-end cpu for a gaming rig, and a 6-core which is useless here) took 6 seconds to go through. For a map the size of vanilla CK2, it would take 2 to 3 minutes. Your mileage may vary. I did make an alternative fast mode for the make terrain batch, it will run much faster, the result will look awful, but it will run in the game. Can be useful if you want to test something quickly.

Color Maps

No further work is required to launch "2 - Make Terrain Color Maps.bat", so I can run it immediately after the first batch is finished.

It generates these files in output/map/terrain :
qROZIqG.png

As you can see, the climate.bmp influences the color of the grass and water. The colors are based on those from vanilla CK2, with a bit of random noise thrown in to avoid making it too artificial-looking.
 
Last edited:
Cry me a River

Going back to the input folder, the program has also generated 2 files in there : a rivers.bmp and a settlements.bmp. I will focus on the first one to begin.

The rivers.bmp is just a copy of your input.bmp, with all colors darkened, that has been enlarged to the size of the real map, and where all water terrain has been replaced by a bright pink color. This makes it relatively easy to draw minor rivers on as you can easily see where the mountains and the seas are and where the water would naturally flow.
The colors expected for this file are based on the ones from the final rivers.bmp :
Cyan (0, 255, 255) : represents the river path. There is no concept of width to manage, the program will do it, more or less well.
Green (0, 255, 0) : represents a primary river source. Nothing will happen if at least one of these is not present.
Yellow (255, 255, 0) : represents a river split. Put one of these next to a river path that connects to a river source to create a new river. It is possible for a river to split multiple times.
Red (255, 0, 0) : represents a river merge. Use it like a river split, except the water will flow towards the merging, whereas it would flow away from the split. Do not put a river source at the end of your merging river.

These colors need to be exactly as is. Any other color is completely ignored (which is why you can have the terrain painted on the map in the first place).

Here are a few examples :
Some basic rivers flowing from a source
lBJw6v9.png


A river merge :
92gdS2p.png


And a river split :
dpxkeeF.png



After adding a few rivers, time to run "3 - Make Rivers Map.bat"

Uh oh, looks like I just found a bug I had not encountered before. Well, do not put a river on the very edge of the map...

And after fixing it up I get a new, non-blocking, error :
a1PG8Tf.png


If I look at these coordinates on my river.bmp, it looks like this :
PO1CNLh.png

The problem is that right after the river split, the river moves one pixel to the left, but then the program doesn't know if it's supposed to go up or left. There should never be multiple paths on a river without a plit or a merge. The game can't handle it either and will simply not draw the whole river.
On the other hand, on the left of this picture you can see that the river path is connected by 2 pixels that are not exactly adjacent to each other, the path moves both left and up at the same time. The game doesn't accept this, but the tool will fix this up before generating the final image, by filling the "holes".

I resolve the problem like this :
TI0fwcb.png


And now I rerun the batch without errors and get this in output/map :

eZrMY7F.png
 
Last edited:
Settlements and Provinces

The next step is probably the second most important, and one I should probably have partially automated. Open up the settlements.bmp that is found in the input folder. It looks like input.bmp with the size of the real map, and now it also has minor rivers painted on it (gray). The purpose of this file is to mark the location of every major settlement in your world.
1 pixel = 1 settlement = 1 province
The goal is to fill the map with just the right amount of dots to make as large or small province as you want.

There are a few hard color codes used here as well, they are :
RED (255, 0, 0) : Marks a settlement spot. A (land) province will be created around here.
YELLOW (255, 255, 0) : Marks a MAJOR settlement spot. This is identical to a red spot for now, but it will receive certain bonuses in later steps. Typically there should be zero or one in each dejure kingdom.
BLUE (0, 0, 255) : Marks a water node. A (sea) province will be created around it.
CYAN (0, 255, 255) : Marks a river node. A (major river / inner sea) province will be created around it.
GREEN (0, 255, 0) ; Marks a wasteland node. A regular land province will be created around it, but it will be ignored by most steps, and will not generate a ruler.
BLACK (0,0,0) : Completely optional a this stage. Will be marked as impassable terrain.

Just like for rivers, these colors need to be exact, and anything that doesn't fit is ignored.

Since the map terrain and rivers are already painted on the settlements.bmp, that makes it rather easy to determine where yoy think a settlement should grow. Typically alongside rivers, coastlines, and mountain passes. It takes a lot of trial and error, and a lot of rework to get it right and I doubt an automated tool would do much better than a human here.

Here is an example of WIP :
syjUGxV.png



Once I'm done I can run "4 - Make Provinces Map.bat"
Near the end there might be some warning messages like "X pixels could not be assigned". This generally means you have forgotten to put some settlements on an island, or you have some weird geography that makes some bit of land unreachable by any of your settlements. So the program doesn't know which province to assign to these land pixels to. You can either go back in settlements.bmp and add some settlements, or edit provinces.bmp directly to attach them to a province yourself. This might be prefereable if you want a province to be made of several small islands, something the tools do not manage well currently.

Common mistakes include forgetting to add any water nodes, placing water nodes on land, or settlements in the sea.

At the end I get this provinces.bmp
NzZ6v7g.png

Not too bad !

But it needs a few manual corrections.

First, the point where major rivers and seas merge almost always looks wrong. Usually the river "spills" into the sea, like here.

Secondly, the provinces in the south, near the desert look kind of wrong, because I didn't put any settlements in the middle of the desert. What I want to do here is put a wasteland province.

Making a wasteland and calling it peace

To create a wasteland province, you simply add a pixel in settlements.bmp, just like for a regular province, but with a pure green color instead of red.
This can be done retroactively, just be sure your pixel is inside the province and that there isn't another.

Lastly, it could be a good idea to add impassable mountains and mare incognitum manually at this point, although it can be hard to know exactly where they would make the most sense. I find it is better to open the map in-game to take note of which province borders look like they should not be passable.

For now I will forget about impassable mountains and just add a wasteland to the south. I picked the color yellow, because, like, sand.
It looks like this :
o4coKIy.png



Final Notes

You might notice that the MakeProvinces creates a provinces.bmp both in input and output folders. I made the tool make a copy in the input folder because I found myself overlaying it constantly when editting other files.
If you run it multiple times you might also notice two things :
  • First it creates a backup of the previous file in the input directory. This is because with manual editting being nearly mandatory, it would be a shame if those changes were tragically lost to a misclick... (that absolutely did not happen to me).
  • Secondly you'll notice that even though they are randomly generated, the provinces do not change color when the tool is re-run. This is rather important because it makes it easier to just add a settlement or 2, rerun the batch, and merge the provinces.bmp manually. If the colors were completely changed you would have to throw everything away from that point, which was how the old version of the tools worked.

Another thing to note is that after you are finished with rivers.bmp and settlements.bmp, you should probably run "1 - Make Terrain Maps.bat" again. This program actually uses info from those 2 files in a few cases.
  • Rivers running through the desert will automatically create patches of grassland around them
  • Rivers running through mountains will lower and flatten the terrain immediately beneath them, so it looks more natural and they are less likely to flow upwards
  • Settlements in deserts will create patches of grass and palm trees around them, to make it look like there's an oasis of sorts at that place.
  • Settlements in mountains will also lower and flatten the ground around them so the little houses look less distorted in-game.

Getting it into the game already

There are still many steps to go, but at this point we can skip them and witness the glory of our map running into the game.
Let's run "6 - Make Provinces Setup.bat"

It will generate a ton of new files. Just copy the whole content of the output folder into this empty mod : https://www.dropbox.com/s/yuce8oknw0doqqe/LNL TestMap mod.zip?dl=0
Launch the game with this mod active.

And it's aliiiive :
gzZaKOs.jpg

35HsvES.jpg

9MMMBCV.jpg

poMJSug.jpg

RipkMTx.jpg
 
Last edited:
Time to make a culture map.
Now, contrary to terrain, rivers and the like, cultures are entirely user-defined, so there is no hardcoding of colors that could possibly work here.
So before painting the map with cultures, we need to make a text file in the input folder that I called cultures.csv. You can create it with excel or another spreadsheet editor but I find a text editor works just as well for this.

Adding Cultures

In the cultures.csv, I can define one culture per line. These cultures should reference the ones in the mod folder or base game. But we need to define what color will identify these cultures for the tools. Each line defines a culture and the format is as such :
First column : culture name. should match exactly one of those present in the common/cultures folder of the game or mod
2nd, 3rd and 4th column : RGB color associated with that culture.

For example :

horse;128;128;0
cat;0;0;0
bear;255;255;255

The next thing to do is paint the cultures on the map, using the colors I just defined. Then save the resulting file as input/cultures.bmp :

gJLArLT.png



Recoloring provinces

Not exactly necessary but nice thing to have : there is a batch called "4b - Make Provinces Map - Recolor mode.bat". What it does is, it updates provinces.bmp, with new randomly generated colors.However those colors are not completely random if a cultures.bmp is present. They will instead be derived from the local culture's color. This is mostly cosmetic but it helps visualize which provinces belong to which culture :

dHUq5b2.png

It does not change the province borders at all.

Adding Religions

This works very much like cultures, except the program does not try to read into the game or mod's files.
In this example I'm going to take the quickest path again, and simply clone cultures.bmp into religions.bmp like this :
gJLArLT.png

Next, I need to create religions.csv to tell the program what color corresponds to which religion, adding 3 lines like this :

tengri_pagan;128;128;0
catholic;0;0;0
norse_pagan;255;255;255

The religion applies to the province and the rulers alike.

Lastly, the game (softly) requires 5 holy sites for every religion. In order to define those, I used a separate csv file : holysite.csv
The format is as follows :
1st column : religion name
2nd & 3rd column : x,y coordinates of a holy site on the bitmap (0,0 is the top-left corner, unlike in-game where it's bottom-left). Whatever province is located at these coordinates will be marked a holy site of that religion. It doesnt need to be the exact coordinates of the settlement, any pixel will do.

For example :
norse_pagan;120;80
norse_pagan;95;245
norse_pagan;230;120
norse_pagan;193;187
norse_pagan;314;92

multiple religions can of course share some or all holy sites, you just need to define the same coordinates for another religion :
norse_pagan;193;187
catholic;496;351
tengri_pagan;193;187
tengri_pagan;496;351
 
Last edited:
This is amazing!
 
So, the Ck2 Generator tool can still make random maps, but all it gives is the basic map files. How would I use your tool to input these files (including a prov.bmp) to keep progressing the map mod? Just hypothetical, but might do it if it works! :)

I am not creative, so I like when the prov.bmp is made for me with the Gen tool, lol.
 
Yeeeeees. I’ve been manually doing a lot of this and I’m super glad you did go ahead and update this tool. It’s extremely handy for making provinces fast.

With wastelands and rivers now coded in it makes it much easier.

Also I noticed you have the provinces generate without names but rather numbers. I’m guessing this is so we can manually enter in custom names faster?
 
This looks awesome. I just was learning Kotlin (another JVM language) with the aim of making a GUI tool to help with mapmodding. May I use your tool as a resource for learning and adapting techniques?

I did give away the source code in the original link, so sure, you can look into it.

So, the Ck2 Generator tool can still make random maps, but all it gives is the basic map files. How would I use your tool to input these files (including a prov.bmp) to keep progressing the map mod? Just hypothetical, but might do it if it works! :)

I am not creative, so I like when the prov.bmp is made for me with the Gen tool, lol.

Hmm... I thought it did a lot more, like full history and such ?

Anyway, if all you have is the map files... well you could put them into the output folder (these also get reused in later steps, especially prov.bmp). The problem is you won't get very far without a settlements.bmp because that's used in almost everything I have made (basically when the tools read your input maps for any kind of province info, all it really looks at are the points at the coordinates of the settlements). It shouldn't be too hard to reverse engineer one, but right now I haven't made that. Do you have the positions.txt file too ? That would make things easier.

At some point, I did make a quick test of reverse engineering the vanilla map, but the results weren't very encouraing so I let that idea slip and focused more on original map-making.

Also I noticed you have the provinces generate without names but rather numbers. I’m guessing this is so we can manually enter in custom names faster?

So, initially that was the idea, yes, and it's still the fallback behaviour. Being able to read province numbers directly on the map can be helpful.
But like I said in the original post, I have also made a method to actually name provinces, but I have not gone into details over that, yet. It works with another csv file, you put title names, a title tier, and either coordinates (fixed assignment) or a culture (semi-random assignment), and when you run province setup, it assigns the names to the titles.

You could also ignore that and use the CK2 map filler, it's another tool that has been around for some time.
 
Generating De Jure Territory

So, now we have a playable map, but it's just a shattered world of 1-province counts. It is also made of 1-province duchies, kingdoms and empires. So we want to change that.
The first step is to run "5 - Make DeJure Maps.bat". This will generate 3 new images in the input folder :
Ifgs4Ke.png

This program tries to group together 2-6 adjacent provinces and make a duchy out of them. Then it tries to group adjacent duchies of the same culture together and make kingdoms out of them.
dejure_<tier>.bmp is a copy of provinces.bmp, where each province is the color of its de jure <tier> capital.
Provinces that were defined as "major" on settlements.bmp will always end up as duchy / kingdom capitals.

Pros : it's very quick and effortless
Cons : the choices it makes don't always make the most sense. It does not deal well with small islands and major rivers.

If you would rather do the work yourself, you can use the template to get started. Open it in an image editor, overlay provinces.bmp, pick a province color and start painting the map with the fill tool.

The tool does not generate empires as these tend to be multi-cultural and huge, but you can and should make a dejure_empires.bmp as well. (If you don't, every kingdom will be its own dejure empire)

For this example I will only use the maps autogenerated because they are good enough for such a simple mod. I will also create a single de_jure empire that regroups all the land on the map. I'm using the dark purple color of the kingdom in the center bottom of the map, so its dejure capital will be the capital of that kingdom, the one I defined as major, where the river bends.
rkO9Png.png


Assigning De Facto Territory

So now we have the basis for some more sensible dejure titles, but we still have a fully shattered world and maybe we don't want that.
It is possible to create 3 new maps : defacto_<tier>.bmp that will define which titles actually exist, and how much land they actually control at the start date. They work exactly like the dejure versions.

I'm going to be lazy here and just copy dejure_duchies and dejure_kingdoms and rename them into defacto_duchies and defacto_kingdoms. So at the start of the game there will be 6 kings, with some dukes under them, not a single independent duke or count, and every border falling neatly into its dejure territory.
I could also make defacto_empires, but I don't want the game to start with an emperor of the world, so I won't do that.
kcImfYd.png

If I wanted one of these titles not to exist, I could just paint it black for example.


Finally I'm going to rerun "6 - Make Provinces Setup.bat", copy all output into the mod folder and launch it in the game, et voilà :
6nxvfVA.jpg
 
Last edited:
Assigning Governments and Settlement types

This is fairly similar to religions and cultures, I can paint the government types on a new bitmap called government.bmp.
Since there are only so many hard-coded government forms, there is no need to edit info.csv, instead it uses pre-defined colors.
Each color corresponds to a general government type, so feudal means anything where the game would say "is_feudal = yes", this would include iqta, theocratic feudal or imperial governments for example.
Government also ties into what type of baronies will be pre-generated for each province. The county capital will be of the preferred type for the chosen government type. More holdings will get added based on the number of slots in the province, but there will always be at least one empty slot, unless the province only has 1 slot.

BLUE (0, 0, 255) is for feudal provinces : The county capital will be a castle. 3+ slots adds a temple. 4+ slots adds a city. 5+ slots adds a second castle. 7 slots adds a second temple.
RED (255, 0, 0) is for republic provinces : The county capital will be a city. 3+ slots adds a temple. 4+ slots adds a castle. 5+ slots adds a second city. 7 slots adds a second temple.
Republic provinces that are coastal and the dejure and defacto capital of a duchy will be considered merchant republics. The mayor will have a family generated and a family palace holding will be created in title history. Vassal patrician houses with their own family palace and a smaller family tree will also be generated.
WHITE (255, 255, 255) is for theocratic provinces : The county capital will be a temple. 3+ slots adds a castle. 4+ slots adds a city. 5+ slots adds a second temple. 7 slots adds a second castle.
Any other color is for tribal provinces : The county capital will be a tribal holding. 5+ slots adds a temple.
Finally, I've added a special case which is not really a form of government. There is no such province in any start date in vanilla CK2, but it can happen during the game.
GREEN (0, 255, 0) is for theocratic tribal provinces (like unreformed pagans) : The county capital will be a temple. 5+ slots adds a vassal tribal holding.

The capitals of de jure kingdoms and holy sites of any religion will also always receive a temple holding if they did not already have one, even if they do not have enough empty slots.

Here is an example :
w3pE2oF.png

I started from the dejure duchy map. Most of the map is black so that will be tribal areas, but along the southern coast the cat-holic are mostly feudal with a 2-province republic, which will meet the requirement to be a merchant republic. Also the bear king will be a theocracy.


Assigning Technology

You can define a certain technology level for each duchy at your start date (defined in info.csv), based on, you guessed it, yet another bitmap : technology.bmp.
The color's RGB components determine the level of advancement in military, economy and cultural tech respectively. Every 30 points of brightness corresponds to one level of technology. So for example the color (60,30,0) represents level 2 in military tech, level 1 in economy tech and level 0 in culture tech. More specific tech advancement (like cavalry, or castle construction) still needs to be done by hand, but the good thing is, all duchies with identical tech advancement will be grouped together in the resulting history/technology file so it should be easy to find exactly what you want to edit.

Here I went with a very simple north/south divide with the south (cats) being more culturally advanced, the north (horses and bears) having better military tech, and everyone being average economically.
2AnoVid.png



Province Settlement Slots


I mentioned province slots in the part about government but didn't explain how it works.
If you've run "6 - Make Provinces Setup.bat" at least once you will have noticed a new file in the input folder :
2XtDsT7.png

The program automatically tries to determine for each province how wealthy/fertile it should be, based on various factors such as the climate (cold is bad, warm/hot is good but not if there is no water), the terrain (rivers, coasts and farmlands are good, plains are ok, desert and arctic are bad), especially close to the settlement, and to an extent, the size of the province. Settlements that were marked as major in settlements.bmp also receive a bonus. Once this is done, all provinces are gathered in an array and sorted by wealth, the poorest 5% provinces are assigned 1 holding slot, the next 15% get 2 slots, the next 30% get 3, the next 30% get 4, the next 15% get 5 and the top 5% get 6.
Finally, the capitals of de jure kingdoms get 1 additional slot, potentially reaching the maximum of 7.
Once this is done, the program generates the numslots.bmp, which lets you visualize the results, but it's not just a visual tool. You can also manually edit numslots.bmp to change the number of slots of any province to whatever you want. The number of slots is based solely on the green component of the color, and each 30 points of brightness correspond to one slot (with a minimum of 1 and a maximum of 7).
When you run "6 - Make Provinces Setup.bat", if a numslots.bmp is present in the input folder, its values will be used to determine the number of slots for each province. If none is present, it will be calculated and the image will be generated. So if you made some changes to your terrain / climate, or added some new provinces, and want to automatically recalculate the number of slots, just delete the existing numslots.bmp.


Results

As usual, run "6 - Make Provinces Setup.bat" to regenerate all the province setup and history files, and put them in the mod folder. You might want to delete the existing history folder in the mod, because the generated files do not always exactly match names, which could cause issues.
Religions and holy sites:
8zlBmuy.jpg

Government, and a playable merchant republic with its patrician vassals (note : the dynasties being named nullbaronyXXXXX is partially to blame on the game. animal cultures lack a from_dynasty_prefix, it should really read "of baronyXXXXX")
8J9ubwx.jpg

Technology levels
U22lRCW.jpg

Religion tab and Holy sites
zCbGiGk.jpg

Exemple of auto-generated family tree. there is some randomness here but not much, most starting families will look like this, with 2 siblings and 2 cousins for the starting ruler. That means lots of noble women to marry at the start.
R8kAwRZ.jpg

A 6-slot feudal province and a 4-slot republic province :
nEEIl3U.jpg
JcKgS9c.jpg
 
Last edited:
Giving names to provinces and titles

This one is relatively easy to explain, but a lot of work for the user.
It relies on a third (and final ?) csv file : localisation.csv

Each line names one title and can have 2 possible formats :

Naming something specific : 4 columns
1st column : Title tier. This can be one of the following keywords : empire, kingdom, duchy, county, barony or province. Province is effectively identical to county.
2nd column : Title name, as it should appear in-game (including capitalisation and spaces. No guarantees on what happens if you use weird characters).
3rd & 4th columns : x,y coordinates of the province you are trying to affect. If naming a multi-province title, this could be any province that is part of it.

Naming something randomly : 3 columns
1st column : Title tier. See above.
2nd column : Title name. See above.
3rd column : Culture name. The name will be added to a pool for that tier and culture. Once all preset names have been assigned and the whole file has been parsed, for each title of that culture that does not have a name (starting with the higher tiers), the program will draw a random one from the pool and assign it, until it runs out of names or out of things to name.

The difficulty here is that in order to name everything, you need a truly huge amount of unique barony names. Personally, I used a random names generator to fill the blanks, but it's not attached with this release (because right now it's very specific to my own projects).

When you first name a province, its first barony (the default capital) will receive the same name.
If the province is a dejure capital of a duchy or kingdom, they will also receive that name, unless they already have one.
Likewise, when you name a duchy, its dejure capital province will be named the same.
When you name a kingdom, it does not affect the titles under it, however.
Empires are neither named by titles below them, nor do they name them.
Specific names are assigned in the order they are found in the file, and will always override any existing names.
Random names never override any existing names.

Here are a few examples :


kingdom;Equestria;332;150
=> This names the kingdom at these same coordinates "Equestria". No further impact

province;Canterlot;332;150
=> This names the province at these coordinates "Canterlot", as well as its capital holding. Since it is the dejure capital of a duchy and a kingdom, these 2 titles will also be named the same. However, because the kingdom already has a name (Equestria), it will not be overriden.

kingdom;Catalonia;cat
=> A kingdom of cat culture could be named "Catalonia". It might not if there are more cat kingdom names available than there are cat kingdoms to name.

duchy;Northumbearland;bear
=> A duchy of bear culture could be named "Northumbearland", as well as its capital holding and province if they do not already have names. If it is the dejure capital of a kingdom that does not already have a name, the kingdom will also be named like that.

Titles will automatically receive internal names based on the assigned in-game name, so for example :
kingdom;Bear Island;120;80
=>This will make a title named k_bear_island internally, that will appear as "Kingdom of Bear Island" in-game.

You can assign specific names to sea provinces and wastelands as well, but currently you cannot assign them randomly, since they have no culture.


After you're done with localisation.csv, once again, you need to run "6 - Make Provinces Setup.bat" to generate the game files. Because the title names will likely have changed, it is especially advised that you purge the history/provinces and history/titles folders of the mod, as there could be leftover history files for titles and provinces that no longer exist.
 
Last edited:
Is there a maximum size a province could be? I remember someone said that province exceed a certain size would crash the game.

Also, is there a minimum number of province I must set up? Since the set up religion step is not require for the mod to load, I assume that the program would assign a random religion to a province, as well as holy site stuff. What happen if I do not meet the 5 holy sites "soft" requirement?
 
Is there a maximum size a province could be? I remember someone said that province exceed a certain size would crash the game.
Probably but I have not encountered it. I did not try to break the game, rather the opposite. :p
Siberia is quite large in vanilla, but perhaps wastelands are treated differently ?

Also, is there a minimum number of province I must set up?
You need at least 1 land province and 1 sea province (whether it's a navigable sea or just a river/lake)

Since the set up religion step is not require for the mod to load, I assume that the program would assign a random religion to a province, as well as holy site stuff. What happen if I do not meet the 5 holy sites "soft" requirement?
Valid cultures are needed to give names and dynasties to the generated characters, but you don't really need a culture map. If you don't have one, everyone will be roman. The tool still needs to be able to find the roman culture in the CK2 folder though.
Likewise if you don't assign religions, everyone defaults to "pagan".
Like this :
kfGvCtt.jpg
If your mod has those, great. If it doesn't, the game will assign "noculture" and "noreligion" to the characters/provinces with invalid cultures or religions. noculture isn't too bad, but noreligion is unplayable.
If you do not have enough holy sites, there will be an easter egg placeholder picture in their stead in the religion tab.
 
Last edited:
Probably but I have not encountered it. I did not try to break the game, rather the opposite. :p
Siberia is quite large in vanilla, but perhaps wastelands are treated differently ?


You need at least 1 land province and 1 sea province (whether it's a navigable sea or just a river/lake)


Valid cultures are needed to give names and dynasties to the generated characters, but you don't really need a culture map. If you don't have one, everyone will be roman. The tool still needs to be able to find the roman culture in the CK2 folder though.
Likewise if you don't assign religions, everyone defaults to "pagan".
Like this :
kfGvCtt.jpg
If your mod has those, great. If it doesn't, the game will assign "noculture" and "noreligion" to the characters/provinces with invalid cultures or religions. noculture isn't too bad, but noreligion is unplayable.
If you do not have enough holy sites, there will be an easter egg placeholder picture in their stead in the religion tab.
Thank you. I have all my province, river, terrain images done by hand already. But I have trouble making the text file required for the mod to load. Does that mean I only need to run the "6 - Make Provinces Setup.bat" ? If it is the case, what are bare minimum the files I need to put in the input folder?