Wiki

trigger · has_game_rule

Definition

  • Supported scope:any
  • Supported target:none

Description

Checks if a game rule is set to a particular option.
Example:
has_game_rule = {
	rule = GER_can_remilitarize_rhineland
	option = yes
}

Hands-On Notes

Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.

Hands-On Usage

has_game_rule is commonly used to dynamically adjust focus tree availability or event paths based on room rules. For example, you can make a specific focus available only when the "Allow Historical Events" rule is enabled. In multiplayer mods, it's frequently used to check whether specific balance options are enabled, thereby deciding whether to trigger certain script logic.

# A decision is available only when the rule permits it
available = {
    has_game_rule = {
        rule = GER_can_remilitarize_rhineland
        option = GER_CAN_REMILITARIZE_RHINELAND_YES
    }
}

Synergy

  • [has_global_flag](/wiki/trigger/has_global_flag): Often placed alongside has_game_rule in the same and block. One checks rule settings while the other confirms whether a global flag has been triggered, jointly guarding the condition gate.
  • [is_historical_focus_on](/wiki/trigger/is_historical_focus_on): Frequently combined with has_game_rule to distinguish priority between "historical mode" and custom rules, preventing rule conflicts.
  • [custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip): Wrapping has_game_rule within it provides players with friendlier localized tooltips explaining why a feature is disabled by rules.
  • [or](/wiki/trigger/or): When a single condition needs to support multiple rule options, wrap multiple has_game_rule blocks with or for clearer logic.

Common Pitfalls

  1. Incorrect capitalization or spelling in the option value: The option field must exactly match the option token defined in the game rules file (common/game_rules/), including case sensitivity. Shortcuts like yes/no are only valid when the rule option itself is named that way; don't arbitrarily omit the prefix.
  2. Using the trigger in a version/mod environment where the rule doesn't exist: If the referenced rule is not defined in the current mod or base game, the trigger won't error but silently returns false, causing the condition block to never be satisfied. This is easily overlooked during debugging; always confirm that the rule is properly registered in common/game_rules/.