Wiki

trigger · has_power_balance

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

checks if power balance is active for country

Example:
has_power_balance = {
	id = power_balance_id
}

实战 · 配合 · 坑

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

实战用法

has_power_balance 常用于需要根据某个势力平衡机制是否已激活来动态控制决策、焦点或事件可用性的 mod 场景中,例如在意识形态对抗系统里判断特定权力天平是否正在运行,再决定是否显示相关选项。

# 示例:仅当指定权力天平激活时,该决策才可用
available = {
    has_power_balance = {
        id = my_mod_faction_balance
    }
}

配合关系

  • [has_any_power_balance](/wiki/trigger/has_any_power_balance):先用此触发器快速判断国家是否存在任意权力天平,再用 has_power_balance 精确定位具体 id,构成粗筛→细筛的两层逻辑。
  • [add_faction_influence_score](/wiki/effect/add_faction_influence_score):在确认权力天平已激活后,配合此 effect 向对应阵营加注影响力分数,保证数值操作只在机制运行期间触发。
  • [faction_influence_ratio](/wiki/trigger/faction_influence_ratio):与 has_power_balance 联用,先确认天平存在,再检查当前各方势力占比,实现更精细的条件判断。

常见坑

  1. id 拼写与定义不一致id 字段必须与 power_balance 文件中定义的 id 完全一致(区分大小写),写错 id 不会报错但永远返回 false,导致相关逻辑静默失效,排查时极为隐蔽。
  2. 在权力天平未定义的国家 scope 下使用:该 trigger 只对拥有对应权力天平机制的国家有意义;若在一个从未触发过该天平的国家 scope 内调用,结果始终为 false,误以为是脚本 bug 而反复排查其他逻辑。

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_power_balance is commonly used in mod scenarios where decisions, focuses, or events need to be dynamically controlled based on whether a specific power balance mechanism has been activated. For example, in an ideological conflict system, it determines whether a particular power balance is currently active before deciding whether to display related options.

# Example: This decision is only available when the specified power balance is activated
available = {
    has_power_balance = {
        id = my_mod_faction_balance
    }
}

Synergy

  • [has_any_power_balance](/wiki/trigger/has_any_power_balance): Use this trigger first to quickly check if the country has any power balance, then use has_power_balance to pinpoint a specific id, creating a two-tier coarse-to-fine filtering logic.
  • [add_faction_influence_score](/wiki/effect/add_faction_influence_score): After confirming the power balance is active, pair it with this effect to add influence score to the corresponding faction, ensuring numerical operations are only triggered during the mechanism's runtime.
  • [faction_influence_ratio](/wiki/trigger/faction_influence_ratio): Use in conjunction with has_power_balance to first confirm the balance exists, then check the current influence distribution among parties, enabling more granular conditional logic.

Common Pitfalls

  1. id spelling inconsistency with definition: The id field must exactly match the id defined in the power_balance file (case-sensitive). Misspelling the id will not produce an error but will always return false, causing related logic to silently fail, making it extremely difficult to debug.
  2. Using on country scopes that never had the power balance defined: This trigger only has meaning for countries that possess the corresponding power balance mechanism. If called within a country scope that has never triggered that balance, the result will always be false, potentially leading to false assumptions that it's a script bug while repeatedly troubleshooting other logic.