Wiki

trigger · has_template_majority_unit

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check if country has a division template that is majority of specific unit

实战 · 配合 · 坑

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

实战用法

has_template_majority_unit 常用于根据国家现有师团模板的主力兵种来触发特定事件或决议,例如判断某国是否以装甲单位为主力从而解锁坦克强化相关的国策或决策。也可用于 AI 战略限制中,确认国家已完成特定兵种建设方向后再允许执行后续指令。

# 在某个决策的 available 块中,判断国家是否拥有以装甲单位为主力的模板
available = {
    has_template_majority_unit = {
        unit = 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):当本 trigger 返回真(国家确实以某兵种为主)时,在 effect 块中给予对应兵种的科研加成,形成"侦测兵种路线 → 奖励专精方向"的完整逻辑链。
  • [ai_has_role_template](/wiki/trigger/ai_has_role_template):同样是针对师团模板的判断 trigger,可与本 trigger 并列,一个判断 AI 模板角色,一个判断模板内兵种占比,组合使用避免条件过于宽松。

常见坑

  1. 混淆"模板主力"与"全国部队主力":本 trigger 检查的是师团模板层面的兵种占比,而非全国所有已部署师团的兵种统计,新手常误以为只要国家装备了大量某兵种装备就会返回真,实际上必须存在一个对应兵种占多数的模板定义才会触发。
  2. 忘记该 trigger 只在 COUNTRY scope 下有效:若将其嵌套在 STATE 或 CHARACTER scope 的条件块中使用,脚本不会报硬错误但逻辑永远不会生效,排查时容易忽略 scope 问题。

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_majority_unit is commonly used to trigger specific events or decisions based on the primary unit type in a nation's existing division templates. For example, you can check whether a country primarily deploys armor units to unlock tank-related focuses or decisions. It can also be used in AI strategy constraints to confirm that a nation has completed a specific unit composition direction before allowing subsequent commands to execute.

# In the available block of a decision, check if the country has a template with armor as the majority unit type
available = {
    has_template_majority_unit = {
        unit = armor
    }
}

Synergy

  • [has_army_size](/wiki/trigger/has_army_size): First use has_army_size to confirm the country possesses a sufficient number of troops, then use this trigger to evaluate the unit type composition of those troops. Combining both provides a more precise assessment of military capability direction.
  • [any_country_division](/wiki/trigger/any_country_division): Can be used together in the same condition block. any_country_division performs detailed checks on whether specific divisions meet certain attributes, complementing this trigger with both macro and micro perspectives.
  • [add_tech_bonus](/wiki/effect/add_tech_bonus): When this trigger returns true (the country indeed has a certain unit type as primary), grant corresponding tech bonuses for that unit type in the effect block, forming a complete logical chain of "detect unit composition → reward specialization direction".
  • [ai_has_role_template](/wiki/trigger/ai_has_role_template): Also a template-focused judgment trigger that can be used alongside this one. One evaluates AI template roles while the other checks unit type proportions within templates, combining them prevents conditions from becoming too permissive.

Common Pitfalls

  1. Confusing "template primary unit" with "national fleet primary unit": This trigger checks unit type proportions at the division template level, not statistics across all deployed divisions nationwide. Beginners often mistakenly assume that equipping the nation with large quantities of a certain unit type will return true, but in reality a template definition with that unit type as the majority must exist for the trigger to fire.
  2. Forgetting this trigger only works under COUNTRY scope: If nested within condition blocks under STATE or CHARACTER scope, the script will not produce a hard error but the logic will never execute. When debugging, scope issues are easily overlooked.