Wiki

effect · force_update_dynamic_modifier

Definition

  • Supported scope:STATE, COUNTRY, CHARACTER, SPECIAL_PROJECT
  • Supported target:THIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITAL

Description

updates the modifiers in current scope (use if you don't want to wait for daily update to update them):
force_update_dynamic_modifier = yes

实战 · 配合 · 坑

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

实战用法

当你通过 add_dynamic_modifierremove_dynamic_modifier 修改某个 scope 的动态修正后,游戏默认等到每日更新才重新计算实际效果;如果 mod 逻辑要求修正在同一事件/决议链中立即生效(例如后续触发器需要读取它的数值),就应在操作完成后立即调用此 effect。典型场景是在一个事件 option 里先给某国家移除旧动态修正、添加新动态修正,再强制刷新,确保 UI 和后续脚本看到的都是最新状态。

option = {
    name = my_event.1.a
    remove_dynamic_modifier = { modifier = old_war_economy }
    add_dynamic_modifier = { modifier = new_war_economy }
    force_update_dynamic_modifier = yes   # 立即生效,不等日更
}

配合关系

  • [add_dynamic_modifier](/wiki/effect/add_dynamic_modifier):添加动态修正后通常紧跟此命令,确保新增修正立即计入计算,而非在下一个 tick 才生效。
  • [remove_dynamic_modifier](/wiki/effect/remove_dynamic_modifier):移除动态修正后同样需要强制刷新,否则旧修正的数值在当前帧内仍被视为有效。
  • [has_dynamic_modifier](/wiki/trigger/has_dynamic_modifier):若后续触发器需要检查某动态修正是否存在或其变量已更新,必须先通过此 effect 刷新,才能保证检查结果准确。

常见坑

  1. 忘记调用导致数值滞后:在同一执行块里修改动态修正后,如果后续逻辑(如同一 hidden_effect 里的触发器判断或 UI 反馈)依赖修正结果,却没有加 force_update_dynamic_modifier = yes,会出现"改了但没生效"的假象,排查起来极为隐蔽。
  2. 在没有动态修正变动的地方滥用:此命令会强制重新计算当前 scope 的所有动态修正,频繁在大量 scope 或每日脉冲中无条件调用会产生不必要的性能开销,应仅在确实有修正变动、且需要即时生效的时机才调用。

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 you modify the dynamic modifiers of a scope via add_dynamic_modifier or remove_dynamic_modifier, the game by default waits until the daily update tick to recalculate the actual effects. If your mod logic requires the modifier to take effect immediately within the same event/decision chain (for example, subsequent triggers need to read its values), you should call this effect immediately after the operation completes. A typical scenario is in an event option where you first remove an old dynamic modifier from a country, add a new dynamic modifier, then force refresh to ensure both the UI and subsequent scripts see the latest state.

option = {
    name = my_event.1.a
    remove_dynamic_modifier = { modifier = old_war_economy }
    add_dynamic_modifier = { modifier = new_war_economy }
    force_update_dynamic_modifier = yes   # Takes effect immediately, no waiting for daily tick
}

Synergy

  • [add_dynamic_modifier](/wiki/effect/add_dynamic_modifier): After adding a dynamic modifier, this command is typically called immediately after to ensure the newly added modifier is factored into calculations immediately, rather than taking effect on the next tick.
  • [remove_dynamic_modifier](/wiki/effect/remove_dynamic_modifier): After removing a dynamic modifier, a force refresh is equally necessary; otherwise, the old modifier's values remain considered valid within the current frame.
  • [has_dynamic_modifier](/wiki/trigger/has_dynamic_modifier): If subsequent triggers need to check whether a dynamic modifier exists or its variables have been updated, you must first refresh via this effect to ensure the check result is accurate.

Common Pitfalls

  1. Forgetting to call leads to value lag: After modifying dynamic modifiers within the same execution block, if subsequent logic (such as trigger checks within the same hidden_effect or UI feedback) depends on the modifier result but fails to include force_update_dynamic_modifier = yes, you'll experience an illusion of "changed but not applied," which is extremely difficult to debug.
  2. Overuse in places with no modifier changes: This command forces a recalculation of all dynamic modifiers for the current scope. Calling it unconditionally and frequently across many scopes or in daily pulses produces unnecessary performance overhead; it should only be called when there are actual modifier changes and immediate effect is required.