political_actions = {
	
	targeted_race_for_the_bomb = {

		icon = generic_research

		allowed = {
			always = no
		}

		available = {
			#Target is FROM
			has_tech = atomic_research
			NOT = { has_global_flag = first_nuke_dropped }
			NOT = { has_idea = race_for_the_bomb }
		}

		#If this trigger matches a country.
		target_trigger = {
			#Target is FROM
			FROM = {
        		NOT = { is_in_faction_with = ROOT }
				has_tech = nuclear_reactor
				any_owned_state = {
					nuclear_reactor > 0
				}
			}
		}

		visible = {
            #Target is FROM
            has_tech = atomic_research
            NOT = { has_global_flag = first_nuke_dropped }
            NOT = { has_idea = race_for_the_bomb }
            FROM = {
        		NOT = { is_in_faction_with = ROOT }
				has_tech = nuclear_reactor
				any_owned_state = {
					nuclear_reactor > 0
				}
			}
		}

		complete_effect = {
			set_country_flag = racing_for_the_bomb
			add_ideas = race_for_the_bomb
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				any_other_country = { has_tech = nukes }
			}
		}
	}

	improved_worker_conditions = {

		icon = generic_industry

		available = {
			has_stability < 1.0
		}

		visible = {
			always = yes
			NOT = { original_tag = GER }
		}

		fire_only_once = no

		modifier = {
			stability_weekly = 0.005
			consumer_goods_factor = 0.05
			industrial_capacity_factory = -0.1
		}

		days_remove = 180
		days_re_enable = 540

		cost = 100

		complete_effect = {

		}

		ai_will_do = {
			base = 0
			modifier = {
				add = 1
				has_stability < 0.6
			}
		}
	}

	promises_of_peace = {

		icon = generic_political_discourse

		available = {
			has_war = no
			has_war_support > 0.2
			has_stability < 1.0
		}

		visible = {
			always = yes
			NOT = { original_tag = GER }
		}

		remove_trigger = {
			has_war = yes
			has_war_support < 0.05
		}

		fire_only_once = no

		modifier = {
			stability_weekly = 0.005
			war_support_weekly = -0.01
			political_power_gain = -0.5
		}

		days_remove = 90
		days_re_enable = 360

		cost = 50

		complete_effect = {

		}

		ai_will_do = {
			base = 0
			modifier = {
				add = 1
				has_stability < 0.4
			}
		}
	}
}

economy_decisions = {

		
}

propaganda_efforts = {

	war_propaganda = {

		icon = generic_prepare_civil_war

		available = {
			NOT = { has_country_flag = war_propaganda_campaign_running }
			threat > 0.5
			has_war_support < 0.5
			has_offensive_war = no
		}

		visible = {
			always = yes
			NOT = { original_tag = GER }			
		}

		fire_only_once = no

		days_remove = 90
		days_re_enable = 180

		cost = 150

		modifier = {
			war_support_weekly = 0.01
		}

		complete_effect = {
			set_country_flag = war_propaganda_campaign_running
		}
		remove_effect = {
			clr_country_flag = war_propaganda_campaign_running
		}

		ai_will_do = {
			base = 0
			modifier = {
				add = 1
				has_war_support < 0.4
				has_war = yes
			}
		}
	}

	#Propaganda campaign against a country in offensive that has caused a lot of tension and started a war
	war_propaganda_against_warmonger = {

		icon = generic_prepare_civil_war

		available = {
			NOT = { has_country_flag = war_propaganda_campaign_running }
			FROM = {
				OR = {
					has_offensive_war = yes
					is_justifying_wargoal_against = ROOT
				}
			}
		}

		visible = {
			FROM = { NOT = { has_government = ROOT } }
			FROM = {
				NOT = { is_neighbor_of = ROOT }
				OR = {
					AND = {
						NOT = { has_government = ROOT }
						has_offensive_war = yes
						has_added_tension_amount > 30
					}
					is_justifying_wargoal_against = ROOT
					has_offensive_war_with = ROOT
				}
			}
		}

		target_trigger = {
			FROM = {
				NOT = { is_neighbor_of = ROOT }
				OR = {
					AND = {
						NOT = { has_government = ROOT }
						has_offensive_war = yes
						has_added_tension_amount > 30
					}
					is_justifying_wargoal_against = ROOT
					has_offensive_war_with = ROOT
				}
			}
		}

		days_remove = 90

		fire_only_once = yes

		cost = 75

		modifier = {
			war_support_weekly = 0.01
		}

		complete_effect = {
			set_country_flag = war_propaganda_campaign_running
		}
		remove_effect = {
			clr_country_flag = war_propaganda_campaign_running
		}

		ai_will_do = {
			factor = 0
		}
	}

	#Propaganda campaign against a neighbor
	war_propaganda_against_warmonger_neighbor = {

		icon = generic_prepare_civil_war

		available = {
			NOT = { has_country_flag = war_propaganda_campaign_running }
			FROM = {
				OR = {
					has_offensive_war = yes 
					is_justifying_wargoal_against = ROOT
					has_war_with = ROOT
				}
			}
		}

		visible = {
			FROM = { NOT = { has_government = ROOT } }
			FROM = {
				is_neighbor_of = ROOT
				OR = {
					AND = {
						NOT = { has_government = ROOT }
						has_offensive_war = yes
					}
					is_justifying_wargoal_against = ROOT
					has_war_with = ROOT
				}
				has_added_tension_amount > 5
			}
		}

		target_trigger = {
			FROM = {
				is_neighbor_of = ROOT
				OR = {
					AND = {
						NOT = { has_government = ROOT }
						has_offensive_war = yes
					}
					is_justifying_wargoal_against = ROOT
					has_war_with = ROOT
				}
				has_added_tension_amount > 5
			}
		}

		days_remove = 90
		days_re_enable = 180

		cost = 50

		modifier = {
			war_support_weekly = 0.01
		}

		complete_effect = {
			set_country_flag = war_propaganda_campaign_running
		}
		remove_effect = {
			clr_country_flag = war_propaganda_campaign_running
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				has_war_support > 0.9
			}
		}
	}
}

