trigger · ai_has_role_template
Definition
- Supported scope:
COUNTRY - Supported target:
none
Description
check if the ai controlled country has any template for a specific role
ai_has_role_templateCOUNTRYnonecheck if the ai controlled country has any template for a specific role
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
ai_has_role_template 常用于 AI 策略或决策的可用条件中,用来判断 AI 国家是否已经为某个特定作战角色(如坦克、步兵、海军陆战队)建立了对应师团模板,从而决定是否触发相应的生产或战略建议。例如,在 AI 策略脚本中,只有当 AI 已有适合某角色的模板时,才允许为其追加装备补贴决策。
# 在某个决策的 available 块中,确保 AI 已拥有对应角色模板再开放决策
available = {
ai_has_role_template = armor
}
[ai_has_role_division](/wiki/trigger/ai_has_role_division):两者同属 AI 部队能力检测系列,ai_has_role_division 检查 AI 是否已部署对应角色的师团,常与本 trigger 串联使用——先确认有模板,再确认有实际兵力。[ai_wants_divisions](/wiki/trigger/ai_wants_divisions):判断 AI 是否有意愿生产更多师团,与本 trigger 组合可构建"AI 既有模板、又有扩编意愿"的复合条件,防止策略在错误时机触发。[add_ai_strategy](/wiki/effect/add_ai_strategy):当确认 AI 已拥有对应角色模板后,通过该 effect 注入具体的 AI 战略指令,使两者形成"条件-执行"的完整逻辑闭环。[add_equipment_subsidy](/wiki/effect/add_equipment_subsidy):在 AI 已有角色模板的前提下,向其提供装备补贴以加速该角色部队的实际建立,常见于联盟辅助或宗主国扶植脚本。armor、infantry、marine 等),直接填写师团模板名称或自定义字符串将导致条件永远不成立,且不会报错,极难排查。is_ai = yes 前置保护),在玩家接管该国后条件行为可能不符合预期,建议始终搭配 is_ai = yes 一同使用。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.
ai_has_role_template is commonly used in AI strategy or decision availability conditions to check whether an AI nation has established a corresponding division template for a specific combat role (such as armor, infantry, or marines). This determines whether to trigger related production or strategic recommendations. For example, in an AI strategy script, a decision to provide equipment subsidies may only be available once the AI has an appropriate template for that role.
# In the available block of a decision, ensure the AI possesses the corresponding role template before enabling the decision
available = {
ai_has_role_template = armor
}
[ai_has_role_division](/wiki/trigger/ai_has_role_division): Both belong to the AI unit capability detection series. ai_has_role_division checks whether the AI has already deployed divisions of a corresponding role, and is commonly chained with this trigger—first confirm the template exists, then confirm actual forces are deployed.[ai_wants_divisions](/wiki/trigger/ai_wants_divisions): Determines whether the AI intends to produce more divisions. Combined with this trigger, it constructs a composite condition of "AI has both the template and expansion intent," preventing strategies from triggering at the wrong moment.[add_ai_strategy](/wiki/effect/add_ai_strategy): After confirming the AI possesses the corresponding role template, inject specific AI strategy directives through this effect, forming a complete "condition-execution" logical loop with this trigger.[add_equipment_subsidy](/wiki/effect/add_equipment_subsidy): Provide equipment subsidies to the AI when it already has role templates, accelerating the actual formation of that role's forces. Commonly seen in alliance support or overlord nation development scripts.armor, infantry, marine, etc.). Directly entering a division template name or custom string will cause the condition to never evaluate as true and produce no error, making it extremely difficult to debug.is_ai = yes protection), the condition's behavior after the player assumes control may not work as expected. It is recommended to always pair this trigger with is_ai = yes.