Democracy still eats a leader on election

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

Deshiba

Colonel
42 Badges
Feb 21, 2020
912
1.339
  • Hearts of Iron IV: La Resistance
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Surviving Mars: First Colony Edition
  • Cities: Skylines Industries
  • Stellaris: Megacorp
  • Hearts of Iron IV: Expansion Pass
  • Surviving Mars: First Colony Edition
  • Cities: Skylines - Campus
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Surviving Mars: Digital Deluxe Edition
  • Stellaris: Federations
  • Crusader Kings III
  • Battle for Bosporus
  • Empire of Sin
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Hearts of Iron IV: By Blood Alone
  • Hearts of Iron IV: No Step Back
  • Hearts of Iron 4: Arms Against Tyranny
  • Hearts of Iron IV: Together for Victory
  • Cities: Skylines Deluxe Edition
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Stellaris
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Cities: Skylines
  • Stellaris - Path to Destruction bundle
  • Cities: Skylines - Mass Transit
  • Surviving Mars
  • Hearts of Iron IV: Death or Dishonor
  • Stellaris: Synthetic Dawn
  • Cities: Skylines - Green Cities
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
On the very first election for a ruler where the same ruler doesn't get elected for another term a different leader gets assigned. When this happens the leader gets removed from your pool, but your previous ruler doesn't get returned to the leader pool. This effectively gives democracies an early game penalty of -1 leaders.

Please fix this by making the first ruler an actual leader in the leader pool.
 
  • 18Like
  • 11
Reactions:
It's been reported literally hundreds of times by now, in top-level posts here or in the Bug Reports sub-forum, and in discussion threads aimed at the devs (mostly dev diaries and feedback threads).

The really stupid thing is that it's quite simple, and obvious enough in cause that I was able to "reverse engineer" it without looking at the game code at all (just at the game files). It's also trivial to fix.

THE CAUSE: The problem is observed when a ruler without a "pre_ruler_class" loses re-election (incidentally, this happens for Oligarchies too). However, the actual bug arguably occurs earlier, at game creation, when the game spawns starting rulers of various empires with no "pre_ruler_class" designation. You can see each ruler, including whether they have a pre_ruler_class, by looking at the decompressed savegame file.

Specifically, that happens when an empire type is able to have multiple leader classes become rulers. There are some empire types where only Governors can be elected, and at least one (Technocracies) where only Scientists can be elected; in those empire types the starting ruler will have a pre_ruler_class set to the correct type. However, there are also many empire types that either have no restriction, or allow some but not all types (anything martial allows both Admirals and Generals, for example). In those empire types, the starting ruler will have no pre_ruler_class, and will thus vanish into the void upon losing re-election.

