Wiki

effect · set_faction_leader

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

set current country as leader of its faction

实战 · 配合 · 坑

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

实战用法

set_faction_leader 常用于 mod 中实现国家权力更迭或剧情事件后的派系领导权转移,例如让某国通过国策或事件取代原有领导国成为联盟核心。典型场景包括:玩家扶植的傀儡国崛起后自立为派系领袖,或原领导国被消灭后由最强盟友接管。

# 某国完成国策后成为本方派系领袖
focus = {
    id = claim_faction_leadership
    ...
    completion_reward = {
        set_faction_leader = yes
    }
}

配合关系

  • [create_faction](/wiki/effect/create_faction):若当前国家尚无派系,需先建立派系,才能再用 set_faction_leader 确立领导地位,二者常顺序搭配。
  • [dismantle_faction](/wiki/effect/dismantle_faction):在重组派系剧情中,可先解散旧派系再由新国家重建并夺取领导权,常与 set_faction_leader 形成完整流程。
  • [has_country_flag](/wiki/trigger/has_country_flag):用于在执行领导权转移前做条件判断,确保只有满足特定剧情标记的国家才会触发该 effect,避免逻辑混乱。
  • [add_to_faction](/wiki/effect/add_to_faction):设定新领袖后,通常需要将其他成员国重新拉入派系,两者配合保证派系成员结构完整。

常见坑

  1. 国家不在任何派系中时使用会报错或无效set_faction_leader 要求执行国本身已经是某个派系的成员,若该国既未加入也未拥有派系则指令不生效,必须先通过 create_factionadd_to_faction 确保派系存在。
  2. 误在非 COUNTRY scope 下调用:此 effect 只能在国家 scope 内执行,若被误写在 STATE 或 CHARACTER scope 下(例如嵌套在 every_owned_state 块内忘记切回国家 scope),会导致脚本错误或静默失败。

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

set_faction_leader is commonly used in mods to implement power transitions between nations or faction leadership transfers following story events, such as allowing a country to assume control of an alliance through national focuses or events, replacing the original leader. Typical scenarios include a player-backed puppet state rising to independence and becoming faction leader, or the original leader being eliminated and replaced by the strongest ally.

# A nation becomes faction leader of its faction upon completing a national focus
focus = {
    id = claim_faction_leadership
    ...
    completion_reward = {
        set_faction_leader = yes
    }
}

Synergy

  • [create_faction](/wiki/effect/create_faction): If the current nation does not yet have a faction, it must first be created before set_faction_leader can be used to establish leadership, with the two effects typically chained in sequence.
  • [dismantle_faction](/wiki/effect/dismantle_faction): In faction restructuring scenarios, you can dismantle the old faction first, then have a new nation rebuild and seize leadership, creating a complete workflow when combined with set_faction_leader.
  • [has_country_flag](/wiki/trigger/has_country_flag): Use this to perform conditional checks before executing a leadership transfer, ensuring only nations with specific story flags trigger the effect and preventing logical conflicts.
  • [add_to_faction](/wiki/effect/add_to_faction): After setting a new leader, other member nations typically need to be re-added to the faction; using both together ensures the faction's member structure remains intact.

Common Pitfalls

  1. Using the effect when the nation is not in any faction causes errors or has no effect: set_faction_leader requires the executing nation to already be a member of some faction. If the nation has neither joined nor owns a faction, the command will not work. You must first use create_faction or add_to_faction to ensure a faction exists.
  2. Accidentally calling it outside COUNTRY scope: This effect can only be executed within country scope. If mistakenly written in STATE or CHARACTER scope (for example, nested inside an every_owned_state block without switching back to country scope), it will cause script errors or fail silently.