Wiki

effect · every_neighbor_state

Definition

  • Supported scope:STATE
  • Supported target:none

Description

Executes children effects on every State neighboring the state 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:
42 = {
	every_neighbor_state = {
		tooltip = my_loc_key # Optional
		random_select_amount = 3 # Optional
		display_individual_scopes = yes # Optional - default = no
		... state scope effects ...
	}
}

实战 · 配合 · 坑

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

实战用法

every_neighbor_state 常用于区域扩张类 mod 中,例如某国占领一个州后自动向所有相邻州添加核心或宣示主权,或在抵抗运动事件中将周边州同步设置为高抵抗等级。它也适合用于地图重绘脚本,批量转移相邻州的归属。

# 当某国占领一个州时,对所有相邻且由敌方控制的州添加宣示
42 = {
    every_neighbor_state = {
        limit = {
            is_owned_by = GER
            NOT = { is_core_of = ROOT }
        }
        add_core_of = ROOT
        add_resistance = 15
    }
}

配合关系

  • any_neighbor_state:在 trigger 侧检查"是否存在满足条件的相邻州",与 every_neighbor_state 形成先判断再执行的标准搭配,避免对空集执行效果。
  • random_neighbor_state:当只需随机选取一个相邻州执行效果时使用,与 every_neighbor_state 互为"全部"与"随机一个"的对应关系。
  • add_core_of:批量为相邻州添加核心是最常见的使用场景,通常在 every_neighbor_state 的子块中调用。
  • transfer_state_to:与 every_neighbor_state 配合可实现连锁转让相邻州归属,常见于战后和平脚本或事件结局处理。

常见坑

  1. 忘记 scope 限制every_neighbor_state 只能在 STATE scope 下调用,若在 COUNTRY scope 中直接使用会导致脚本报错或行为异常,需先通过 capital_scope 等方式切入具体州 scope。
  2. limit 内误用 effect 命令:新手容易将 add_resistance 等 effect 写入 limit = { } 块中,limit 只接受 trigger,所有执行操作必须写在 limit 外部的子块里。

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_neighbor_state is commonly used in territorial expansion mods — for example, automatically adding cores or claims to all neighboring states after a country occupies one, or synchronously setting surrounding states to a high resistance level during resistance movement events. It is also well-suited for map-redrawing scripts that bulk-transfer ownership of adjacent states.

# When a country occupies a state, add claims to all neighboring states controlled by the enemy
42 = {
    every_neighbor_state = {
        limit = {
            is_owned_by = GER
            NOT = { is_core_of = ROOT }
        }
        add_core_of = ROOT
        add_resistance = 15
    }
}

Synergy

  • any_neighbor_state: Checks on the trigger side whether any neighboring state meets the specified conditions. Pairing this with every_neighbor_state gives you the classic pattern of checking before acting, preventing effects from being applied to an empty set.
  • random_neighbor_state: Use this when you only need to apply an effect to a single randomly selected neighboring state. It and every_neighbor_state are counterparts — "all" versus "one at random."
  • add_core_of: Bulk-adding cores to neighboring states is the most common use case, typically called inside the child block of every_neighbor_state.
  • transfer_state_to: Combining this with every_neighbor_state enables chain-transferring ownership of adjacent states, frequently seen in post-war peace scripts or event outcome handling.

Common Pitfalls

  1. Forgetting scope restrictions: every_neighbor_state can only be called within a STATE scope. Using it directly inside a COUNTRY scope will cause script errors or unexpected behavior — you must first enter a specific state scope via something like capital_scope.
  2. Accidentally placing effect commands inside limit: Beginners often write effects such as add_resistance inside a limit = { } block. limit only accepts triggers; all executable operations must be placed in the child block outside of limit.