Wiki

trigger · has_wargoal_against

Definition

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

Description

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

实战 · 配合 · 坑

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

实战用法

has_wargoal_against 常用于判断某国是否已经对目标国家宣告了战争目标,从而控制决策或焦点的可用条件——例如"只有当玩家已对目标国拥有特定战争目标时,才允许触发后续外交事件或强化战争选项"。在多路线 mod 中也常用于互斥判断,防止玩家重复添加相同性质的战争目标。

# 只有当本国已对德国持有夺取州省类战争目标时,决策才可用
available = {
    has_wargoal_against = {
        target = GER
        type = take_state
    }
}

配合关系

  • [create_wargoal](/wiki/effect/create_wargoal):最直接的搭档,先用 has_wargoal_against 检查战争目标是否存在,不存在时才执行 create_wargoal,避免重复创建。
  • [declare_war_on](/wiki/effect/declare_war_on):通常在确认已有战争目标后再触发宣战 effect,逻辑上保持"先有目标再宣战"的顺序。
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):两者配合可以区分"我主动持有战争目标"与"我处于防御战"两种战争状态,用于编写更精细的条件分支。
  • [any_enemy_country](/wiki/trigger/any_enemy_country):与 has_wargoal_against 组合可以遍历当前敌国并检查是否对特定敌国持有指定类型战争目标,适合多目标国场景。

常见坑

  1. 混淆"有战争目标"与"处于交战状态"has_wargoal_against 只检查是否存在战争目标,即使尚未宣战也会返回真;新手常误以为它等同于"正在与该国交战",需要额外配合 [has_defensive_war_with](/wiki/trigger/has_defensive_war_with) 或其他交战状态 trigger 才能准确判断。
  2. target 填写了不支持的 scope 关键字target 字段只接受白名单内的 scope 指向(如 THISROOTFROM 等)或具体国家 tag,直接写省份或州省 ID 会导致脚本报错或条件永远不成立,务必确认填入的是合法的国家 scope。

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_wargoal_against is commonly used to check whether a nation has already declared a war goal against a target nation, allowing you to control the availability of decisions or focuses—for example, "only allow subsequent diplomatic events or war escalation options to trigger if the player already holds a specific war goal against the target nation." In multi-path mods, it's also frequently used for mutual exclusion checks to prevent players from repeatedly adding war goals of the same type.

# Decision is only available if this nation holds a "take state" type war goal against Germany
available = {
    has_wargoal_against = {
        target = GER
        type = take_state
    }
}

Synergy

  • [create_wargoal](/wiki/effect/create_wargoal): The most direct companion effect. Use has_wargoal_against to check if the war goal exists first; only execute create_wargoal if it doesn't, avoiding duplicate creation.
  • [declare_war_on](/wiki/effect/declare_war_on): Typically triggered after confirming that a war goal already exists, maintaining the logical sequence of "establish goal before declaring war."
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): Combined together, these allow you to distinguish between "I actively hold a war goal" and "I am in a defensive war," enabling more granular conditional branching.
  • [any_enemy_country](/wiki/trigger/any_enemy_country): Pairing with has_wargoal_against allows you to iterate through current enemies and check whether you hold a specific type of war goal against each, suitable for multi-target scenarios.

Common Pitfalls

  1. Confusing "having a war goal" with "being in active combat": has_wargoal_against only checks whether a war goal exists; it returns true even if war hasn't been declared yet. Beginners often mistakenly treat it as equivalent to "currently at war with that nation," requiring additional use of [has_defensive_war_with](/wiki/trigger/has_defensive_war_with) or other war status triggers for accurate detection.
  2. Using unsupported scope keywords in the target field: The target field only accepts whitelisted scope references (such as THIS, ROOT, FROM, etc.) or concrete nation tags. Writing provinces or state IDs directly will cause script errors or the condition to never evaluate true. Always ensure the value you provide is a valid nation scope.