From Crusader Kings II Wiki
Revision as of 05:49, 13 April 2018 by (talk)
Jump to navigation Jump to search

Optimization is a set of mechanisms and techniques that ensures that the game performance remains acceptable after hundred years.

The game performance mainly depends on the number of living characters, on whom events need to be processed, and that need to be kept in the save files.[1] The number of characters is itself closely tied to the number of provinces. But it is worth noting that courts are only generated for characters above baron level (except for patricians), so adding more barons has considerably less of an effect on performance than adding more counts.


Pruning is the removal of unimportant characters, so that the number of courtiers remains reasonable and game performance acceptable due to events & decisions processed on courtiers.

It balances out the random character generation used to populate courts, since characters may not die naturally as fast as new ones get generated.

Pruned characters are killed with death reason death_vanished, aka "vanished without a trace".

Pruning is controlled by:

  • NDefines.NEngine.COURT_PRUNE_SIZE = 10: courts larger than this will be checked for pruning each month
  • NDefines.NEngine.HEALTH_IMMUNITY_TO_PRUNING = 7: if a character has that much health, they won't be pruned
  • NDefines.NEngine.PRUNE_MINIMAL_AGE = 40
  • Courtiers who have minor titles, friends, lovers, consorts or rivals are excluded
  • Immortal characters are excluded
  • Characters marked as special interest by the player are excluded.

There's also a related scripted trigger used in some mass disease events:

is_unimportant_trigger = {
	NOR = {
		is_married = yes
		is_landed = yes
		has_job_title = yes
		has_minor_title = yes
		AND = {
			NOT = { dynasty = none }
			num_of_dynasty_members = 2
		any_lover = { ai = no }
		any_close_relative = { ai = no }
		any_friend = { ai = no }
		any_rival = { ai = no }
		any_consort = { ai = no }
		num_of_claims = 1
		has_character_flag = eternal_life_mystic
		trait = horse
		has_character_modifier = in_seclusion
		immortal = yes

Note that another trigger of pruning is the inheritance of a title: rather than moving all characters of the old court of the title to the court of the new holder, some characters are pruned.

Due to a different behavior,[2] these characters die of death_natural reason and some of the checks above (immortal, ...) are bypassed.

Save compression

Script optimizations