Wiki

trigger · is_in_state

Definition

  • Supported scope:CHARACTER
  • Supported target:THIS, ROOT, PREV, FROM, CAPITAL

Description

Checks if the character is in a specific state.
Works for deployed generals (HQ location), scientists (facility location including faction programs), and operatives (mission location).

### Example

Check if a general is in a specific state

any_unit_leader = { is_in_state = 64 # Brandenburg }

Check if any scientist is in the capital

every_character = { limit = { is_active_scientist = yes } is_in_state = root.capital }

实战 · 配合 · 坑

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

实战用法

is_in_state 常用于情报/间谍系统的事件触发,例如当特工在某目标地区执行任务时才激活特定剧情,或在科学家已被分配到特定设施时限制某些选项。也可以用于战役事件,检查指挥官的总部是否已推进到关键战略要地。

# 特工潜入指定州份后触发特殊事件
any_character = {
    limit = {
        is_operative = yes
        is_operative_captured = no
        is_in_state = 219 # 例:柏林所在州
    }
    operative_leader_event = { id = my_mod.42 }
}

配合关系

  • is_operative — 在检查 is_in_state 前先确认角色身份为特工,避免对将领或科学家误判。
  • operative_leader_mission — 配合使用可同时限定"在该州"且"正执行特定任务",精确锁定触发条件。
  • is_active_scientist — 检查科学家是否在某设施(州份)内工作时,需先用此 trigger 确认角色处于激活研究状态。
  • is_army_leader — 检查将领总部位置前,先用此 trigger 确认角色为部署中的陆军指挥官,防止 scope 内混入非将领角色导致逻辑失效。

常见坑

  1. scope 不正确导致静默失败is_in_state 仅在 CHARACTER scope 下有效,若在国家 scope(如 country_event 的顶层)直接调用而未通过 any_unit_leaderevery_character 等先切换进角色 scope,条件会直接视为假而不报错,非常难以排查。

  2. 将领位置是 HQ 而非前线:对将领使用此 trigger 检测的是其司令部(HQ)所在州,而非其麾下部队实际交战的州份。新手常误以为检测的是战线位置,导致在快速推进战役中触发条件始终不符合预期。

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

is_in_state is commonly used to trigger events in the intelligence/operative system — for example, activating a specific storyline only when an operative is carrying out a mission in a target region, or restricting certain options when a scientist has already been assigned to a particular facility. It can also be used in campaign events to check whether a commander's HQ has advanced to a key strategic location.

# Trigger a special event once an operative has infiltrated the target state
any_character = {
    limit = {
        is_operative = yes
        is_operative_captured = no
        is_in_state = 219 # e.g. the state containing Berlin
    }
    operative_leader_event = { id = my_mod.42 }
}

Synergy

  • is_operative — Confirm the character is an operative before evaluating is_in_state, to avoid false positives on generals or scientists.
  • operative_leader_mission — Combine with is_in_state to simultaneously require "in this state" and "executing a specific mission," pinning down the trigger condition precisely.
  • is_active_scientist — When checking whether a scientist is working at a particular facility (state), use this trigger first to confirm the character is in an active research state.
  • is_army_leader — Before checking a general's HQ location, use this trigger to confirm the character is an actively deployed army commander, preventing non-general characters from slipping into the scope and silently breaking your logic.

Common Pitfalls

  1. Silent failure due to incorrect scope: is_in_state is only valid inside a CHARACTER scope. If it is called directly at the top level of a country scope (e.g. the root of a country_event) without first switching into a character scope via any_unit_leader, every_character, or similar, the condition will simply evaluate as false with no error message — making it extremely difficult to diagnose.

  2. A general's position is their HQ, not the front line: When used on a general, this trigger checks the state containing their headquarters (HQ), not the states where their subordinate units are actually engaged in combat. Beginners often assume it reflects the front-line position, which causes trigger conditions to never fire as expected during fast-moving offensive campaigns.