Wiki

trigger · has_cavalry_ratio

Definition

  • Supported scope:COMBATANT
  • Supported target:none

Description

Check that ratio of cavalry battalions in the composition of a side of combating troops are over a certain level.
For example:
has_cavalry_ratio > 0.5

实战 · 配合 · 坑

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

实战用法

has_cavalry_ratio 常用于战斗相关的 modifier 或 trait 触发场景,例如当某一交战方骑兵比例足够高时,为其附加专属战斗奖励,或者在特定地形(如平原、沙漠)战斗中激活骑兵突击的决策/特性。它只在 COMBATANT scope(即战斗双方各自的视角)内有效,因此通常出现在 on_combat_enter 或战斗相关的事件触发块中。

# 骑兵主导冲击:当进攻方骑兵比例超过 50% 时触发特殊 trait
on_combat_enter = {
    attacker = {
        limit = {
            is_attacker = yes
            has_cavalry_ratio > 0.5
            is_fighting_in_terrain = plains
        }
        add_trait = { trait = cavalry_charge_specialist }
    }
}

配合关系

  • is_attacker / is_defender:区分进攻方与防守方后再检测骑兵比例,避免对双方同时触发逻辑,让效果只作用于特定一侧。
  • is_fighting_in_terrain:骑兵在特定地形(平原、沙漠)优势更明显,将地形检测与骑兵比例检测叠加,可以做出更贴近战术现实的条件判断。
  • has_artillery_ratio:与炮兵比例触发同构,常成对出现用于"兵种构成判断"逻辑,方便对比或互斥地处理不同兵种主导的部队组成。
  • is_winning:在己方已占优势且骑兵比例高时叠加奖励,模拟骑兵扩大战果、追击溃敌的战术效果。

常见坑

  1. 忘记 scope 必须是 COMBATANT:直接在国家 scope(country scope)或省份 scope 里写 has_cavalry_ratio 会导致脚本报错或永远不触发,必须确保代码位于战斗双方的上下文块(如 attacker = { }defender = { } 内)中才有效。
  2. 比较运算符写成赋值或等号has_cavalry_ratio = 0.5 在语义上是"等于精确值",实际中几乎不可能命中;应使用 > 0.5> 0.3 这样的不等式,否则条件永远为假却难以察觉。

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

has_cavalry_ratio is commonly used in combat-related modifier or trait trigger scenarios, such as granting exclusive combat bonuses to a combatant when their cavalry composition reaches a sufficient threshold, or activating cavalry charge decisions/traits in specific terrain types (e.g., plains, deserts). It is only effective within the COMBATANT scope (i.e., the perspective of each side in combat), so it typically appears in on_combat_enter or combat-related event trigger blocks.

# Cavalry-led charge: triggers special trait when attacker's cavalry ratio exceeds 50%
on_combat_enter = {
    attacker = {
        limit = {
            is_attacker = yes
            has_cavalry_ratio > 0.5
            is_fighting_in_terrain = plains
        }
        add_trait = { trait = cavalry_charge_specialist }
    }
}

Synergy

  • is_attacker / is_defender: Distinguish between attacker and defender before checking cavalry ratio, avoiding logic triggering simultaneously for both sides and ensuring effects apply only to the intended party.
  • is_fighting_in_terrain: Cavalry gains more pronounced advantages in specific terrains (plains, deserts); stacking terrain detection with cavalry ratio checks enables more tactically realistic conditional logic.
  • has_artillery_ratio: Structurally analogous to artillery ratio triggering, often paired for "unit composition assessment" logic, facilitating comparison or mutual exclusion when handling different unit type-dominant force compositions.
  • is_winning: Stack additional bonuses when your side is already winning and cavalry ratio is high, simulating the tactical effect of cavalry expanding victories and pursuing routed enemies.

Common Pitfalls

  1. Forgetting the scope must be COMBATANT: Writing has_cavalry_ratio directly in country scope or province scope causes script errors or prevents triggering; code must be positioned within the context blocks of combatants (such as within attacker = { } or defender = { }) to function properly.
  2. Using assignment or equality operators instead of comparison operators: has_cavalry_ratio = 0.5 semantically means "equals exact value," which is almost impossible to hit in practice; use inequality operators like > 0.5 or > 0.3 instead, otherwise the condition remains perpetually false yet difficult to detect.