Wiki

trigger · has_license

Definition

  • Supported scope:COUNTRY
  • Supported target:any

Description

Country has specific active license
Example: has_license = {
	from = TAG # has license from this country, optional
	 #if archetype is specified equipment should not be specified
	archetype = light_tank_chassis #any light tank chassis license
	equipment = { # classical equipment reference
		type = light_tank_equipment_2
		version = 0 # optional: omit to match any version of the type
	}
}

实战 · 配合 · 坑

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

实战用法

has_license 常用于判断某国是否已从其他国家获得特定装备的生产授权,从而解锁专属决策、国策或科研奖励。例如在二战 mod 中,可以检测某小国是否拥有德国坦克的生产许可,进而允许其建造特定的装甲师模板或触发外交事件。

# 只有在持有轴心国坦克授权时,才允许执行该决策
available = {
    has_license = {
        from = GER
        archetype = medium_tank_equipment
    }
}

配合关系

  • [has_any_license](/wiki/trigger/has_any_license):当不关心具体来源国或型号、只需判断"是否持有任何授权"时,与 has_license 互为精粗两档搭配使用。
  • [create_production_license](/wiki/effect/create_production_license):通常在 effect 块中用该命令授予许可,随后在 trigger 块中用 has_license 验证是否授予成功,形成"给予—检测"闭环。
  • [has_design_based_on](/wiki/trigger/has_design_based_on):与 has_license 配合可区分"拥有授权"与"已基于授权设计了变体"这两个不同阶段,避免逻辑混淆。
  • [any_purchase_contract](/wiki/trigger/any_purchase_contract):区分"生产授权"与"采购合同"两种不同的装备获取方式,在复杂军贸 mod 中常需同时检测两者。

常见坑

  1. archetypeequipment 不能同时使用:官方定义明确说明二者互斥,若同时填写则脚本行为未定义,新手容易误以为可以叠加过滤,实际上应根据需要二选一。
  2. 省略 from 不等于匹配所有来源:省略 from 字段时会匹配来自任意国家的授权,但若误将 from 写成自身 TAG,则永远无法满足条件(国家不能向自己颁发授权),导致条件始终为假。

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_license is commonly used to check whether a nation has obtained production licenses for specific equipment from other countries, thereby unlocking exclusive decisions, focus trees, or research bonuses. For example, in WWII-themed mods, you can detect whether a minor nation possesses a German tank production license, and subsequently allow it to construct specific armor divisions or trigger diplomatic events.

# Only permit this decision to execute if the Axis tank license is held
available = {
    has_license = {
        from = GER
        archetype = medium_tank_equipment
    }
}

Synergy

  • [has_any_license](/wiki/trigger/has_any_license): When the source nation or specific model variant is irrelevant and you only need to check "whether any license exists," use this alongside has_license as a coarse/fine filtering pair.
  • [create_production_license](/wiki/effect/create_production_license): Typically grant licenses using this command in effect blocks, then verify successful granting with has_license in trigger blocks, forming a "grant–verify" closed loop.
  • [has_design_based_on](/wiki/trigger/has_design_based_on): Combine with has_license to distinguish between "possessing a license" and "already designed a variant based on the license," preventing logical confusion between these two distinct stages.
  • [any_purchase_contract](/wiki/trigger/any_purchase_contract): Differentiate between "production license" and "procurement contract" as two separate equipment acquisition methods; complex arms trade mods often require checking both simultaneously.

Common Pitfalls

  1. archetype and equipment cannot be used simultaneously: The official specification clearly states they are mutually exclusive; using both results in undefined script behavior. Beginners often mistakenly believe they can stack filters, but in reality you must choose one based on your needs.
  2. Omitting from does not mean matching all sources: When the from field is omitted, it matches licenses from any nation. However, if you mistakenly write from with your own TAG, the condition will never be satisfied (a nation cannot issue itself a license), causing the condition to always evaluate false.