trigger · has_defensive_war_with
Definition
- Supported scope:
COUNTRY - Supported target:
THIS,ROOT,PREV,FROM,OWNER,CONTROLLER,OCCUPIED,CAPITAL
Description
One country has defensive war against other country.
has_defensive_war_withCOUNTRYTHIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITALOne country has defensive war against other country.
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
此 trigger 常用于防御战争相关的事件或决策场景,例如为正在被侵略的国家解锁特殊援助选项、激活抵抗加成 idea,或触发"本土保卫战"类型的剧本事件。下面示例展示一个决策:仅当本国处于针对特定敌国的防御战争时才可用。
available = {
has_defensive_war_with = FROM
}
也可在事件触发条件中使用,判断玩家国家是否正被某目标国侵略:
trigger = {
has_defensive_war_with = ROOT
}
[has_defensive_war](/wiki/trigger/has_defensive_war):has_defensive_war 只判断"是否存在任何防御战争",而 has_defensive_war_with 精确到对手国家,两者常嵌套或并列使用,先粗筛再精确锁定目标。[any_enemy_country](/wiki/trigger/any_enemy_country):可在 any_enemy_country 的子条件中配合使用,遍历敌国并用 has_defensive_war_with 筛选出真正的攻击方,逻辑更严谨。[has_war_goal_against](/wiki/trigger/has_war_goal_against) (见下注)/[can_declare_war_on](/wiki/trigger/can_declare_war_on):配合后者可在 AI 策略或决策中区分"防御中"与"可宣战"两种互斥状态,避免逻辑冲突。[add_ideas](/wiki/effect/add_ideas):当条件满足时添加"全国动员"类 idea,赋予防御方战时加成,是最典型的 effect 配合方式。THIS/ROOT/PREV/FROM/OWNER 等动态 scope 关键词,不能直接写国家 tag 字符串(如 GER),否则脚本解析会静默失败,条件永远为假。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.
This trigger is commonly used in defensive war-related events or decision scenarios, such as unlocking special aid options for invaded nations, activating resistance bonus ideas, or triggering "homeland defense" type scripted events. The example below shows a decision that is only available when your country is in a defensive war against a specific enemy.
available = {
has_defensive_war_with = FROM
}
It can also be used in event trigger conditions to check whether the player's nation is being invaded by a target nation:
trigger = {
has_defensive_war_with = ROOT
}
[has_defensive_war](/wiki/trigger/has_defensive_war): has_defensive_war only checks "whether any defensive war exists", while has_defensive_war_with pinpoints the opposing nation. Both are often nested or used in parallel—first coarse filtering, then precise target identification.[any_enemy_country](/wiki/trigger/any_enemy_country): Can be used within any_enemy_country subscopes to iterate through enemy nations and filter actual attackers with has_defensive_war_with, providing more rigorous logic.[has_war_goal_against](/wiki/trigger/has_war_goal_against) (see note below) / [can_declare_war_on](/wiki/trigger/can_declare_war_on): When combined, these allow distinguishing between "currently defending" and "can declare war" as mutually exclusive states in AI strategies or decisions, avoiding logical conflicts.[add_ideas](/wiki/effect/add_ideas): When conditions are met, adds "full mobilization" type ideas to grant the defending nation wartime bonuses—the most typical effect synergy.THIS/ROOT/PREV/FROM/OWNER, and cannot directly write nation tag strings (e.g., GER). Otherwise the script parsing will silently fail and the condition will always be false.