Wiki

trigger · has_template_containing_unit

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check if country has a division template that contains a specific unit

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_containing_unit is commonly used to check whether a country has created a division template containing a specific unit type (such as tank companies or engineer squads), enabling corresponding tech recommendations, focus unlocks, or AI behavior branching. For example, when the player first adds heavy tank companies to a template, it can automatically trigger decisions or events related to armored warfare.

# Unlock specific decisions when the player has a division template containing heavy tank companies
available = {
    has_template_containing_unit = {
        unit = heavy_armor
    }
}

Synergy

  • [has_army_size](/wiki/trigger/has_army_size): First use has_army_size to confirm the country has deployed a sufficient number of divisions, then use this trigger to verify whether those divisions contain the specified unit type. Together they allow precise checks on whether armored forces meet size requirements.
  • [any_country_division](/wiki/trigger/any_country_division): Can be used in conjunction within the subscope of any_country_division to check deployed divisions rather than templates, complementing this trigger to cover both "template exists" and "unit deployed" scenarios.
  • [add_tech_bonus](/wiki/effect/add_tech_bonus): After confirming the template contains the target unit type, use add_tech_bonus to grant related technology research bonuses, forming a "have equipment → reward research" logic loop.
  • [division_template](/wiki/effect/division_template): When conditions are not met, use division_template directly in the effect block to create templates with specified unit types for AI countries, forming a "detect → build" pairing with this trigger.

Common Pitfalls

  1. Incorrect unit type names: The unit field must contain the internal code name (such as heavy_armor, engineer), not the localized display name or division template name. Misspellings won't produce an error but will silently cause the condition to always evaluate false, making them extremely difficult to debug.
  2. Confusing template definitions with deployed units: This trigger only checks whether the unit type exists in the template definition. Even if there are no actual divisions using that template deployed on the map, the condition returns true as long as the unit company/squad exists in the template itself. Do not confuse this with actual deployment quantities.