Wiki

effect · add_dynamic_modifier

Definition

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

Description

adds a dynamic modifier to the containing scope (country / state / unit-leader / special-project).
Updates the cooldown if exists.
Optionaly you can give a scope that will restrict the dynamic modifier to it.
example :
12 = {
  add_dynamic_modifier = {
    modifier = dynamic_modifier_name
    days = 42 # will be temporary if specified, can be variable
    scope = GER # optional, state/countrytag or a variable containing that. 
				# if specified the dynamic variable will target that scope
				# in this example : adds the modifier to state 12 but only applies for country GER
  }
}

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

add_dynamic_modifier is commonly used in scenarios where modifier values need to be dynamically adjusted based on variables, such as scaling bonuses/penalties in real-time according to a country's industrial capacity or resource levels, or applying temporary debuffs to specific countries or states (e.g., war damage, blockade penalties). Its core difference from static modifiers like add_state_modifier / add_ideas is that the modifier's numerical values come from variables and change in real-time as the game progresses.

# Add a dynamic modifier to Germany lasting 60 days, bound to the GER scope
42 = {
    add_dynamic_modifier = {
        modifier = war_damage_modifier
        scope = GER
        days = 60
    }
}

Synergy

  • [remove_dynamic_modifier](/wiki/effect/remove_dynamic_modifier): After adding a dynamic modifier, remove it when conditions are met, forming a complete lifecycle management of "add → condition trigger → remove".
  • [force_update_dynamic_modifier](/wiki/effect/force_update_dynamic_modifier): When the bound variable changes within a tick, force the dynamic modifier to refresh its actual numerical value, preventing display or calculation lag.
  • [has_dynamic_modifier](/wiki/trigger/has_dynamic_modifier): Check in a trigger whether a scope already possesses the dynamic modifier, preventing accidental stacking or used for branching logic.
  • [add_days_remove](/wiki/effect/add_days_remove): If you need to temporarily extend the duration of an existing dynamic modifier in an event or decision, use this in combination to modify the countdown.

Common Pitfalls

  1. Forgetting the scope field causes the modifier to apply to the wrong target: When called under a state (STATE) scope without specifying scope, the modifier affects all countries that own that state; if you only want it to affect a specific country, you must explicitly write scope = TAG, otherwise the modifier may unexpectedly spread to other countries.
  2. Adding a dynamic modifier when its variable is not initialized: If the variable that a dynamic modifier depends on has not been assigned a value when the modifier is added (is 0 or doesn't exist), the modifier will calculate with a default value of 0, appearing to have "no effect". Beginners often mistakenly think the script is wrong, but you should ensure that the corresponding variable is initialized with a value via set_variable or related effects before calling add_dynamic_modifier.