Wiki

trigger · num_of_nukes

Definition

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

Description

check amount of nukes

实战 · 配合 · 坑

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

实战用法

num_of_nukes 常用于判断某国是否积累了足够的核弹头,以解锁特殊决策、外交选项或事件分支,例如"核威慑"类 mod 中限制宣战或触发外交压力事件。也可用于成就类 mod 的完成条件检测。

# 示例:当本国核弹数量达到阈值时,激活"核威慑宣言"决策
available = {
    num_of_nukes > 5
}

配合关系

  • [add_nuclear_bombs](/wiki/effect/add_nuclear_bombs) — 搭配使用时,先用 num_of_nukes 判断当前存量,再决定是否通过该 effect 增减核弹数量,避免超限或重复奖励。
  • [has_completed_focus](/wiki/trigger/has_completed_focus) — 通常要求既完成特定国策研究又拥有足够核弹,才能满足某项决策的全部前提条件。
  • [has_war_support](/wiki/trigger/has_war_support)(白名单中对应 has_bombing_war_support / has_casualties_war_support)— 在核威慑相关事件中,将核弹数量与战争支持度结合判断,模拟民众对核打击的态度门槛。
  • [exists](/wiki/trigger/exists) — 配合目标 scope 使用,确保被检查的国家标签当前存在于游戏中,防止因国家已消亡导致 trigger 报错。

常见坑

  1. Scope 混用num_of_nukes 仅在 COUNTRY scope 下有效,新手容易在 STATEUNIT_LEADER scope 内直接写入,导致脚本报错或永远返回假,需确保外层 scope 是国家或通过 OWNER 等 target 显式转换。
  2. 比较符遗漏:该 trigger 需要配合比较运算符(> < = 等)使用,写成 num_of_nukes = 0num_of_nukes < 1 语义相同但含义易混淆,初学者常误用 num_of_nukes = yes 这种布尔写法,导致条件无法正确求值。

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_nukes is commonly used to check whether a country has accumulated enough nuclear warheads to unlock special decisions, diplomatic options, or event branches. For example, in "nuclear deterrence"-themed mods, it can restrict war declarations or trigger diplomatic pressure events. It can also be used to verify completion conditions in achievement-focused mods.

# Example: Activate the "Nuclear Deterrence Declaration" decision when the country's nuclear warhead count reaches a threshold
available = {
    num_of_nukes > 5
}

Synergy

  • [add_nuclear_bombs](/wiki/effect/add_nuclear_bombs) — When used together, first check the current stockpile with num_of_nukes, then decide whether to increase or decrease warheads via this effect to avoid exceeding limits or duplicate rewards.
  • [has_completed_focus](/wiki/trigger/has_completed_focus) — Typically requires both completing a specific focus research and possessing sufficient nuclear warheads to satisfy all prerequisites for a particular decision.
  • [has_war_support](/wiki/trigger/has_war_support) (corresponding to has_bombing_war_support / has_casualties_war_support in the whitelist) — In nuclear deterrence-related events, combine nuclear warhead count with war support to simulate the population's threshold of acceptance toward nuclear strikes.
  • [exists](/wiki/trigger/exists) — Used together with target scope to ensure the checked country tag currently exists in the game, preventing trigger errors due to the country having been eliminated.

Common Pitfalls

  1. Scope Confusion: num_of_nukes is only valid under COUNTRY scope. Beginners often write it directly within STATE or UNIT_LEADER scope, causing script errors or permanently returning false. Always ensure the outer scope is a country, or explicitly convert via OWNER or similar targets.
  2. Missing Comparison Operators: This trigger must be paired with comparison operators (> < = etc.). Writing num_of_nukes = 0 and num_of_nukes < 1 are semantically identical but easily confused in meaning. Beginners often mistakenly use boolean syntax like num_of_nukes = yes, preventing the condition from evaluating correctly.