Wiki

trigger · is_power_balance_in_range

Definition

  • Supported scope:any
  • Supported target:none

Description

checks if current value power balance is within a certain range

Example:
is_power_balance_in_range = {
	id = power_balance_id
	range = power_balance_range_id
}

实战 · 配合 · 坑

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

实战用法

is_power_balance_in_range 常用于势力平衡系统的事件触发或决议解锁,例如当意识形态天平偏向某一侧到特定区间时,才允许玩家触发特殊外交选项或剧情事件。在自定义冷战 mod 中,可以用它来判断"资本主义 vs 共产主义"的势力差是否进入某个临界范围,从而激活代理战争机制。

# 仅当权力平衡处于某个特定区间时,才允许触发事件选项
available = {
    is_power_balance_in_range = {
        id = cold_war_balance
        range = tension_high_range
    }
}

配合关系

  • [power_balance_value](/wiki/trigger/power_balance_value):直接读取当前势力平衡数值,与 is_power_balance_in_range 形成互补——前者用于精确数值比较,后者用于区间判断,两者结合可实现多段式条件分支。
  • [power_balance_weekly_change](/wiki/trigger/power_balance_weekly_change):判断势力平衡的变化趋势,配合区间检测可区分"当前处于高位且还在上升"与"处于高位但已在下滑"两种不同情境。
  • [add_power_balance_value](/wiki/effect/add_power_balance_value):在 trigger 确认势力平衡位于目标区间后,通过此 effect 在 effect 块中进一步推动平衡偏移,实现"达到临界点后加速"的雪球机制。
  • [is_power_balance_side_active](/wiki/trigger/is_power_balance_side_active):检查势力平衡的某一侧是否处于激活状态,与区间判断配合使用可避免在平衡尚未初始化时就执行条件逻辑,防止脚本报错。

常见坑

  1. idrange 填写顺序颠倒或字段名拼写错误id 对应的是在 power_balance 定义文件中注册的平衡体系 ID,range 对应的是该体系下具体的区间 ID,两者不可互换,且必须在对应的数据库文件中提前声明,否则游戏会静默忽略条件或直接报 invalid token 错误。
  2. 在势力平衡尚未激活的 scope 下直接使用:若对应的 power_balance 在当前存档中还未被任何 focus/event 激活,is_power_balance_in_range 会始终返回 false 而不给出任何提示,建议先用 [is_power_balance_side_active](/wiki/trigger/is_power_balance_side_active) 做前置守卫检查。

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

is_power_balance_in_range is commonly used to trigger events or unlock decisions in the power balance system. For example, when an ideological scale tilts toward one side within a specific range, it allows the player to activate special diplomatic options or narrative events. In custom Cold War mods, you can use it to check whether the power difference between "capitalism vs communism" falls within a critical threshold, thereby activating proxy war mechanics.

# Event option is only available when power balance falls within a specific range
available = {
    is_power_balance_in_range = {
        id = cold_war_balance
        range = tension_high_range
    }
}

Synergy

  • [power_balance_value](/wiki/trigger/power_balance_value): Directly retrieves the current power balance value, forming a complement to is_power_balance_in_range — the former is used for precise numerical comparison, while the latter is used for range checking. Combining both enables multi-stage conditional branching.
  • [power_balance_weekly_change](/wiki/trigger/power_balance_weekly_change): Determines the trend of power balance change. When combined with range detection, it can distinguish between scenarios like "currently at a high value and still rising" versus "at a high value but declining."
  • [add_power_balance_value](/wiki/effect/add_power_balance_value): After the trigger confirms the power balance is within the target range, use this effect in the effect block to further push the balance shift, implementing a "snowball mechanism" that accelerates once a critical point is reached.
  • [is_power_balance_side_active](/wiki/trigger/is_power_balance_side_active): Checks whether one side of the power balance is in an active state. When combined with range checking, it prevents executing conditional logic before the balance is initialized, avoiding script errors.

Common Pitfalls

  1. Reversed order of id and range fields or typos in field names: id corresponds to the balance system ID registered in the power_balance definition file, while range corresponds to a specific range ID within that system. These are not interchangeable and must be declared in advance in the corresponding database file. Otherwise, the game will silently ignore the condition or throw an invalid token error.
  2. Using directly in a scope where the power balance has not been activated: If the corresponding power_balance has not been activated by any focus/event in the current save, is_power_balance_in_range will always return false without any warning. It is recommended to use [is_power_balance_side_active](/wiki/trigger/is_power_balance_side_active) as a guard check first.