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 }
		}

		target_root_trigger = {
            has_tech = atomic_research
            NOT = { has_global_flag = first_nuke_dropped }
            NOT = { has_idea = race_for_the_bomb }
		}

		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
		}

		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
		}

		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 = {

	infrastructure_building_slot = {

		icon = generic_construction

		allowed = {
            always = yes
        }

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

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

		fire_only_once = no
		days_re_enable = 30

		cost = 100

		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
        }

		available = {
            has_war = yes
            any_owned_state = {
            	NOT = { has_state_flag = war_building_slot_flag }
            	is_fully_controlled_by = ROOT
            }
        }

		visible = {
			has_war = yes
			any_owned_state = {
				NOT = { has_state_flag = war_building_slot_flag }
				is_fully_controlled_by = ROOT
			}
		}

		fire_only_once = no

		cost = 50

		complete_effect = {
        	add_war_support = -0.025
			add_stability = -0.025
			if = {
				limit = {
					any_owned_state = {
						is_fully_controlled_by = ROOT
            			free_building_slots = {
							building = industrial_complex
							size > 1
							include_locked = yes
						}
						NOT = { has_state_flag = war_building_slot_flag }
						infrastructure > 8
					}
				}
				random_owned_state = {
					limit = {
						is_fully_controlled_by = ROOT
            			free_building_slots = {
							building = industrial_complex
							size > 1
							include_locked = yes
						}
						NOT = { has_state_flag = war_building_slot_flag }
						infrastructure > 8
					}
					add_extra_state_shared_building_slots = 1
					set_state_flag = war_building_slot_flag
				}
			}
			else_if = {
				limit = {
					any_owned_state = {
						is_fully_controlled_by = ROOT
            			free_building_slots = {
							building = industrial_complex
							size > 1
							include_locked = yes
						}
						NOT = { has_state_flag = war_building_slot_flag }
						infrastructure > 5
					}
				}
				random_owned_state = {
					limit = {
						is_fully_controlled_by = ROOT
            			free_building_slots = {
							building = industrial_complex
							size > 1
							include_locked = yes
						}
						NOT = { has_state_flag = war_building_slot_flag }
						infrastructure > 5
					}
					add_extra_state_shared_building_slots = 1
					set_state_flag = war_building_slot_flag
				}
			}
			else = {
				random_owned_state = {
					limit = {
						is_fully_controlled_by = ROOT
            			free_building_slots = {
							building = industrial_complex
							size > 1
							include_locked = yes
						}
						NOT = { has_state_flag = war_building_slot_flag }
						infrastructure > 8
					}
					add_extra_state_shared_building_slots = 1
					set_state_flag = war_building_slot_flag
				}
			}
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 10
				all_owned_state = { free_building_slots = { building = industrial_complex size < 1 include_locked = no } }
			}
			modifier = {
				any_owned_state = {
					infrastructure > 5
					free_building_slots = { building = industrial_complex size > 0 include_locked = no }
				}
				factor = 0
			}
		}
	}
}

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 = {
			
		}

		fire_only_once = no

		modifier = {
			war_support_weekly = 0.01
		}

		days_remove = 90
		days_re_enable = 180

		cost = 150

		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
			}
		}
	}

	war_propaganda_against_warmonger = {

		icon = generic_prepare_civil_war

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

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

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

		fire_only_once = yes

		modifier = {
			war_support_weekly = 0.01
		}

		days_remove = 90
		days_re_enable = 180

		cost = var:war_propaganda_cost?75

		complete_effect = {
			log = "[GetDateText]: [Root.GetName]: Decision war_propaganda_against_warmonger"
			set_country_flag = war_propaganda_campaign_running
		}

		remove_effect = {
			log = "[GetDateText]: [Root.GetName]: Decision remove war_propaganda_against_warmonger"
			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

		allowed = {
			has_dlc = "Waking the Tiger"
		}

		available = {
			controls_state = 189
			controls_state = 372
			OR = { 
				NOT = { 
					owns_state = 189
					owns_state = 372
				}
				any_enemy_country = { 
					OR = { 
						controls_state = 90
						controls_state = 91
						controls_state = 92
						controls_state = 361
						controls_state = 362
						controls_state = 371
						controls_state = 373
						controls_state = 375
						controls_state = 376
						controls_state = 411
					}
				}
			}
		}

		visible = {
			has_war = yes
			NOT = { has_global_flag = SUEZ_CANAL_BLOCKED }
			any_controlled_state = {
				OR = {
					region = 28
					region = 128
				}
			}
		}

		fire_only_once = no

		modifier = {
			civilian_factory_use = 5
		}

		days_remove = 30

		cost = 75

		complete_effect = { 
			hidden_effect = { 
				if = { 
					limit = { 
						NOT = { 
							owns_state = 189
							owns_state = 372
						}
					}
					random_country = { 
						limit = { 
							owns_state = 189
							owns_state = 372
						}
						country_event = { id = generic.12 days = 1 }
					}
				}
			}
		}

		remove_effect = { 
			if = { 
				limit = { 
					OR = { 
						has_full_control_of_state = 189
						has_full_control_of_state = 372
					}
				}
				set_country_flag = blew_up_suez
				set_global_flag = SUEZ_CANAL_BLOCKED
				country_event = { id = wtt_news.40 hours = 6}
			}
		}

		ai_will_do = { 
			factor = 1
			modifier = { 
				factor = 0
				NOT = { 
					any_enemy_country = { 
						OR = { 
							controls_state = 90
							controls_state = 91
							controls_state = 92
							controls_state = 361
							controls_state = 362
							controls_state = 371
							controls_state = 373
							controls_state = 375
							controls_state = 376
							controls_state = 411
							OR = { 
								divisions_in_state = { state = 90 size > 2 }
								divisions_in_state = { state = 91 size > 2 }
								divisions_in_state = { state = 92 size > 2 }
								divisions_in_state = { state = 361 size > 2 }
								divisions_in_state = { state = 362 size > 2 }
								divisions_in_state = { state = 371 size > 2 }
								divisions_in_state = { state = 373 size > 2 }
								divisions_in_state = { state = 375 size > 2 }
								divisions_in_state = { state = 376 size > 2 }
								divisions_in_state = { state = 411 size > 2 }
							}
						}
					}
				}
			}
			modifier = { 
				factor = 0 # Don't blow the canal when you've got troops needing supplies in the Horn of Africa,and no land route has been established there
				any_allied_country = { 
					NOT = { 
						OR = { 
							has_full_control_of_state = 375
							has_full_control_of_state = 376
							has_full_control_of_state = 411
						}
					}
					NOT = { has_full_control_of_state = 378 }
					OR = { 
						divisions_in_state = { state = 379 size > 0 }
						divisions_in_state = { state = 383 size > 0 }
					}
				}
			}
			modifier = { 
				factor = 200 # Try to cut the enemy off from the mediterranean if you also occupy Gibraltar
				OR = { 
					has_full_control_of_state = 9
					any_allied_country = { 
						has_full_control_of_state = 9
					}
				}
				has_war = yes
			}
		}
	}

	blow_panama_canal = {

		icon = GFX_decision_generic_ignite_civil_war

		allowed = {
			has_dlc = "Waking the Tiger"
			
		}

		available = {
			has_full_control_of_state = 188
		}

		visible = {
			has_war = yes
			NOT = { has_global_flag = PANAMA_CANAL_BLOCKED }
			any_controlled_state = {
				OR = {
					region = 34
					region = 124
				}
			}
		}

		fire_only_once = no

		modifier = {
			civilian_factory_use = 5
		}

		days_remove = 30

		cost = 75

		complete_effect = {
			hidden_effect = {
				if = {
					limit = {
						NOT = {
							owns_state = 188
						}
					}
					random_country = {
						limit = {
							owns_state = 188
						}
						country_event = { id = generic.13 days = 1 }
					}
				}
			}
		}

		remove_effect = {
			if = {
				limit = {
					OR = {
						has_full_control_of_state = 188
						has_full_control_of_state = 320
					}
				}
				set_country_flag = blew_up_panama
				set_global_flag = PANAMA_CANAL_BLOCKED
				country_event = { id = wtt_news.41 hours = 6}
			}
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				has_navy_size = {
					size > 50
				}
				NOT = {
					any_enemy_country = {
						has_navy_size = {
							size > 50
						}
					}
				}
			}
		}
	}
}