operations = {
	
	blow_suez_canal = {

		icon = GFX_decision_generic_ignite_civil_war

		available = {
			OR = {
				has_full_control_of_state = 446
				has_full_control_of_state = 453
			}
			OR = {
				NOT = {
					owns_state = 446
					owns_state = 453
				}
				any_country = {
					has_war_with = ROOT
					OR = {
						controls_state = 452
						controls_state = 447
						controls_state = 446
						controls_state = 456
						controls_state = 457
						controls_state = 453
						controls_state = 454
						controls_state = 455
					}
				}
			}
		}
	
		visible = {
			has_war = yes
			NOT = { has_global_flag = SUEZ_CANAL_BLOCKED }
			any_state = {
				is_controlled_by = ROOT
				OR = {
					region = 28
					region = 128
				}
			}
		}
	
		fire_only_once = no
	
		days_remove = 30
	
		cost = 75
	
		modifier = {
			civilian_factory_use = 5
		}

		complete_effect = {
			hidden_effect = {
				if = {
					limit = {
						NOT = {
							owns_state = 446
							owns_state = 453
						}
					}
					random_country = {
						limit = {
							owns_state = 446
							owns_state = 453
						}
						country_event = { id = generic.12 days = 1 }
					}
				}
			}
		}
	
		remove_effect = {
			if = {
				limit = {
					OR = {
						has_full_control_of_state = 446
						has_full_control_of_state = 453
					}
				}
				set_country_flag = blew_up_suez
				set_global_flag = SUEZ_CANAL_BLOCKED
				country_event = { id = wtt_news.40 hours = 6}
			}
			effect_tooltip = {
				if = {
					limit = {
						ENG = {
							owns_state = 446
							owns_state = 453
						}
					}
					add_war_support = -0.05
					add_stability = -0.05
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				any_country = {
					is_in_faction_with = ROOT
					NOT = {
						OR = {
							has_full_control_of_state = 457
							has_full_control_of_state = 456
						}
						has_full_control_of_state = 551
					}
					OR = {
						divisions_in_state = { state = 550 size > 0 }
						divisions_in_state = { state = 268 size > 0 }
						divisions_in_state = { state = 269 size > 0 }
						divisions_in_state = { state = 559 size > 0 }
					}
				}
			}
			modifier = {
				factor = 200
				OR = {
					has_full_control_of_state = 118
					any_other_country = {
						is_in_faction_with = ROOT
						has_full_control_of_state = 118
					}
				}
				has_war = yes
				NOT = { tag = ENG }
			}
		}
	}

	blow_panama_canal = {

		icon = GFX_decision_generic_ignite_civil_war

		available = {
			OR = {
				has_full_control_of_state = 685
				AND = {
					has_full_control_of_state = 304
					any_country = {
						has_war_with = ROOT
						owns_state = 685
					}
				}
			}
		}
	
		visible = {
			has_war = yes
			NOT = { has_global_flag = PANAMA_CANAL_BLOCKED }
			any_state = {
				is_controlled_by = ROOT
				OR = {
					region = 34
					region = 124
				}
			}
		}
	
		fire_only_once = no
	
		days_remove = 30
	
		cost = 75
	
		modifier = {
			civilian_factory_use = 5
		}

		complete_effect = {
			hidden_effect = {
				if = {
					limit = {
						NOT = {
							owns_state = 685
						}
					}
					random_country = {
						limit = {
							owns_state = 685
						}
						country_event = { id = generic.13 days = 1 }
					}
				}
			}
		}
	
		remove_effect = {
			if = {
				limit = {
					OR = {
						has_full_control_of_state = 685
						has_full_control_of_state = 304
					}
				}
				set_country_flag = blew_up_panama
				set_global_flag = PANAMA_CANAL_BLOCKED
				country_event = { id = wtt_news.41 hours = 6}
			}
			effect_tooltip = {
				if = {
					limit = {
						USA = { owns_state = 685 }
					}
					add_war_support = -0.05
					add_stability = -0.05
				}
			}
		}
		ai_will_do = {
			factor = 1
		}
	}
}

special_projects = {

	rebuild_suez_canal = {

		icon = GFX_decision_generic_special_project

		available = {
			has_full_control_of_state = 446
			has_full_control_of_state = 453
			num_of_civilian_factories > 50
		}
	
		visible = {
			has_global_flag = SUEZ_CANAL_BLOCKED
		}
	
		fire_only_once = no
	
		days_remove = 365
	
		cost = 250
	
		modifier = {
			civilian_factory_use = 50
		}
	
		remove_effect = {
			if = {
				limit = {
					has_full_control_of_state = 446
					has_full_control_of_state = 453
				}
				set_country_flag = rebuilt_suez
				clr_global_flag = SUEZ_CANAL_BLOCKED
				country_event = { id = wtt_news.42 hours = 6}
			}
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				has_navy_size = { size < 100 }
			}
			modifier = {
				factor = 200
				NOT = {
					OR = {
						has_full_control_of_state = 118
						any_other_country = {
							is_in_faction_with = ROOT
							has_full_control_of_state = 118
						}
					}
				}
				OR = {
					ITA = { surrender_progress < 0.1 }
					NOT = { tag = ENG }
				}
				has_full_control_of_state = 447
				has_full_control_of_state = 454
				has_full_control_of_state = 452
				has_full_control_of_state = 456
				has_full_control_of_state = 457
				NOT = { has_country_flag = blew_up_suez }
			}
		}
	}

	rebuild_panama_canal = {

		icon = GFX_decision_generic_special_project

		available = {
			has_full_control_of_state = 685
			NOT = {
				any_country = {
					has_war_with = ROOT
					controls_state = 304
				}
			}
			num_of_civilian_factories > 80
		}
	
		visible = {
			has_global_flag = PANAMA_CANAL_BLOCKED
		}
	
		fire_only_once = no
	
		days_remove = 550
	
		cost = 400
	
		modifier = {
			civilian_factory_use = 80
		}
	
		remove_effect = {
			if = {
				limit = {
					has_full_control_of_state = 685
					NOT = {
						any_country = {
							has_war_with = ROOT
							controls_state = 304
						}
					}
				}
				set_country_flag = rebuilt_panama
				clr_global_flag = PANAMA_CANAL_BLOCKED
				country_event = { id = wtt_news.43 hours = 6}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				has_navy_size = { size < 100 }
			}
			modifier = {
				factor = 0
				has_country_flag = blew_up_panama
			}
		}
	}
}

