Wiki

trigger · has_truce_with

Definition

  • Supported scope:COUNTRY
  • Supported target:THIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITAL

Description

has_truce_with = yes/no - Checks if the country has truce with the specified country

实战 · 配合 · 坑

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

实战用法

has_truce_with 常用于外交或决策 mod 中,防止玩家或 AI 在停战协议期间重复宣战或触发侵略性决策。例如在某个"打破停战"的决策里用它作前置条件检查:

available = {
    has_truce_with = FROM
}

这样只有当本国与目标国确实存在停战协议时,该决策才可用(或反过来用 NOT 包裹来禁止操作)。

配合关系

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):两者常并列检查,确认当前既无停战协议、也无防御战争,再允许宣战类决策触发。
  • [can_declare_war_on](/wiki/trigger/can_declare_war_on):综合验证宣战合法性时,has_truce_with 作为补充条件,排除停战期间的宣战窗口。
  • [declare_war_on](/wiki/effect/declare_war_on):执行宣战 effect 前,通常在 available/limit 里用 NOT = { has_truce_with = ... } 把关,避免脚本报错或逻辑矛盾。
  • [has_war](/wiki/trigger/has_war):与停战检查搭配,完整覆盖"当前是否处于战争或停战"两种互斥状态。

常见坑

  1. 忘记用 NOT 取反:新手常想表达"没有停战时才能触发",却直接写 has_truce_with = yes,结果逻辑反向——只有存在停战时条件才为真,应改为 NOT = { has_truce_with = <target> }
  2. scope 指向错误:该 trigger 须在 COUNTRY scope 下使用,若不小心写在 STATE scope 内(如 every_owned_state 的子块里)会静默失效或报 scope 错误,需确保外层 scope 是国家。

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_truce_with is commonly used in diplomatic or decision-making mods to prevent players or AI from repeatedly declaring war or triggering aggressive decisions during a truce period. For example, it can be used as a precondition check in a decision to "break the truce":

available = {
    has_truce_with = FROM
}

This makes the decision available only when the country actually has an active truce agreement with the target nation (or conversely, wrap it with NOT to prohibit the action).

Synergy

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): Often checked in parallel to confirm the current state has neither an active truce nor a defensive war before allowing war declaration decisions to trigger.
  • [can_declare_war_on](/wiki/trigger/can_declare_war_on): When comprehensively validating war declaration legality, has_truce_with serves as a supplementary condition to exclude war windows during truce periods.
  • [declare_war_on](/wiki/effect/declare_war_on): Before executing a war declaration effect, typically use NOT = { has_truce_with = ... } in the available/limit block to prevent script errors or logical contradictions.
  • [has_war](/wiki/trigger/has_war): Combined with truce checks to fully cover both mutually exclusive states—whether the country is currently at war or under truce.

Common Pitfalls

  1. Forgetting to use NOT for negation: Beginners often intend to express "can only trigger when there is no truce" but accidentally write has_truce_with = yes, resulting in inverted logic—the condition becomes true only when a truce exists. The correct approach is NOT = { has_truce_with = <target> }.
  2. Incorrect scope targeting: This trigger must be used within a COUNTRY scope. If accidentally placed in a STATE scope (such as within a every_owned_state subblock), it will silently fail or produce a scope error. Always ensure the outer scope is at the country level.