Wiki

trigger · has_war_with

Definition

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

Description

is countries at war

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 is commonly used to determine whether two countries are at war, thereby controlling whether certain event options, decisions, or focuses are available—for example, disabling diplomatic options during wartime or triggering peace events after war concludes. It is also frequently used in AI strategy logic to check whether allies are engaged in conflict with a specific country to decide whether to join the war.

# Example: This decision is only available when at war with Germany
available = {
    has_war_with = GER
}

Synergy

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): Using this together allows further distinction between whether the current war is defensive or offensive in nature, useful for providing special bonuses to the defender or triggering exclusive events.
  • [any_enemy_country](/wiki/trigger/any_enemy_country): When you need to check "is at war with any country meeting certain conditions," pairing any_enemy_country with internal conditions is more flexible and concise than writing multiple has_war_with statements.
  • [declare_war_on](/wiki/effect/declare_war_on): Common practice is to first use has_war_with in a limit clause to exclude countries already at war, preventing duplicate war declarations that could cause script errors or logic confusion.
  • [exists](/wiki/trigger/exists): It is best to confirm the target country still exists before checking war status, otherwise evaluating this trigger against an eliminated country may produce unexpected results.

Common Pitfalls

  1. Scope and target confusion: The scope for has_war_with is COUNTRY and must be called within a country scope. Beginners sometimes write this trigger directly in a state scope or unit leader scope, causing parsing errors or silent failures. You must first switch to country scope using OWNER or similar.
  2. Misunderstanding bidirectional relationships: This trigger checks whether both parties are in the same war, not the unidirectional direction of war declaration. Therefore, you do not need to write it once for each side—if A has_war_with B is true, then B has_war_with A is also true. Duplicate coding results in logical redundancy.