trigger · has_template
Definition
- Supported scope:
COUNTRY - Supported target:
none
Description
Check if country has a division template of specific name
has_templateCOUNTRYnoneCheck if country has a division template of specific name
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
has_template 常用于检查某国是否已建立特定编制的师模板,适合在国策、决策或 AI 策略中作为前置条件,例如判断玩家是否完成了装甲师或精锐步兵师的编制准备。典型场景包括:只有当国家拥有某个模板时才解锁后续决策,或用于 AI 行为判断。
# 决策的 available 块:只有建立了"装甲师"模板才可触发
available = {
has_template = "装甲师"
}
[has_army_size](/wiki/trigger/has_army_size):先用 has_template 确认模板存在,再用此 trigger 检查实际部署的兵力数量,两者配合形成完整的军事准备判断。[any_country_division](/wiki/trigger/any_country_division):has_template 只验证模板存在,any_country_division 可进一步核查该模板是否已有实际部队在场上运行。[division_template](/wiki/effect/division_template):在 effect 块中用于动态创建或修改师模板,通常在 has_template 判断为假时才执行,避免重复创建同名模板。[delete_unit_template_and_units](/wiki/effect/delete_unit_template_and_units):需要替换旧模板时,先用 has_template 确认目标模板存在,再用此 effect 安全删除,防止删除不存在模板导致报错。"Armored Division" 和 "armored division" 会被视为不同模板,建议直接复制游戏内或脚本中定义的原始名称。has_template 只在 COUNTRY scope 下有效,若误写在 STATE 或 CHARACTER scope 内,触发器不会报错但会始终返回假,排查时容易忽略。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 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"
}
[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."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.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.