Wiki

effect · create_dynamic_country

Definition

  • Supported scope:any
  • Supported target:any

Description

creates a dynamic country and runs child effects on it. example :
create_dynamic_country = { 
  original_tag = ITA #original tag of new country
  copy_tag = ITA # if set, it will copy stuff from copy tag instead of original_tag
 #...effects to run on new country}

实战 · 配合 · 坑

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

实战用法

create_dynamic_country 常用于 mod 中在游戏进行中动态生成一个全新的傀儡国、分裂国或特殊剧情国家,而无需在历史文件中预先定义该标签。例如在内战事件或分裂剧情中,可以基于原有国家(original_tag)复制基础数据,再立即在子块中执行一系列初始化效果(设定首都、给予省份、设置政府等)。

# 意大利内战:动态创建北意大利分裂政权
create_dynamic_country = {
    original_tag = ITA
    copy_tag = ITA
    set_capital = 516          # 米兰省
    transfer_state = 159
    transfer_state = 160
    set_politics = {
        ruling_party = communism
        elections_allowed = no
    }
    save_event_target_as = north_italy_breakaway
}

配合关系

  • [save_event_target_as](/wiki/effect/save_event_target_as) — 在子块内立即将新生成的动态国家保存为事件目标,方便后续其他事件或效果通过目标引用它,否则动态国家创建后将难以再次精确定位。
  • [hidden_effect](/wiki/effect/hidden_effect) — 将 create_dynamic_country 包裹在隐藏效果块中,避免玩家界面出现不必要的提示信息,适合在幕后静默初始化国家。
  • [every_country](/wiki/effect/every_country) — 创建完成后,用 every_country 遍历所有国家,对新动态国家的外交关系(如宣战理由、阵营关系)进行批量初始化。
  • [country_exists](/wiki/trigger/country_exists) — 在执行创建前或创建后的条件判断中,用于检查原始标签是否存在,防止脚本在目标国家已灭亡时报错或产生异常行为。

常见坑

  1. 子块效果的 scope 理解错误:新手容易忘记 create_dynamic_country 的花括号子块内,scope 已经自动切换到新创建的动态国家,不需要也不应该在子块内再写 = { } 来切换 scope,直接写效果即可;若误以为仍在原始 scope 下执行,会导致效果错误地作用于触发国而非新国家。
  2. original_tagcopy_tag 混用导致数据污染original_tag 决定新国家的基础模板(国旗、科技树等历史数据来源),而 copy_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

create_dynamic_country is commonly used in mods to dynamically generate a brand new puppet state, breakaway nation, or special event country during gameplay without pre-defining the tag in the history files. For example, in civil war events or secession scenarios, you can duplicate base data from an original nation (original_tag), then immediately execute a series of initialization effects within the child block (setting capital, granting states, configuring government, etc.).

# Italian Civil War: dynamically create a Northern Italian breakaway regime
create_dynamic_country = {
    original_tag = ITA
    copy_tag = ITA
    set_capital = 516          # Milan province
    transfer_state = 159
    transfer_state = 160
    set_politics = {
        ruling_party = communism
        elections_allowed = no
    }
    save_event_target_as = north_italy_breakaway
}

Synergy

  • [save_event_target_as](/wiki/effect/save_event_target_as) — Immediately save the newly created dynamic country as an event target within the child block, making it convenient for subsequent events or effects to reference it via the target; otherwise, the dynamic country will be difficult to locate precisely after creation.
  • [hidden_effect](/wiki/effect/hidden_effect) — Wrap create_dynamic_country in a hidden effect block to prevent unnecessary notifications from appearing in the player's UI, suitable for silently initializing countries behind the scenes.
  • [every_country](/wiki/effect/every_country) — After creation is complete, use every_country to iterate through all nations and batch-initialize diplomatic relations for the new dynamic country (such as casus belli and faction relationships).
  • [country_exists](/wiki/trigger/country_exists) — In conditional checks before or after creation, used to verify whether the original tag exists, preventing script errors or unexpected behavior when the target nation has been eliminated.

Common Pitfalls

  1. Misunderstanding scope within child block effects: Beginners often forget that within the curly braces of create_dynamic_country, the scope has automatically switched to the newly created dynamic country; you should not and do not need to write additional = { } to switch scope within the block—simply write the effects directly. If you mistakenly assume you are still executing under the original scope, effects will be incorrectly applied to the triggering country rather than the new nation.
  2. Data pollution from mixing original_tag and copy_tag: original_tag determines the base template of the new nation (flag, tech tree, and other historical data sources), while copy_tag additionally copies the current runtime state of that nation in the game (technologies, generals, etc.). Carelessly filling both without understanding their distinction can cause the new nation to unexpectedly inherit military or economic states it shouldn't have, leading to balance issues.