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 }
		}
		#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 = GFX_ar_improved_worker_conditions
		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.75
			}			
		}
	}

	promises_of_peace = {
		icon = GFX_ar_promises_of_peace
		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
			}			
		}
	}
}

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
		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 = {
					is_justifying_wargoal_against = ROOT
					AND = {
						has_war_with = ROOT
						is_neighbor_of = ROOT
					}
					has_offensive_war = yes
				}
			}			
		}
		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
							}
						}
					}
				}
			}
		}

		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
							}
						}
					}
				}
			}
			if = {
				limit = {
					FROM = {
						is_neighbor_of = ROOT
					}
					set_temp_variable = { war_propaganda_cost = 50 }
				}
			}
		}

		days_remove = 90
		days_re_enable = 180
		fire_only_once = yes
		cost = var:war_propaganda_cost?75
		modifier = {
			war_support_weekly = 0.01
		}
		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 = 446
			controls_state = 453
			OR = {
				NOT = {
					owns_state = 446
					owns_state = 453
				}
				any_enemy_country = {
					OR = {
						controls_state = 452
						controls_state = 447
						controls_state = 456
						controls_state = 457
						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}
			}			
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = {
					any_enemy_country = {
						OR = {
							controls_state = 452
							controls_state = 447
							controls_state = 456
							controls_state = 457
							controls_state = 454
							controls_state = 455
							OR = {
								divisions_in_state = { state = 454 size > 2 }
								divisions_in_state = { state = 447 size > 2 }
								divisions_in_state = { state = 457 size > 2 }
								divisions_in_state = { state = 456 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 = 457
							has_full_control_of_state = 456
						}
					}
					NOT = { 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 # Try to cut the enemy off from the mediterranean if you also occupy Gibraltar
				OR = {
					has_full_control_of_state = 118
					any_allied_country = {
						has_full_control_of_state = 118
					}
				}
				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 = 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}
			}			
		}
		ai_will_do = {
			factor = 1
			# modifier = {
				# factor = 0 # Don't blow up the canal as USA. Ever.
				# tag = USA
			# }
			modifier = {
				factor = 0 # Don't blow up the canal if enemies have weak navies but you are a strong naval power
				has_navy_size = {
					size > 50
				}
				NOT = {
					any_enemy_country = {
						has_navy_size = {
							size > 50
						}
					}
				}
			}
			# modifier = {
				# factor = 200 # Always blow up the canal as JAP or GER when at war with USA (priority)
				# OR = {
					# is_in_faction_with = JAP
					# is_in_faction_with = GER
				# }
				# has_war_with = USA
			# }
		}
	}
}

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 > 15
		}	
		visible = {
			has_global_flag = SUEZ_CANAL_BLOCKED
		}	
		fire_only_once = no	
		days_remove = 365	
		cost = 120	
		modifier = {
			civilian_factory_use = 15
		}	
		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 # Don't bother if your navy is weak AND not ENG
				# has_navy_size = { size < 100 }
				# NOT = { tag = ENG }
			# }			
			# modifier = {
				# factor = 200 # Prioritize if UK
				# tag = ENG
			# }
			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 = 685
			NOT = {
				any_enemy_country = {
					controls_state = 304
				}
			}
			num_of_civilian_factories > 25
		}
	
		visible = {
			has_global_flag = PANAMA_CANAL_BLOCKED
		}
	
		fire_only_once = no
	
		days_remove = 180
	
		cost = 400
	
		modifier = {
			civilian_factory_use = 25
		}
	
		remove_effect = {
			if = {
				limit = {
					has_full_control_of_state = 685
					NOT = {
						any_enemy_country = {
							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 # Don't bother if your navy is weak AND not USA
				# has_navy_size = { size < 50 }
				# NOT = { tag = USA }
				# has_war = yes
			# }
			# modifier = {
				# factor = 200 # Prioritize if you decisively beat USA's navy
				# has_war_with = USA
				# USA = { has_navy_size = { size < 50 } }
				# has_navy_size = { size > 100 }
			# }
			# modifier = {
				# factor = 200 # Prioritize if USA
				# tag = USA
			# }
			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

		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
        }
        cost = 100
        days_remove = -1
        remove_trigger = {
        	OR = {
            	has_war = no
            	not = { has_idea = tot_economic_mobilisation }
            }
        }
        modifier = {
            conscription = 0.03
            stability_factor = -0.05
        }
        ai_will_do = {
			factor = 1

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

    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 < 100
				factor = 0 #use as pp dump
			}			
		}

		remove_effect = {

		}

		complete_effect = {			
			
		}
    }
}

foreign_politics = {
	object_to_attaches = {
		allowed = {
            has_dlc = "Waking the Tiger"
        }

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

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

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

economy_decisions = {
	restructure_supply_system = { #one time boost to get a few cheap supply hubs
		visible = { 
			OR = {
				is_major = no
				AND = {
					is_faction_leader = yes
					num_of_factories < 51 #would be a minor if it wasn't for faction leader status
				}
			}
		}
		fire_only_once = yes
		days_remove = 120
		ai_will_do = {
			factor = 1
			modifier = {
				num_of_factories < 30
				factor = 0
			}
		}
		modifier = {
			production_speed_supply_node_factor = 3
		}
		complete_effect = {
			set_variable = { node_goal = num_of_supply_nodes }
			add_to_variable = { node_goal = 3 } #maximum 3 additional nodes
		}
		cancel_trigger = {			
			 check_variable = { node_goal < num_of_supply_nodes } #if the number of supply nodes exceeds the old number by +3, immediately cancel
		}
	}
	
	seize_some_trains_woo = { #repeating train seize
		visible = { 
			num_of_factories < 60
		}		
		available = {
			has_equipment = { train_equipment < 101 }
			has_tech = basic_train
		}		
		days_remove = 180
		ai_will_do = {
			factor = 1
			modifier = {
				has_stability < 0.56
				factor = 0
			}
		}
		complete_effect = {
			add_equipment_to_stockpile = {
				type = train_equipment
				amount = 15
			}
			add_stability = -0.05
		}
	}	
	infrastructure_building_slot = {

		icon = generic_construction

        allowed = {
            always = yes
        }

        cost = 100
        fire_only_once = no

        days_re_enable = 30

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

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