Wiki

trigger · career_profile_check_ratio

Definition

  • Supported scope:any
  • Supported target:any

Description

Compares the ratio (first/second) of two career profile values to a number

实战 · 配合 · 坑

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

实战用法

career_profile_check_ratio 适合在生涯模式相关的 mod 中,根据玩家两项生涯数据的比值动态解锁奖励、勋章或特殊事件,例如判断"胜仗次数/总战役次数"是否达到一定水准。常见于检查玩家表现比例后决定是否触发特定剧情分支。

# 判断某两项生涯数值的比值是否达到阈值
trigger = {
    career_profile_check_ratio = {
        first = career_wins
        second = career_total_battles
        ratio > 0.75
    }
}

配合关系

  • [career_profile_check_value](/wiki/trigger/career_profile_check_value) — 单独检查某一项生涯数值的绝对量,常与比值检查并列使用,确保分母(第二项)不为零时才做比率判断更安全。
  • [career_profile_check_points](/wiki/trigger/career_profile_check_points) — 检查生涯积分总量,通常和比率条件一起放入 and 块,构成"积分达标且表现比率达标"的复合门槛。
  • [career_profile_check_medal](/wiki/trigger/career_profile_check_medal) — 比率通过后往往紧接着判断是否已获得对应勋章,避免重复授予奖励。
  • [and](/wiki/trigger/and) / [or](/wiki/trigger/or) — 将比率检查与其他生涯条件组合成复合逻辑,是包裹多个 career_profile_check_* 系列 trigger 的标准写法。

常见坑

  1. 分母为零导致除零错误:若 second 对应的生涯数值在某些存档中可能为 0(例如玩家从未打过战役),直接使用该 trigger 可能引发脚本报错或非预期结果,应先用 career_profile_check_value 确认第二项大于 0 再做比率判断。
  2. 比较符号写法错误:HOI4 脚本中比较运算符(><>= 等)与字段赋值写法容易混淆,新手有时误写成 ratio = 0.75 而非 ratio > 0.75,导致条件永远不满足或仅在精确相等时成立。

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

career_profile_check_ratio is ideal for career mode-related mods to dynamically unlock rewards, medals, or special events based on the ratio of two career statistics, such as determining whether "number of victories / total campaigns" meets a certain threshold. It is commonly used to check player performance ratios before deciding whether to trigger specific story branches.

Check whether the ratio of two career values meets the threshold

trigger = { career_profile_check_ratio = { first = career_wins second = career_total_battles ratio > 0.75 } }

Synergy

  • [career_profile_check_value](/wiki/trigger/career_profile_check_value) — Checks the absolute value of a single career statistic; commonly used alongside ratio checks to ensure safer conditional logic by verifying the denominator (second value) is non-zero before performing ratio calculations.
  • [career_profile_check_points](/wiki/trigger/career_profile_check_points) — Checks total career points; typically combined with ratio conditions within an and block to create a composite threshold of "points qualified AND performance ratio qualified."
  • [career_profile_check_medal](/wiki/trigger/career_profile_check_medal) — After passing the ratio check, this is often used immediately after to verify whether the corresponding medal has already been awarded, preventing duplicate reward grants.
  • [and](/wiki/trigger/and) / [or](/wiki/trigger/or) — Combines ratio checks with other career conditions into compound logic; the standard approach for wrapping multiple career_profile_check_* series triggers.

Common Pitfalls

  1. Division by zero errors from null denominator: If the career value corresponding to second could be 0 in certain save files (e.g., the player has never fought a campaign), using this trigger directly may cause script errors or unexpected results. Always use career_profile_check_value to confirm the second value is greater than 0 before performing the ratio check.
  2. Incorrect comparison operator syntax: Comparison operators (>, <, >=, etc.) in HOI4 scripts are easily confused with field assignment syntax; beginners sometimes mistakenly write ratio = 0.75 instead of ratio > 0.75, causing the condition to never be satisfied or only when values match exactly.