Wiki

effect · set_rule

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Adds rule to country. This one overrides all other rules on country 
set_rule = { 
 desc = desc_key # A description of why the rule is set (you can get original tooltip using DESC key) 
 can_not_declare_war = 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

set_rule is commonly used in national focuses, decisions, or events to temporarily or permanently restrict a country's behavior. Examples include preventing puppet states from declaring war independently or forcing specific ideological regimes to remain locked into certain diplomatic actions. When paired with clear_rule, it enables an "unlock" mechanism ideal for implementing stage-based restrictions in mission chains.

# Example: After signing a peace treaty, a country cannot declare war for a period
country_event = {
    option = {
        name = peace_treaty.1.a
        set_rule = {
            desc = PEACE_TREATY_NO_WAR_DESC
            can_not_declare_war = yes
        }
    }
}

Synergy

  • [clear_rule](/wiki/effect/clear_rule) — Once set_rule adds a restriction, use clear_rule to revoke it when conditions are met. They form a "switch" pair; omitting the removal logic causes rules to remain permanent.
  • [has_active_rule](/wiki/trigger/has_active_rule) — In trigger blocks, check whether a specific rule is currently active. Useful for determining if a country is already restricted and prevents accidentally applying the same rule twice.
  • [add_days_remove](/wiki/effect/add_days_remove) — When rules are attached to ideas with time limits, combine this with timed idea removal to simulate rule expiration (since set_rule itself has no native expiry parameter).
  • [country_event](/wiki/effect/country_event) — Commonly triggered within event options to apply set_rule, then paired with clear_rule in follow-up scheduled events, forming a complete diplomatic restriction narrative chain.

Common Pitfalls

  1. Forgetting to revoke rules — Once set_rule is applied, it remains active indefinitely. Beginners often write set_rule without calling clear_rule at the appropriate moment, leaving the country permanently restricted throughout the entire game, unable to conduct normal diplomacy.
  2. Confusing the desc field with localization keys — The desc field expects a localization key, not direct display text. Entering a plain string without defining the corresponding entry in the .yml localization file causes the in-game tooltip to display the raw key string, resulting in incorrect help text.