special_projects = {

	rebuild_suez_canal = {

		icon = GFX_decision_generic_special_project

		available = {
			has_full_control_of_state = 189
			has_full_control_of_state = 372
			num_of_civilian_factories > 15
		}

		visible = {
			has_global_flag = SUEZ_CANAL_BLOCKED
		}

		fire_only_once = no

		modifier = {
			civilian_factory_use = 15
		}

		days_remove = 365

		cost = 120

		remove_effect = {
			if = {
				limit = {
				has_full_control_of_state = 189
				has_full_control_of_state = 372
				}
				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 # Don't bother if your navy is weak
				has_navy_size = { size < 100 }
			}
			modifier = {
				factor = 10 # Prioritize if not at war
				has_war = no
			}
		}
	}

	rebuild_panama_canal = {

		icon = GFX_decision_generic_special_project

		available = {
			has_full_control_of_state = 188
			NOT = {
				any_enemy_country = {
					controls_state = 320
				}
			}
			num_of_civilian_factories > 25
		}

		visible = {
			has_global_flag = PANAMA_CANAL_BLOCKED
		}

		fire_only_once = no

		modifier = {
			civilian_factory_use = 25
		}

		days_remove = 180

		cost = 400

		remove_effect = {
			if = {
				limit = {
					has_full_control_of_state = 188
					NOT = {
						any_enemy_country = {
							controls_state = 320
						}
					}
				}
				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 # Don't bother if your navy is weak
				has_navy_size = { size < 50 }
				has_war = yes
			}
			modifier = {
				factor = 10 # Prioritize if not at war
				has_war = no
			}
		}
	}
}

