Wiki

effect · set_state_category

Definition

  • Supported scope:STATE
  • Supported target:none

Description

Sets the category of a state
Example: set_state_category = large_town

实战 · 配合 · 坑

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

实战用法

set_state_category 常用于动态改变省份的发展等级,例如在工业化事件中将偏远地区升级为城市,或在战争破坏事件中将城市降级为废墟。它也适合用于 focus 树或决策系统中,让玩家通过投资解锁更高建筑槽位上限。

# 某个决策的 complete_effect 中:将目标州升级为大城市
complete_effect = {
    every_owned_state = {
        limit = {
            has_state_category = large_town
            is_core_of = ROOT
        }
        set_state_category = city
        add_extra_state_shared_building_slots = 2
    }
}

配合关系

  • [has_state_category](/wiki/trigger/has_state_category):在执行升降级之前先检查当前类别,避免对不符合条件的州重复操作或跳级。
  • [add_extra_state_shared_building_slots](/wiki/effect/add_extra_state_shared_building_slots):升级州类别后通常同步增加建筑槽位,使两者效果保持逻辑一致。
  • [set_building_level](/wiki/effect/set_building_level):降级惩罚场景中,往往需要同时降低建筑等级来体现破坏效果,与类别降级配套使用。
  • [add_state_modifier](/wiki/effect/add_state_modifier):升级后附加州修正(如生产加成),为类别变化提供实际的游戏数值支撑。

常见坑

  1. 在非 STATE scope 下调用set_state_category 只能在 STATE scope 内使用,若误写在 COUNTRY scope(如直接放在 country_eventoption 顶层而不用 every_owned_state 包裹),游戏会报作用域错误甚至静默失效,检查时要确认上下文已正确切换到 STATE。
  2. 类别字符串拼写错误:类别名称(如 ruraltownlarge_towncitylarge_city 等)必须与游戏定义完全一致,拼错不会报语法错误但不会生效,建议直接参照 common/state_category 目录下的原版文件核对名称。

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

set_state_category is commonly used to dynamically change a state's development tier—for example, upgrading a remote region to city status in an industrialization event, or downgrading an urban center to ruins in a war damage event. It also works well in focus trees or decision systems, allowing players to unlock higher building slot caps through investment.

# In the complete_effect of a decision: upgrade the target state to city
complete_effect = {
    every_owned_state = {
        limit = {
            has_state_category = large_town
            is_core_of = ROOT
        }
        set_state_category = city
        add_extra_state_shared_building_slots = 2
    }
}

Synergy

  • [has_state_category](/wiki/trigger/has_state_category): Check the current category before executing an upgrade or downgrade to avoid redundant operations on ineligible states or unintended skipping of tiers.
  • [add_extra_state_shared_building_slots](/wiki/effect/add_extra_state_shared_building_slots): After upgrading a state's category, it's typical to simultaneously increase building slots to keep both effects logically consistent.
  • [set_building_level](/wiki/effect/set_building_level): In downgrade penalty scenarios, reducing building levels alongside category downgrades often reinforces the destruction effect and should be paired together.
  • [add_state_modifier](/wiki/effect/add_state_modifier): Append state modifiers (such as production bonuses) after an upgrade to provide tangible numerical support for the category change.

Common Pitfalls

  1. Calling outside STATE scope: set_state_category only works within STATE scope. If mistakenly placed in COUNTRY scope (such as directly in a country_event option without wrapping it in every_owned_state), the game will throw a scope error or silently fail. Always verify the context has correctly switched to STATE before execution.
  2. Misspelled category names: Category identifiers (rural, town, large_town, city, large_city, etc.) must match the game's definitions exactly. Typos won't trigger syntax errors but will simply not take effect. Cross-reference the vanilla files in the common/state_category directory to confirm correct names.