Wiki

trigger · has_template_ai_majority_unit

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check if country has a division template that is majority of specific unit using AI's priorities rather than visual

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

此 trigger 常用于 AI 行为调整类 mod 中,当需要判断某国是否已形成以特定兵种(如装甲、炮兵)为主力的师团模板时触发后续策略。与普通视觉判断不同,它使用 AI 内部的优先级权重来计算"主力兵种",因此更适合用在 AI 决策路径、顾问激活条件等对 AI 逻辑敏感的场景。

# 示例:若某国 AI 判定已拥有以装甲为主的师团模板,则激活对应顾问
advisor_activation_trigger = {
    has_template_ai_majority_unit = {
        unit_type = armor
    }
}

配合关系

  • [ai_has_role_template](/wiki/trigger/ai_has_role_template):两者都是针对师团模板的 AI 层面判断,常组合使用以双重确认 AI 的师团构成方向是否符合预期策略分支。
  • [ai_has_role_division](/wiki/trigger/ai_has_role_division):在确认模板存在后,进一步检查 AI 是否已实际部署了该角色的师团,形成"模板→部署"的完整验证链。
  • [add_ai_strategy](/wiki/effect/add_ai_strategy):当 trigger 条件满足时,通过此 effect 追加或强化 AI 的战略倾向,使 AI 顺势扩充已被识别的主力兵种。
  • [add_tech_bonus](/wiki/effect/add_tech_bonus):确认 AI 已以某兵种为主力后,给予对应科技加成,引导 AI 沿着该兵种路线深化发展。

常见坑

  1. 误以为与视觉呈现一致:该 trigger 使用 AI 的内部优先级权重而非编辑器中肉眼可见的兵种占比来判断,在人类玩家的师团模板上可能得到与直觉不符的结果,不应将其用于面向玩家的 UI 或事件条件。
  2. scope 混用:此 trigger 仅在 COUNTRY scope 下有效,新手容易在 STATE 或 CHARACTER scope 的 limit 块中误用,导致脚本报错或永远返回假而难以排查。

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

This trigger is commonly used in AI behavior adjustment mods. It fires when you need to determine whether a nation has formed division templates with a specific unit type (such as armor or artillery) as the backbone force, then trigger subsequent strategies. Unlike simple visual inspection, it uses the AI's internal priority weights to calculate the "backbone unit type," making it more suitable for scenarios sensitive to AI logic such as AI decision paths and advisor activation conditions.

# Example: If a nation's AI determines it already possesses division templates with armor as the backbone, activate the corresponding advisor
advisor_activation_trigger = {
    has_template_ai_majority_unit = {
        unit_type = armor
    }
}

Synergy

  • [ai_has_role_template](/wiki/trigger/ai_has_role_template): Both are AI-level judgments targeting division templates and are often combined to double-confirm whether the AI's division composition aligns with the expected strategy branch.
  • [ai_has_role_division](/wiki/trigger/ai_has_role_division): After confirming the template exists, further check whether the AI has actually deployed divisions of that role, forming a complete verification chain of "template → deployment."
  • [add_ai_strategy](/wiki/effect/add_ai_strategy): When the trigger condition is satisfied, use this effect to append or reinforce the AI's strategic inclination, allowing the AI to expand the backbone unit type that has been identified.
  • [add_tech_bonus](/wiki/effect/add_tech_bonus): After confirming the AI has adopted a certain unit type as its backbone, grant corresponding tech bonuses to guide the AI to deepen development along that unit type line.

Common Pitfalls

  1. Mistakenly assuming consistency with visual presentation: This trigger uses the AI's internal priority weights rather than the unit type ratios visible to the naked eye in the editor, and may produce results inconsistent with intuition on human player division templates. It should not be used in player-facing UI or event conditions.
  2. Mixing scopes: This trigger is only valid under COUNTRY scope. Beginners often misuse it in limit blocks under STATE or CHARACTER scopes, causing script errors or perpetually returning false, making it difficult to debug.