Wiki

trigger · has_war_with_wargoal_against

Definition

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

Description

Checks if country has a war started with a wargoal against the target.
Example 1:
has_war_with_wargoal_against = {
  target = GER
  type = take_state  # (optional: if not specified any wargoal will do)
}
Example 2:
has_war_with_wargoal_against = GER  # (any wargoal will do)

实战 · 配合 · 坑

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

实战用法

has_war_with_wargoal_against 常用于判断当前国家是否对某一特定目标发动了带有特定战争目标的战争,典型场景包括:决策或国策的解锁条件(例如只有当玩家以"吞并国土"为战争目标进攻德国时才能激活某个特殊决策),或者 AI 逻辑中检测战争意图以决定是否触发事件。

# 仅当本国以"占领州省"为战争目标对 GER 开战时,该决策才可用
available = {
    has_war_with_wargoal_against = {
        target = GER
        type = take_state
    }
}

配合关系

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):常与本 trigger 一起构成"攻守双向检测",一个判断我方是否主动持有战争目标,另一个判断我方是否在被动防御,避免逻辑混淆。
  • [any_enemy_country](/wiki/trigger/any_enemy_country):用于在不确定目标的情况下遍历所有敌国,再在子条件中调用本 trigger 筛选出拥有特定战争目标的那场战争。
  • [create_wargoal](/wiki/effect/create_wargoal):通常在 effect 块中与本 trigger 的结果联动——先用本 trigger 确认战争目标是否已存在,再决定是否补充创建新战争目标,防止重复添加。
  • [declare_war_on](/wiki/effect/declare_war_on):宣战 effect 执行后,往往需要在后续 trigger 中用本命令验证宣战是否携带了预期的战争目标类型,常见于事件链的条件校验节点。

常见坑

  1. 省略 type 时误以为只匹配某种战争目标:不填 type 字段时,trigger 会对"任意战争目标"返回真,因此如果只想检测特定类型(如 take_state),必须显式写出 type = take_state,否则只要双方处于交战状态且存在任何战争目标即会触发,容易造成条件过于宽松。
  2. 混淆 scope 方向:本 trigger 检测的是"当前 scope 国家对 target 持有战争目标",而非反向。新手常把 target 写成本国自身,或在错误的 scope(如 STATE scope)下调用,导致条件永远不成立;务必确认外层 scope 为 COUNTRY,且 target 指向的是被攻击方。

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_with_wargoal_against is commonly used to check whether the current country has declared war against a specific target with a particular war goal. Typical use cases include decision or focus availability conditions (for example, activating a special decision only when the player attacks Germany with "Annex" as the war goal), or in AI logic to detect war intentions and determine whether to trigger events.

# This decision is only available if this country is at war with GER with "take_state" as the war goal
available = {
    has_war_with_wargoal_against = {
        target = GER
        type = take_state
    }
}

Synergy

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): Often paired with this trigger to form "bidirectional conflict detection"—one checks if your side actively holds war goals, the other checks if your side is passively defending, preventing logical confusion.
  • [any_enemy_country](/wiki/trigger/any_enemy_country): Used to iterate through all enemy nations when the target is uncertain, then invoke this trigger in sub-conditions to filter out wars with specific war goals.
  • [create_wargoal](/wiki/effect/create_wargoal): Typically linked with the result of this trigger in effect blocks—first use this trigger to confirm whether the war goal already exists, then decide whether to create additional war goals, preventing duplication.
  • [declare_war_on](/wiki/effect/declare_war_on): After a declare war effect executes, you often need to verify in subsequent triggers using this command that the declaration carried the expected war goal type, commonly seen in condition validation nodes of event chains.

Common Pitfalls

  1. Assuming the trigger matches only a specific war goal when type is omitted: When the type field is left blank, the trigger returns true for "any war goal," so if you only want to check a specific type (such as take_state), you must explicitly write type = take_state. Otherwise, the condition will fire whenever the two nations are at war and any war goal exists, making the condition too permissive.
  2. Confusing scope direction: This trigger checks whether the "current scope country holds a war goal against target," not the reverse. Newcomers often set target to their own country or call the trigger in the wrong scope (such as STATE scope), causing the condition to never activate. Always ensure the outer scope is COUNTRY and that target points to the attacked nation.