trigger · has_state_category
Definition
- Supported scope:
STATE - Supported target:
none
Description
Check if state has a specific state category
has_state_categorySTATEnoneCheck if state has a specific state category
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
has_state_category 常用于判断某地块的发展等级或类型,例如在决策的 available 条件中限制只有达到特定城市化程度的州才能触发特定事件或建设项目。在占领与合规机制 mod 中,也常用于区分农村州与城市州,给予不同的抵抗值或服从度加成逻辑。
# 示例:仅当该州等级为城市(urban)时才允许执行某决策
available = {
has_state_category = urban
}
[is_owned_by](/wiki/trigger/is_owned_by):通常与归属判断一起出现,先确认该州属于特定国家,再检查其类别,避免对非己方州错误触发逻辑。[set_state_category](/wiki/effect/set_state_category):常作为"前置条件检查"与"结果执行"的配对,先用 has_state_category 确认当前类别不符合目标,再用此 effect 升级或变更类别。[state_population](/wiki/trigger/state_population):人口数量往往与州类别高度相关,两者一同用于更精确地筛选"真正意义上的大城市州"。[compliance](/wiki/trigger/compliance):在占领脚本中,常需要同时满足一定合规度且州类别达标,才允许推进政策改革。has_state_category 只在 STATE scope 下有效,若不小心写在 COUNTRY scope 的 trigger 块里(如国家事件的顶层 trigger),会导致脚本解析报错或静默失效,需确保使用前已通过 any_neighbor_state、every_neighbor_state 等方式正确切换到 STATE scope。urban、large_city 等)均来自 map/state_category.txt,若手写名称与文件中定义不一致,条件永远不会为真,且通常不会有明显报错提示,调试时容易被忽略。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.
has_state_category is commonly used to check the development level or type of a state. For example, it can be placed in a decision's available condition to restrict triggering specific events or construction projects only to states that have reached a certain urbanization threshold. In occupation and compliance mods, it is also frequently used to distinguish between rural and urban states, applying different resistance or compliance modifiers accordingly.
# Example: Allow a decision to execute only when the state category is urban
available = {
has_state_category = urban
}
[is_owned_by](/wiki/trigger/is_owned_by): Usually appears alongside ownership checks. First confirm the state belongs to a specific country, then check its category to avoid incorrectly triggering logic on states not controlled by you.[set_state_category](/wiki/effect/set_state_category): Often paired as a "precondition check" and "result execution" pair. First use has_state_category to verify the current category does not match the target, then apply this effect to upgrade or change the category.[state_population](/wiki/trigger/state_population): Population numbers are typically highly correlated with state category. Using both together allows for more precise filtering of "truly major urban states."[compliance](/wiki/trigger/compliance): In occupation scripts, it is common to require both a minimum compliance level and the state category to meet the threshold before allowing policy reforms to proceed.has_state_category only works in STATE scope. If accidentally written in a trigger block at COUNTRY scope (such as the top-level trigger of a national event), it will cause script parsing errors or silent failures. Ensure proper scope switching via any_neighbor_state, every_neighbor_state, etc. before use.urban, large_city, etc.) are defined in map/state_category.txt. If manually typed names do not match those in the file, the condition will never evaluate to true, and usually no obvious error message will appear, making it easy to overlook during debugging.