war_measures = {

	spawn_wildlingzombies = {

		icon = generic_prepare_civil_war

		available = {
			original_tag = GER
			command_power > 35
		}

		visible = {
			original_tag = GER
			DEN = { exists = yes }
			GER = { has_war_with = DEN }
		}

#		fire_only_once = yes

		days_remove = 1
		days_re_enable = 33
		
		cost = 1

		days_remove = 1

		complete_effect = {
			add_command_power = -35
			GER = { country_event = { id = germany.124 } }
		}

		ai_will_do = {
			factor = 80
		}
	}
	
	emergency_factory_conversion_defensive = {

		icon = generic_industry

		available = {
			num_of_civilian_factories > 5 #Change this if amount of factories change
		}

		visible = {
			has_defensive_war = yes
			has_offensive_war = no			
		}

		fire_only_once = no

		days_re_enable = 90

		cost = 100

		complete_effect = {
			replace_civ_with_arms_factories = yes
			add_war_support = -0.05
		}
		ai_will_do = {
			factor = 0
		}
	}

	emergency_factory_conversion_offensive = {

		icon = generic_industry

		available = {
			num_of_civilian_factories > 5 #Change this if amount of factories change
		}

		visible = {
			has_offensive_war = yes
		}

		fire_only_once = no

		days_re_enable = 90

		cost = 100

		complete_effect = {
			replace_civ_with_arms_factories = yes
			add_war_support = -0.05
			add_stability = -0.03
		}
		ai_will_do = {
			factor = 0
		}
	}

	desperate_defense = {

		icon = generic_prepare_civil_war

		available = {
			surrender_progress > 0.5
		}

		visible = {
			surrender_progress > 0
		}

		fire_only_once = no

		days_remove = 45
		days_re_enable = 360

		cost = 50
		ai_will_do = {
			factor = 1
			modifier = {
				surrender_progress > 0.6
				factor = 10
			}
		}

		modifier = {
			defence = 0.2
			dig_in_speed_factor = 0.5
		}

		complete_effect = {

		}
	}

	women_in_the_workforce = {

		icon = generic_industry

        allowed = {
            always = yes
        }

        available = {
            has_war = yes
            has_idea = tot_economic_mobilisation
            OR = {
                AND = {
                    has_government = democratic
                    has_war_support > 0.79
                }
                AND = {
                    has_government = communism
                    has_war_support > 0.79
                }
                AND = {
                    has_government = fascism
                    OR = {
                        has_war_support > 0.89
                        surrender_progress > 0
                    }
                }
                AND = {
                    has_government = neutrality
                    has_war_support > 0.84
                    has_stability > 0.7
                }
            }
        }
        visible = {
            has_war = yes
	    NOT = { original_tag = GER }
        }
        cost = 100
        days_remove = -1

        remove_trigger = {
            has_war = no
        }

        modifier = {
            conscription = 0.03
            stability_factor = -0.05
        }
        ai_will_do = {
			factor = 1
		}
		complete_effect = {
#			if = {
#				limit = {
#					tag = CAN
#				}
#				country_event = { id = canada_vanilla.1 hours = 6 } # Ronnie the Bren Gun Girl
#			}
        }
   }

    war_bonds = {

    	icon = generic_industry

    	allowed = {
            always = yes
        }

        available = {
            has_war = yes
            OR = {
                AND = {
                    has_government = democratic
                    has_war_support > 0.79
                }
                AND = {
                    has_government = communism
                    has_war_support > 0.79
                }
                AND = {
                    has_government = fascism
                    OR = {
                        has_war_support > 0.89
                        surrender_progress > 0
                    }
                }
                AND = {
                    has_government = neutrality
                    has_war_support > 0.84
                    has_stability > 0.7
                }
            }
        }
        visible = {
            has_war = yes
        }

        fire_only_once = no

		days_remove = 180

		cost = GER_war_bonds_var?50

		modifier = {
			consumer_goods_factor = -0.05
		}

		ai_will_do = {
			factor = 1
			modifier = {
				has_political_power < 150
				factor = 0 #use as pp dump
			}
		}

		remove_effect = {

		}

		complete_effect = {
			if = {
				limit = {
					NOT = {
						check_variable = {
							var = GER_war_bonds_var
							value = 100
							compare = greater_than_or_equals
						}
					}
				}
				set_variable = {
					var = GER_war_bonds_var
					value = 50
				}
			}
			add_to_variable = {
				var = GER_war_bonds_var
				value = 25
			}
			if = {
				limit = {
					check_variable = {
						var = GER_war_bonds_var
						value = 100
						compare = greater_than_or_equals
					}
					NOT = {
						check_variable = {
							var = GER_war_bonds_war_support_var
							value = 5
							compare = greater_than_or_equals
						}
					}
				}
				set_variable = {
					var = GER_war_bonds_war_support_var
					value = -5
				}
				add_war_support = GER_war_bonds_war_support_var
			}
			if = {
				limit = {
					check_variable = {
						var = GER_war_bonds_var
						value = 100
						compare = greater_than_or_equals
					}
					check_variable = {
						var = GER_war_bonds_war_support_var
						value = 5
						compare = greater_than_or_equals
					}
				}
				add_to_variable = {
					var = GER_war_bonds_war_support_var
					value = -2.5
				}
				add_war_support = GER_war_bonds_war_support_var
			}
		}
    }
}

