Wiki

trigger · is_power_balance_side_active

Definition

  • Supported scope:any
  • Supported target:none

Description

checks if specified side is currently active

Example:
is_power_balance_side_active = {
	id = power_balance_id
	side = side_id
}

实战 · 配合 · 坑

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

实战用法

在制作势力平衡(Power Balance)系统的 mod 时,常需要根据某一阵营是否处于激活状态来决定是否触发事件、解锁决议或显示 AI 逻辑分支。例如,当玩家的意识形态斗争尚未达到激活阈值时,屏蔽某些选项;或在 available 块中确认某阵营确实活跃后才允许执行相关操作。

# 仅当"左翼"阵营处于激活状态时,该决议才可选
decision_example = {
    available = {
        is_power_balance_side_active = {
            id = ideology_struggle
            side = left_wing_side
        }
    }
}

配合关系

  • [is_power_balance_in_range](/wiki/trigger/is_power_balance_in_range):通常先用 is_power_balance_side_active 确认阵营已激活,再用 is_power_balance_in_range 检查当前数值是否落在期望区间,二者组合构成完整的势力平衡条件判断。
  • [has_power_balance_modifier](/wiki/trigger/has_power_balance_modifier):激活状态检查通过后,往往需要进一步确认该阵营是否已附加了特定修正值,两个 trigger 通常嵌套在同一 and 块中。
  • [add_power_balance_value](/wiki/effect/add_power_balance_value):在 effect 块里,确认阵营激活后才执行数值变化,避免对未激活阵营写入数值引发脚本错误。
  • [add_power_balance_modifier](/wiki/effect/add_power_balance_modifier):与激活检查配合,仅在阵营活跃时叠加 modifier,防止 modifier 被错误地施加到处于休眠状态的阵营上。

常见坑

  1. idside 填反或混淆id 对应的是整个势力平衡系统的标识符,side 才是该系统下具体阵营的标识符,两者来自不同的定义层级,若互相填错会导致 trigger 永远返回假且不报错,极难排查。
  2. 在势力平衡系统未定义的 scope 下误用:虽然该 trigger 支持 any scope,但若引用的 id 所对应的势力平衡系统根本未在 common/power_balance/ 中定义,或该文件未被正确加载,trigger 同样静默失败,新手常误以为是逻辑写错而非文件缺失。

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

When creating Power Balance mods, you often need to decide whether to trigger events, unlock decisions, or display AI logic branches based on whether a particular side is active. For example, you might block certain options when the player's ideological struggle hasn't reached the activation threshold, or confirm in an available block that a side is truly active before allowing related operations to execute.

# This decision is only selectable when the "left_wing_side" is active
decision_example = {
    available = {
        is_power_balance_side_active = {
            id = ideology_struggle
            side = left_wing_side
        }
    }
}

Synergy

  • [is_power_balance_in_range](/wiki/trigger/is_power_balance_in_range): Typically use is_power_balance_side_active first to confirm a side is activated, then use is_power_balance_in_range to check whether the current value falls within the expected range. These two triggers combine to form complete power balance condition checks.
  • [has_power_balance_modifier](/wiki/trigger/has_power_balance_modifier): After the activation status check passes, you often need to further confirm whether that side has the specified modifier attached. The two triggers are typically nested within the same and block.
  • [add_power_balance_value](/wiki/effect/add_power_balance_value): In effect blocks, confirm the side is active before executing value changes, avoiding script errors from writing values to inactive sides.
  • [add_power_balance_modifier](/wiki/effect/add_power_balance_modifier): Combined with activation checks, only stack modifiers when the side is active, preventing modifiers from being incorrectly applied to dormant sides.

Common Pitfalls

  1. Mixing up or reversing id and side: id corresponds to the identifier of the entire power balance system, while side is the identifier of a specific side within that system. They come from different definition levels. Filling them incorrectly will cause the trigger to always return false without error, making it extremely difficult to debug.
  2. Misusing the trigger in scopes where the power balance system is undefined: Although this trigger supports any scope, if the id you reference doesn't correspond to a power balance system defined in common/power_balance/, or the file hasn't been loaded correctly, the trigger silently fails. Beginners often mistakenly assume the logic is wrong rather than the file is missing.