Wiki

effect · every_owned_state

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Executes children effects on every State owned by the country in scope (or \"random_select_amount\" of random state if specified) that fulfills the \"limit\" trigger.
tooltip=key can be added to override tooltip title.
By default the effects are only displayed once, you may display them for each matching state with display_individual_scopes.
ex:
SOV = {
	every_owned_state = {
		tooltip = my_loc_key # Optional
		random_select_amount = 3 # Optional
		display_individual_scopes = yes # Optional - default = no
		... state scope effects ...
	}
}

实战 · 配合 · 坑

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

实战用法

every_owned_state 常用于战争结束后对战胜国所有领土批量执行操作,例如清除旗帜、设置建筑等级或转移核心;也用于游戏开局初始化,对特定国家的全部州批量添加资源或合规度。

# 示例:战胜国对自己所有州清除临时旗帜并提升顺从度
GER = {
    every_owned_state = {
        limit = {
            is_controlled_by = GER
            has_state_flag = temp_occupation_flag
        }
        clr_state_flag = temp_occupation_flag
        add_compliance = 10
    }
}

配合关系

  • is_controlled_by:在 limit 块内筛选出由本国实际控制的州,避免对被占领或争议领土误操作。
  • set_building_level:遍历所有拥有州后批量将特定建筑调整到指定等级,适合初始化 mod 场景或战后重建事件。
  • add_resistance:在抵抗值相关事件中,对符合条件的所有占领州统一增减抵抗值,与 limit 中的 has_active_resistance 配合筛选目标。
  • transfer_state_to:结合 limit 条件,将满足特定条件的多个州一次性转交给另一国,常见于和平谈判脚本或决议效果。

常见坑

  1. 忘记 limit 导致误操作全部州every_owned_state 会遍历该国拥有的所有州,如果不加 limit 限制,效果会作用于包括本土核心州在内的每一个州,容易造成意料之外的大规模状态变更,务必养成加 limit 的习惯。
  2. scope 混淆导致字段报错every_owned_state 进入的是 STATE scope,在其内部不能直接使用仅属于 COUNTRY scope 的命令(如 add_ideas),必须通过 owner = { ... } 或类似方式切回 COUNTRY 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

every_owned_state is commonly used after a war ends to batch-process all territories belonging to the victor — for example, clearing flags, setting building levels, or transferring cores. It is also used during game startup initialization to bulk-add resources or compliance to every state owned by a specific country.

# Example: After victory, clear temporary flags and raise compliance across all owned states
GER = {
    every_owned_state = {
        limit = {
            is_controlled_by = GER
            has_state_flag = temp_occupation_flag
        }
        clr_state_flag = temp_occupation_flag
        add_compliance = 10
    }
}

Synergy

  • is_controlled_by: Used inside a limit block to filter for states actually controlled by the country, preventing unintended operations on occupied or contested territory.
  • set_building_level: After iterating over all owned states, bulk-sets specific buildings to a target level — ideal for mod initialization scenarios or post-war reconstruction events.
  • add_resistance: In resistance-related events, uniformly adjusts resistance values across all qualifying occupied states; pair with has_active_resistance inside limit to narrow down the targets.
  • transfer_state_to: Combined with limit conditions, transfers multiple states meeting specific criteria to another country in a single pass — commonly seen in peace deal scripts or decision effects.

Common Pitfalls

  1. Forgetting limit and accidentally affecting every state: every_owned_state iterates over all states owned by the country. Without a limit block, the effect applies to every single state including core homeland states, which can easily cause large-scale unintended changes. Always make it a habit to include a limit.
  2. Scope confusion causing field errors: every_owned_state enters STATE scope. Inside it, you cannot directly use commands that belong exclusively to COUNTRY scope (such as add_ideas). You must switch back to COUNTRY scope first via owner = { ... } or a similar construct before executing country-level commands.