Hands-On Usage
When a mod needs to dynamically assemble a faction group with custom appearance based on a player or AI decision or focus line, create_faction_from_template is ideal—it allows overriding the template's preset name, icon, and color at runtime, enabling the same template to present different appearances across different story branches. For example, in a "United Axis" focus tree, based on the player's chosen ideology branch, assign the faction completely different localized names and color schemes:
GER = {
create_faction_from_template = {
template = axis_template
name = FACTION_EURASIAN_AXIS
icon = GFX_faction_eurasian_icon
color = { 0.8 0.2 0.1 }
}
}
Synergy
[add_to_faction](/wiki/effect/add_to_faction): Immediately recruit ally nations into the faction after creation, avoiding the awkward situation where a new faction only contains its creator for extended periods.
[dismantle_faction](/wiki/effect/dismantle_faction): In faction rebuild or replacement narratives, dismantle the old faction first, then create a new one from the template, ensuring clean faction data.
[has_country_flag](/wiki/trigger/has_country_flag): Used to check whether the faction creation process has already been triggered, preventing duplicate template invocations that could cause errors or logic conflicts.
[create_wargoal](/wiki/effect/create_wargoal): Generate war goals against target nations after faction establishment, chaining diplomatic and military processes into a complete narrative sequence.
Common Pitfalls
- The template ID must be predefined in
common/faction_templates/ beforehand. Entering a non-existent template value directly in the effect will not produce an error message, but the faction will silently fail to create. Newcomers often mistakenly blame logic errors and repeatedly troubleshoot conditions because of this.
- The creator's scope must be the actual leader nation of the faction. If called from a non-leader nation's scope, the game will not automatically transfer leadership, potentially causing the faction leader to deviate from the template's expectations, which may subsequently trigger abnormal behavior in
add_to_faction or diplomatic AI.