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 
}

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

set_rule 常用于国家焦点、决策或事件中,临时或永久地限制某个国家的行为,例如傀儡国无法主动宣战、特定意识形态政权被强制锁定某些外交行为。与 clear_rule 配合可实现"解锁"机制,适合做任务链中的阶段性限制。

# 示例:某国签署和平协议后,暂时无法宣战
country_event = {
    option = {
        name = peace_treaty.1.a
        set_rule = {
            desc = PEACE_TREATY_NO_WAR_DESC
            can_not_declare_war = yes
        }
    }
}

配合关系

  • [clear_rule](/wiki/effect/clear_rule)set_rule 添加限制后,需要用 clear_rule 在条件满足时撤销,二者是一对"开关"关系,缺少解除逻辑会导致规则永久生效。
  • [has_active_rule](/wiki/trigger/has_active_rule) — 在 trigger 块中检测某条规则是否当前生效,常用于判断是否已处于限制状态,避免重复施加同一规则。
  • [add_days_remove](/wiki/effect/add_days_remove) — 若规则附加在 idea 上时间有限,可配合定时移除 idea 的方式变相实现规则的时效性(因为 set_rule 本身无原生到期参数)。
  • [country_event](/wiki/effect/country_event) — 常在事件选项中触发 set_rule,并在后续计划事件中配合 clear_rule 解除,形成完整的外交限制叙事链。

常见坑

  1. 忘记撤销规则set_rule 一旦设置会持续生效,新手常常只写了 set_rule 而没有在适当时机调用 clear_rule,导致该国在整个游戏流程中永久被限制,无法正常进行外交行为。
  2. desc 字段混淆本地化键desc 填写的是本地化 key 而非直接显示文本,若填入普通字符串而未在 .yml 本地化文件中定义对应条目,游戏内 tooltip 会显示原始 key 字符串,造成提示信息错误。

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.