Wiki

trigger · war_length_with

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Check number of months the country has been at war with X for Y months.
 war_length_with = { tag = X months > Y }

实战 · 配合 · 坑

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

实战用法

war_length_with 常用于在长期战争中触发特殊事件或解锁决议,例如当玩家与某国交战超过一定月数后开放外交谈判选项、激活战争疲惫惩罚或允许媾和决议。该 trigger 也适合用于 AI 策略脚本中,让 AI 在久拖不决的战争中改变行为方针。

# 示例:与德国交战超过 18 个月后可激活某项决议
available = {
    war_length_with = {
        tag = GER
        months > 18
    }
}

配合关系

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):先确认己方处于对目标国的防御战状态,再用 war_length_with 判断持续时长,逻辑更严谨。
  • [has_war_support](/wiki/trigger/has_war_support)(即 [has_bombing_war_support](/wiki/trigger/has_bombing_war_support) 等同类):长期战争往往伴随战争支持度变化,组合检查可做出更细腻的触发条件。
  • [activate_targeted_decision](/wiki/effect/activate_targeted_decision):满足交战时长条件后,用此 effect 激活针对目标国的特定决议(如媾和、施压等)。
  • [any_war_score](/wiki/trigger/any_war_score):结合战争分数判断,可同时检验"打了多久"与"打得怎么样",避免仅凭时长就触发不合理结果。

常见坑

  1. tag 填写大小写错误或使用了动态标签tag 字段必须填写固定的三字母国家标签(如 GERSOV),若目标国是通过动态 tag 生成的势力,war_length_with 无法正确匹配,会导致条件永远不满足。
  2. 误以为月数是"双向计时":该 trigger 统计的是当前 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

war_length_with is commonly used to trigger special events or unlock decisions during prolonged conflicts. For example, you can use it to unlock diplomatic negotiation options after fighting a specific nation for a certain number of months, activate war fatigue penalties, or enable peace settlement decisions. This trigger is also well-suited for AI behavior scripts, allowing the AI to shift strategy when a war drags on without resolution.

# Example: Enable a specific decision after fighting Germany for more than 18 months
available = {
    war_length_with = {
        tag = GER
        months > 18
    }
}

Synergy

  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): First confirm that your country is in a defensive war with the target, then use war_length_with to check duration for more rigorous logic.
  • [has_war_support](/wiki/trigger/has_war_support) (equivalent to [has_bombing_war_support](/wiki/trigger/has_bombing_war_support) and similar): Prolonged wars often correlate with fluctuations in war support, combining checks allows for more nuanced trigger conditions.
  • [activate_targeted_decision](/wiki/effect/activate_targeted_decision): After meeting the war duration condition, use this effect to activate a specific decision targeting the enemy nation (such as peace negotiations or coercion).
  • [any_war_score](/wiki/trigger/any_war_score): By combining with war score checks, you can verify both "how long we've fought" and "how well we're doing," avoiding unreasonable triggers based solely on duration.

Common Pitfalls

  1. Incorrect case in tag field or using dynamic tags: The tag field must contain a fixed three-letter country code (like GER or SOV). If the target nation is generated through dynamic tag assignment, war_length_with cannot match correctly and the condition will never be satisfied.
  2. Assuming the month counter is "bidirectional": This trigger counts the continuous months of war between your current scope nation and the target. If the war ends due to a ceasefire agreement or annexation and then restarts, the counter resets. New modders often forget this and become confused when the condition suddenly stops working.