Wiki

effect · add_named_threat

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Adds country threat

实战 · 配合 · 坑

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

实战用法

add_named_threat 常用于事件或决策中,让某个国家的行为向全世界施加"威胁值",从而触发其他国家的 AI 反应或联盟警觉机制。例如在扩张性国策或宣战事件中,为侵略方附加有具体名称标签的威胁,便于后续用该名称做条件判断或显示在 tooltip 中。

# 某国完成侵略性国策后触发
country_event = {
    id = my_mod.101
    immediate = {
        add_named_threat = {
            threat = 2
            name = my_mod_aggressive_expansion
        }
    }
}

配合关系

  • [add_threat](/wiki/effect/add_threat):无命名版本的威胁增加,两者常对比使用——需要在 UI 或脚本中追踪具体来源时用 add_named_threat,批量快速叠加时用 add_threat
  • [has_added_tension_amount](/wiki/trigger/has_added_tension_amount):检测当前世界紧张度是否达到阈值,与 add_named_threat 配合构成"施加威胁 → 判断全局紧张局势"的完整逻辑链。
  • [create_wargoal](/wiki/effect/create_wargoal):AI 国家在威胁积累到一定程度后常被触发宣战目标,两者组合模拟"侵略升级"剧情。
  • [add_opinion_modifier](/wiki/effect/add_opinion_modifier):威胁上升后同步降低外交关系,让 mod 中的国际反应更真实立体。

常见坑

  1. name 字段必须对应已本地化的字符串键,若未在 .yml 本地化文件中定义对应条目,游戏内 tooltip 会显示原始键名(如 my_mod_aggressive_expansion)而非可读文本,容易被误以为脚本出错。
  2. 威胁是全局共享数值,不是单独施加给目标国——新手常误以为可以"只让某两国之间增加威胁",实际上该 effect 作用于执行 scope 的国家,影响的是世界紧张度池,无法通过 target 限定接收方。

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

add_named_threat is commonly used in events or decisions to make a country's actions impose "threat" to the rest of the world, thereby triggering AI responses or alliance alert mechanisms in other nations. For example, in expansionist national focuses or war declaration events, you can attach a named threat with a specific label to the aggressor, making it easy to reference by name in subsequent conditional checks or display in tooltips.

# Triggered after a country completes an aggressive focus
country_event = {
    id = my_mod.101
    immediate = {
        add_named_threat = {
            threat = 2
            name = my_mod_aggressive_expansion
        }
    }
}

Synergy

  • [add_threat](/wiki/effect/add_threat): The unnamed version of threat increase; both are often used contrastively—use add_named_threat when you need to track specific sources in UI or scripts, and use add_threat for bulk rapid accumulation.
  • [has_added_tension_amount](/wiki/trigger/has_added_tension_amount): Checks if the current world tension has reached a threshold; combined with add_named_threat to form a complete logic chain of "impose threat → evaluate global tension".
  • [create_wargoal](/wiki/effect/create_wargoal): AI nations are often triggered to create war goals once threat accumulates to a certain level; the two together simulate "escalating aggression" storylines.
  • [add_opinion_modifier](/wiki/effect/add_opinion_modifier): Synchronously reduce diplomatic relations as threat rises, making international responses in your mod more realistic and nuanced.

Common Pitfalls

  1. The name field must correspond to a localized string key—if the corresponding entry is not defined in the .yml localization file, the in-game tooltip will display the raw key name (e.g., my_mod_aggressive_expansion) rather than readable text, easily mistaken as a scripting error.
  2. Threat is a globally shared value, not applied exclusively between two nations—newcomers often mistakenly believe they can "add threat only between two specific countries," but in reality this effect applies to the executing scope's country and affects the world tension pool; you cannot limit the recipient via target.