Wiki

trigger · has_template

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Check if country has a division template of specific name

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_template is commonly used to check whether a country has established a division template of a specific type. It serves as a prerequisite condition in national focuses, decisions, or AI strategies—for example, determining whether the player has completed preparation of an armored division or elite infantry division template. Typical scenarios include unlocking subsequent decisions only when a country possesses a certain template, or using it for AI behavior evaluation.

# Available block in a decision: only trigger if an "Armored Division" template exists
available = {
    has_template = "Armored Division"
}

Synergy

  • [has_army_size](/wiki/trigger/has_army_size): First use has_template to confirm the template exists, then apply this trigger to check the actual deployed troop count. Together they form a complete military readiness assessment.
  • [any_country_division](/wiki/trigger/any_country_division): has_template only verifies template existence, while any_country_division can further verify whether that template already has active units deployed on the map.
  • [division_template](/wiki/effect/division_template): Used in effect blocks to dynamically create or modify division templates. Typically execute this only when has_template evaluates to false, avoiding duplicate creation of same-named templates.
  • [delete_unit_template_and_units](/wiki/effect/delete_unit_template_and_units): When replacing an old template, first confirm the target template exists with has_template, then safely delete it with this effect to prevent errors from deleting non-existent templates.

Common Pitfalls

  1. Template name case and spacing must match exactly: The game performs exact string matching on template names, so "Armored Division" and "armored division" are treated as different templates. It is recommended to copy the original name directly as defined in-game or in scripts.
  2. Scope confusion causes silent failure: has_template is only valid under COUNTRY scope. If mistakenly written within STATE or CHARACTER scope, the trigger will not error but will always return false, making it easy to overlook during debugging.