Wiki

trigger · has_resources_amount

Definition

  • Supported scope:STATE
  • Supported target:none

Description

checks for amount of resources in state
Example:
has_resources_amount = {
	resource = chromium
	amount > 10
	state = 31 (optional - can be used in state scope instead)
	delivered = no # (optional, default: no) check the actual delivered amount from the state to its controller, with all modifiers applied

实战 · 配合 · 坑

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

实战用法

has_resources_amount 常见于资源相关的决策解锁条件、国策可用性判断,以及动态事件触发(例如"当某州铬矿储量超过阈值时才允许建设特定工厂")。配合 delivered = yes 参数还可以检查实际输送量,适合制作资源短缺警告事件或殖民地开发 mod 中的产能评估逻辑。

# 决策 available 块示例:只有铬矿实际交付量超过 10 才可执行
available = {
    has_resources_amount = {
        resource = chromium
        amount > 10
        delivered = yes
    }
}

配合关系

  • [resource_count_trigger](/wiki/trigger/resource_count_trigger):同为资源类 trigger,resource_count_trigger 面向国家范围汇总,而 has_resources_amount 面向州范围精确检查,两者组合可以做"全国总量达标且某关键州本地储量也充足"的双重门槛。
  • [is_owned_by](/wiki/trigger/is_owned_by):在跨国 mod 逻辑中,常先用 is_owned_by 确认目标州的主权归属,再用 has_resources_amount 验证该州资源量,避免条件作用在错误的属主上。
  • [add_resource](/wiki/effect/add_resource):在 effect 块中作为后续操作配套使用——先用 has_resources_amount 判断资源是否低于下限,再用 add_resource 补充,形成"低于阈值则补充"的自动调节逻辑。
  • [has_state_category](/wiki/trigger/has_state_category):资源产出往往与州规模挂钩,同时检查州类别可过滤掉小型州,使触发条件更符合设计预期。

常见坑

  1. 比较运算符需与字段分开写成独立行,即 amount > 10 是正确格式;新手容易写成 amount = > 10 或把数值直接赋给 amountamount = 10),后者在语义上是"恰好等于 10"而非"大于 10",导致条件几乎永远不成立。
  2. 忘记区分 delivered 默认值的含义:默认 delivered = no 检查的是州的原始储量(含未开采潜力的静态值),而非控制国实际收到的数量;若 mod 逻辑关心的是"玩家手上真正能用的资源",必须显式加上 delivered = 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

has_resources_amount commonly appears in resource-related decision unlock conditions, national focus availability checks, and dynamic event triggers (for example, "allow construction of a specific factory only when chromium reserves in a state exceed a threshold"). Combined with the delivered = yes parameter, it can also check actual delivery amounts, making it suitable for creating resource shortage warning events or production capacity evaluation logic in colonization mods.

# Example in decision available block: execution allowed only if chromium delivery exceeds 10
available = {
    has_resources_amount = {
        resource = chromium
        amount > 10
        delivered = yes
    }
}

Synergy

  • [resource_count_trigger](/wiki/trigger/resource_count_trigger): Both are resource-type triggers; resource_count_trigger operates at the nation scope for aggregation, while has_resources_amount operates at the state scope for precise checks. Combining both allows you to create a "dual threshold" condition: national total meets quota AND critical state has sufficient local reserves.
  • [is_owned_by](/wiki/trigger/is_owned_by): In cross-national mod logic, it's common practice to first use is_owned_by to confirm the sovereignty of the target state, then use has_resources_amount to verify resource amounts in that state, preventing the condition from being evaluated against the wrong owner.
  • [add_resource](/wiki/effect/add_resource): Used as a follow-up operation in effect blocks—first check with has_resources_amount whether resources fall below a minimum threshold, then replenish with add_resource, creating an "auto-adjust if below threshold" logic loop.
  • [has_state_category](/wiki/trigger/has_state_category): Resource output is often tied to state size; checking state category simultaneously filters out small states, making trigger conditions more aligned with design intent.

Common Pitfalls

  1. Comparison operators must be written on a separate line from the field, meaning amount > 10 is the correct format. Beginners often mistakenly write amount = > 10 or directly assign a value to amount (like amount = 10), where the latter semantically means "exactly equal to 10" rather than "greater than 10", causing the condition to almost never evaluate to true.
  2. Forgetting the distinction between delivered default value semantics: By default, delivered = no checks the state's raw reserves (static value including unexploited potential), not the actual quantity the controlling nation receives. If your mod logic cares about "resources the player actually has available", you must explicitly add delivered = yes; otherwise, resources could be completely blockaded yet still be falsely judged as "sufficient".