Wiki

trigger · is_ai

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Checks if country is AI controlled.

实战 · 配合 · 坑

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

实战用法

is_ai 最常见于平衡性 mod 中,对 AI 国家给予额外资源或简化决策条件,避免 AI 因复杂前置条件卡死流程。也常用于限制某些仅对玩家有意义的 focus/decision 选项,防止 AI 触发后产生不合逻辑的剧情分支。

# 某个国家决策:仅玩家可手动触发,AI 自动跳过
available = {
    NOT = { is_ai = yes }
}

# 或在 modifier 中给 AI 补偿
if = {
    limit = { is_ai = yes }
    add_political_power = 50
}

配合关系

  • [has_country_flag](/wiki/trigger/has_country_flag):常与 is_ai 组合,用"仅 AI 且带有特定 flag"来追踪 AI 是否已执行过某一补偿逻辑,防止重复触发。
  • [add_political_power](/wiki/effect/add_political_power) / [add_stability](/wiki/effect/add_stability):AI 缺乏玩家的微操能力,用这类 effect 在 is_ai = yes 分支内给 AI 适当加成,维持游戏平衡。
  • [has_completed_focus](/wiki/trigger/has_completed_focus):玩家版国策树往往有复杂分支,配合 is_ai 可以让 AI 走精简路径——只检查关键 focus 是否完成,跳过人机体验不同的中间步骤。
  • [country_event](/wiki/effect/country_event):对 AI 触发专属补偿或剧情事件时,在 trigger 块加 is_ai = yes 过滤,确保该事件不会弹给玩家打断沉浸感。

常见坑

  1. 混淆 is_ai = yesis_ai = no 的逻辑方向:新手有时在 available 块里写 is_ai = yes 本意是"只有 AI 才满足条件",却忘了这样一来玩家永远无法触发该决策。若想"玩家专属",应写 NOT = { is_ai = yes } 或直接 is_ai = no
  2. 在非 COUNTRY scope 下调用is_ai 只能在国家 scope 内生效,若父块 scope 已切换为 state 或 character(例如在 any_owned_state 的 limit 里直接写),脚本会报 scope 错误或静默返回假,需先用 owner = { is_ai = yes } 等方式切回国家 scope。

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_ai most commonly appears in balance mods, providing AI nations with additional resources or simplified decision conditions to prevent AI from getting stuck due to complex prerequisites. It's also frequently used to restrict certain focus/decision options that only make sense for human players, preventing AI from triggering illogical story branches after selection.

# A certain nation's decision: only manually triggerable by player, AI automatically skips
available = {
    NOT = { is_ai = yes }
}

# Or provide compensation to AI via modifier
if = {
    limit = { is_ai = yes }
    add_political_power = 50
}

Synergy

  • [has_country_flag](/wiki/trigger/has_country_flag): Commonly combined with is_ai to track whether AI has already executed a certain compensation logic using the condition "AI only and has specific flag", preventing duplicate triggers.
  • [add_political_power](/wiki/effect/add_political_power) / [add_stability](/wiki/effect/add_stability): AI lacks the micromanagement capabilities of human players; these effects are used within is_ai = yes branches to give AI appropriate bonuses and maintain game balance.
  • [has_completed_focus](/wiki/trigger/has_completed_focus): Player-oriented national focus trees often have complex branches; combined with is_ai, this allows AI to follow streamlined paths—checking only if key focuses are completed while skipping intermediate steps that differ between human and AI experience.
  • [country_event](/wiki/effect/country_event): When triggering exclusive compensation or story events for AI, add is_ai = yes filtering in the trigger block to ensure such events don't pop up for players and break immersion.

Common Pitfalls

  1. Confusing the logic direction of is_ai = yes versus is_ai = no: Beginners sometimes write is_ai = yes in an available block intending "only AI satisfies this condition", but forget that this means players can never trigger that decision. To create a "player-exclusive" option, use NOT = { is_ai = yes } or directly is_ai = no.
  2. Calling outside COUNTRY scope: is_ai only works within country scope; if the parent block's scope has already switched to state or character (for example, directly writing it in the limit of any_owned_state), the script will report a scope error or silently return false. You need to switch back to country scope first using methods like owner = { is_ai = yes }.