Conditions
Conditions are used to specify to which country, state etc. a certain command should be applied. They appear in certain more general blocks or in limit
blocks to restrict scopes. Without conditions, commands would simply be applied to every entity a scope applies to. A condition will always evaluate to exactly either true
or false
.
For example, a scope that countries might instead be made to only target countries that have a core in America. Or an event that has two effects could be made to stop after applying the first effect, if a specific condition is currently active.
Examples[edit]
For example, the following command would cause every country in the game to hold an election:
every_country = { hold_election = yes }
while this block will cause an election in every country with a democratic government:
every_country = { limit = { has_government = democratic } hold_election = yes }
While this simply shortens the list of entities affected, limits are also often used to narrow a random select:
random_country = { limit = { NOT = { has_war = yes } } # Do effect }
This will choose a random country that is not at war. (Note: Instead of NOT = { has_war = yes }
it is of course also possible to just say has_war = no
. That is actually better, but this way it is possible to display how to do a simple negation that works with any other condition, not all of which are as simple to reverse like this).
Limits can also themselves take scopes, but not all scopes valid in command blocks are also valid in condition scopes. For example, every_country
can be used for commands, but for conditions, any_country
must be used instead. This code will cause an election to be held in every country in the game, if at least one country with a democratic government exists:
if = { limit = { any_country = { has_government = democratic } } every_country = { hold_election = yes } }
Note the use of the special if
scope in this example. A limit
simply placed in a normal command scope will narrow the entities the command is applied to, but the commands will always be executed. An if
on the other hand determines if the commands are executed at all: if the if
evaluates to true
, the commands are executed. Otherwise, they are ignored.
Operators[edit]
While it is possible to get away with using single conditions, usually what is really necessary is to check a complex set of conditions, which need to be present in any set of specific scenarios in order to apply. Basically, while asking "Is the subject at war?" is fairly simple, often you really need a filter such as "Is A at war with B and winning", or "is A in faction with C and still loosing a war with B"? Or maybe "is C allied with B and at war with A"? For this there is a set of simple, yet powerful tools available, as part of plain logic syntax:
Name | Description | Example |
---|---|---|
AND | All conditions contained within must be true |
AND = { ai_irrationality > 50 has_war = yes } |
OR | At least one of the following conditions must be true |
OR = { is_coastal = yes free_building_slots > 5 } |
NOT | Reverses the logic result of its content. That is, if the content is "True", then the result of the NOT is "False" and vice versa. |
NOT = { has_global_flag = fall_of_france } |
If none of these are used, AND
is assumed; the explicit AND
scope is most often used inside OR
scopes or to clarify otherwise hard-to-read code.
What's even better, you can combine them by nesting one within the other, to build truly complex conditions with a flexibility that is hard to fathom.
The Conditions[edit]
This is a list of all the conditions currently known. Conditions tend to only apply to specific Scopes, as only a country can be at war and only states have airfields, etc... Just use common sense and feel free to update anything you successfully used.
Condition | Description | Scope | Example | Game Version |
---|---|---|---|---|
amount_research_slots | Checks the number of research slots | Country | amount_research_slots < 5 | 1.3.3 |
num_divisions | Checks the number of divisions | Country | num_divisions > 10 | 1.3.3 |
has_focus_tree | Checks if a country has a specific focus tree | Country | has_focus_tree = <id> | 1.3.3 |
is_staging_coup | Checks if a country is staging a coup | Country | is_staging_coup = yes | 1.3.3 |
has_full_control_of_state | Checks if country controls every province of a state | Country | GER = { has_full_control_of_state = 55 } | 1.3.3 |
has_army_experience | Checks the amount of army xp | Country | has_army_experience > 5 | 1.3.3 |
has_air_experience | Checks the amount of air xp | Country | has_air_experience > 5 | 1.3.3 |
has_navy_experience | Checks the amount of navy xp | Country | has_navy_experience > 5 | 1.3.3 |
has_country_leader | Checks for a specific country leader | Country | has_country_leader = { id = 17 ruling_only = yes name = "Boaty McBoatface" } | 1.3.3 |
has_tech_bonus | Checks for a bonus for a single tech or a tech category | Country | has_tech_bonus = { technology = early_fighter category = industry } | 1.3.3 |
has_resources_amount | Checks the amount of resources in a state | Country | has_resources_amount = { resource = chromium amount > 5 state = 31 } | 1.3.3 |
num_of_subjects | Checks the number of subjects | Country | num_of_subjects > 0 | 1.3 |
num_tech_sharing_groups | Checks the amount of tech sharing a groups a country is in | Country | num_of_tech_sharing_groups > 1 | 1.3 |
compare_autonomy_progress_ratio | Checks the autonomy progress | Country | compare_autonomy_progress_ratio > 0.6 | 1.3 |
ai_irrationality | Checks AI irrationality value | AI | ai_irrationality < 20 | 1.0 |
ai_liberate_desire | Checks how willing the AI is to liberate another country | AI | Needs to be tested | 1.0 |
always | Always returns specified value | Anywhere | always = no | 1.0 |
any_claim | Checks for claims between two countries | Country | Needs to be tested | 1.0 |
any_war_score | Checks for war score in any ongoing war involving the country | Country | any_war_score > 50 | 1.0 |
armor | Checks for the average armor level of a combatant | Combat | Needs to be tested | 1.0 |
can_research | Checks if a country can research a technology | Country | can_research = basic_medium_tank | 1.0 |
controls_state | Checks if a country controls a state | Country | GER = { controls_state = 332 } | 1.0 |
country_exists | Checks if a specified country exists | Anywhere | country_exists = YUG | 1.0 |
date >, date < | Check for the current in-game date | Anywhere | date > 1937.1.1 | 1.0 |
dig_in | Checks for lowest dig-in level | Combat | Needs to be tested | 1.0 |
distance_to | Checks distance between two states | State | Needs to be tested | 1.0 |
divisions_in_state | Checks for the amount of division in state | State | divisions_in_state = { state = 605 size > 0 } | 1.0 |
exists | Checks if a country exists | Anywhere | GER = { exists = yes } | 1.0 |
fastest_unit | Checks if the fastest unit in combat has a certain speed value | Combat | Needs to be tested | 1.0 |
focus_progress | Checks for the progress on a national focus | Country | focus_progress = { focus = focus_id progress > 0.5 } | 1.0 |
free_building_slots | Checks for the amount of free building slots | State | any_owned_state = { free_building_slots = { building = industrial_complex size > 0 include_locked = yes } } | 1.0 |
frontage_full | Checks for full frontage in combat | Combat | Needs to be tested | 1.0 |
gives_military_access_to | Checks if a country is giving military access to another country | Country | gives_military_access_to = GER | 1.0 |
hardness | Checks lowest/highest hardness level in combat | Combat | Needs to be tested | 1.0 |
has_added_tension_amount | Variable for how much world tension a country has caused ( 1.0 = 100% ) | Country | has_added_tension_amount > 0.1 | 1.0 |
has_annex_war_goal | Checks if a country has the annex wargoal towards another country | Country | has_annex_war_goal = POL | 1.0 |
has_army_manpower | Variable for the amount of manpower a country has deployed in divisions | Country | has_army_manpower = { size > 549999 } | 1.0 |
has_army_size | Checks the amount of all or certain division | Country | has_army_size = { type = infantry size > 75 } | 1.0 |
has_autonomy_state | Checks the autonomy level of a country (integrated_puppet, dominion, etc) | Country | has_autonomy_state = autonomy_satellite | 1.3.3 |
has_available_idea_with_traits | Checks if a country has ideas with specified traits available | Country | Needs to be tested | 1.0 |
has_built | Checks if a country has built a certain number of specified buildings after taking a goal | Country | Needs to be tested | 1.0 |
has_capitulated | Checks if a country has capitulated | Country | NOR = { has_capitulated = yes } | 1.0 |
has_carrier_airwings_on_mission | Checks if carrier airwings are on a mission | ??? | has_carrier_airwings_on_mission = yes | 1.0 |
has_civil_war | Checks if a country is a participant in a civil war | Country | SPR = { has_civil_war = yes } | 1.0 |
has_combat_modifier | Checks for a combat modifier in combat | Combat | Needs to be tested | 1.0 |
has_completed_focus | Checks if a national focus has been completed | Country | GER = { has_completed_focus = GER_anschluss } | 1.0 |
has_country_flag | Checks for a country flag | Country | ENG = { has_country_flag = chamberlain_resigned } | 1.0 |
has_defensive_war | Checks if in a defensive war | Country | CHI = { has_defensive_war = yes } | 1.0 |
has_defensive_war_with | Checks for a defensive war against a country | Country | CHI = { has_defensive_war_with = JAP } | 1.0 |
has_deployed_air_force_size | Variable for a country's amount of deployed planes | Country | ENG = { has_deployed_air_force_size > 100 } | 1.0 |
has_equipment | Checks for the amount of equipment | Country | has_equipment = { infantry_equipment > 500 } | 1.0 |
has_flanked_opponent | Check if flanking an enemy | Combat | Needs to be tested | 1.0 |
has_global_flag | Checks if a global flag is active | Anywhere | has_global_flag = fall_of_france | 1.0 |
has_government | Checks a country's current ideology | Country | USA = { has_government = communism } | 1.0 |
has_guaranteed | Checks if a country has guaranteed another country | Country | FRA = { has_guaranteed = POL } | 1.0 |
has_idea | Checks for a specified idea | Country | has_idea = idea_id | 1.0 |
has_idea_with_trait | Checks for an idea with a specified trait | Country | SOV = { has_idea_with_trait = communist_revolutionary } | 1.0 |
has_manpower | Checks the amount of manpower | Country | has_manpower > 10000 | 1.0 |
has_manpower_for_recruit_change_to | Checks if country has enough manpower to change recruitment laws | Country | has_manpower_for_recruit_change_to = { value = 0.01 group = mobilization_laws } | 1.0 |
has_max_planning | Checks for maximum planning bonus in combat | Combat | has_max_planning = yes | 1.0 |
has_military_access_to | Checks if a country has military access to another country | Country | has_military_access_to = ITA | 1.0 |
has_national_unity | Variable for the national unity of a nation | Country | has_national_unity > 70 | 1.0 |
has_navy_size | Variable for the amount of ships a nation has | Country | has_navy_size = { size > 10 } | 1.0 |
has_offensive_war | Checks if in an offensive war | Country | has_offensive_war = yes | 1.0 |
has_offensive_war_with | Checks for a offensive war against a country | Country | has_offensive_war_with = SOV | 1.0 |
has_opinion | Checks for the current opinion towards another country | Country | has_opinion = { target = SOV value < -50 } | 1.0 |
has_opinion_modifier | Checks for a specific opinion modifier with another country | Country | SOV = { has_opinion_modifier = unprovoked_aggression } | 1.0 |
has_political_power | Checks the amount of political power | Country | has_political_power > 100 | 1.0 |
has_reserves | Checks for reserves in combat | Combat | Needs to be tested | 1.0 |
has_start_date | Checks the initial start date of the current game | Anywhere | Needs to be tested | 1.0 |
has_state_flag | Checks for a state flag | State | 713 = { has_state_flag = GER_second_ljubljana_award_GER_demand } | 1.0 |
has_tech | Checks if a country has a specified tech | Country | SOV = { has_tech = basic_medium_tank } | 1.0 |
has_template_containing_unit | Checks if country has a template with specified units | Country | FRA = { has_template_containing_unit = light_armor } | 1.0 |
has_trait | Checks if a leader has a trait | Leader | Needs to be tested | 1.0 |
has_volunteers_from | Checks if a country has volunteer from another country | Country | SPR = { has_volunteers_from = GER } | 1.0 |
has_war | Checks if a country is at war | Country | has_war = yes | 1.0 |
has_war_together_with | Checks if two countries are on the same side in a war | Country | GER = { has_war_together_with = ITA } | 1.0 |
has_war_with | Checks if at war with specified country | Country | GER = { has_war_with = FRA } | 1.0 |
has_war_with_amount | Checks the amount of wars and current world tension | Anywhere | Needs to be tested | 1.0 |
ic_ratio | Compares the total industrial capacity of two countries | Country | ic_ratio = { tag = ITA ratio > 0.4 } | 1.0 |
is_ai | Checks if a country is run by AI | Country | is_ai = yes | 1.0 |
is_amphibious_invasion | Checks if combat is an amphibious invasion | Combat | is_amphibious_invasion = yes | 1.0 |
is_attacker | Checks if attacker in combat | Combat | is_attacker = yes | 1.0 |
is_border_conflict | Checks if a state is in border conflict | State | any_owned_state = { is_border_conflict = yes } | 1.0 |
is_claimed_by | Checks if state is claimed by a country | State | any_owned_state = { is_claimed_by = GER } | 1.0 |
is_coastal | Checks if a state is coastal | State | any_owned_state = { is_coastal = yes } | 1.0 |
is_controlled_by | Checks if a state is controlled by a country | State | 332 = { is_controlled_by = GER } | 1.0 |
is_core_of | Checks if state is a core of a country | Country | any_owned_state = { is_core_of = CHI } | 1.0 |
is_defender | Checks if a defender in combat | Combat | is_defender = yes | 1.0 |
is_demilitarized_zone | Checks if a state is demilitarized | State | any_owned_state = { is_demilitarized_zone = yes } | 1.0 |
is_faction_leader | Checks if a country is a leader of any faction | Country | is_faction_leader = yes | 1.0 |
is_fighting_air_units | Checks if fighting air units | ??? | is_fighting_air_units = yes | 1.0 |
is_fighting_in_terrain | Checks the terrain of combat | Combat | is_fighting_in_terrain = marsh | 1.0 |
is_guaranteed_by | Checks if guaranteed by a specified country | Country | is_guaranteed_by = USA | 1.0 |
is_historical_focus_on | Checks if game is set on historical | Anywhere | is_historical_focus_on = yes | ? |
is_in_faction | Checks if member of any faction | Country | is_in_faction = yes | 1.0 |
is_in_faction_with | Checks if in the same faction with a country | Country | is_in_faction_with = GER | 1.0 |
is_in_home_area | Checks if a state is connected to the capital | State | any_owned_state = { is_in_home_area = yes } | 1.0 |
is_ironman | Checks if current game is in Ironman mode | Anywhere | is_ironman = yes | 1.0 |
is_lend_leasing | Checks if giving lend lease to a country | Country | is_lend_leasing = SPR | 1.0 |
is_major | Checks if a country is a major | Country | is_major = yes | 1.0 |
is_neighbor_of | Checks if neighbors with a specified country | Country | is_neighbor_of = GER | 1.0 |
is_on_continent | Checks the continent of a state | State | any_owned_state = { is_on_continent = africa } | 1.0 |
is_owned_by | Checks if a state is owned by a country | State | 332 = { is_owned_by = GER } | 1.0 |
is_puppet | Checks if a country is a puppet (puppet specified in autonomy levels) | Country | is_puppet = yes | 1.0 |
is_puppet_of | Checks if a county is a puppet of a specified country (puppet specified in autonomy levels) | Country | is_puppet_of = ENG | 1.0 |
is_subject | Checks if a country is a subject | Country | RAJ = { is_subject = yes } | 1.3 |
is_subject_of | Checks if a country is a subject of a specified country | Country | RAJ = { is_subject_of = ENG } | 1.3 |
is_winning | Checks if winning in combat | Combat | is_winning = yes | 1.0 |
land_doctrine_level | Checks researched land doctrine level | Country | Needs to be tested | 1.0 |
less_combat_width_than_opponent | Checks for combat width in combat | Combat | Needs to be tested | 1.0 |
night | Checks if combat is at night | Combat | night = yes | 1.0 |
num_of_available_civilian_factories | Checks the amount of unused civilian factories | Country | num_of_available_civilian_factories > 1 | 1.0 |
num_of_available_military_factories | Check the amount of unused military factories | Country | num_of_available_military_factories > 1 | 1.0 |
num_of_available_naval_factories | Checks the amount of unused naval dockyards | Country | num_of_available_naval_factories > 1 | 1.0 |
num_of_civilian_factories | Checks the amount of civilian factories in a country | Country | num_of_civilian_factories > 10 | 1.0 |
num_of_controlled_states | Checks the number of controlled states | Country | num_of_controlled_states > 10 | 1.0 |
num_of_factories | Checks the total amount of factories | Country | num_of_factories > 50 | 1.0 |
num_of_military_factories | Checks the amount of military factories in a country | Country | num_of_military_factories > 10 | 1.0 |
num_of_naval_factories | Checks the amount of naval dockyards in a country | Country | num_of_naval_factories > 10 | 1.0 |
'buildingtype' | Checks the amount of a buildingtype in a state | State | dockyard > 10 | 1.0 |
num_of_nukes | Checks the amount of nukes | Country | num_of_nukes > 1 | 1.0 |
original_tag | Checks the original tag of a country (for civil wars) | Country | original_tag = SPR | 1.0 |
owns_state | Checks if a country owns a state | Country | GER = { owns_state = 332 } | 1.0 |
phase | Checks for a combat phase | Combat | Needs to be tested | 1.0 |
recon_advantage | Checks for recon advantage in combat | Combat | recon_advantage = yes | 1.0 |
region/area | Checks if a state is part of a specified strategic region | State | any_state = { region = 34 } | 1.0 |
reserves | Checks the amount of reserves | ??? | Needs to be tested | 1.0 |
ships_in_area | Checks the amount of ships in an area | Area | ships_in_area = { area = 168 size > 1 } | 1.0 |
ships_in_state_ports | Checks the number of ships in a state's provinces | State | any_owned_state = { ships_in_state_ports > 10 } | 1.0 |
skill | Checks leaders skill level | Leader | Needs to be tested | 1.0 |
skill_advantage | Compares skill levels of commanders | Combat | Needs to be tested | 1.0 |
state_population | Checks the states population | State | any_owned_state = { state_population = 40000 } | 1.0 |
strength_ratio | Checks the relation of army strengths with a country | Country | strength_ratio = { tag = SOV ratio > 0.8 } | 1.0 |
surrender_progress | Checks the surrender progress | Country | surrender_progress > 0.7 | 1.0 |
tag | Checks the tag of the country | Country | tag = FRA | 1.0 |
temperature | Checks for the temperature of a combat province | Province | Needs to be tested | 1.0 |
threat | Checks global threat value | Anywhere | threat < 0.5 | 1.0 |
ideology > x | Checks popularity of an ideology | Country | communism > 0.5 | 1.0 |
Documentation | Effects • Triggers • Modifiers • Scopes • Localisation |
Scripting | AI • Bookmarks • Buildings • Cosmetic tags • Countries • Divisions • Decisions • Equipment • Events • Ideas • Ideologies • National Focuses • Resources • Technology • Units |
Map | Map • Terrain • States • Supply areas • Strategic regions |
Graphical | Interface • Graphical Assets |
Cosmetic | Portraits • Namelists • Music • Sound |
Other | Console commands • Troubleshooting • Mod structure |