游戏规则模组制作

本页面所适用的版本可能已经过时,最后更新于2.6
(重定向自Game rules modding


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

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

<rule_name> = {
	name = LOCALIZATION_KEY_FOR_RULE_NAME
	group = LOCALIZATION_KEY_FOR_RULE_GROUP
	option = {
		name = <option1_name>
		text = LOCALIZATION_KEY_FOR_OPTION1_NAME
		desc = LOCALIZATION_KEY_FOR_OPTION1_DESC
	}
	option = {
		name = <option2_name>
		achievements = no #Optional
		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.
  • The same is true for alt_start_achievements = yes/no, which determines whether the option disables achievements when using alternate starts (shattered/randomised world). Defaults to yes even if achievements = no.
  • You can create custom rule group, for example group = "RULE_GROUP_MY_MOD".
  • Parameter "achievements = no" adds to LOCALIZATION_KEY_FOR_OPTION_DESC a red text " This option turns off achievements." (localisation key "RULE_ACHIEVEMENTS_WARNINGS" in ReapersDue.csv).
  • If you want a rule to have a different default value when using alternate starts, use alt_start_default = <option_name>.

Usage

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.