Wiki

trigger · num_faction_members

Definition

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

Description

Compares the number of members in the faction for the current country. 
 Example: num_faction_members > 10

实战 · 配合 · 坑

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

实战用法

num_faction_members 常用于判断某国所在阵营的规模,例如在国策或决策的 available 块里限制"阵营至少有 N 个成员才能执行外交行动",或在 trigger 块里检测阵营是否已壮大到足以发动战争。需要注意的是,该 trigger 要求当前国家本身必须是某个阵营的成员,否则返回 false 而非 0。

# 国策 available:只有阵营成员超过 3 国时才能解锁此国策
focus = {
    id = GER_grand_offensive
    available = {
        is_faction_leader = yes
        num_faction_members > 3
    }
    ...
}

配合关系

  • [has_completed_focus](/wiki/trigger/has_completed_focus):常先用国策完成情况判断外交路线走向,再用 num_faction_members 确认阵营规模,组合控制后续选项的解锁节奏。
  • [alliance_strength_ratio](/wiki/trigger/alliance_strength_ratio):阵营人数多不等于实力强,两者组合可以同时过滤"成员够多且综合军力达标"的双重条件,让触发更严谨。
  • [add_to_faction](/wiki/effect/add_to_faction):当 num_faction_members 未达阈值时,可在 effect 块里调用此命令拉入新成员,逻辑上形成"检测→补充→再检测"的完整闭环。
  • [create_wargoal](/wiki/effect/create_wargoal):典型用法是先用 num_faction_members > X 确保阵营体量足够,再生成战争目标,避免以弱小阵营仓促宣战。

常见坑

  1. 未加入阵营时使用会静默失败:若当前国家不属于任何阵营,trigger 直接返回 false,脚本不会报错,但逻辑永远不会触发——新手常误以为此时返回 0 参与比较,需在同一块内先加 is_in_faction = yes 做前置守卫。
  2. 比较运算符写成等号赋值:HOI4 脚本中数值比较必须写 num_faction_members > 5num_faction_members < 5,不支持 ==;若漏写运算符或写成 = 5,游戏会解析报错或产生意外行为。

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

num_faction_members is commonly used to assess the size of a faction that a country belongs to. For example, in the available block of a national focus or decision, it can restrict diplomatic actions to only execute when "the faction has at least N members," or in a trigger block to detect whether the faction has grown large enough to launch a war. Note that this trigger requires the current country to be a member of a faction itself; otherwise it returns false rather than 0.

# Focus available: unlock this focus only when faction members exceed 3 countries
focus = {
    id = GER_grand_offensive
    available = {
        is_faction_leader = yes
        num_faction_members > 3
    }
    ...
}

Synergy

  • [has_completed_focus](/wiki/trigger/has_completed_focus): Typically use focus completion status to determine diplomatic direction first, then use num_faction_members to confirm faction size; combining these conditions controls the unlock timing of subsequent options.
  • [alliance_strength_ratio](/wiki/trigger/alliance_strength_ratio): More faction members does not equal greater strength. Using both together allows filtering dual conditions of "sufficient members AND adequate combined military power," making triggers more robust.
  • [add_to_faction](/wiki/effect/add_to_faction): When num_faction_members falls below the threshold, invoke this command in the effect block to recruit new members, logically forming a complete "check → supplement → check again" loop.
  • [create_wargoal](/wiki/effect/create_wargoal): The typical pattern is to first use num_faction_members > X to ensure the faction is large enough, then generate war goals, preventing hasty declarations of war with a weak faction.

Common Pitfalls

  1. Silent failure when used outside a faction: If the current country does not belong to any faction, the trigger directly returns false. The script will not error, but the logic will never fire—newcomers often mistakenly believe it returns 0 for comparison. Add is_in_faction = yes as a guard condition beforehand within the same block.
  2. Using assignment operator instead of comparison operator: In HOI4 scripting, numerical comparisons must use num_faction_members > 5 or num_faction_members < 5; == is not supported. Omitting the operator or writing = 5 will cause the game to throw a parse error or produce unexpected behavior.