Wiki

trigger · has_nationality

Definition

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

Description

Checks whether the operative has the specified nationality.
NOTE: this is invalid on non-operatives.
Examples:
has_nationality = GER

实战 · 配合 · 坑

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

实战用法

has_nationality 常用于谍报/特工系统的 mod 场景,例如根据特工的国籍决定其是否可以执行特定任务、触发专属事件,或在 limit 块中筛选目标特工进行国籍转换。以下示例展示如何限制只对德国特工执行某操作:

# 在 operative_leader_event 的 trigger 块中
trigger = {
    is_operative = yes
    has_nationality = GER
}

配合关系

  • [is_operative](/wiki/trigger/is_operative):使用 has_nationality 前必须确认角色是特工身份,否则游戏脚本会报错,两者几乎总是成对出现。
  • [set_nationality](/wiki/effect/set_nationality):常见于"策反/转化特工"逻辑——先用 has_nationality 判断原始国籍,再用 set_nationality 将其转变为新阵营。
  • [turn_operative](/wiki/effect/turn_operative):将对方特工转为己方时,通常先以 has_nationality 筛选出目标国籍的特工,再触发策反效果。
  • [add_nationality](/wiki/effect/add_nationality):为特工增加双重国籍前,可用 has_nationality 检查其当前主国籍,避免逻辑冲突。

常见坑

  1. 在非特工角色 scope 下使用has_nationality 对普通将领、顾问等非 operative 角色无效,脚本不会报语法错误但永远返回 false,需配合 is_operative = yes 提前过滤,否则逻辑会静默失效。
  2. 混淆"国籍"与"所属国":特工的 nationality(国籍)和其当前被哪个国家雇用/控制是两个不同概念,has_nationality 检查的是前者,不能用来判断特工当前效忠于哪国,新手容易将两者混用导致条件判断错误。

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

has_nationality is commonly used in espionage/operative system mod scenarios, such as determining whether an operative can execute specific missions based on their nationality, triggering exclusive events, or filtering target operatives for nationality conversion within limit blocks. The following example demonstrates how to restrict an operation to only German operatives:

# In the trigger block of operative_leader_event
trigger = {
    is_operative = yes
    has_nationality = GER
}

Synergy

  • [is_operative](/wiki/trigger/is_operative): Before using has_nationality, you must confirm the character is an operative, otherwise the game script will error. These two almost always appear together in pairs.
  • [set_nationality](/wiki/effect/set_nationality): Common in "turn/convert operative" logic—first use has_nationality to check the original nationality, then use set_nationality to convert them to the new faction.
  • [turn_operative](/wiki/effect/turn_operative): When turning an enemy operative into your own, typically filter operatives of the target nationality using has_nationality first, then trigger the defection effect.
  • [add_nationality](/wiki/effect/add_nationality): Before granting an operative dual nationality, you can use has_nationality to check their current primary nationality and avoid logical conflicts.

Common Pitfalls

  1. Using it under non-operative character scopes: has_nationality has no effect on regular generals, advisors, and other non-operative characters. The script will not throw a syntax error but will always return false. You must filter in advance with is_operative = yes, otherwise the logic will silently fail.
  2. Confusing "nationality" with "employment nation": An operative's nationality and which country currently employs/controls them are two different concepts. has_nationality checks the former and cannot be used to determine which nation an operative is currently loyal to. Beginners often conflate the two, resulting in incorrect condition logic.