Wiki

trigger · num_of_available_military_factories

Definition

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

Description

check amount of available military factories

实战 · 配合 · 坑

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

实战用法

num_of_available_military_factories 常用于判断一个国家当前空闲(未被分配生产任务)的军工厂数量,适合在决策 available 块中限制玩家只有在有足够闲置产能时才能激活某项生产计划,或在 AI 策略事件中根据工业余量触发不同分支。

# 示例:只有拥有至少 5 座可用军工厂时,才能激活该决策
available = {
    num_of_available_military_factories > 4
}

配合关系

  • [building_count_trigger](/wiki/trigger/building_count_trigger):常与本 trigger 联用,先确认总军工数量再判断空闲数量,避免因全部军工被占用而导致逻辑误判。
  • [add_equipment_production](/wiki/effect/add_equipment_production):在满足本 trigger 的条件块通过后,用该 effect 下达新的生产订单,确保下单时确实有余量承接。
  • [has_country_flag](/wiki/trigger/has_country_flag):配合国家标记防止重复触发,当空闲军工数量达标且标记未设置时才执行后续逻辑,避免事件/决策刷屏。
  • [focus_progress](/wiki/trigger/focus_progress):在国策进度判断中同步检查可用军工数,用于模拟"国策需要工业余力才能推进"的叙事场景。

常见坑

  1. "可用"不等于"总量":本 trigger 统计的是当前未被生产队列占用的军工厂数,若玩家把所有军工都排满了队列,即使拥有几十座军工,该值也可能为 0,不要用它替代统计总军工数的逻辑。
  2. scope 必须是国家:该 trigger 只能在 COUNTRY scope 下使用,若误放在 state scope(如 limit 套在 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

num_of_available_military_factories is commonly used to check the current number of idle (unassigned to production queues) military factories owned by a country. It's ideal for restricting player activation of production plans in decision available blocks—only allowing them when sufficient spare capacity exists—or triggering different branches in AI strategy events based on industrial surplus.

# Example: Decision can only be activated if the country has at least 5 available military factories
available = {
    num_of_available_military_factories > 4
}

Synergy

  • [building_count_trigger](/wiki/trigger/building_count_trigger): Often used in tandem with this trigger to first confirm total military factory count before checking idle capacity, preventing logic errors from all factories being fully queued.
  • [add_equipment_production](/wiki/effect/add_equipment_production): After this trigger's conditions pass, use this effect to issue new production orders, ensuring spare capacity actually exists to handle them.
  • [has_country_flag](/wiki/trigger/has_country_flag): Pair with country flags to prevent repeated activation—execute follow-up logic only when available factories meet the threshold AND the flag isn't set, avoiding event/decision spam.
  • [focus_progress](/wiki/trigger/focus_progress): When checking national focus progress, simultaneously verify available military factories to simulate narrative scenarios like "the focus requires industrial spare capacity to advance."

Common Pitfalls

  1. "Available" is not "total": This trigger counts only military factories currently not occupied by production queues. If a player fills every factory with queued items, the value may be 0 even with dozens of factories—don't use it as a substitute for logic that counts total military factory capacity.
  2. Scope must be COUNTRY: This trigger only works in COUNTRY scope. Placing it incorrectly in state scope (e.g., limit nested inside every_owned_state without switching back to country scope) will cause script errors or silent failure.