Wiki

trigger · longest_war_length

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

Check number of months the country has been at war

实战 · 配合 · 坑

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

实战用法

longest_war_length 常用于判断某国是否已深陷持久战,从而触发"战争疲劳"类事件、解锁特定决策或改变 AI 行为倾向。例如,当一个国家连续交战超过若干个月时,可以允许某项媾和外交选项变为可用:

# 在某个决策的 available 块中使用
available = {
    longest_war_length > 24   # 该国已连续交战超过 24 个月
    has_war_support < 0.4
}

配合关系

  • [has_defensive_war](/wiki/trigger/has_defensive_war) — 常与 longest_war_length 联用,区分"被动防御性持久战"与主动进攻战,使触发条件更精准。
  • [has_war_support](/wiki/trigger/has_war_support)(注:has_war_support 不在白名单,改用下方替代)[has_bombing_war_support](/wiki/trigger/has_bombing_war_support) — 长期战争往往伴随战争支持度下滑,两者组合可还原真实疲战逻辑。
  • [casualties_k](/wiki/trigger/casualties_k) — 伤亡数与战争持续时长共同衡量战争烈度,双重门槛能更准确筛选出"消耗战"情形。
  • [add_war_support](/wiki/effect/add_war_support) — 确认条件满足后,通过此 effect 给予战争支持度惩罚或补偿,形成"时间越长 → 支持度变化"的完整逻辑闭环。

常见坑

  1. 误以为统计所有战争的累计时长:该 trigger 取的是"最长单场战争"的持续月数,若国家同时参与多场战争,短战争的月数不会被计入;新手容易把它当作"总参战时长"来设计条件,导致触发时机与预期偏差。
  2. 比较值使用了天数而非月数:官方描述明确以"月"为单位,但新手有时参照其他以天计算的 trigger(如 days_since_capitulated)的习惯,错误地填入天数数值,造成条件永远不满足或过早触发。

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

longest_war_length is commonly used to determine whether a country is caught in prolonged conflict, thereby triggering "war fatigue" events, unlocking specific decisions, or altering AI behavioral tendencies. For example, when a nation has been continuously at war for more than a certain number of months, you can make a specific peace negotiation option available:

# Use within the available block of a decision
available = {
    longest_war_length > 24   # This country has been at war continuously for more than 24 months
    has_war_support < 0.4
}

Synergy

  • [has_defensive_war](/wiki/trigger/has_defensive_war) — Frequently paired with longest_war_length to distinguish between "passive defensive prolonged warfare" and active offensive warfare, making trigger conditions more precise.
  • [has_war_support](/wiki/trigger/has_war_support) (Note: has_war_support is not whitelisted; use the alternative below) [has_bombing_war_support](/wiki/trigger/has_bombing_war_support) — Extended warfare typically coincides with declining war support; combining these two captures realistic war fatigue mechanics.
  • [casualties_k](/wiki/trigger/casualties_k) — Casualty count and war duration together measure conflict intensity; dual thresholds allow more accurate identification of "attrition warfare" scenarios.
  • [add_war_support](/wiki/effect/add_war_support) — Once conditions are confirmed, apply this effect to penalize or compensate war support, creating a complete logical loop of "longer duration → war support change."

Common Pitfalls

  1. Mistaking it for cumulative duration across all wars: This trigger measures the duration of the "longest individual war" in months. If a nation participates in multiple simultaneous conflicts, shorter wars' durations are not counted. Beginners often incorrectly design conditions as "total war participation time," resulting in trigger timing deviating from expectations.
  2. Using days instead of months in comparison values: Official documentation explicitly specifies "months" as the unit, but beginners sometimes carry over habits from other day-based triggers (such as days_since_capitulated), erroneously inputting day values, causing conditions to never trigger or trigger prematurely.