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
- 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.
- 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.