Game rules modding

From Crusader Kings II Wiki
Jump to: navigation, search

Game rules are enumerated global values, that can only be modified at game start.

In their simplest form (on/off), they are similar to boolean global flags, but can get more complex (fewer/default/more).

The benefit of game rules is that they have a nice dedicated UI to manage the options at the start of a game, so there's less modding needed than using decisions.

Definition[edit]

Rules are defined in folder common/game_rules/. The format is:

<rule_name> = {
	name = LOCALIZATION_KEY_FOR_RULE_NAME
	option = {
		name = <option1_name>
		text = LOCALIZATION_KEY_FOR_OPTION1_NAME
		desc = LOCALIZATION_KEY_FOR_OPTION1_DESC
	}
	option = {
		name = <option2_name>
		text = LOCALIZATION_KEY_FOR_OPTION2_NAME
		desc = LOCALIZATION_KEY_FOR_OPTION2_DESC
	}
}

Notes:

  • The first option is the default one at game start.
  • If certain rule only makes sense to appear with a DLC, it can use dlc = "The Reaper's Due"
  • Each option can have achievements = yes/no. This doesn't make sense to be used for mods, as they already disable achievements by changing the checksum.

Usage[edit]

Selected option of a rule can be compared from scripting via the condition has_game_rule = { name = <rule_name> value = <option_name> }

Some vanilla rules are not used from scripting and modify hardcoded behavior, similar to defines, which is not possible for mods.

Modding
History
Scripting
Common
DefinesGame rulesReligionCultureTraitsTechnologyLawsBuildingsCasus BelliObjectivesGovernmentsDiseaseDeathMinor titles
Gfx/Sfx/localisation