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
has_template_containing_unitCOUNTRYnonecheck if country has a division template that contains a specific unit
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
has_template_containing_unit 常用于判断某国是否已组建含有特定兵种(如坦克营、工兵连)的师级模板,从而触发对应的科技建议、国策解锁或 AI 行为分支。例如,当玩家首次将重型坦克营加入模板时,自动弹出装甲化战争相关的决议或事件。
# 当玩家拥有包含重型坦克营的师模板时,解锁特定决议
available = {
has_template_containing_unit = {
unit = heavy_armor
}
}
[has_army_size](/wiki/trigger/has_army_size):先用 has_army_size 确认国家部署了足够数量的师,再用本 trigger 验证这些师是否包含指定兵种,两者结合可精准检查装甲部队规模是否达标。[any_country_division](/wiki/trigger/any_country_division):可在 any_country_division 的子作用域中配合使用,用于检查实际下场的师而非模板,与本 trigger 互补覆盖"模板存在"与"单位已部署"两种场景。[add_tech_bonus](/wiki/effect/add_tech_bonus):确认模板中含有目标兵种后,通过 add_tech_bonus 给予相关技术研发加成,形成"有装备→奖励研发"的逻辑闭环。[division_template](/wiki/effect/division_template):当条件不满足时,可在 effect 块里用 division_template 直接为 AI 国家创建含指定兵种的模板,与本 trigger 形成"检测→补建"配对。unit 字段必须填写内部代码名(如 heavy_armor、engineer),而非本地化显示名称或师模板名,填错时游戏不会报错但条件永远为假,非常难以排查。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.
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
}
}
[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.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.