Wiki

effect · set_relation_rule

Definition

  • Supported scope:COUNTRY
  • Supported target:THIS

Description

DEPRECATED: See add_relation_rule_override

实战 · 配合 · 坑

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

实战用法

set_relation_rule 是一个已废弃的旧版指令,历史上用于设置国家间的外交关系规则(如是否允许宣战、贸易等),在早期 mod 中常见于阵营关系或傀儡关系的初始化阶段。由于官方已将其标记为 DEPRECATED,任何新 mod 应改用 add_relation_rule_override 替代。若你在维护老旧 mod,见到此指令时请视其为迁移标记。

# ❌ 旧写法(已废弃,不推荐在新 mod 中使用)
GER = {
    set_relation_rule = {
        # 旧参数写法,行为已不受保证
    }
}

# ✅ 新写法(应替换为)
GER = {
    add_relation_rule_override = {
        # 使用当前支持的参数
    }
}

配合关系

  • [add_relation_rule_override](/wiki/effect/add_relation_rule_override) — 这是官方指定的替代品,迁移时应直接用此指令重写原有逻辑,功能语义相同但受到持续支持。
  • [diplomatic_relation](/wiki/effect/diplomatic_relation) — 常与关系规则类指令搭配,用于同步设置正式外交关系状态(如保证、不侵犯条约等)。
  • [add_opinion_modifier](/wiki/effect/add_opinion_modifier) — 在调整关系规则的同时修改双边好感度,使外交状态与 AI 行为倾向保持一致。
  • [has_active_rule](/wiki/trigger/has_active_rule) — 用于检测某条关系规则是否已生效,可在条件判断中配合使用以避免重复设置。

常见坑

  1. 继续在新 mod 中使用此指令:由于游戏版本迭代,DEPRECATED 指令随时可能被引擎静默忽略或报错,直接照搬含有 set_relation_rule 的老 mod 代码而不替换为 add_relation_rule_override,会导致规则根本不生效且难以排查。
  2. 误以为 scope 可以是 STATE 或 CHARACTER:此指令仅在 COUNTRY scope 下有效,若在事件的 option 中写在 state scope 内(例如通过 every_owned_state 进入后调用),游戏不会报语法错误但指令会被跳过,造成逻辑静默失败。

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_relation_rule is a deprecated legacy command that was historically used to configure diplomatic relationship rules between nations (such as whether war declarations or trade are permitted). It was commonly seen in early mods during the initialization phase of faction or puppet relationships. Since the official codebase has marked it as DEPRECATED, any new mod should use add_relation_rule_override instead. If you are maintaining older mods and encounter this command, treat it as a migration marker.

# ❌ Old syntax (deprecated, not recommended for new mods)
GER = {
    set_relation_rule = {
        # Legacy parameter syntax, behavior no longer guaranteed
    }
}

# ✅ New syntax (should be replaced with)
GER = {
    add_relation_rule_override = {
        # Uses currently supported parameters
    }
}

Synergy

  • [add_relation_rule_override](/wiki/effect/add_relation_rule_override) — This is the official replacement. When migrating, you should directly rewrite the original logic using this command. The functional semantics remain the same but it receives continuous support.
  • [diplomatic_relation](/wiki/effect/diplomatic_relation) — Commonly paired with relation rule commands to simultaneously configure formal diplomatic status (such as guarantees, non-aggression pacts, etc.).
  • [add_opinion_modifier](/wiki/effect/add_opinion_modifier) — While adjusting relation rules, modify bilateral opinion ratings to keep diplomatic state and AI behavior alignment consistent.
  • [has_active_rule](/wiki/trigger/has_active_rule) — Used to check whether a specific relation rule is already active. Can be paired in conditional checks to avoid duplicate configurations.

Common Pitfalls

  1. Continuing to use this command in new mods: Due to game version iterations, DEPRECATED commands may be silently ignored by the engine or cause errors at any time. Directly copying old mod code containing set_relation_rule without replacing it with add_relation_rule_override will result in rules failing to take effect and becoming difficult to debug.
  2. Incorrectly assuming the scope can be STATE or CHARACTER: This command is only valid within a COUNTRY scope. If you place it within a state scope in an event's option block (for example, by entering through every_owned_state), the game will not report a syntax error but the command will be skipped, causing silent logic failure.