Wiki

trigger · state_population_k

Definition

  • Supported scope:STATE
  • Supported target:none

Description

check the population in the state in thousands (use to avoid variable overflows)

实战 · 配合 · 坑

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

实战用法

state_population_k 常用于人口门槛检测场景,例如判断某地区是否拥有足够人口才允许建造特定设施、触发移民事件或解锁特定决策。与 state_population 相比,它以千为单位传入数值,可有效避免大数字在脚本变量运算中溢出。

# 仅当州人口超过 500,000(即 500k)时才允许执行该决策
available = {
    state_population_k > 500
}

配合关系

  • [state_population](/wiki/trigger/state_population):两者功能相近,当需要精确到个位的小人口数值比较时可改用此 trigger,与 state_population_k 搭配可分层做粗细两级判断。
  • [has_state_category](/wiki/trigger/has_state_category):人口往往与州等级强相关,配合检查州类别可构建更严密的条件(如"大城市且人口超过阈值")。
  • [set_state_category](/wiki/effect/set_state_category):在 effect 块中根据人口条件自动升降州类别,是最典型的联动写法——先用 state_population_k 判断,再用此 effect 改变等级。
  • [compliance](/wiki/trigger/compliance):人口规模与顺从度常共同决定占领政策收益,两者联用可筛选出"人多且顺从"的高价值州。

常见坑

  1. 单位混淆:新手容易把实际人口数值(如 1000000)直接填入,但该 trigger 以千为单位,正确写法是 state_population_k > 1000,填原始数值会导致条件永远不成立或逻辑错误。
  2. Scope 用错state_population_k 只能在 STATE scope 下使用,若在 COUNTRY 或 CHARACTER scope 内直接调用会报错,需先用 any_owned_state/every_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

state_population_k is commonly used for population threshold detection scenarios, such as determining whether a region has sufficient population to allow construction of specific facilities, trigger immigration events, or unlock certain decisions. Compared to state_population, it accepts values in thousands, effectively preventing integer overflow issues that can occur with large numbers in script variable calculations.

# Only allow this decision to execute if the state population exceeds 500,000 (i.e., 500k)
available = {
    state_population_k > 500
}

Synergy

  • [state_population](/wiki/trigger/state_population): Similar functionality; use this trigger when you need precise single-unit comparisons for small population values. Combining both triggers enables a two-level coarse-to-fine filtering approach.
  • [has_state_category](/wiki/trigger/has_state_category): Population is often strongly correlated with state category. Pairing it with state category checks constructs more robust conditions (e.g., "major city AND population exceeds threshold").
  • [set_state_category](/wiki/effect/set_state_category): In effect blocks, automatically upgrade or downgrade state category based on population conditions—this is the classic integration pattern: first use state_population_k to check the threshold, then apply this effect to change the tier.
  • [compliance](/wiki/trigger/compliance): Population scale and compliance often jointly determine occupation policy yields. Using both together filters for high-value states that are "populous AND compliant".

Common Pitfalls

  1. Unit Confusion: Beginners often mistakenly input raw population values (e.g., 1000000) directly, but this trigger uses thousands as its unit. The correct syntax is state_population_k > 1000. Using raw values causes the condition to never evaluate as true or produces logic errors.
  2. Scope Misuse: state_population_k only works within STATE scope. Calling it directly in COUNTRY or CHARACTER scope will cause an error. You must first switch to the correct scope using constructs like any_owned_state or every_state before using it.