Wiki

effect · add_named_threat

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Adds country threat

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.