foreign_politics = {
	object_to_attaches = {

		allowed = {
            always = yes
        }

        cost = 50
        fire_only_once = no

        days_re_enable = 30

        available = {
        }

        visible = {
        	FROM = {
        		NOT = { has_country_flag = rejected_withdrawing_attache }
        		NOT = { has_country_flag = rejected_withdrawing_attache@ROOT }
        	}
        	has_war = yes
        	NOT = { has_war_with = FROM }
        	any_enemy_country = {
				has_attache_from = FROM
			}
		}

		target_trigger = {
			NOT = { has_war_with = FROM }
			#FROM = { has_sent_attache = yes } # Make such trigger to optimize if it becomes a performance problem again.
			any_enemy_country = {
				has_attache_from = FROM
			}			
		}

        complete_effect = {
			FROM = { country_event = { id = generic.14 hours = 6 } }
		}
		ai_will_do = {
			factor = 1
		}
	}
}

economy_decisions = {
	infrastructure_building_slot = {

		icon = generic_construction

        allowed = {
            always = yes
        }

        cost = 100
        fire_only_once = no

        days_re_enable = 30

        available = {
            any_state = {
            	NOT = { has_state_flag = infrastructure_building_slot_flag }
            	is_fully_controlled_by = ROOT
            	is_owned_by = ROOT
				free_building_slots = {
					building = infrastructure
					size < 1
				}
            }
        }

        visible = {
			any_state = {
            	NOT = { has_state_flag = infrastructure_building_slot_flag }
            	is_fully_controlled_by = ROOT
            	is_owned_by = ROOT
				free_building_slots = {
					building = infrastructure
					size < 1
				}
            }
		}

        complete_effect = {
			random_owned_state = {
				limit = {
					is_fully_controlled_by = ROOT
					is_owned_by = ROOT
            		free_building_slots = {
						building = industrial_complex
						size > 1
						include_locked = yes
					}
					free_building_slots = {
						building = infrastructure
						size < 1
					}
					NOT = { has_state_flag = infrastructure_building_slot_flag }
				}
				add_extra_state_shared_building_slots = 1
				set_state_flag = infrastructure_building_slot_flag
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 10
				any_owned_state = { free_building_slots = { building = industrial_complex size < 1 include_locked = no } }
			}
		}
    }

    war_building_slot = {

    	icon = generic_construction

        allowed = {
            always = yes
        }

        cost = 50
        fire_only_once = no

        available = {
            any_state = {
            	NOT = { has_state_flag = war_building_slot_flag }
            	is_fully_controlled_by = ROOT
            	is_owned_by = ROOT
            }
            has_war = yes
        }

        visible = {
        	any_state = {
            	NOT = { has_state_flag = war_building_slot_flag }
            	is_fully_controlled_by = ROOT
            	is_owned_by = ROOT
            }
            has_war = yes
		}

        complete_effect = {
        	add_war_support = -0.025
			add_stability = -0.025
			random_owned_state = {
				limit = {
					is_fully_controlled_by = ROOT
					is_owned_by = ROOT
            		free_building_slots = {
						building = industrial_complex
						size > 1
						include_locked = yes
					}
					NOT = { has_state_flag = infrastructure_building_slot_flag }
				}
				add_extra_state_shared_building_slots = 1
				set_state_flag = war_building_slot_flag
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 10
				any_owned_state = { free_building_slots = { building = industrial_complex size < 1 include_locked = no } }
			}
		}
    }
}

