Wiki

trigger · has_power_balance_modifier

Definition

  • Supported scope:any
  • Supported target:none

Description

checks if the power balance has a modifier added to it

Example:
has_power_balance_modifier = {
	id = power_balance_id
	modifier = static_modifier_id
}

实战 · 配合 · 坑

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

实战用法

在制作势力平衡(Power Balance)系统相关 mod 时,常用此 trigger 在事件或决策的 available / trigger 块中检查某个修正是否已被添加,从而避免重复添加或实现互斥逻辑。例如,确认某阵营的特定加成尚未生效后再触发后续事件:

available = {
    NOT = {
        has_power_balance_modifier = {
            id = my_pb_east_west
            modifier = eastern_bloc_dominance
        }
    }
}

配合关系

  • [add_power_balance_modifier](/wiki/effect/add_power_balance_modifier):最直接的搭档——先用 has_power_balance_modifier 检查修正是否存在,不存在时才执行添加,防止重复叠加。
  • [remove_power_balance_modifier](/wiki/effect/remove_power_balance_modifier):在条件成立(修正已存在)时移除对应修正,实现"有则清除"的状态切换逻辑。
  • [remove_all_power_balance_modifiers](/wiki/effect/remove_all_power_balance_modifiers):当需要重置整个势力平衡状态时,先用 trigger 确认有修正存在再批量清除,避免无意义的脚本调用。
  • [is_power_balance_in_range](/wiki/trigger/is_power_balance_in_range):常与本 trigger 组合使用,既检查特定修正是否存在,又检查当前势力平衡数值是否在目标区间,双重条件共同把关决策触发时机。

常见坑

  1. idmodifier 字段写反或遗漏id 指的是势力平衡本身的唯一标识符,modifier 才是挂载在其上的静态修正 id,两者含义不同,填错会导致 trigger 永远返回 false 且游戏日志不一定报错。
  2. 误以为 scope 限制为某国:该 trigger 的支持 scope 为 any,但实际脚本中仍需确保当前执行上下文能访问到对应的势力平衡定义;若势力平衡是在特定 DLC 或特定 mod 文件中定义的,未加载时同样会静默失败而非报错。

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 mods related to Power Balance systems, this trigger is commonly used in the available / trigger blocks of events or decisions to check whether a modifier has already been added, thereby preventing duplicate additions or implementing mutually exclusive logic. For example, after confirming that a specific bonus for a certain faction has not yet taken effect, proceed to trigger subsequent events:

available = {
    NOT = {
        has_power_balance_modifier = {
            id = my_pb_east_west
            modifier = eastern_bloc_dominance
        }
    }
}

Synergy

  • [add_power_balance_modifier](/wiki/effect/add_power_balance_modifier): The most direct companion—first use has_power_balance_modifier to check if the modifier exists, and only execute the addition if it does not, preventing duplicate stacking.
  • [remove_power_balance_modifier](/wiki/effect/remove_power_balance_modifier): Remove the corresponding modifier when conditions are met (modifier already exists), implementing a "remove if present" state-switching logic.
  • [remove_all_power_balance_modifiers](/wiki/effect/remove_all_power_balance_modifiers): When you need to reset the entire power balance state, first use the trigger to confirm that modifiers exist, then batch remove them, avoiding meaningless script calls.
  • [is_power_balance_in_range](/wiki/trigger/is_power_balance_in_range): Frequently combined with this trigger, simultaneously checking whether a specific modifier exists and whether the current power balance value is within the target range, with both conditions jointly gatekeeping the decision trigger timing.

Common Pitfalls

  1. Reversing or omitting the id and modifier fields: id refers to the unique identifier of the power balance itself, while modifier is the static modifier id mounted on it; the two have different meanings, and filling them incorrectly causes the trigger to always return false, and the game log may not report an error.
  2. Mistakenly assuming the scope is limited to a specific country: The supported scope of this trigger is any, but in actual scripts you still need to ensure that the current execution context can access the corresponding power balance definition; if the power balance is defined in a specific DLC or specific mod file and is not loaded, it will similarly fail silently rather than report an error.