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
}

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.