effect · random_neighbor_state
Definition
- Supported scope:
STATE - Supported target:
none
Description
Executes children effects on random neighbor state that fulfills the "limit" trigger.
random_neighbor_stateSTATEnoneExecutes children effects on random neighbor state that fulfills the "limit" trigger.
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
random_neighbor_state 常用于扩张类 mod 中,让某个州随机向一个邻近州施加核心、索取领土,或传播抵抗/顺从效果,实现动态的地缘政治蔓延。也可用于事件中,让占领方随机在一个邻近州建造建筑或改变控制权,模拟战时资源整合。
# 在某个州事件中,随机选取一个由敌方控制的邻近州,为当前标签添加对其的核心
state_event = {
id = my_mod.1
...
option = {
name = my_mod.1.a
random_neighbor_state = {
limit = {
NOT = { is_owned_by = ROOT }
is_controlled_by = ROOT
}
add_core_of = ROOT
add_claim_by = ROOT
}
}
}
random_neighbor_state 执行效果,避免在无合法目标时静默失败。limit 块时,游戏会从所有邻近州中随机抽取,包括己方控制或不相关的州,应始终通过 limit 明确筛选条件,若无合法目标则该 effect 静默跳过,不会报错也不会执行。random_neighbor_state 仅在 STATE scope 下有效,若在国家 scope(如 country_event 的 option 顶层)直接写会导致脚本报错或无效,必须先通过 random_state、capital_scope 等进入正确的 STATE scope 后再调用。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.
random_neighbor_state is commonly used in expansion-focused mods to have a state randomly impose cores on a neighboring state, claim territory, or spread resistance/compliance effects, simulating dynamic geopolitical expansion. It can also be used in events to let an occupying power randomly construct buildings or change control in a neighboring state, modeling wartime resource consolidation.
# In a state event, randomly select a neighboring state not owned by ROOT but controlled by ROOT,
# then add a core and claim on it for the current tag
state_event = {
id = my_mod.1
...
option = {
name = my_mod.1.a
random_neighbor_state = {
limit = {
NOT = { is_owned_by = ROOT }
is_controlled_by = ROOT
}
add_core_of = ROOT
add_claim_by = ROOT
}
}
}
random_neighbor_state to apply the effect — this prevents silent failures when no valid target is available.limit filter to transfer ownership of the randomly selected neighboring state to a specified country; frequently seen in event-driven territorial redistribution scenarios.limit and selecting an unintended state: Without a limit block, the game draws randomly from all neighboring states, including those you own or that are otherwise irrelevant. Always use limit to define explicit selection criteria. If no valid target exists, the effect is silently skipped — no error is thrown and nothing is executed.random_neighbor_state is only valid within a STATE scope. Writing it at the top level of a country_event option will cause a script error or have no effect. You must first enter a valid STATE scope — for example via random_state or capital_scope — before calling it.