Wiki

effect · create_unit

Definition

  • Supported scope:any
  • Supported target:none

Description

Create unit effect, just like in OOB, example: 
create_unit = { 
	# unit detauls 
	division = "name = \"1. Northern Redemption Army\" division_template = \"Redemption Army\" start_experience_factor = 0.5" 
	# country to spawn unit for 
	owner = MAN 
	 
	 
	# a prov id can be specified 
	prioritize_location = 12406 
	 
	# can be set to yes to be able to spawn units on enemy provs. 
	allow_spawning_on_enemy_provs = no 
	# province controllers can be scored using this scorer. otherwise it will prio your owned provs first, friendly provs second.  
	# it will also prio provs with scores and less units firstl 
	country_score = { 
		base = 100 
		 
		modifier = { 
			tag = MAN 
			add = 100 
		} 
	} 
   count = 1 # can be specified to spawn more than one units 
   id = 42 # an id can be given to delete units later on   divisional_commander_xp = 4 # give the division commander experience on unit creation }

实战 · 配合 · 坑

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

实战用法

create_unit 常用于剧情事件、国策完成后为某国生成历史感部队,例如在国策链末尾为玩家凭空生成一支精锐师,或在事件触发时为 AI 国家增援前线。配合 prioritize_location 可将部队尽量投放到指定省份,适合演绎特定战役的开局局面。

# 国策完成后为满洲国生成一支精锐步兵师
MAN = {
    create_unit = {
        division = "name = \"关东守备第一师\" division_template = \"Infantry Division\" start_experience_factor = 0.3"
        owner = MAN
        prioritize_location = 12406
        allow_spawning_on_enemy_provs = no
        count = 1
        divisional_commander_xp = 2
    }
}

配合关系

  • [hidden_effect](/wiki/effect/hidden_effect):将 create_unit 包裹在隐藏块中,避免生成部队时在事件界面弹出无关提示,保持叙事干净。
  • [damage_units](/wiki/effect/damage_units):先用 create_unit 生成部队,再用 damage_units 模拟该部队已经历过苦战、残缺上阵的剧情效果。
  • [save_event_target_as](/wiki/effect/save_event_target_as):在生成前保存目标国家为事件目标,确保 owner 字段指向正确的动态国家,尤其在多国联动脚本中至关重要。
  • [any_state](/wiki/trigger/any_state):在触发条件层判断某省份归属或存在性,确认满足条件后再执行 create_unit,防止部队生成在无效位置。

常见坑

  1. division 字段的模板名必须与目标国家已有的师团模板完全一致(大小写、空格均不能有误),否则游戏会静默失败——不报错但部队根本不会生成,新手常因此以为脚本没执行。
  2. 忘记指定 ownerowner 所指国家当前不存在,会导致部队归属混乱或直接报错;在动态国家脚本中应先用 [country_exists](/wiki/trigger/country_exists) 确认国家存在,再执行创建。

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

create_unit is commonly used in scripted events and national focus trees to spawn historically-themed units for a nation upon completion—for example, generating an elite division out of thin air at the end of a focus chain for the player, or reinforcing an AI nation's frontline when an event triggers. Combined with prioritize_location, units can be deployed preferentially to a specified province, making it ideal for recreating the opening setup of a particular campaign scenario.

# Spawn an elite infantry division for Manchukuo upon focus completion
MAN = {
    create_unit = {
        division = "name = \"关東守備第一師\" division_template = \"Infantry Division\" start_experience_factor = 0.3"
        owner = MAN
        prioritize_location = 12406
        allow_spawning_on_enemy_provs = no
        count = 1
        divisional_commander_xp = 2
    }
}

Synergy

  • [hidden_effect](/wiki/effect/hidden_effect): Wrap create_unit inside a hidden block to suppress irrelevant notifications in the event interface when units spawn, keeping the narrative clean.
  • [damage_units](/wiki/effect/damage_units): First spawn units with create_unit, then apply damage_units to simulate the narrative effect of those units having already endured bitter combat and entering the field depleted.
  • [save_event_target_as](/wiki/effect/save_event_target_as): Save the target nation as an event target before spawning to ensure the owner field points to the correct dynamic nation—especially critical in multi-nation coordinated scripts.
  • [any_state](/wiki/trigger/any_state): Check province ownership or existence at the trigger condition level to confirm the precondition is met before executing create_unit, preventing units from spawning in invalid locations.

Common Pitfalls

  1. The division template name in the division field must exactly match an existing division template for the target nation (case and spacing must be perfect), otherwise the game fails silently—no error is thrown, but the unit simply won't spawn. Newcomers often mistake this for the script not executing at all.
  2. Omitting owner or specifying a country that no longer exists causes unit ownership confusion or direct errors. In dynamic nation scripts, always use [country_exists](/wiki/trigger/country_exists) to confirm the nation exists before executing the creation command.