foreign_support = {

###  #  # ###  #   #  ##      ###   ##   ##  ###  
#  # #  # #  # ## ## #  #     #  # #  # #  # #  # 
###  #  # ###  # # # ####     ###  #  # #### #  # 
#  # #  # #  # #   # #  #     #  # #  # #  # #  # 
###   ##  #  # #   # #  #     #  #  ##  #  # ###  

	 ##  #    ##   ## ### 
	#  # #   #  # #   #   
	#    #   #  #  #  ##  
	#  # #   #  #   # #   
	 ##  ###  ##  ##  ### 

	CHI_close_burma_road = {

		allowed = {
			#Everyone
		}

		available = {
			any_state = {
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = { is_subject_of = ROOT }
				}
				has_state_flag = CHI_needed_for_burma_road
			}			
		}

		visible = {
			is_subject = no
			any_country = {
				check_variable = { CHI_burma_road_current_level > 0 }
				NOT = { is_in_faction_with = ROOT }
				NOT = { tag = ROOT }
			}
			any_state = {
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = { is_subject_of = ROOT }
				}
				has_state_flag = CHI_needed_for_burma_road
			}
		}

		fire_only_once = no

		cost = 0

		modifier = {

		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				any_country = {
					check_variable = { CHI_burma_road_current_level > 0 }
					OR = {
						is_subject = no
						is_subject_of = ROOT
						is_in_faction_with = ROOT
					}
					NOT = { has_war_with = ROOT }
				}
			}
			modifier = {
				factor = 200
				any_country = {
					check_variable = { CHI_burma_road_current_level > 0 }
					OR = {
						has_war_with = ROOT
						AND = {
							is_subject = yes
							NOT = { is_subject_of = ROOT }
							NOT = { is_in_faction_with = ROOT }
						}
					}
				}
			}
		}

		complete_effect = {
			hidden_effect = {
				every_state = {
					limit = {
						has_state_flag = CHI_needed_for_burma_road
						OR = {
							is_controlled_by = ROOT
							CONTROLLER = { is_subject_of = ROOT }
						}
					}
					set_state_flag = CHI_burma_road_closed_state
				}
			}
			random_country = {
				#Country that had the route
				limit = { check_variable = { CHI_burma_road_current_level > 0 } }
				hidden_effect = {					
					set_variable = { tempvar = 0 }
					subtract_from_variable = { var = tempvar value = CHI_burma_road_current_level }

					add_offsite_building = { type = arms_factory level = tempvar }
					#In case we need to reopen
					set_variable = { CHI_burma_road_closed_level = CHI_burma_road_current_level }
					set_variable = { CHI_burma_road_current_level = 0 }
					clear_variable = tempvar
				}
				country_event = { id = wtt_burma_road.2 }
				custom_effect_tooltip = close_burma_road_explanation # Prints the contents of the CHI_burma_road_current_level variable
			}
		}
	}

	###  ###  ##  ###  ### #  # 
	#  # #   #  # #  # #   ## # 
	###  ##  #  # ###  ##  # ## 
	#  # #   #  # #    #   #  # 
	#  # ###  ##  #    ### #  # 
	CHI_reopen_burma_road = {

		allowed = {
			#Everyone
		}

		available = {
			any_state = {
				has_state_flag = CHI_burma_road_closed_state
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = { is_subject_of = ROOT }
				}
			}
		}

		visible = {
			is_subject = no
			any_country = {
				check_variable = { CHI_burma_road_closed_level > 0 }
				NOT = { has_war_with = ROOT }
			}
			any_state = {
				has_state_flag = CHI_burma_road_closed_state
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = {
						OR = {
							is_subject_of = ROOT
							check_variable = { CHI_burma_road_closed_level > 0 }
						}
					}
				}
			}
		}

		fire_only_once = no

		cost = 0

		modifier = {

		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 200
				any_country = {
					check_variable = { CHI_burma_road_closed_level > 0 }
					OR = {
						is_subject = no
						is_subject_of = ROOT
						is_in_faction_with = ROOT
					}
					NOT = { has_war_with = ROOT }
				}
			}
			modifier = {
				factor = 0
				any_country = {
					check_variable = { CHI_burma_road_closed_level > 0 }
					OR = {
						has_war_with = ROOT
						AND = {
							is_subject = yes
							NOT = { is_subject_of = ROOT }
							NOT = { is_in_faction_with = ROOT }
						}
					}
				}
			}
		}

		complete_effect = {
			every_state = {
				limit = {
					has_state_flag = CHI_burma_road_closed_state
					OR = {
						is_controlled_by = ROOT
						CONTROLLER = {
							OR = {
								is_subject_of = ROOT
								check_variable = { CHI_burma_road_closed_level > 0 }
							}
						}
					}
				}
				custom_effect_tooltip = CHI_burma_road_reopen_state
				clr_state_flag = CHI_burma_road_closed_state
			}

			random_country = {
				limit = { check_variable = { CHI_burma_road_closed_level > 0 } }
				if = {
					limit = {
						any_state = {
							has_state_flag = CHI_burma_road_closed_state							
							NOT = { is_controlled_by = ROOT }
							CONTROLLER = {
								NOT = { is_subject_of = ROOT }
								NOT = { check_variable = { CHI_burma_road_closed_level > 0 } }
							}
						}
					}
					country_event = { id = wtt_burma_road.3 } #We opened our part of the road
				}
				else = {
					#Road is fully reopened
					if = {
						limit = { NOT = { tag = ROOT } }
						country_event = { id = wtt_burma_road.4 }
					}
					hidden_effect = {					
						add_offsite_building = { type = arms_factory level = CHI_burma_road_closed_level }
						set_variable = { CHI_burma_road_current_level = CHI_burma_road_closed_level }
						clear_variable = CHI_burma_road_closed_level 
					}
					custom_effect_tooltip = reopen_burma_road_explanation # Prints the contents of the CHI_burma_road_closed_level variable
				}
			}
		}
	}