war_measures = {

	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

		modifier = {
			defence = 0.2
			dig_in_speed_factor = 0.5
		}

		days_remove = 45
		days_re_enable = 360

		cost = 50

		complete_effect = {

		}

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

	women_in_the_workforce = {

		icon = generic_industry

		allowed = {
            always = yes
        }

		available = {
			has_war = yes
			has_idea = tot_economic_mobilisation
			OR = {
				AND = {
					has_government = absolutist
					has_war_support > 0.79
				}
				AND = {
					has_government = communism
					has_war_support > 0.79
				}
				AND = {
					has_government = democratic
					has_war_support > 0.79
				}
				AND = {
					has_government = fascism
					has_war_support > 0.79
					surrender_progress > 0
				}
				AND = {
					has_government = radical
					has_war_support > 0.79
				}
				AND = {
					has_government = neutrality
					has_war_support > 0.84
					has_stability > 0.7
				}
			}
		}

		visible = {
            has_war = yes
        }

		remove_trigger = {
        	OR = {
            	has_war = no
            	not = { has_idea = tot_economic_mobilisation }
            }
        }

		modifier = {
            conscription = 0.03
            stability_factor = -0.05
        }

		days_remove = -1

		cost = 100

		complete_effect = {
		}

		ai_will_do = {
			factor = 1

			modifier = {
				factor = 3
				has_manpower < 100000
			}
		}
	}

	war_bonds = {

		icon = generic_industry

		allowed = {
            always = yes
        }

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

		visible ={
			has_war = yes
		}

		fire_only_once = no

		modifier = {
			consumer_goods_factor = -0.05
		}

		days_remove = 180

		cost = GER_war_bonds_var?50

		complete_effect = {
			if = {
				limit = {
					check_variable = {
						var = GER_war_bonds_var
						value = 50
						compare = less_than
					}
				}
				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
					}
					check_variable = {
						var = GER_war_bonds_war_support_var
						value = -0.025
						compare = greater_than
					}
				}
				set_variable = {
					var = GER_war_bonds_war_support_var
					value = -0.025
				}
			}
			if = {
				limit = {
					check_variable = {
						var = GER_war_bonds_war_support_var
						value = -0.025
						compare = less_than_or_equals
					}
				}
				add_to_variable = {
					var = GER_war_bonds_war_support_var
					value = -0.025
				}
				add_war_support = GER_war_bonds_war_support_var
			}
		}

		remove_effect = {

		}

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

foreign_politics = {

	object_to_attaches = {

		allowed = {
            has_dlc = "Waking the Tiger"
        }

		available = {
        }

		target_root_trigger = {
			has_war = yes
			has_capitulated = no
		}

		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
			}			
		}

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

		fire_only_once = no
		days_re_enable = 30

		cost = 50

		complete_effect = {
			FROM = { country_event = { id = generic.14 hours = 6 } }
			hidden_effect = {
				FROM = { set_country_flag = object_attache_going_on }
			}
		}

		ai_will_do = {
			factor = 1
		}
	}
}

