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.

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.