#   ### ###   ##      ###   ##   ##  ###  
#   #   #  # #  #     #  # #  # #  # #  # 
#   ##  #  # #  #     ###  #  # #### #  # 
#   #   #  # #  #     #  # #  # #  # #  # 
### ### ###   ##      #  #  ##  #  # ###  
	

	 ##  #    ##   ## ### 
	#  # #   #  # #   #   
	#    #   #  #  #  ##  
	#  # #   #  #   # #   
	 ##  ###  ##  ##  ### 

	CHI_close_ledo_road = {

		allowed = {
			#Everyone
		}

		available = {
			any_state = {
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = { is_subject_of = ROOT }
				}
				has_state_flag = CHI_needed_for_ledo_road
			}			
		}

		visible = {
			is_subject = no
			any_country = {
				check_variable = { CHI_ledo_road_current_level > 0 }
				NOT = { is_in_faction_with = ROOT }
				NOT = { tag = ROOT }
			}
			any_state = {
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = { is_subject_of = ROOT }
				}
				has_state_flag = CHI_needed_for_ledo_road
			}
		}

		fire_only_once = no

		cost = 0

		modifier = {

		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				any_country = {
					check_variable = { CHI_ledo_road_current_level > 0 }
					OR = {
						is_subject = no
						is_subject_of = ROOT
						is_in_faction_with = ROOT
					}
					NOT = { has_war_with = ROOT }
				}
			}
			modifier = {
				factor = 200
				any_country = {
					check_variable = { CHI_ledo_road_current_level > 0 }
					OR = {
						has_war_with = ROOT
						AND = {
							is_subject = yes
							NOT = { is_subject_of = ROOT }
							NOT = { is_in_faction_with = ROOT }
						}
					}
				}
			}
		}

		complete_effect = {
			hidden_effect = {
				every_state = {
					limit = {
						has_state_flag = CHI_needed_for_ledo_road
						OR = {
							is_controlled_by = ROOT
							CONTROLLER = { is_subject_of = ROOT }
						}
					}
					set_state_flag = CHI_ledo_road_closed_state
				}
			}
			random_country = {
				#Country that had the route
				limit = { check_variable = { CHI_ledo_road_current_level > 0 } }
				hidden_effect = {					
					set_variable = { tempvar = 0 }
					subtract_from_variable = { var = tempvar value = CHI_ledo_road_current_level }

					add_offsite_building = { type = arms_factory level = tempvar }
					#In case we need to reopen
					set_variable = { CHI_ledo_road_closed_level = CHI_ledo_road_current_level }
					set_variable = { CHI_ledo_road_current_level = 0 }
					clear_variable = tempvar
				}
				country_event = { id = wtt_ledo_road.2 }
				custom_effect_tooltip = close_ledo_road_explanation # Prints the contents of the CHI_ledo_road_current_level variable
			}
		}
	}

	###  ###  ##  ###  ### #  # 
	#  # #   #  # #  # #   ## # 
	###  ##  #  # ###  ##  # ## 
	#  # #   #  # #    #   #  # 
	#  # ###  ##  #    ### #  # 
	CHI_reopen_ledo_road = {

		allowed = {
			#Everyone
		}

		available = {
			any_state = {
				has_state_flag = CHI_ledo_road_closed_state
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = { is_subject_of = ROOT }
				}
			}
		}

		visible = {
			is_subject = no
			any_country = {
				check_variable = { CHI_ledo_road_closed_level > 0 }
				NOT = { has_war_with = ROOT }
			}
			any_state = {
				has_state_flag = CHI_ledo_road_closed_state
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = {
						OR = {
							is_subject_of = ROOT
							check_variable = { CHI_ledo_road_closed_level > 0 }
						}
					}
				}
			}
		}

		fire_only_once = no

		cost = 0

		modifier = {

		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 200
				any_country = {
					check_variable = { CHI_ledo_road_closed_level > 0 }
					OR = {
						is_subject = no
						is_subject_of = ROOT
						is_in_faction_with = ROOT
					}
					NOT = { has_war_with = ROOT }
				}
			}
			modifier = {
				factor = 0
				any_country = {
					check_variable = { CHI_ledo_road_closed_level > 0 }
					OR = {
						has_war_with = ROOT
						AND = {
							is_subject = yes
							NOT = { is_subject_of = ROOT }
							NOT = { is_in_faction_with = ROOT }
						}
					}
				}
			}
		}

		complete_effect = {
			every_state = {
				limit = {
					has_state_flag = CHI_ledo_road_closed_state
					OR = {
						is_controlled_by = ROOT
						CONTROLLER = {
							OR = {
								is_subject_of = ROOT
								check_variable = { CHI_ledo_road_closed_level > 0 }
							}
						}
					}
				}
				custom_effect_tooltip = CHI_ledo_road_reopen_state
				clr_state_flag = CHI_ledo_road_closed_state
			}

			random_country = {
				limit = { check_variable = { CHI_ledo_road_closed_level > 0 } }
				if = {
					limit = {
						any_state = {
							has_state_flag = CHI_ledo_road_closed_state							
							NOT = { is_controlled_by = ROOT }
							CONTROLLER = {
								NOT = { is_subject_of = ROOT }
								NOT = { check_variable = { CHI_ledo_road_closed_level > 0 } }
							}
						}
					}
					country_event = { id = wtt_ledo_road.3 } #We opened our part of the road
				}
				else = {
					#Road is fully reopened
					if = {
						limit = { NOT = { tag = ROOT } }
						country_event = { id = wtt_ledo_road.4 }
					}
					hidden_effect = {					
						add_offsite_building = { type = arms_factory level = CHI_ledo_road_closed_level }
						set_variable = { CHI_ledo_road_current_level = CHI_ledo_road_closed_level }
						clear_variable = CHI_ledo_road_closed_level
					}
					custom_effect_tooltip = reopen_ledo_road_explanation # Prints the contents of the CHI_ledo_road_closed_level variable
				}
			}
		}
	}

