Wiki

trigger · has_defensive_war

Definition

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

Description

is country at defensive war

实战 · 配合 · 坑

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

实战用法

has_defensive_war 常用于国策、决议或事件中,判断本国是否正在遭受他国主动发起的战争,从而触发特定的防御性加成或外交援助选项。例如在一个"抵抗侵略"主题的 mod 中,只有当玩家处于防御战状态时才能激活某些紧急动员决议:

# 在决议的 available 块中
available = {
    has_defensive_war = yes
    has_war_support > 0.3
}

配合关系

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):在确认处于防御战之后,进一步缩小范围至特定交战国,常与本 trigger 嵌套使用以精确匹配场景。
  • [any_enemy_country](/wiki/trigger/any_enemy_country):遍历所有交战敌国,与 has_defensive_war 组合可确认防御战背景下敌方是否满足额外条件(如意识形态、规模等)。
  • [add_ideas](/wiki/effect/add_ideas):在防御战触发的事件或决议中,给予本国紧急动员类国策思潮,是防御战判断后最常见的奖励效果。
  • [add_war_support](/wiki/effect/add_war_support):防御战往往伴随战争意志的动态调整,通过本 trigger 限定只在防御状态下才执行战争意志加成,避免逻辑错误。

常见坑

  1. 与攻击战混淆has_defensive_war 仅在本国被宣战(即作为防御方)时返回真,若本国同时存在主动宣战的进攻战,该 trigger 依然可能为真——新手常误以为"处于防御战"就等于"没有任何攻击性战争目标",实际两者并不互斥,需要结合 has_annex_war_goal 等 trigger 做额外排除。
  2. scope 指向错误:该 trigger 只能用于 COUNTRY scope,若误放在 state 或 character 相关的 scope 下(如 any_owned_state 的 limit 块内层忘记切回国家 scope),会导致脚本报错或静默失效,调试时需仔细检查当前 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_defensive_war is commonly used in national focuses, decisions, or events to determine whether your country is currently under attack from another nation's offensive war declaration, thereby triggering specific defensive bonuses or diplomatic aid options. For example, in a mod centered on "resisting aggression," certain emergency mobilization decisions can only be activated when the player is in a defensive war state:

# In the available block of a decision
available = {
    has_defensive_war = yes
    has_war_support > 0.3
}

Synergy

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): After confirming you are in a defensive war, further narrows the scope to a specific enemy nation; commonly nested with this trigger for precise scenario matching.
  • [any_enemy_country](/wiki/trigger/any_enemy_country): Iterates through all enemy nations at war; combined with has_defensive_war, it can verify whether enemies meet additional conditions (such as ideology, military strength, etc.) within the defensive war context.
  • [add_ideas](/wiki/effect/add_ideas): In events or decisions triggered by defensive war, grants your nation emergency mobilization-themed national spirit ideas; this is the most common reward effect following has_defensive_war checks.
  • [add_war_support](/wiki/effect/add_war_support): Defensive wars often involve dynamic adjustments to war support; using this trigger to restrict war support increases to defensive states only prevents logic errors and ensures correct execution.

Common Pitfalls

  1. Confusion with offensive wars: has_defensive_war returns true only when your nation is declared upon (i.e., as the defending side). Even if your nation simultaneously has offensive wars from your own declarations, this trigger can still evaluate to true—beginners often mistakenly believe "in a defensive war" means "has no offensive war goals whatsoever," but these are not mutually exclusive. You must combine this with additional triggers like has_annex_war_goal to properly exclude unwanted cases.
  2. Incorrect scope targeting: This trigger only works under COUNTRY scope. If mistakenly placed in a state or character-related scope (such as forgetting to switch back to country scope within a limit block inside any_owned_state), it will cause script errors or silent failures. Careful scope hierarchy inspection is essential during debugging.