Hands-On Usage
random_list is commonly used to produce randomized outcomes after event options or decisions fire — for example, granting a random amount of political power, applying different national buffs at random, or creating probabilistic story branches. The higher a branch's weight, the greater its chance of being selected, making random_list ideal for building "dice-roll" style random event systems.
# Randomly award political power or set a global flag; different weights represent different probabilities
random_list = {
seed = random
60 = {
add_to_variable = { var = pp_reward value = 10 }
}
30 = {
add_to_variable = { var = pp_reward value = 50 }
}
10 = {
set_global_flag = rare_jackpot_flag
add_to_variable = { var = pp_reward value = 200 }
}
}
Synergy
- hidden_effect: Wrap
random_list inside hidden_effect to prevent the random branches from generating unwanted tooltip text in the event window, keeping the UI clean.
- set_variable / add_to_variable: Modify variables inside individual branches, then use
check_variable triggers downstream to read and act on the result.
- log: Write
log = yes at the top level of random_list, or use log inside individual branches, to record which branch was selected — useful for debugging.
- if: Use
if with conditions inside individual branches so that certain random outcomes only take effect when the country is in a specific state, preventing logic errors.
Common Pitfalls
- Using a float or negative number as a weight: Weights in
random_list must be non-negative integers or variable names. Writing something like 0.5 = { ... } or a negative weight will cause a script parse error or undefined behavior. If you want to use a variable as a weight, make sure that variable has already been assigned a value in the current scope and is not negative.
- Assuming all branches execute:
random_list selects and executes exactly one branch per evaluation — it does not independently roll each branch against its probability. If you need multiple effects to each trigger at their own independent probability, use multiple separate random effects instead.