### #  # ###     #  # #  # #   # ###  
 #  #  # #       #  # #  # ## ## #  # 
 #  #### ##      #### #  # # # # ###  
 #  #  # #       #  # #  # #   # #    
 #  #  # ###     #  #  ##  #   # #

	 ##  #    ##   ## ### 
	#  # #   #  # #   #   
	#    #   #  #  #  ##  
	#  # #   #  #   # #   
	 ##  ###  ##  ##  ### 
 	CHI_close_the_hump = {

 		allowed = {
 			#Everyone
 		}

 		available = {
 			any_state = {
 				OR = {
 					is_controlled_by = ROOT
 					CONTROLLER = { is_subject_of = ROOT }
 				}
 				has_state_flag = CHI_needed_for_the_hump
 			}			
 		}

 		visible = {
 			is_subject = no
 			any_country = {
 				check_variable = { CHI_the_hump_current_level > 0 }
 				NOT = { is_in_faction_with = ROOT }
 				NOT = { tag = ROOT }
 			}
 			any_state = {
 				OR = {
 					is_controlled_by = ROOT
 					CONTROLLER = { is_subject_of = ROOT }
 				}
 				has_state_flag = CHI_needed_for_the_hump
 			}
 		}

 		fire_only_once = no

 		cost = 0

 		modifier = {

 		}

 		ai_will_do = {
 			factor = 1
			modifier = {
				factor = 0
				any_country = {
					check_variable = { CHI_the_hump_current_level > 0 }
					OR = {
						is_subject = no
						is_subject_of = ROOT
						is_in_faction_with = ROOT
					}
					NOT = { has_war_with = ROOT }
				}
			}
			modifier = {
				factor = 200
				any_country = {
					check_variable = { CHI_the_hump_current_level > 0 }
					OR = {
						has_war_with = ROOT
						AND = {
							is_subject = yes
							NOT = { is_subject_of = ROOT }
							NOT = { is_in_faction_with = ROOT }
						}
					}
				}
			}
 		}

 		complete_effect = {
 			hidden_effect = {
 				every_state = {
 					limit = {
 						has_state_flag = CHI_needed_for_the_hump
 						OR = {
 							is_controlled_by = ROOT
 							CONTROLLER = { is_subject_of = ROOT }
 						}
 					}
 					set_state_flag = CHI_the_hump_closed_state
 				}
 			}
 			random_country = {
 				#Country that had the route
 				limit = { check_variable = { CHI_the_hump_current_level > 0 } }
 				hidden_effect = {					
 					set_variable = { tempvar = 0 }
 					subtract_from_variable = { var = tempvar value = CHI_the_hump_current_level }

 					add_offsite_building = { type = arms_factory level = tempvar }
 					#In case we need to reopen
 					set_variable = { CHI_the_hump_closed_level = CHI_the_hump_current_level }
 					set_variable = { CHI_the_hump_current_level = 0 }
 					clear_variable = tempvar
 				}
 				country_event = { id = wtt_the_hump.2 }
				custom_effect_tooltip = close_the_hump_explanation # Prints the contents of the CHI_the_hump_current_level variable
 			}
 		}
 	}

 	###  ###  ##  ###  ### #  # 
 	#  # #   #  # #  # #   ## # 
 	###  ##  #  # ###  ##  # ## 
 	#  # #   #  # #    #   #  # 
 	#  # ###  ##  #    ### #  # 
 	CHI_reopen_the_hump = {

 		allowed = {
 			#Everyone
 		}

 		available = {
 			any_state = {
 				has_state_flag = CHI_the_hump_closed_state
 				OR = {
 					is_controlled_by = ROOT
 					CONTROLLER = { is_subject_of = ROOT }
 				}
 			}
 		}

 		visible = {
 			is_subject = no
 			any_country = {
 				check_variable = { CHI_the_hump_closed_level > 0 }
 				NOT = { has_war_with = ROOT }
 			}
 			any_state = {
 				has_state_flag = CHI_the_hump_closed_state
 				OR = {
 					is_controlled_by = ROOT
 					CONTROLLER = {
 						OR = {
 							is_subject_of = ROOT
 							check_variable = { CHI_the_hump_closed_level > 0 }
 						}
 					}
 				}
 			}
 		}

 		fire_only_once = no

 		cost = 0

 		modifier = {

 		}

 		ai_will_do = {
 			factor = 1
			modifier = {
				factor = 200
				any_country = {
					check_variable = { CHI_the_hump_closed_level > 0 }
					OR = {
						is_subject = no
						is_subject_of = ROOT
						is_in_faction_with = ROOT
					}
					NOT = { has_war_with = ROOT }
				}
			}
			modifier = {
				factor = 0
				any_country = {
					check_variable = { CHI_the_hump_closed_level > 0 }
					OR = {
						has_war_with = ROOT
						AND = {
							is_subject = yes
							NOT = { is_subject_of = ROOT }
							NOT = { is_in_faction_with = ROOT }
						}
					}
				}
			}
 		}

 		complete_effect = {
 			every_state = {
 				limit = {
 					has_state_flag = CHI_the_hump_closed_state
 					OR = {
 						is_controlled_by = ROOT
 						CONTROLLER = {
 							OR = {
 								is_subject_of = ROOT
 								check_variable = { CHI_the_hump_closed_level > 0 }
 							}
 						}
 					}
 				}
 				custom_effect_tooltip = CHI_the_hump_reopen_state
 				clr_state_flag = CHI_the_hump_closed_state
 			}

 			random_country = {
 				limit = { check_variable = { CHI_the_hump_closed_level > 0 } }
 				if = {
 					limit = {
 						any_state = {
 							has_state_flag = CHI_the_hump_closed_state							
 							NOT = { is_controlled_by = ROOT }
 							CONTROLLER = {
 								NOT = { is_subject_of = ROOT }
 								NOT = { check_variable = { CHI_the_hump_closed_level > 0 } }
 							}
 						}
 					}
 					country_event = { id = wtt_the_hump.3 } #We opened our part of the road
 				}
 				else = {
 					#Road is fully reopened
 					if = {
 						limit = { NOT = { tag = ROOT } }
 						country_event = { id = wtt_the_hump.4 }
 					}
 					hidden_effect = {					
 						add_offsite_building = { type = arms_factory level = CHI_the_hump_closed_level }
 						set_variable = { CHI_the_hump_current_level = CHI_the_hump_closed_level }
 						clear_variable = CHI_the_hump_closed_level
 					}
					custom_effect_tooltip = reopen_the_hump_explanation # Prints the contents of the CHI_the_hump_closed_level variable
 				}
 			}
 		}
 	}


