Wiki

effect · ai_message

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

ai message... ?

实战 · 配合 · 坑

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

实战用法

ai_message 主要用于在 mod 中向 AI 国家传递某种内部消息或提示信号,常见于需要触发 AI 特定行为响应的场景,例如当玩家完成某项国策后通知 AI 盟友调整策略。由于官方文档对其参数描述极为有限,实际使用中多作为调试或实验性功能出现。

country_event = {
    id = my_mod.1
    hidden = yes
    immediate = {
        ai_message = {
            # 具体参数视实际游戏版本测试为准
        }
    }
}

配合关系

  • [add_ai_strategy](/wiki/effect/add_ai_strategy) — 两者常组合使用,在发送 ai_message 的同时通过 add_ai_strategy 给 AI 国家补充具体的策略权重,使 AI 行为调整更加完整。
  • [has_country_flag](/wiki/trigger/has_country_flag) — 用于在执行 ai_message 前检查特定标志位是否已设置,防止重复触发或在错误时机发送消息。
  • [country_event](/wiki/effect/country_event) — 常与 ai_message 搭配,在消息发送的同一执行块中同时触发一个隐藏事件,借助事件链实现更复杂的 AI 响应逻辑。
  • [clr_country_flag](/wiki/effect/clr_country_flag) — 发送消息后及时清除标志位,配合标志控制确保消息仅在预期条件下发送一次。

常见坑

  1. 参数不明导致静默失败:由于官方描述极度缺失,新手往往直接空写或随意填写参数,导致 effect 静默跳过却不报错,难以排查;建议在游戏日志和控制台中反复验证实际效果,不要假设其行为与字面含义完全吻合。
  2. 误以为可在非 COUNTRY scope 下使用:该 effect 仅支持 COUNTRY scope,若误写在 STATE 或 CHARACTER 等 scope 的执行块中会直接报错或被忽略,新手在嵌套 scope 时需格外注意当前 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

ai_message is primarily used to send internal messages or signal hints to AI nations within mods, commonly appearing in scenarios that require triggering specific AI behavioral responses—such as notifying AI allies to adjust their strategy after the player completes a certain focus. Due to severely limited official documentation on its parameters, actual usage often appears as a debugging or experimental feature.

country_event = {
    id = my_mod.1
    hidden = yes
    immediate = {
        ai_message = {
            # Specific parameters should be verified through testing with the actual game version
        }
    }
}

Synergy

  • [add_ai_strategy](/wiki/effect/add_ai_strategy) — Often combined with ai_message; while sending the message, use add_ai_strategy to supplement concrete strategy weights for the AI nation, making AI behavioral adjustments more comprehensive.
  • [has_country_flag](/wiki/trigger/has_country_flag) — Used to check whether a specific flag has been set before executing ai_message, preventing duplicate triggers or messages sent at the wrong time.
  • [country_event](/wiki/effect/country_event) — Commonly paired with ai_message; trigger a hidden event in the same execution block where the message is sent, leveraging event chains to implement more complex AI response logic.
  • [clr_country_flag](/wiki/effect/clr_country_flag) — Clear the flag promptly after sending the message, working in tandem with flag control to ensure the message is only sent once under intended conditions.

Common Pitfalls

  1. Silent failures due to unclear parameters: Because official descriptions are critically sparse, newcomers often leave parameters empty or fill them arbitrarily, causing the effect to silently skip without errors, making troubleshooting difficult. It is recommended to repeatedly verify actual behavior in the game log and console rather than assuming its behavior matches literal meaning perfectly.
  2. Mistakenly assuming usage outside COUNTRY scope: This effect only supports COUNTRY scope; if mistakenly placed in the execution block of STATE or CHARACTER scopes, it will either throw an error or be ignored. Beginners must exercise extra care regarding the current scope when nesting scopes.