Wiki

effect · add_relation_rule_override

Definition

  • Supported scope:COUNTRY
  • Supported target:THIS

Description

Adds an override rule to the country's relation to other countries. If there are multiple applicable overrides for a rule, then they are combined using AND logic for positive rules (e.g. can_access_market) and OR logic for negative rules (e.g. can_not_declare_war). 
The description of the effect is based on the trigger or the target country.The description when using the rule override is based: on the target country; the trigger at the time of effect evaluation; or the provided usage_desc.
The following rules are currently supported: can_send_volunteer, can_access_market
Alternative 1:
add_relation_rule_override = { 
 target = GER # [Required] Target country usage_desc = REASON_DESCRIPTION # [Optional] usage description can_not_declare_war = yes # [Required] 
}
Alternative 2:
add_relation_rule_override = { 
 trigger = is_democratic_country # [Required] Named trigger usage_desc = DEMOCRATIC_COUNTRY # [Optional] usage description can_not_declare_war = yes # [Required] 
}

实战 · 配合 · 坑

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

实战用法

add_relation_rule_override 常用于外交协议、意识形态限制或剧本事件场景,例如让某个民主国家无法对盟友宣战,或限制特定国家间的志愿者派遣。它的优势在于可以绑定命名触发器(named trigger)动态判断条件,而非硬编码目标标签,适合需要灵活外交规则的 mod。

# 事件选项:德国无法对美国宣战(直接绑定目标标签)
option = {
    name = example.1.a
    add_relation_rule_override = {
        target = USA
        usage_desc = REASON_PEACE_TREATY
        can_not_declare_war = yes
    }
}

# 或:对所有民主国家启用市场准入
add_relation_rule_override = {
    trigger = is_democratic_country
    usage_desc = DEMOCRATIC_MARKET_ACCESS
    can_access_market = yes
}

配合关系

  • [has_active_rule](/wiki/trigger/has_active_rule):用于在后续触发器中检查某条规则覆盖是否已经生效,配合本 effect 做前置或后续判断逻辑。
  • [clear_rule](/wiki/effect/clear_rule):当外交协议失效或玩家做出新选择时,用于清除之前通过本 effect 添加的规则覆盖,两者形成成对的"添加/移除"工作流。
  • [add_opinion_modifier](/wiki/effect/add_opinion_modifier):规则覆盖通常伴随外交关系变化,添加关系修正可以在 UI 层面直观反映规则生效的外交背景。
  • [diplomatic_relation](/wiki/effect/diplomatic_relation):在设置宣战或市场准入规则时,往往同步调整正式外交关系状态(如不侵犯条约、贸易协定),两者共同构成完整的外交事件效果。

常见坑

  1. targettrigger 二选一,不可混用:新手容易同时写 targettrigger 字段,但两者是互斥的两种使用形式(Alternative 1 / Alternative 2),同时出现会导致脚本解析异常或规则不生效。
  2. 规则名称写错导致静默失败:目前仅支持有限的规则名(如 can_not_declare_warcan_send_volunteercan_access_market),若写了游戏不支持的规则名,脚本不会报错但完全无效,调试时极难发现。

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

add_relation_rule_override is commonly used in diplomatic agreements, ideology restrictions, or scripted event scenarios—for example, preventing a democratic nation from declaring war on an ally, or restricting volunteer deployment between specific countries. Its strength lies in binding named triggers for dynamic condition evaluation rather than hardcoding target tags, making it ideal for mods requiring flexible diplomatic rules.

# Event option: Germany cannot declare war on USA (direct target binding)
option = {
    name = example.1.a
    add_relation_rule_override = {
        target = USA
        usage_desc = REASON_PEACE_TREATY
        can_not_declare_war = yes
    }
}

# Or: enable market access for all democratic nations
add_relation_rule_override = {
    trigger = is_democratic_country
    usage_desc = DEMOCRATIC_MARKET_ACCESS
    can_access_market = yes
}

Synergy

  • [has_active_rule](/wiki/trigger/has_active_rule): Used in subsequent triggers to check whether a rule override is already active; pair it with this effect for prerequisite or follow-up decision logic.
  • [clear_rule](/wiki/effect/clear_rule): When a diplomatic agreement expires or the player makes a new choice, clears the rule override previously added by this effect, forming a paired "add/remove" workflow.
  • [add_opinion_modifier](/wiki/effect/add_opinion_modifier): Rule overrides typically accompany diplomatic relationship changes; adding opinion modifiers provides intuitive UI-level reflection of the diplomatic context behind rule activation.
  • [diplomatic_relation](/wiki/effect/diplomatic_relation): When setting war declaration or market access rules, simultaneously adjust formal diplomatic status (such as non-aggression pacts or trade agreements); together they constitute a complete diplomatic event outcome.

Common Pitfalls

  1. target and trigger are mutually exclusive: Beginners often write both target and trigger fields simultaneously, but they represent two alternative usage patterns (Alternative 1 / Alternative 2). Writing both causes script parsing errors or rules failing silently.
  2. Silent failure from typos in rule names: Only a limited set of rule names are supported (such as can_not_declare_war, can_send_volunteer, can_access_market). Using unsupported rule names won't generate script errors but will have no effect whatsoever, making debugging extremely difficult.