#  #  ##  #  #  ##  ###     ###   ##  #  # ### ### 
#  # #  # ## # #  #  #      #  # #  # #  #  #  #   
#### #### # ## #  #  #      ###  #  # #  #  #  ##  
#  # #  # #  # #  #  #      #  # #  # #  #  #  #   
#  # #  # #  #  ##  ###     #  #  ##   ##   #  ### 

	 ##  #    ##   ## ### 
	#  # #   #  # #   #   
	#    #   #  #  #  ##  
	#  # #   #  #   # #   
	 ##  ###  ##  ##  ### 

	CHI_close_hanoi_route = {

		allowed = {
			#Everyone
		}

		available = {
			any_state = {
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = { is_subject_of = ROOT }
				}
				has_state_flag = CHI_needed_for_hanoi_route
			}			
		}

		visible = {
			is_subject = no
			any_country = {
				check_variable = { CHI_hanoi_route_current_level > 0 }
				NOT = { is_in_faction_with = ROOT }
				NOT = { tag = ROOT }
			}
			any_state = {
				OR = {
					is_controlled_by = ROOT
					CONTROLLER = { is_subject_of = ROOT }
				}
				has_state_flag = CHI_needed_for_hanoi_route
			}
		}

		fire_only_once = no

		cost = 0

		modifier = {

		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				any_country = {
					check_variable = { CHI_hanoi_route_current_level > 0 }
					OR = {
						is_subject = no
						is_subject_of = ROOT
						is_in_faction_with = ROOT
					}
					NOT = { has_war_with = ROOT }
				}
			}
			modifier = {
				factor = 200
				any_country = {
					check_variable = { CHI_hanoi_route_current_level > 0 }
					OR = {
						has_war_with = ROOT
						AND = {
							is_subject = yes
							NOT = { is_subject_of = ROOT }
							NOT = { is_in_faction_with = ROOT }
						}
					}
				}
			}
		}

		complete_effect = {
			hidden_effect = {
				every_state = {
					limit = {
						has_state_flag = CHI_needed_for_hanoi_route
						OR = {
							is_controlled_by = ROOT
							CONTROLLER = { is_subject_of = ROOT }
						}
					}
					set_state_flag = CHI_hanoi_route_closed_state
				}
			}
			random_country = {
				#Country that had the route
				limit = { check_variable = { CHI_hanoi_route_current_level > 0 } }
				hidden_effect = {					
					set_variable = { tempvar = 0 }
					subtract_from_variable = { var = tempvar value = CHI_hanoi_route_current_level }

					add_offsite_building = { type = arms_factory level = tempvar }
					#In case we need to reopen
					set_variable = { CHI_hanoi_route_closed_level = CHI_hanoi_route_current_level }
					set_variable = { CHI_hanoi_route_current_level = 0 }
					clear_variable = tempvar
				}
				country_event = { id = wtt_hanoi_route.2 }
				custom_effect_tooltip = close_hanoi_route_explanation # Prints the contents of the CHI_hanoi_route_current_level variable
			}
		}
	}
}