Wiki

trigger · is_in_faction

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check if member of any faction

实战 · 配合 · 坑

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

实战用法

is_in_faction 常用于判断某国是否已加入任意阵营,从而决定是否显示或解锁特定决策、国策分支或外交选项。例如在一个"独立外交"mod 中,可以要求某国必须尚未加入任何阵营才能触发中立路线:

available = {
    NOT = { is_in_faction = yes }
    is_subject = no
}

配合关系

  • [any_allied_country](/wiki/trigger/any_allied_country):在确认当前国家已入阵营后,进一步筛查阵营盟友是否满足某条件,两者常叠套使用。
  • [create_faction](/wiki/effect/create_faction):在 effect 块中先以 NOT = { is_in_faction = yes } 作 limit,确保不重复建立阵营再执行创建,避免脚本报错。
  • [add_to_faction](/wiki/effect/add_to_faction):邀请他国入阵营前通常需要用 is_in_faction = no 排除已在其他阵营的目标,两者搭配保证逻辑安全。
  • [dismantle_faction](/wiki/effect/dismantle_faction):解散阵营前先用 is_in_faction = yes 验证该国确实是阵营领袖或成员,防止对无阵营国家执行无效操作。

常见坑

  1. 混淆 yes/no 语义:新手常写 is_in_faction = GER 或直接省略值,实际上该 trigger 只接受 yes / no 作为值,不能用来判断加入的是哪个具体阵营——若需判断特定阵营成员身份,应改用 is_in_faction_with 或配合 any_allied_country 做间接检查。
  2. 在 effect 块内直接使用is_in_faction 是纯条件判断,只能放在 triggerlimitavailableallowed 等条件块中;有新手误将其写进 if 的 effect 层级外或直接放在 on_action 的顶层 effect 块里,导致解析错误或条件被静默忽略。

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

is_in_faction is commonly used to determine whether a country has joined any faction, enabling decisions about whether to display or unlock specific decisions, focus tree branches, or diplomatic options. For example, in an "Independent Diplomacy" mod, you might require a country to remain outside all factions before triggering a neutrality path:

available = {
    NOT = { is_in_faction = yes }
    is_subject = no
}

Synergy

  • [any_allied_country](/wiki/trigger/any_allied_country): After confirming the current country is in a faction, use this to further filter whether faction allies meet certain conditions. These two are often nested together.
  • [create_faction](/wiki/effect/create_faction): In effect blocks, first use NOT = { is_in_faction = yes } as a limit to ensure you don't create duplicate factions before executing the creation, avoiding script errors.
  • [add_to_faction](/wiki/effect/add_to_faction): Before inviting another country to join a faction, typically filter out targets already in other factions using is_in_faction = no. This pairing ensures logical safety.
  • [dismantle_faction](/wiki/effect/dismantle_faction): Before dismantling a faction, first verify with is_in_faction = yes that the country is indeed a faction leader or member, preventing ineffective operations on countries outside any faction.

Common Pitfalls

  1. Confusing yes/no semantics: Beginners often write is_in_faction = GER or omit the value entirely. In reality, this trigger only accepts yes or no as values and cannot determine which specific faction a country joined. To check membership in a particular faction, use is_in_faction_with instead, or perform indirect checks with any_allied_country.
  2. Direct use within effect blocks: is_in_faction is a pure condition check and can only appear in condition blocks like trigger, limit, available, or allowed. Some beginners mistakenly place it outside the effect layer of an if statement or directly in the top-level effect block of an on_action, causing parsing errors or conditions to be silently ignored.