• 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.

faiuwle

Field Marshal
30 Badges
Sep 3, 2016
3.618
17
  • Crusader Kings II
  • Crusader Kings II: Sword of Islam
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: The Republic
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Holy Fury
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Monks and Mystics
  • Crusader Kings II: Reapers Due
  • Stellaris
  • Crusader Kings II: Conclave
  • Crusader Kings II: Horse Lords
  • Pillars of Eternity
  • Crusader Kings II: Way of Life
  • Europa Universalis III: Collection
  • Semper Fi
  • Majesty 2 Collection
  • Heir to the Throne
  • Magicka 2
  • Hearts of Iron III Collection
  • Hearts of Iron III: Their Finest Hour
  • Hearts of Iron III
  • For the Motherland
  • Divine Wind
  • Europa Universalis III
  • Cities in Motion 2
A little while ago, I saw someone post a script in a reddit comment that exported family trees from saves and converted them to GEDCOM, which can be read by most family tree software. Unfortunately it was last updated in 2013. So I took it, updated it to the latest non-beta save version (it may still work with the beta patch, however), rewrote the parser, and added new features to it that I wanted. Since the other authors of the script don't care who changes or shares it, I thought I would post it here in case it was useful for anyone else.

What you need

1. A UNENCRYPTED savefile.
2. Python 2.7, available for Windows and linux (NOT 3.x)
3. The scripts, (just click "Clone or download" and then "Download zip" and you'll get a zipfile with the scripts and the readme)
3. Knowledge of the path to your CK2 install directory, and to your mod directory if you play with mods.
4. A program that can read GEDCOM files. If you don't have one, there's a great free site I used to use for making Sims 2 family trees that also reads GEDCOM, familyecho.com. I've been using that for all of my testing and CK2 family tree purposes as well.

How to run the script

First, open settings.py in your favorite text editor or word processor. At the top there is a section like so:

## User Options ######################################################
# Your CK2 install directory:
ck2_install_dir = r'C:\Program Files (x86)\Steam\steamapps\common\Crusader Kings II'
#ck2_install_dir = r'/home/ruth/.local/share/Steam/steamapps/common/Crusader Kings II'
# Your mod directory where mods get installed:
mod_dir = r'C:\Users\User\Documents\Paradox Interactive\Crusader Kings II\mod'
#mod_dir = r'/home/ruth/.paradoxinteractive/Crusader Kings II/mod'
# Remove characters with no family? (Mainly only has an effect if you generate the entire tree)
cull_loners = True
# Remove otherwise unrelated spouses that produced no children?
cull_childless_spouses = False
# Use real fathers (as opposed to presumed fathers?
real_fathers = False
# Generate primary title in "occupation" field and years of rule in "notes" field?
generate_titles = True

The lines that begin with # are comments. The rest describe options that you may want to play with. ck2_install_dir is the path to your install directory (I've included here my path on Windows to give you a hint where to find it, and my path on linux in the comment below). mod_dir is the path to your mod directory, although you don't need it if you don't play with any mods. The other options can be either True or False and I've given descriptions of what they are in the comments. (The reason it puts primary titles in the "occupation" field is that you can set family echo to show that field under the names, which suited my needs.)

Next: place your savefile in the same directory as the scripts. In Windows, you can just double-click on ck2_ged.py and tell windows to open it with Python (if you're in linux, I trust you know how to run a python script). It will prompt you for what mods you are using, read the files it needs, then prompt you for your savefile name. At some point it will also ask you how big a tree you want (there are four options). When it finishes, you'll have a <savename>.ged file in the same directory as the script and the save. You can test it by loading it into familyecho.com

Limitations and caveats

- The save takes a little while to read. There is a little ASCII progress bar that at least works in Windows that shows you how fast it is going. The longer the save ran for and the more people the game generated, the longer it will take to read. If you don't want titles generated, turn it off - the script will have to chew through less of your savefile (although the progress bar will be inaccurate).

- Depending on what settings you choose and how fecund your dynasty was, the resulting .ged file can be quite large. I generated a family tree of every single person that ever lived on a 769-1450 game and it was 85 Mb, 77 Mb after removing the loners. In the same game, I generated a family tree of every single Abbasid, and their non-Abbasid spouses, parents, and descendants, and it was 13 Mb. Just the Abbasids and their non-dynastic close family members got it down to 1.6 Mb. Note that family echo only accepts files less than 8 Mb (but it loaded the 1.6 Mb file just fine). The entire tree is probably not a good choice unless you have a program that can handle all that data. I don't know what the numbers look like if your dynasty is so big that e.g. the game crashes when you load the dynasty tree.

- Regnal numbers may be different from in-game regnal numbers if there are inconsistently linked names.

- There seems to be no way to tell if a deceased person held a title as a viceroyalty, so the script just assumes that if the title is currently a viceroyalty it always was. This really only matters to determining dead people's proper rank names.

Anyway, let me know if something is broken. I did a bunch of tests, but there's probably many things I wasn't able to cover.

Bug Reports
Post in the thread. I probably need to see your save file and know what mods you are using.

Changelog
 
Last edited:
  • 1Like
Reactions:
Yo after it does that loading thing and before it asks me how big a tree I get several errors:
"Traceback (most recent call last):
File "C:\Users\John T\Desktop\rtu\ck2_ged.py", line 1648, in <module>
main()
File "C:\Users\John T\Desktop\rtu\ck2_ged.py", line 1392, in main
player_id, dynasty_map, character_map, title_map, misc_localization = read_save (savefilename, dynasty_map)
File "C:\Users\John T\Desktop\rtu\ck2_ged.py", line 882, in read_save
dynasty_id = character_map[int(founder_id)].dynasty_id
KeyError: 1"
Can I get help to fix this?
 
I'm at work right now, but in the meantime can you post your save? Edit: Also, what mods are you using?

I noticed a couple things changed from 2.7.1 to 2.7.2, but I don't remember anything major that would break the script. I've made a few changes, but haven't pushed them yet.
 
Last edited:
I'm at work right now, but in the meantime can you post your save? Edit: Also, what mods are you using?

I noticed a couple things changed from 2.7.1 to 2.7.2, but I don't remember anything major that would break the script. I've made a few changes, but haven't pushed them yet.
My save is called 'Eirinn1464_01_01' (cause I was on observe for awhile, and the game over screen never showed up) and the only mod I'm using is HIP.
 
Hmm, I'm not sure if it's that HIP maybe changed the naming convention of patrician house titles, or if that's something that can happen in an unmodded game, too.

If you download it again from git it should process your file now.
 
So I was having some issues getting your script to work with one of my (MP) saves - python would crash. The error was happening at line 891 (and later at 898). After modifying my savefile, I got your script to work fine. We were using a small personal mod, but I don't think this effects what's detailed below.

The issues were a dynamic barony and dynamic kingdom title. My friend, tribal, had settled as a republic, however for some reason the patrician title name didn't follow the pattern of b_dyn_[founder_id]. The number was, as far as I can find, unrelated to the founder. This was true with the custom kingdom title as well. Your script assumes that the number of the custom titles are the founder's ids, which is true for the rest of the custom titles in my save, but not true for those two titles which my friend founded. I assume a similar error would exist for custom empire titles.

I'm not sure if this is true for all player-made custom titles, or just other-player-made titles in MP games.

I'd guess instead of assuming founders, maybe check the savefile line about 46 lines later, which states the founder as the first entry in title history?

Also I didn't see anything in your script checking for e_dyn_####, which I assume will throw an error?
 
Interesting! Yeah, a safer bet to get the dynasty would probably be checking the dynasty of the holder or finding the founder during the title history reading. I don't check for empires because I only need it for the name of the patrician house title (or nomad clan title).

Does the game use _dyn_ for custom titles too? I might have to change that to keep k_dyn from always assuming a nomad clan...