Wiki

trigger · has_war

Definition

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

Description

is country at war

实战 · 配合 · 坑

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

实战用法

has_war 常用于判断某国是否处于战争状态,从而控制决策、国策或事件的可用性。例如在和平时期限制某些战时决策的触发,或在战争中解锁特定的应急措施。

# 某决策仅在本国未处于战争时可用
available = {
    NOT = { has_war = yes }
}

# 事件 trigger:仅当目标国正在交战时触发
trigger = {
    FROM = {
        has_war = yes
    }
}

配合关系

  • [has_defensive_war](/wiki/trigger/has_defensive_war):配合使用可区分"主动参战"与"被动防御战",精细化判断当前战争性质。
  • [has_civil_war](/wiki/trigger/has_civil_war):与 has_war 并用,可排除内战情况,仅在外部战争时触发逻辑。
  • [declare_war_on](/wiki/effect/declare_war_on):触发宣战前通常用 has_war = no 做前置检查,避免重复宣战导致逻辑混乱。
  • [can_declare_war_on](/wiki/trigger/can_declare_war_on):两者组合用于完整的宣战前置条件验证——先确认己方状态,再确认宣战资格。

常见坑

  1. 忘记指定 scopehas_war 只在 COUNTRY scope 下有效,直接写在 STATE scope 的 limit 块中会报错或静默失效,需要用 OWNER = { has_war = yes } 等方式转换 scope。
  2. 误以为内战不计入战争:内战同样会使 has_war 返回 yes,若想排除内战场景需额外配合 NOT = { has_civil_war = yes } 进行过滤。

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_war is commonly used to check whether a country is in a state of war, allowing you to control the availability of decisions, national focuses, or events. For example, you can restrict certain wartime decisions from triggering during peacetime, or unlock specific emergency measures when at war.

# This decision is only available when the country is not at war
available = {
    NOT = { has_war = yes }
}

# Event trigger: only fires when the target country is actively at war
trigger = {
    FROM = {
        has_war = yes
    }
}

Synergy

  • [has_defensive_war](/wiki/trigger/has_defensive_war): Use in combination to distinguish between "offensive war" and "defensive war", allowing for finer-grained assessment of the current nature of conflict.
  • [has_civil_war](/wiki/trigger/has_civil_war): When used together with has_war, you can exclude civil war scenarios and trigger logic only for external wars.
  • [declare_war_on](/wiki/effect/declare_war_on): Before declaring war, it's standard practice to use has_war = no as a precondition check to avoid confused logic from duplicate war declarations.
  • [can_declare_war_on](/wiki/trigger/can_declare_war_on): Combine both to validate complete prerequisites for war declaration—first confirm your own state, then verify your right to declare war.

Common Pitfalls

  1. Forgetting to specify scope: has_war is only valid in COUNTRY scope. Using it directly in a STATE scope limit block will cause errors or silent failure. Use scope conversion like OWNER = { has_war = yes } instead.
  2. Mistakenly assuming civil wars don't count as wars: Civil wars also cause has_war to return yes. If you need to exclude civil war scenarios, you must additionally filter with NOT = { has_civil_war = yes }.