Wiki

trigger · can_declare_war_on

Definition

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

Description

checks if the country could potentially declare a war on the target ( according to game rules, relationship, etc... ). Example can_declare_war_on = GER

实战 · 配合 · 坑

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

实战用法

can_declare_war_on 常用于判断某国在当前外交状态下是否具备对目标宣战的条件,典型场景包括:在决议(decision)或国策(focus)的 available 块中限制玩家或 AI 只有在可以合法宣战时才能触发相关选项,避免脚本强行绕过游戏外交规则。例如在一个"发动征服战争"的决策中:

available = {
    can_declare_war_on = GER
}

也可以结合动态 target 写法,用于通用事件判断当前国家是否可以对 FROM 宣战:

trigger = {
    can_declare_war_on = FROM
}

配合关系

  • [declare_war_on](/wiki/effect/declare_war_on)can_declare_war_on 是宣战前的条件校验,通常作为 declare_war_on effect 执行前的 availablelimit 守卫,确保宣战行为本身合法。
  • [create_wargoal](/wiki/effect/create_wargoal):在实际宣战前往往需要先创建战争目标,两者配合可以构成"先检查可宣战性 → 生成战争目标 → 执行宣战"的完整流程。
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):当需要区分"主动宣战"与"已处于防御战"两种状态时,两个 trigger 搭配使用,可以精确分支处理不同的外交情境逻辑。
  • [exists](/wiki/trigger/exists):在判断能否宣战之前先确认目标国家存在,避免因目标已被消灭导致 trigger 产生意外行为。

常见坑

  1. 误以为此 trigger 仅检查"是否已有战争目标"can_declare_war_on 综合检查游戏规则、外交关系、战争状态等多项条件,并非单纯判断战争目标是否存在。若目标国与本国已处于同一战争或是盟友,此 trigger 会返回 false,初学者常因此在测试中困惑为何明明有战争目标却仍判断失败。
  2. 在 effect 块中直接使用:该 trigger 只能写在条件判断块(trigger/limit/available/allowed)中,将其写入 effect 块会导致脚本报错或静默失效,新手容易将它与 [declare_war_on](/wiki/effect/declare_war_on) 混淆放错位置。

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

can_declare_war_on is commonly used to verify whether a country meets the conditions to declare war on a target under the current diplomatic status. Typical scenarios include restricting the player or AI to trigger related options only when they can legally declare war within a decision (decision) or national focus (focus) available block, preventing scripts from forcefully circumventing the game's diplomatic rules. For example, in a "Launch a Conquest War" decision:

available = {
    can_declare_war_on = GER
}

It can also be combined with dynamic target syntax to check in generic events whether the current nation can declare war on FROM:

trigger = {
    can_declare_war_on = FROM
}

Synergy

  • [declare_war_on](/wiki/effect/declare_war_on): can_declare_war_on serves as a pre-war condition check, typically functioning as an available or limit guard before executing the declare_war_on effect, ensuring the war declaration itself is legal.
  • [create_wargoal](/wiki/effect/create_wargoal): Before actually declaring war, a war goal usually needs to be created first. Used together, these form a complete workflow: "check declarability → generate war goal → execute war declaration."
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): When needing to distinguish between "active war declaration" and "already in defensive war" states, using both triggers together allows precise branching logic for different diplomatic scenarios.
  • [exists](/wiki/trigger/exists): Before checking if war can be declared, first verify that the target nation exists, preventing unexpected trigger behavior caused by the target already being eliminated.

Common Pitfalls

  1. Mistaking this trigger for only checking "whether a war goal already exists": can_declare_war_on comprehensively checks game rules, diplomatic relations, war status, and multiple other conditions—it is not merely judging whether a war goal exists. If the target nation and this nation are already in the same war or are allies, this trigger returns false. Beginners often become confused during testing when a war goal clearly exists but the check still fails.
  2. Using it directly in effect blocks: This trigger can only be placed in conditional judgment blocks (trigger/limit/available/allowed). Writing it into an effect block causes script errors or silent failure. Novices frequently confuse it with [declare_war_on](/wiki/effect/declare_war_on) and place it in the wrong location.