trigger · has_war_with
Definition
- Supported scope:
COUNTRY - Supported target:
THIS,ROOT,PREV,FROM,OWNER,CONTROLLER,OCCUPIED,CAPITAL
Description
is countries at war
has_war_withCOUNTRYTHIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITALis countries at war
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
has_war_with 常用于判断两国是否处于交战状态,从而决定某事件选项、决策或国策是否可用——例如限制外交选项在战争期间不可点击,或在战争结束后触发和平事件。也常用于 AI 策略逻辑中,判断盟友是否正在与特定国家交战以决定是否参战。
# 示例:只有与德国处于战争状态时,该决策才可用
available = {
has_war_with = GER
}
[has_defensive_war_with](/wiki/trigger/has_defensive_war_with):配合使用可进一步区分当前战争是防御性质还是主动发起,用于为守方提供特殊加成或触发专属事件。[any_enemy_country](/wiki/trigger/any_enemy_country):当需要判断"是否与任意满足某条件的国家交战"时,any_enemy_country 搭配内部条件比多次写 has_war_with 更灵活简洁。[declare_war_on](/wiki/effect/declare_war_on):常见于先用 has_war_with 做 limit 排除已经开战的情况,避免重复宣战导致脚本报错或逻辑混乱。[exists](/wiki/trigger/exists):战争判断前最好先确认目标国家仍然存在,否则对已被消灭的国家执行判断可能产生意外结果。has_war_with 的 scope 是 COUNTRY,必须在国家 scope 下调用。新手有时在 state scope 或 unit leader scope 中直接写该 trigger,导致解析错误或静默失效,需要先用 OWNER 等切换到国家 scope。has_war_with B 为真,B has_war_with A 同样为真,重复编写会造成逻辑冗余。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.
has_war_with is commonly used to determine whether two countries are at war, thereby controlling whether certain event options, decisions, or focuses are available—for example, disabling diplomatic options during wartime or triggering peace events after war concludes. It is also frequently used in AI strategy logic to check whether allies are engaged in conflict with a specific country to decide whether to join the war.
# Example: This decision is only available when at war with Germany
available = {
has_war_with = GER
}
[has_defensive_war_with](/wiki/trigger/has_defensive_war_with): Using this together allows further distinction between whether the current war is defensive or offensive in nature, useful for providing special bonuses to the defender or triggering exclusive events.[any_enemy_country](/wiki/trigger/any_enemy_country): When you need to check "is at war with any country meeting certain conditions," pairing any_enemy_country with internal conditions is more flexible and concise than writing multiple has_war_with statements.[declare_war_on](/wiki/effect/declare_war_on): Common practice is to first use has_war_with in a limit clause to exclude countries already at war, preventing duplicate war declarations that could cause script errors or logic confusion.[exists](/wiki/trigger/exists): It is best to confirm the target country still exists before checking war status, otherwise evaluating this trigger against an eliminated country may produce unexpected results.has_war_with is COUNTRY and must be called within a country scope. Beginners sometimes write this trigger directly in a state scope or unit leader scope, causing parsing errors or silent failures. You must first switch to country scope using OWNER or similar.has_war_with B is true, then B has_war_with A is also true. Duplicate coding results in logical redundancy.