Wiki

trigger · has_defensive_war_with

Definition

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

Description

One country has defensive war against other country.

实战 · 配合 · 坑

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

实战用法

此 trigger 常用于防御战争相关的事件或决策场景,例如为正在被侵略的国家解锁特殊援助选项、激活抵抗加成 idea,或触发"本土保卫战"类型的剧本事件。下面示例展示一个决策:仅当本国处于针对特定敌国的防御战争时才可用。

available = {
    has_defensive_war_with = FROM
}

也可在事件触发条件中使用,判断玩家国家是否正被某目标国侵略:

trigger = {
    has_defensive_war_with = ROOT
}

配合关系

  • [has_defensive_war](/wiki/trigger/has_defensive_war)has_defensive_war 只判断"是否存在任何防御战争",而 has_defensive_war_with 精确到对手国家,两者常嵌套或并列使用,先粗筛再精确锁定目标。
  • [any_enemy_country](/wiki/trigger/any_enemy_country):可在 any_enemy_country 的子条件中配合使用,遍历敌国并用 has_defensive_war_with 筛选出真正的攻击方,逻辑更严谨。
  • [has_war_goal_against](/wiki/trigger/has_war_goal_against) (见下注)[can_declare_war_on](/wiki/trigger/can_declare_war_on):配合后者可在 AI 策略或决策中区分"防御中"与"可宣战"两种互斥状态,避免逻辑冲突。
  • [add_ideas](/wiki/effect/add_ideas):当条件满足时添加"全国动员"类 idea,赋予防御方战时加成,是最典型的 effect 配合方式。

常见坑

  1. scope 方向混淆:trigger 的执行 scope 必须是其中一方(Country A),而填入的 target 是另一方(Country B),含义是"A 对 B 拥有防御战争"。新手容易把双方搞反,导致条件始终不触发——务必确认"谁在 scope 里、谁是参数"。
  2. target 写错标签格式:target 只接受 THIS/ROOT/PREV/FROM/OWNER 等动态 scope 关键词,不能直接写国家 tag 字符串(如 GER),否则脚本解析会静默失败,条件永远为假。

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

This trigger is commonly used in defensive war-related events or decision scenarios, such as unlocking special aid options for invaded nations, activating resistance bonus ideas, or triggering "homeland defense" type scripted events. The example below shows a decision that is only available when your country is in a defensive war against a specific enemy.

available = {
    has_defensive_war_with = FROM
}

It can also be used in event trigger conditions to check whether the player's nation is being invaded by a target nation:

trigger = {
    has_defensive_war_with = ROOT
}

Synergy

  • [has_defensive_war](/wiki/trigger/has_defensive_war): has_defensive_war only checks "whether any defensive war exists", while has_defensive_war_with pinpoints the opposing nation. Both are often nested or used in parallel—first coarse filtering, then precise target identification.
  • [any_enemy_country](/wiki/trigger/any_enemy_country): Can be used within any_enemy_country subscopes to iterate through enemy nations and filter actual attackers with has_defensive_war_with, providing more rigorous logic.
  • [has_war_goal_against](/wiki/trigger/has_war_goal_against) (see note below) / [can_declare_war_on](/wiki/trigger/can_declare_war_on): When combined, these allow distinguishing between "currently defending" and "can declare war" as mutually exclusive states in AI strategies or decisions, avoiding logical conflicts.
  • [add_ideas](/wiki/effect/add_ideas): When conditions are met, adds "full mobilization" type ideas to grant the defending nation wartime bonuses—the most typical effect synergy.

Common Pitfalls

  1. Scope direction confusion: The trigger's execution scope must be one party (Country A), while the filled target is the other party (Country B). The meaning is "A has a defensive war against B". Beginners often reverse the two sides, causing the condition to never trigger—always confirm "who is in scope and who is the parameter".
  2. Target tag format error: The target only accepts dynamic scope keywords like THIS/ROOT/PREV/FROM/OWNER, and cannot directly write nation tag strings (e.g., GER). Otherwise the script parsing will silently fail and the condition will always be false.