Triggers

Conditions (also known as triggers) are used to specify when the execution of effects occurs. When a trigger returns true, then the execution will continue, otherwise it stops. Multiple triggers can be used together.

Any Scope
Can be used in country, state or unit leader scopes.

Country Scope
Can be used in country scope.

State Scope
Can be used in state scope.

Unit Leader Scope
Can be used in unit leader scope.

Combat
These triggers only work in special unit leader combat scopes, i.e. Combat Tactics.

They should not be used in the regular unit leader scopes.

Variables
Can be used in country, state or unit leader scopes.

Remember that variables need to refer to the scope they were set in.

This means you can't check a country variable in a state scope without scoping the variable.

For example, to get the country variable whilst in a state scope, you'd do the following:

= {   = {        limit = { check_variable = { from.my_country_var > 0.0 } }   } }

See Variables for more information.

Flow Control
These scopes alter the evaluation of triggers or introduce effect-like behaviour within a trigger scope.

Count Triggers
Introduced in patch 1.5.

This scope allows a group of triggers to be evaluated multiple times, and if they reach a specified number of passes, then count_triggers returns true.

For example, if you wanted to check if atleast five states out of a group of 10 met their triggers, you'd do the following:

count_triggers = { amount = 5 10 = { state_population = 100000 } 11 = { state_population = 100000 } 12 = { state_population = 100000 } 13 = { state_population = 100000 } 14 = { state_population = 100000 } 15 = { state_population = 100000 } 16 = { state_population = 100000 } 17 = { state_population = 100000 } 18 = { state_population = 100000 } 19 = { state_population = 100000 } 20 = { state_population = 100000 } }

Hidden Trigger
This scope allows triggers to be hidden from the player tooltip. It is useful if you have some messy triggers that may confuse the player. It is useful to use custom_trigger_tooltip in combination with this.

hidden_trigger = { country_exists = GER }

Custom Trigger Tooltip
This scope allows a custom tooltip to be displayed for a group of triggers. Here is an example:

custom_trigger_tooltip = { tooltip = sunrise_invasion_tt any_state = { is_owned_by = JAP is_on_continent = europe is_coastal = yes } }

Operators
There are two extra operators for triggers, > (greater than) and < (less than).

They are used for numerical or date triggers, and provide an exclusive check for their value.

This means a trigger using them will return true if the result is any number below (or above).

Note that equals in Hearts of Iron 4 only checks for exact equality, i.e. x = y, whereas in previous games it checks for equals or greater than, i.e. x >= y.

Context Scopes
There are three general scopes all triggers operate in:
 * country
 * state
 * unit leader

They give context to a trigger by stating what the trigger is checking against.

Each country acts as a sub-scope of the general country scope, i.e.  will check only against Germany, whereas   will check against all countries. Likewise for states and unit leaders.

The important lesson here is that triggers for one type of scope will not work in the other scopes generally (there are exceptions).

Execution Scopes
The use of the following scopes allows for far more flexiblity within triggers.

By default in trigger scopes AND is applied. Within a OR scope, usage of AND can be used to restore the behaviour it grants, allowing for very flexible checks.

For example, the following uses this to allow numerous valid states in one check:

OR = { AND = { original_tag = GER has_stability > 0.5 }   AND = { OR = { original_tag = ENG original_tag = USA }       has_stability > 0.75 }   has_stability > 0.9 }

In this example, there are three valid states, being Germany with more than 50% stability, being England or USA with more than 75% stability, or being any other country with more than 90% stability.