So, I've been looking into how the annexing process in resolvePersonalUnions() interacts with HRE electors and emperor setting in distributeHRESubtitles() , and I found it rather problematic.
If an elector is annexed, it leads to the elector disappearing entirely, that status isn't copied to the annexing tag. Same thing happens for the emperor, which is arguably worse. I believe the same thing can happen to free cities, but I don't have a save where that happens.
Now, I wrote a fix for it, but I'm not entirely happy with it. Firstly, it doesn't deal with the case where an elector annexes another elector. EU4 simply doesn't support one tag having multiple electoral votes. And secondly, it points to a bunch more structural issues.
Now, as a background, I'm testing this with a save where I'm HRE-ifying the Roman Empire, which is Hellenic, and still mostly tribal. (Ruler designer and nomad shenanigans, don't ask.)
HRE titles get assigned before secondary titles are annexed, which makes a lot of sense when you're a Christian HRE. From that perspective, you'll want cases where you have potential PU junior electors, and titles, not total lands giving electorates make a lot of sense. However, with a Hellenic religion, where PU's aren't a thing, it would make more sense to look at the total amount of DEV a ruler has, not which title (before merging) has the most DEV.
So, I see multiple ways of solving this:
A) The minimal fix: merge Emperor/Elector status during the annexing process, correct the emperor tag and government reform, but nothing more. If we come up short on electors, it'll be up to the Emperor to hand them out manually.
B) Not just merge the Emperor and Elector status, but keep a list of monarchy Electors on standby in case an Elector annexes another one.
C) Doing resolvePersonalUnions() first, then distributeHRESubtitles() , and making sure the emperor status is set for the primary title.
D) Choosing based on the religion of the Emperor, if it supports PU's, use A or B, if it doesn't, use C.
I'm happy to implement any of these, just want to know what the preference is, to increase the chance of the pull request being accepted.
Also, the wiki says "HRE Electors from CK2 are preserved if possible - they need to hold elector duchies and survive the conversion process.", but the current code doesn't actually do that. I could look into adding that as well, if you'd like?
I think we need to have a chat about the whole system, starting at the source.
1. Electorates are assigned to an elector's primary title. in majority of cases this will mean a kingdom, primary duchy or similar.
- If the elector doesn't own an independent title (he was a duke under an existing kingdom and we're not shattering those through config), the electorate is lost. We'll assign someone else, later.
- If through shattering shenanigans the elector lost his primary title (kingdom for example), and it's not clear what should be his primary, we assign electorate to the first title that holds some land.
- Is it possible to lose electors at this stage? Absolutely, someone is always lost but more importantly to remember, most common outcome is to have 6-7 duchies. We want a historical mix of up to 3 bishoprics, and 4 secular ones anyway so no harm done.
2. We take great care to preserve the emperorship. The emperor is flagged as such, we hive him absolute priority when mapping provinces so he always has a capital. His e_hre title is of course always lost, but whatever actual land he holds will have to suffice.
3. Now we come to distributeHRESubtitles(). We haven't annexed any title yet.
- without an emperor, we bail and there's no HRE.
- Otherwise we set up free cities and electors in that order. This is important as we never assign electorates to free cities so we need to know which those are.
4. setFreeCities()
- During free city generation, chances of finding 12 OPM republics in an incoming CK2 game is absolutely zero. We take first all the OPM republics we have, and then bolster the number with OPM bishoprics or duchies/counties, providing they aren't electors (from ck2 stage) and not someone's vassals. Will we get all 12? Doubtful but possible, depending on the number of incoming OPMs.
- Keep in mind, free cities cannot be electors. This is why we generate them first, to leave the larger duchies and similar available to populate elector slots.
5. setElectors()
- we start on elector generation.
- first we look at incoming titles flagged as electors. If we have 3 bishoprics, great, otherwise we take random ones, or substitute with non-free-city republics. If neither are available, we'll shove some duchies in later.
- Then we take 4 duchies, preferably marked in ck2 as electorates, and if not enough of those, we take random ones to fill out the slots.
- Pope is a special snowflake and if in HRE will always override and take the first elector position.
This part usually ooks like so:
Code:
2020-08-11 15:08:37 [INFO] -> Setting Electors
2020-08-11 15:08:37 [INFO] - Electorate set: BAD (from c_baden)
2020-08-11 15:08:37 [INFO] - Electorate set: MAI (from d_mainz)
2020-08-11 15:08:37 [INFO] - Electorate set: SAX (from d_saxony)
2020-08-11 15:08:37 [INFO] - Electorate set: Z83 (from c_trier)
2020-08-11 15:08:37 [INFO] - Electorate set: HAN (from d_angria)
2020-08-11 15:08:37 [INFO] - Electorate set: ALS (from d_alsace)
2020-08-11 15:08:37 [INFO] - Electorate set: Z29 (from d_cordoba)
We've - wherever possible - preserved electorate seats from CK2, and there is an emperor, who is or is not an elector.
6. We come to resolvePersonalUnions()
- No matter what happens with auxiliary titles, the primary title will remain an elector for incoming ck2 electors (see step 1), so no fear of losing electorates/emperorship for those with a set primary title.
- if there was no primary title, we take the first one that has some land and use that one as primary. will this be the same one as in step 1? Maybe, maybe not.
- for catholics this means that in that rare case the electorate may fall under a PU. While unfortunate, I'm against transferring the electorate as the electorate PU might break away from primary title, which is the whole point of doing PUs in the first place.
- for non-catholics this means the electorate may be destroyed. The emperor will assign new ones immediately, but yes, we can fix this on annex as you proposed by transferring the electorate status.
- is it possible for the emperor to die in this fashion? Huh, that's a new one, I've never seen it happen but I suppose it's possible. Again, as you proposed, in annexCountry() we can transfer over the emperorship flag.
I've pushed a patch where these flags (emperor/elector) will be preserved on annex. I see no need to preserve reforms or similar as those have been set for every incoming tag according tho their title specifics. I'd also like to see your test save so I can give the patch a whirl, along with your log.txt.