Wiki

trigger · any_war_score

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

compares the warscore of all wars in a country to see if any fullfills the comparison condition 0-100 - Example: any_war_score > 40

实战 · 配合 · 坑

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

实战用法

any_war_score 常用于判断某国是否在任意一场战争中占据优势,从而触发外交事件、开放选项或调整 AI 战略。例如可用于"当己方在至少一场战争中战绩超过 60 分时,才允许提出和平谈判的决策"。

# 在 decision/focus 的 available 块中:判断是否有一场战争战绩超过 60
available = {
    has_war = yes
    any_war_score > 60
}

也可结合事件触发:当战绩不佳时阻止选项激活:

trigger = {
    has_war = yes
    any_war_score < 20
    has_war_support < 0.4
}

配合关系

  • has_warany_war_score 只在交战状态下有意义,通常先用 has_war = yes 确保国家处于战争中,再检查战绩数值,避免逻辑错误。
  • has_war_support:战场战绩与战争支持度往往联动判断,两者组合可精确描述一国的整体战争态势。
  • has_defensive_war:区分防御战与进攻战后再检查战绩,可为不同战争性质设置不同的阈值条件。
  • create_wargoal:在满足战绩条件后,通过该 effect 追加新的战争目标,模拟"趁胜追击"的外交逻辑。

常见坑

  1. 不加 has_war 前置保护:当国家未处于任何战争时,any_war_score 的行为未定义或直接返回假,若不先检查 has_war = yes 就直接比较数值,逻辑可能出现静默失效,条件块永远不满足却难以排查原因。
  2. 数值范围混淆:战绩的合法范围是 0–100(整数比较),部分新手误将其当作 0–1 的小数比例(如写 any_war_score > 0.6),导致条件永远无法命中。

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

any_war_score is commonly used to check whether a country holds an advantage in at least one ongoing war, enabling diplomatic events, unlocking options, or adjusting AI strategy. A typical use case is "allow a peace negotiation decision only when the country's war score exceeds 60 in at least one war."

# Inside a decision/focus available block: check whether war score exceeds 60 in any war
available = {
    has_war = yes
    any_war_score > 60
}

It can also be used in event triggers to block an option from activating when the war is going poorly:

trigger = {
    has_war = yes
    any_war_score < 20
    has_war_support < 0.4
}

Synergy

  • has_war: any_war_score is only meaningful while a country is at war. Always guard with has_war = yes first before checking the score value to avoid silent logic errors.
  • has_war_support: Battlefield war score and war support are frequently evaluated together; combining the two gives a precise picture of a country's overall war situation.
  • has_defensive_war: Distinguishing between defensive and offensive wars before checking war score lets you apply different threshold conditions depending on the nature of the conflict.
  • create_wargoal: Once a war score condition is met, use this effect to append new war goals, simulating a "press the advantage" diplomatic logic.

Common Pitfalls

  1. Missing has_war guard: When a country is not involved in any war, any_war_score is either undefined or evaluates to false outright. Comparing the value without first checking has_war = yes can cause silent failures where the condition block never evaluates to true yet is difficult to debug.
  2. Confusing the value range: The valid range for war score is 0–100 (integer comparison). Some newcomers mistakenly treat it as a 0–1 decimal ratio (e.g., writing any_war_score > 0.6), causing the condition to never match.