命令百科

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) 确认国家存在,再执行创建。