THE FIX: There are two easy ways to fix this. One of them is to, when creating a ruler from nothing (at game start, or possibly any other time an empire is created), always assign them a pre_ruler_class randomly chosen from among the allowed classes. The other one is, whenever a ruler without pre_ruler_class loses re-election, randomly convert them to an eligible class. The first is the better fix but the second is arguably simpler. One could of course do both, a belt-and-suspenders type approach (ensure that the situation doesn't come up *AND* that you can handle it if it does).

You can manually fix the problem by, before an election occurs, saving the game, unzipping the save, editing the game state to ensure every ruler has a pre_ruler_class, and re-zipping the save with the edited file. The instructions for save-game editing are on the wiki.
 
  • 18
  • 2Like
Reactions:
It's been reported literally hundreds of times by now, in top-level posts here or in the Bug Reports sub-forum, and in discussion threads aimed at the devs (mostly dev diaries and feedback threads).
I know, I've reported it myself before. I was just baffled that we're about 5 patches further from last time I tried democracy and there's still no fix for this.
I'm also venting because I just lost a really good scientist and got nothing in return, but let's not talk about that.
 
Yeah, my personal "fix" it's to hire and dismiss leaders from the pool until I get a leader with same (or better, to compensate for the loss of a more expert leader) traits and the use the console command to add back the money spent.
 
Moreover, many versions ago, probably some years now, it once HAD in fact been fixed.

And then it got broken again.

Hopefully if we keep the thread active someone may take note of it.
 
  • 3
  • 1Like
Reactions:
One of the many unwritten rules of Stellaris (along with gestalts getting less things, spiritualists being a meme, and hive minds being terrible) is that democracy must always be the worst form of government.
 
  • 3Haha
Reactions:
One of the many unwritten rules of Stellaris (along with gestalts getting less things, spiritualists being a meme, and hive minds being terrible) is that democracy must always be the worst form of government.
Sure, but this hits Oligarchies (which are considered pretty good) and Megacorps (which don't get any choices of ruler selection type and are a major component of a paid expension) too.

They fixed Duuk's bug, hopefully they can fix one that actually has gameplay impact. Ideally sometime soon...
 
I fixed this long ago for my stelaris installation:
common/on_actions/ufd_on_actions.txt:
Code:
on_game_start_country = {
    events = {
        ufd_bugfix.1 #Fix vanishing rulers
    }
}
events/ufd_bugfix_events.txt:
Code:
namespace = ufd_bugfix

country_event = {
  id = ufd_bugfix.1
  is_triggered_only = yes
  hide_window = yes
 
  trigger = {
    is_country_type = default
    is_regular_empire = yes
  }
 
  immediate = {
    leader = {
      root = {
        random_list = {
          60 = { #Scientist
            clone_leader = {
              target = prev
              class = scientist
              traits = {
                trait = leader_trait_adaptable
              }
            }
            modifier = {
              factor = 0
              root = {
                NOT = {
                  OR = {
                    has_valid_civic = civic_technocracy
                    AND = {
                      is_militarist = no
                      has_authority = auth_democratic
                    }
                  }
                }
              }
            }
          }
          20 = { #Govenor
            clone_leader = {
              target = prev
              class = governor
              traits = {
                trait = leader_trait_adaptable
              }
            }
            modifier = {
              factor = 0
              root = {
                NOT = {
                  OR = {
                    has_authority = auth_corporate
                    AND = {
                      NOT = { has_valid_civic = civic_technocracy }
                      OR = {
                        is_militarist = no
                        has_authority = auth_democratic
                      }
                      NOT = { has_valid_civic = civic_warrior_culture }
                    }
                  }
                }
              }
            }
          }
          20 = { #Admiral
            clone_leader = {
              target = prev
              class = admiral
              traits = {
                trait = leader_trait_adaptable
              }
            }
            modifier = {
              factor = 0
              root = {
                NOT = {
                  AND = {
                    NOT = { has_valid_civic = civic_technocracy }
                    is_pacifist = no
                    NOT = { has_authority = auth_corporate }
                    OR = {
                      has_authority = auth_democratic
                      is_militarist = yes
                    }
                  }
                }
              }
            }
          }
        }
        last_created_leader = {
          remove_trait = leader_trait_adaptable
          switch = {
            trigger = leader_class
            scientist = {
              random_list = {
                2 = {
                  add_trait = leader_trait_adaptable
                }
                2 = {
                  add_trait = leader_trait_resilient
                }
                1 = {
                  add_trait = leader_trait_eager
                }
                3 = {
                  add_trait = leader_trait_meticulous
                }
                5 = {
                  add_trait = leader_trait_spark_of_genius
                }
                2 = {
                  add_trait = leader_trait_carefree
                }
                2 = {
                  add_trait = leader_trait_roamer
                }
                2 = {
                  if = {
                    limit = { root = {has_ancrel = yes } }
                    add_trait = leader_trait_archaeologist_ancrel
                  }
                  else = {
                    add_trait = leader_trait_archaeologist
                  }
                }
                3 = {
                  add_trait = leader_trait_maniacal
                }
                1 = {
                  add_trait = leader_trait_expertise_materials
                }
                1 = {
                  add_trait = leader_trait_expertise_propulsion
                }
                1 = {
                  add_trait = leader_trait_expertise_voidcraft
                }
                1 = {
                  add_trait = leader_trait_expertise_industry
                }
                1 = {
                  add_trait = leader_trait_expertise_field_manipulation
                }
                1 = {
                  add_trait = leader_trait_expertise_particles
                }
                1 = {
                  add_trait = leader_trait_expertise_computing
                }
                1 = {
                  add_trait = leader_trait_expertise_new_worlds
                }
                1 = {
                  add_trait = leader_trait_expertise_statecraft
                }
                1 = {
                  add_trait = leader_trait_expertise_biology
                }
                1 = {
                  add_trait = leader_trait_expertise_military_theory
                }
              }
            }
            governor = {
              random_list = {
                2 = {
                  add_trait = leader_trait_adaptable
                }
                2 = {
                  add_trait = leader_trait_resilient
                }
                1 = {
                  add_trait = leader_trait_eager
                }
                1 = {
                  add_trait = leader_trait_army_veteran
                }
                1 = {
                  add_trait = leader_trait_retired_fleet_officer
                }
                2 = {
                  add_trait = leader_trait_architectural_interest
                }
                2 = {
                  add_trait = leader_trait_intellectual
                }
                1 = {
                  add_trait = leader_trait_righteous
                }
                1 = {
                  add_trait = leader_trait_environmental_engineer
                }
                1 = {
                  add_trait = leader_trait_bureaucrat
                }
                2 = {
                  modifier = {
                    factor = 0
                    root  = { allows_slavery = no }
                  }
                  add_trait = leader_trait_iron_fist
                }
                2 = {
                  modifier = {
                    factor = 0
                    root  = { is_lithoid = yes }
                  }
                  add_trait = leader_trait_agrarian_upbringing
                }
              }
            }
            admiral = {
              random_list = {
                2 = {
                  add_trait = leader_trait_adaptable
                }
                1 = {
                  add_trait = leader_trait_resilient
                }
                1 = {
                  add_trait = leader_trait_eager
                }
                3 = {
                  add_trait = leader_trait_trickster
                }
                1 = {
                  add_trait = leader_trait_fleet_logistician
                }
                3 = {
                  add_trait = leader_trait_engineer
                }
                2 = {
                  add_trait = leader_trait_aggressive
                }
                1 = {
                  add_trait = leader_trait_cautious
                }
                1 = {
                  add_trait = leader_trait_scout
                }
                1 = {
                  add_trait = leader_trait_unyielding
                }
                1 = {
                  add_trait = leader_trait_gale_speed
                }
              }
            }
          }
        }
        assign_leader = last_created_leader
      }
      if = {
        limit = { exists = this }
        kill_leader = { show_notification = no }
      }
    }
  }
}
 
Last edited:
  • 4
Reactions:
That sounds helpful.

@grekulf, could you or your team take a look at this? It seems that @ubuntufreakdragon may have worked out a fix to a very long standing bug (see the post immediately above mine), which would thus hopefully be fairly easy to implement. Granted, you and your team know far more about the inner workings of Stellaris than we do, so perhaps there would be a complication that I can't foresee, but otherwise this eliminates the frustrating (from an RP standpoint) of your first leader vanishing entirely if they lose an election [which forces you to hire an extra leader to make up the loss of a leader, hurts narratives by eliminating their chance to make a comeback, and generally encourages save-and-reload behavior to try to keep your first leader from disappearing instantly and forever, long before they would have naturally died).

As I've said before, what's really frustrating about this bug is that you guys had fixed it in ages past, only for it to become broken again, and its never been re-fixed since.
 
  • 5Like
  • 1
Reactions:
As I said, they once fixed it an explicitly mentioned it in the patch notes at the time.

Then it got unfixed, somehow, and I can't comment on whether they know about it or not.
 
  • 2Like
  • 1
Reactions:
I fixed this long ago for my stelaris installation:
Code:
namespace = ufd_bugfix

country_event = {
  id = ufd_bugfix.1
  is_triggered_only = yes
  hide_window = yes

  trigger = {
    is_country_type = default
    is_regular_empire = yes
  }

  immediate = {
    leader = {
      root = {
        random_list = {
          60 = { #Scientist
            clone_leader = {
              target = prev
              class = scientist
              traits = {
                trait = leader_trait_adaptable
              }
            }
            modifier = {
              factor = 0
              root = {
                NOT = {
                  OR = {
                    has_valid_civic = civic_technocracy
                    AND = {
                      is_militarist = no
                      has_authority = auth_democratic
                    }
                  }
                }
              }
            }
          }
          20 = { #Govenor
            clone_leader = {
              target = prev
              class = governor
              traits = {
                trait = leader_trait_adaptable
              }
            }
            modifier = {
              factor = 0
              root = {
                NOT = {
                  OR = {
                    has_authority = auth_corporate
                    AND = {
                      NOT = { has_valid_civic = civic_technocracy }
                      OR = {
                        is_militarist = no
                        has_authority = auth_democratic
                      }
                      NOT = { has_valid_civic = civic_warrior_culture }
                    }
                  }
                }
              }
            }
          }
          20 = { #Admiral
            clone_leader = {
              target = prev
              class = admiral
              traits = {
                trait = leader_trait_adaptable
              }
            }
            modifier = {
              factor = 0
              root = {
                NOT = {
                  AND = {
                    NOT = { has_valid_civic = civic_technocracy }
                    is_pacifist = no
                    NOT = { has_authority = auth_corporate }
                    OR = {
                      has_authority = auth_democratic
                      is_militarist = yes
                    }
                  }
                }
              }
            }
          }
        }
        last_created_leader = {
          remove_trait = leader_trait_adaptable
          switch = {
            trigger = leader_class
            scientist = {
              random_list = {
                2 = {
                  add_trait = leader_trait_adaptable
                }
                2 = {
                  add_trait = leader_trait_resilient
                }
                1 = {
                  add_trait = leader_trait_eager
                }
                3 = {
                  add_trait = leader_trait_meticulous
                }
                5 = {
                  add_trait = leader_trait_spark_of_genius
                }
                2 = {
                  add_trait = leader_trait_carefree
                }
                2 = {
                  add_trait = leader_trait_roamer
                }
                2 = {
                  if = {
                    limit = { root = {has_ancrel = yes } }
                    add_trait = leader_trait_archaeologist_ancrel
                  }
                  else = {
                    add_trait = leader_trait_archaeologist
                  }
                }
                3 = {
                  add_trait = leader_trait_maniacal
                }
                1 = {
                  add_trait = leader_trait_expertise_materials
                }
                1 = {
                  add_trait = leader_trait_expertise_propulsion
                }
                1 = {
                  add_trait = leader_trait_expertise_voidcraft
                }
                1 = {
                  add_trait = leader_trait_expertise_industry
                }
                1 = {
                  add_trait = leader_trait_expertise_field_manipulation
                }
                1 = {
                  add_trait = leader_trait_expertise_particles
                }
                1 = {
                  add_trait = leader_trait_expertise_computing
                }
                1 = {
                  add_trait = leader_trait_expertise_new_worlds
                }
                1 = {
                  add_trait = leader_trait_expertise_statecraft
                }
                1 = {
                  add_trait = leader_trait_expertise_biology
                }
                1 = {
                  add_trait = leader_trait_expertise_military_theory
                }
              }
            }
            governor = {
              random_list = {
                2 = {
                  add_trait = leader_trait_adaptable
                }
                2 = {
                  add_trait = leader_trait_resilient
                }
                1 = {
                  add_trait = leader_trait_eager
                }
                1 = {
                  add_trait = leader_trait_army_veteran
                }
                1 = {
                  add_trait = leader_trait_retired_fleet_officer
                }
                2 = {
                  add_trait = leader_trait_architectural_interest
                }
                2 = {
                  add_trait = leader_trait_intellectual
                }
                1 = {
                  add_trait = leader_trait_righteous
                }
                1 = {
                  add_trait = leader_trait_environmental_engineer
                }
                1 = {
                  add_trait = leader_trait_bureaucrat
                }
                2 = {
                  modifier = {
                    factor = 0
                    root  = { allows_slavery = no }
                  }
                  add_trait = leader_trait_iron_fist
                }
                2 = {
                  modifier = {
                    factor = 0
                    root  = { is_lithoid = yes }
                  }
                  add_trait = leader_trait_agrarian_upbringing
                }
              }
            }
            admiral = {
              random_list = {
                2 = {
                  add_trait = leader_trait_adaptable
                }
                1 = {
                  add_trait = leader_trait_resilient
                }
                1 = {
                  add_trait = leader_trait_eager
                }
                3 = {
                  add_trait = leader_trait_trickster
                }
                1 = {
                  add_trait = leader_trait_fleet_logistician
                }
                3 = {
                  add_trait = leader_trait_engineer
                }
                2 = {
                  add_trait = leader_trait_aggressive
                }
                1 = {
                  add_trait = leader_trait_cautious
                }
                1 = {
                  add_trait = leader_trait_scout
                }
                1 = {
                  add_trait = leader_trait_unyielding
                }
                1 = {
                  add_trait = leader_trait_gale_speed
                }
              }
            }
          }
        }
        assign_leader = last_created_leader
      }
      if = {
        limit = { exists = this }
        kill_leader = { show_notification = no }
      }
    }
  }
}
any chance you could create a mod that does this? I'm sure I'm not the only one who would appreciate such a fix that wouldn't require me to edit the files, every time I do that i always seem to screw something up. the only exception would be when i killed the nebula code to save my gpu, and i don't think just ripping out a chunk of code counts
 
Last edited:
  • 1
Reactions:
Well, it seems we're getting somewhere
 
  • 3
Reactions:
Well, it seems we're getting somewhere
Here's hoping. If it gets rolled into the test branch I'd love to know if it's actually fixed if and when that happens. I can't test because I have Stellaris on GOG :-/
 
  • 2Like
Reactions:
Well, it seems we're getting somewhere

That's wonderful. Let's hope they fix it this time. But at least we've finally gotten their attention.

Maybe its just me, but @Alfray Stryke has seemed to be really responsive on our feedback, more so than I remember past QA responses to have been. If they or their bosses at PDX are reading this post, I'd like to extend my thanks to them.
 
  • 4
  • 1Love
Reactions:
There wont be a Steam mod by me as I don't own Stelaris via steam.
Technically this fix just replaces the first ruler at day one by a clone that has the pre_ruler_class property filled.
This however leads to the empiere getting a deelect message, an if the bug wasn't active in first place even a leader died message, (as the fix kills the original if it doesn't go away).
But if anyone wishes to create a steam mod just create an empty mod via the launcher add two txt files for the paths given above, fill the with my code and pack the file.
I hereby grant the permission to upload the resulting mod as long as it stays free and I get my credit.

Btw. I know how to fix many bugs, name me a bug and I will likely name you the fix.
 
Last edited:
  • 2
  • 1Love
Reactions: