Wiki

trigger · all_enemy_country

Definition

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

Description

check if all enemy countries meet the trigger. tooltip=key can be defined to override title

实战 · 配合 · 坑

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

实战用法

all_enemy_country 常用于检查当前战争中所有敌国是否同时满足某一条件,例如判断是否所有敌人都已濒临崩溃、已有合法战争目标、或均属于特定政治体制,从而触发特殊事件或解锁专属决策。典型场景包括:当所有敌国均已投降/被占领时自动触发胜利事件,或判断敌方阵营是否全员为法西斯政权以开放特殊外交选项。

# 示例:仅当所有敌国都已投降时,才允许触发和平决议事件
available = {
    has_war = yes
    all_enemy_country = {
        has_capitulated = yes
    }
}

配合关系

  • any_enemy_country:与 all_enemy_country 互补,一个要求"全部满足",一个要求"至少一个满足",常对比使用来区分"全面胜利"与"部分优势"两种判断分支。
  • has_war:在调用 all_enemy_country 前通常需要先确认本国处于战争状态,否则在无战争时该 trigger 因没有敌国可遍历而结果不可预期。
  • has_war_with:用于进一步指定对特定国家的战争关系,配合 all_enemy_country 的遍历可构建"是否与特定敌国集团全员交战"的复合条件。
  • controls_state:在 all_enemy_country 的子块内使用,用于判断每个敌国是否已失去对关键省份/州的控制,实现"敌国领土全面沦陷"的胜利条件检查。

常见坑

  1. 无敌国时返回值的误解:当本国当前没有任何交战对手时,all_enemy_country 的遍历集合为空,HOI4 中空集的 all_ 系列 trigger 会返回 true(vacuous truth,即"对空集中所有元素命题成立"),新手可能误以为会返回 false,从而导致在和平时期意外触发本该只在战争胜利后激活的内容,应在外层先加 has_war = yes 保护。
  2. any_enemy_country 混用逻辑反转:新手容易将两者的语义搞反,在需要"至少一个敌国满足"的场景误用了 all_enemy_country,导致条件过于严苛而永远不触发;核对业务逻辑时请明确区分"全称量词(all)"与"存在量词(any)"。

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

all_enemy_country is commonly used to check whether all countries currently at war with the scope nation simultaneously meet a given condition — for example, determining whether every enemy is on the verge of collapse, already has a valid war goal against them, or all belong to a specific political ideology. This allows modders to fire special events or unlock exclusive decisions. Typical use cases include automatically triggering a victory event when all enemy nations have surrendered or been occupied, or checking whether every member of the opposing faction is a fascist regime in order to unlock special diplomatic options.

# Example: only allow the peace resolution event to fire when all enemy countries have capitulated
available = {
    has_war = yes
    all_enemy_country = {
        has_capitulated = yes
    }
}

Synergy

  • any_enemy_country: The counterpart to all_enemy_country — one requires "all must match," the other requires "at least one must match." They are frequently used together to distinguish between a "total victory" branch and a "partial advantage" branch.
  • has_war: You should almost always confirm the country is at war before calling all_enemy_country. Without an active war there are no enemies to iterate over, and the trigger's return value in that state can be unpredictable.
  • has_war_with: Used to narrow the war relationship down to a specific nation. Combined with the iteration of all_enemy_country, this lets you build composite conditions such as "are we at war with every member of a particular enemy faction?"
  • controls_state: Used inside the all_enemy_country block to check whether each enemy has lost control of key provinces or states, enabling a "complete territorial conquest" victory condition check.

Common Pitfalls

  1. Misreading the return value when there are no enemies: When the scoped country has no active enemies, the iteration set of all_enemy_country is empty. In HOI4, all_ series triggers evaluated against an empty set return true (vacuous truth — "the proposition holds for all elements of an empty set"). Beginners often assume the result would be false, which can cause content intended only for post-war victory to fire unexpectedly during peacetime. Always guard against this with has_war = yes in the outer scope.
  2. Logic inversion when mixing all_enemy_country with any_enemy_country: It is easy to confuse the semantics of the two. Using all_enemy_country in a situation that only requires "at least one enemy satisfies the condition" makes the check far too strict and it will likely never trigger. When reviewing your logic, be explicit about whether you need a universal quantifier (all) or an existential quantifier (any).