Wiki

trigger · is_in_faction_with

Definition

  • Supported scope:COUNTRY
  • Supported target:THIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITAL

Description

check if member of same faction as specified country

实战 · 配合 · 坑

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

实战用法

is_in_faction_with 常用于联盟外交类 mod 中,判断两国是否同属一个阵营,从而决定是否触发特定事件、解锁决议或限制战争目标。例如在设计"只有盟友才能共享情报"的 decision 时,可用此 trigger 作为 available 条件:

# 判断当前国家是否与德国同属一个阵营,才可执行此决议
available = {
    is_in_faction_with = GER
}

配合关系

  • [any_allied_country](/wiki/trigger/any_allied_country):遍历所有盟国时,可配合 is_in_faction_with 进一步确认某个盟国是否真正在同一阵营内(盟国与同阵营成员在边缘情况下并不完全等价)。
  • [exists](/wiki/trigger/exists):在使用 is_in_faction_with 前先确认目标国家存在,避免因目标国家已亡导致 trigger 报错或静默失败。
  • [add_to_faction](/wiki/effect/add_to_faction):常用于"若尚未同属阵营则强制拉入"的逻辑中,与 is_in_faction_with 做取反判断后执行加入操作。
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):联合判断"同盟友处于防御战"场景,确定是否触发援助或自动参战类事件。

常见坑

  1. 目标国不在任何阵营时返回 false 而非报错:新手容易误以为只要双方存在某种外交关系(如互为保证国)就会返回 true,实际上两国必须同时是同一阵营的正式成员,否则一律返回 false,需提前用 exists 和阵营相关 trigger 做好前置过滤。
  2. scope 混淆导致判断对象错误is_in_faction_with 的 scope 是被判断的国家,target 是用来比较的国家,在嵌套 every_faction_memberany_allied_country 循环内使用时,容易将 THIS/ROOT/PREV 对应关系搞错,导致实际上在用同一个国家与自己比较,永远返回 true。

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_with is commonly used in alliance diplomacy mods to determine whether two countries belong to the same faction, thereby deciding whether to trigger specific events, unlock decisions, or restrict war goals. For example, when designing a decision like "only allies can share intelligence," you can use this trigger as an available condition:

# Check if the current country belongs to the same faction as Germany before executing this decision
available = {
    is_in_faction_with = GER
}

Synergy

  • [any_allied_country](/wiki/trigger/any_allied_country): When iterating through all allies, combine with is_in_faction_with to further confirm whether a specific ally truly belongs to the same faction (allies and faction members are not entirely equivalent in edge cases).
  • [exists](/wiki/trigger/exists): Before using is_in_faction_with, first verify that the target country exists to avoid trigger errors or silent failures caused by a defunct target nation.
  • [add_to_faction](/wiki/effect/add_to_faction): Commonly used in logic like "if not already in the same faction, force them to join." Execute the join operation after negating is_in_faction_with.
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): Combined judgment for "allies in a defensive war" scenarios to determine whether to trigger aid or auto-join war events.

Common Pitfalls

  1. Target country not in any faction returns false rather than error: Beginners often mistakenly assume that any diplomatic relationship between the two parties (such as being mutual guarantors) will return true. In reality, both countries must simultaneously be formal members of the same faction; otherwise it always returns false. Perform pre-filtering using exists and faction-related triggers beforehand.
  2. Scope confusion causing incorrect judgment target: The scope of is_in_faction_with is the country being judged, and the target is the country for comparison. When used within nested every_faction_member or any_allied_country loops, it's easy to misalign THIS/ROOT/PREV relationships, resulting in comparing the same country with itself, always returning true.