Hoi4 modding Wiki
Advertisement

Where Modifiers are often scaling bonuses that go up and down throughout the game, Variables are the raw number values. The amount of political power a country has is for example a game variable that can be read with "has_political_power" and used as a trigger. Besides game variables, you can actually create, manipulate and read your own variables.

Variables provide powerful but widely unused tools within ParadoxScript that allow for more dynamic and scaling effects, conditions and rewards. You can store a number inside a variable, and then use it later as part of some other condition or effect. Variables are quite hard to use, because the list of game variables is incomplete, and whether or not variables can be used in a specific context is inconsistent.

Game variables: Game variables are read-only numbers and statistics about the current game state, there is a set list of game variables that can be referenced, which is quite incomplete. They can be read and stored like other variables, and most of them can also be used as triggers to check if they are higher or lower than another number.

Storing variables: "set_variable" (or "set_temp_variable")

Reading variables: As triggers with check_variable and to a lesser extend: has_variable. As effects you can sometimes use them within their scope by writing their name where normally a number is expected. It is unclear under what circumstances this does not work.

Manipulating variables: "add_to_variable", "subtract_from_variable", "multiply_variable", "divide_variable", "clamp_variable", "round_variable". (or X_temp_variable)

https://hoi4.paradoxwikis.com/Variables

Examples[]

To help increase the use of variables and temp variables, please add any examples you have below:

Political power gained based on number of core states :

add_political_power = num_core_states

Normally you must put a number behind the add_political_power effect, but here you see it replaced with num_core_states, which is a game variable that can be accessed within country context.

Stability based on conscription:

set_temp_variable = { temp1 = modifier@conscription }
multiply_temp_variable = { temp1 = 3 }
add_stability = temp1

The above example sets temp1 as a temporarily variable, that is equal to the current country's conscription rate. Conscription rate is not a variable, but a modifier, that is why "modifier@" is used in front of it. It then multiplies that number by 3 and adds it as stability to the current country. I believe both conscription rate and stability are used here as factors where 0.01 = 1%.

Advertisement