Wiki

effect · leave_faction

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Country leaves the faction

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

leave_faction is commonly used in mods to design events or decisions for "leaving an alliance". For example, allowing a minor nation to declare neutrality under specific political conditions, or breaking away from the Axis or Allied faction. Typical scenarios include: the player triggering an event and choosing to "withdraw from the pact", or the AI automatically leaving a faction through hidden effects when the war situation becomes unfavorable.

# Decision option: declare withdrawal from faction
option = {
    name = my_event.1.a
    leave_faction = yes
    add_political_power = -50
    add_stability = -0.05
}

Synergy

  • [has_country_flag](/wiki/trigger/has_country_flag): Check before execution whether the country has been flagged as "cannot voluntarily leave", preventing duplicate or conflicting triggers.
  • [dismantle_faction](/wiki/effect/dismantle_faction): If the country is simultaneously the faction leader, using leave_faction alone will result in orphaned sub-factions. Use dismantle_faction to dismantle the faction first before handling subsequent logic.
  • [add_opinion_modifier](/wiki/effect/add_opinion_modifier): After leaving the faction, typically add negative opinion modifiers to the former leader to simulate the realistic impact of diplomatic rupture.
  • [create_wargoal](/wiki/effect/create_wargoal): Pair with subsequent events on the faction leader's side to allow them to declare war on the betrayer, enhancing narrative coherence.

Common Pitfalls

  1. Using directly on the faction leader causes automatic faction dissolution: In HOI4, when the faction leader leaves the faction, the engine forcibly dissolves the entire faction. If the mod intends only to "replace the leader" rather than disband the faction, use dismantle_faction combined with create_faction to rebuild instead of relying on leave_faction.
  2. Scope not switched to the correct country: The scope of leave_faction must be the country that is leaving the faction itself. Beginners often forget to switch scope using PREV/FROM/every_faction_member when ROOT is the faction leader, causing the wrong country to be kicked from the faction.