trigger · exists
Definition
- Supported scope:
COUNTRY - Supported target:
none
Description
Check if the current country exist. The country of the scope you are in. Example: DEN = { exists = yes }
existsCOUNTRYnoneCheck if the current country exist. The country of the scope you are in. Example: DEN = { exists = yes }
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
exists 常用于国家事件或决策的 trigger/available 块中,防止脚本对已经被消灭(不存在)的国家进行操作,避免出现空指针错误或逻辑异常。例如在一个"邀请盟友加入阵营"的决策里,先确认目标国仍然存在再执行后续判断:
available = {
GER = { exists = yes }
GER = { is_in_faction = no }
}
[has_capitulated](/wiki/trigger/has_capitulated):投降国在技术上可能仍"存在",配合使用可区分"存在但已投降"与"彻底亡国"两种状态,逻辑更严谨。[any_allied_country](/wiki/trigger/any_allied_country):遍历盟友时嵌套 exists = yes 作为过滤条件,确保循环内的每个盟友都是有效国家。[annex_country](/wiki/effect/annex_country):在执行吞并前先用 exists = yes 做前置检查,防止对已不存在的国家标签执行吞并导致脚本报错。[country_event](/wiki/effect/country_event):向特定国家发送事件前确认其存在,避免事件发往已灭亡的国家标签而静默失败。exists = yes 只检查国家标签是否仍在游戏中注册,已投降但未被吞并的国家依然返回 true,若需排除投降国需额外搭配 has_capitulated = no。exists 写进 effect(效果)块,例如直接放在 country_event 的 immediate 里,这会导致脚本解析报错——exists 是纯判断 trigger,只能出现在条件块中。