Wiki

effect · create_railway_gun

Definition

  • Supported scope:any
  • Supported target:none

Description

Create railway gun effect, just like in OOB, example:
create_railway_gun = {
	equipment = railway_gun_equipment_1
	name = "Created Railway Gun" #optional
	location = 12406 #optional, created in capital otherwise
}

实战 · 配合 · 坑

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

实战用法

create_railway_gun 常用于剧本事件、国策完成奖励或战役开场脚本中,为玩家或 AI 国家直接生成一辆铁路炮,无需依赖生产队列。例如在"秘密武器计划"国策完成时赠予部队:

focus = {
    id = GER_secret_railway_gun_program
    ...
    completion_reward = {
        create_railway_gun = {
            equipment = railway_gun_equipment_1
            name = "Dora"
            location = 9 # 柏林省份 ID
        }
    }
}

配合关系

  • [has_dlc](/wiki/trigger/has_dlc):铁路炮相关装备通常依赖特定 DLC,使用前判断 DLC 是否启用,避免脚本在缺少 DLC 的存档中报错。
  • [create_unit](/wiki/effect/create_unit):常与 create_unit 配合,同时生成铁路炮和护卫步兵师,构成完整的战斗序列。
  • [hidden_effect](/wiki/effect/hidden_effect):将 create_railway_gun 包裹在 hidden_effect 中,可静默执行(不显示游戏日志通知),适合 AI 刷兵逻辑。
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip):当铁路炮生成被藏在 hidden_effect 里时,搭配此命令向玩家显示可读的提示文本,保持界面友好。

常见坑

  1. 省份 ID 填写错误location 填的是省份(province)ID 而非州(state)ID,两者数值体系不同,填错会导致铁路炮生成在错误位置甚至报错崩溃;若省份不属于该国控制范围,炮也可能无法正常生成。
  2. 装备未解锁就生成equipment 指定的装备科技若尚未被目标国家研究,铁路炮仍会生成,但会出现装备不足(strength 为 0)的异常状态,应配合 [has_dlc](/wiki/trigger/has_dlc) 或变量检查提前做好条件过滤。

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_railway_gun is commonly used in scripted events, national focus completion rewards, or campaign opening scripts to directly spawn a railway gun for player or AI nations without relying on production queues. For example, when completing a "Secret Weapons Program" focus to grant units to a nation:

focus = {
    id = GER_secret_railway_gun_program
    ...
    completion_reward = {
        create_railway_gun = {
            equipment = railway_gun_equipment_1
            name = "Dora"
            location = 9 # Berlin province ID
        }
    }
}

Synergy

  • [has_dlc](/wiki/trigger/has_dlc): Railway gun-related equipment typically depends on specific DLCs. Check whether DLC is enabled before use to avoid script errors in saves lacking the required DLC.
  • [create_unit](/wiki/effect/create_unit): Often paired with create_unit to simultaneously spawn railway guns and escort infantry divisions, forming a complete combat formation.
  • [hidden_effect](/wiki/effect/hidden_effect): Wrapping create_railway_gun in hidden_effect allows silent execution (no game log notifications), suitable for AI reinforcement logic.
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip): When railway gun spawning is hidden within hidden_effect, pair this command with readable tooltip text displayed to the player, maintaining UI friendliness.

Common Pitfalls

  1. Incorrect province ID: The location field accepts province ID not state ID—these use different numerical systems. Entering the wrong one causes the railway gun to spawn at the wrong location or even crash; if the province is outside the nation's control range, the gun may fail to spawn properly.
  2. Spawning equipment before research: If the equipment technology specified in equipment has not yet been researched by the target nation, the railway gun still spawns but enters an abnormal state with zero strength. Use [has_dlc](/wiki/trigger/has_dlc) or variable checks beforehand to filter conditions properly.