effect · add_ai_strategy
Definition
- Supported scope:
COUNTRY - Supported target:
THIS,ROOT,PREV,FROM,OWNER,CONTROLLER,OCCUPIED,CAPITAL
Description
Adds strategy entry to country AI
add_ai_strategyCOUNTRYTHIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITALAdds strategy entry to country AI
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.
add_ai_strategy is primarily used to dynamically intervene in AI behavioral logic when events, decisions, or national focuses are triggered—for example, making a certain nation's AI prioritize attacking specific targets, maintain friendly relations with another nation, or increase weighting toward certain action types. It is commonly found in diplomatic event chains, where it increases an AI ally's affinity weighting toward a specific nation, or after war erupts, concentrates AI military forces in particular directions.
# In an event option, increase the target nation's AI alliance tendency toward the player
country_event = {
id = my_mod.1
option = {
name = my_mod.1.a
FROM = {
add_ai_strategy = {
type = alliance
id = "TAG"
value = 100
}
}
}
}
[has_country_flag](/wiki/trigger/has_country_flag): Use flags first to detect whether a strategy injection has already been executed, avoiding repeated stacking of similar strategies that could cause weight values to spiral out of control.[add_opinion_modifier](/wiki/effect/add_opinion_modifier): In diplomatic scenarios, pair with AI strategy adjustments to both alter AI decision tendencies and provide visible relationship feedback to the player—more logically complete.[add_named_threat](/wiki/effect/add_named_threat): When events raise threat levels, simultaneously adjust the AI's hostility strategy toward specific nations, keeping AI behavior synchronized with global situation changes.[ai_irrationality](/wiki/trigger/ai_irrationality): Serve as a precondition check for the AI's random behavior variance; inject critical strategies only when the AI is in a rational state to prevent strategies from being overridden by random factors.type values require different subfields (such as whether id should contain a nation TAG or another identifier). Using a template without verifying the type documentation causes the strategy to silently fail with no AI behavior change, and the console will not report an error.value depends on the strategy type; not all types follow "positive value = higher tendency." For example, in certain types, negative values represent increased hostility, and reversing the sign will cause AI behavior to be completely opposite to expectations.