Wiki

effect · state_event

Definition

  • Supported scope:STATE, COUNTRY
  • Supported target:none

Description

Fires a state event.
Example:
state_event = {
	id = usa.61 # The event to fire.
	# Optional Fields:
	hours = 12 # The number of hours to wait before firing the event.
	days = 5 # The number of days to wait before firing the event.
	months = 1 # The number of months to wait before firing the event, where a month is treated as 30 days.
		# Note:  hours, days, and months can all be used and will simply be added together.
	random_hours = 18 # A random amount of hours to be added to the delay before firing, from 0 up to but not including random_hours.
	random_days = 2 # A random amount of days to be added to the delay before firing, from 0 up to but one hour less than random_days.
		# Note:  random_hours and random_days can both be used and will simply be added together.
	random = 6 # Equivalent to random_hours; preserverd for backwards compatibility.
	random = { chance = 50 ... } # Specify a set of child effects to execute as part of this effect, with a percentage chance of randomly happening or not (as a group, not individually).
	tooltip = usa.61.t # Manually specify which tooltip to use for this effect.
	trigger_for = GER # Indicate which country this state effect applies to. Value can be any of the following:
		# controller - The country that currently controls the state.
		# owner - The country that currently owns the state.
		# occupied - The country that has been occupied in the state by the current controller.
		# from - The country of the from scope.
		# prev - The country of the prev scope.
		# root - The country of the root scope.
		# TAG - A hard-coded country tag such as GER or ENG.
}

实战 · 配合 · 坑

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

实战用法

state_event 常用于需要将事件逻辑绑定到特定州省而非国家的场景,例如占领事件、资源争夺、地区起义等,在 STATE scope 下触发时可精准控制事件归属地。trigger_for 字段使其在多国共享同一州省的情况下(如驻军国与所有者不同)仍能将事件推送给正确的一方,非常适合占领与抵抗系统相关的 mod。

# 在某州抵抗度超标时,向控制该州的国家发送警告事件
every_controlled_state = {
    limit = {
        has_active_resistance = yes
        resistance_count_trigger > 50
    }
    state_event = {
        id = resistance.10
        days = 3
        trigger_for = controller
    }
}

配合关系

  • [has_active_resistance](/wiki/trigger/has_active_resistance):常作为触发 state_event 的前置条件,判断州省是否存在活跃抵抗运动,避免事件无意义触发。
  • [compliance](/wiki/trigger/compliance):在事件触发条件中检查顺从度阈值,配合 state_event 实现顺从度阶段性变化的叙事事件链。
  • [add_resistance](/wiki/effect/add_resistance):常在 state_event 的 option 结果中使用,根据玩家选择调整州省抵抗值,形成"事件→选择→州省状态改变"的闭环。
  • [every_controlled_state](/wiki/effect/every_controlled_state):作为外层循环遍历州省,配合 state_event 批量对满足条件的州省逐一触发事件。

常见坑

  1. 忽略 scope 导致事件无法触发:在 COUNTRY scope 下使用 state_event 时未指定 trigger_for,事件实际归属不明确;而在 STATE scope 下也需注意当前 scope 确实是州而非国家,混淆两者会导致事件静默失败且无报错提示。
  2. 误将 random 同时写为延迟和随机效果块random = 6 表示随机小时延迟,而 random = { chance = 50 ... } 是概率执行子效果块,两种写法语义完全不同,若不加区分地在同一事件中混用,逻辑会发生难以调试的错误。

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

state_event is commonly used in scenarios where event logic needs to be bound to a specific state rather than a country, such as occupation events, resource conflicts, and regional uprisings. When triggered within a STATE scope, it allows precise control over event ownership. The trigger_for field enables the event to be delivered to the correct party even when multiple countries share the same state (such as when an occupying force differs from the owner), making it especially suitable for mods related to occupation and resistance systems.

# Send a warning event to the country controlling a state when resistance exceeds threshold
every_controlled_state = {
    limit = {
        has_active_resistance = yes
        resistance_count_trigger > 50
    }
    state_event = {
        id = resistance.10
        days = 3
        trigger_for = controller
    }
}

Synergy

  • [has_active_resistance](/wiki/trigger/has_active_resistance): Commonly serves as a precondition for triggering state_event, checking whether active resistance exists in a state to avoid meaningless event triggers.
  • [compliance](/wiki/trigger/compliance): Checks compliance thresholds in event trigger conditions, working with state_event to implement narrative event chains with phased compliance changes.
  • [add_resistance](/wiki/effect/add_resistance): Frequently used in the option outcomes of state_event, adjusting state resistance values based on player choices to form a closed loop of "event → choice → state change."
  • [every_controlled_state](/wiki/effect/every_controlled_state): Serves as an outer loop to iterate through states, paired with state_event to batch-trigger events on all qualifying states one by one.

Common Pitfalls

  1. Overlooking scope causes event failure to trigger: When using state_event in a COUNTRY scope without specifying trigger_for, the event's actual ownership becomes unclear; conversely, within a STATE scope you must ensure the current scope is indeed a state and not a country. Confusing the two will result in silent event failure with no error message.
  2. Mixing random as both delay and conditional effect block: random = 6 denotes a random hour delay, whereas random = { chance = 50 ... } is a probability-based conditional effect block. These two syntaxes have completely different semantics, and mixing them indiscriminately in the same event will cause difficult-to-debug logic errors.