governments_in_exile = {

	request_reinstatement = {

		icon = generic_independence

		days_re_enable = 120 # Prevent event spam

		cost = 100

		available = {
			surrender_progress < 0.75
			all_owned_state = {
				is_controlled_by = ROOT
			}
		}

		visible = {
			surrender_progress < 0.25
			FROM = { is_hosting_exile = ROOT }
			any_owned_state = {
				is_controlled_by = ROOT
			}
		}

		targets = { host }
		
		target_trigger = { FROM = { is_hosting_exile = ROOT } }
		
		complete_effect = {
			FROM = {
				country_event = { id = mtg_exile_government.2 }
			}
		}

		ai_will_do = {
			factor = 15
		}
	}

	grant_parliamentary_audience = {

		icon = eng_install_government

		available = {
		    FROM = {
		    	has_legitimacy < 39
		    }
		}

		visible = {
			FROM = { is_exiled_in = ROOT }
		    FROM = {
		    	has_legitimacy < 40
		    }
		}

		target_array = exiles
		
		target_trigger = { FROM = { is_exiled_in = ROOT } }
		

		
		targeted_modifier = {
			tag = FROM
			targeted_legitimacy_daily = 0.05
		}
		
		cost = 10
		days_remove = 120
		days_re_enable = 30

		ai_will_do = {
			factor = 0.5
			modifier = {
				OR = {
					has_political_power < 50
					political_power_daily < 0.3
				}
				factor = 0
			}
			modifier = {
				factor = 0
				FROM = {
					has_legitimacy > 60
				}
			}
		}
	}

	lobby_for_parliamentary_support = {

		icon = eng_install_government

		available = {
		}

		visible = {
			FROM = { is_hosting_exile = ROOT }
		}

		targets = { host }

		target_trigger = { FROM = { is_hosting_exile = ROOT } }
		
		modifier = {
			military_factory_donations = 3
	        industrial_factory_donations = 3
			legitimacy_daily = 0.1
		}	

		complete_effect = { 
			FROM = { add_political_power = 15 }
		}
		
		cost = 100
		days_remove = 180
		days_re_enable = 60

		ai_will_do = {
			factor = 100
			modifier = {
				factor = 0
				FROM = {
					has_legitimacy > 50
				}
			}
		}
	}

	public_support_for_from = {

		icon = eng_install_government

		available = {
		    FROM = {
		    	has_legitimacy < 29
		    }
		}

		visible = {
			is_major = yes
			FROM = { is_in_faction_with = ROOT }
		    FROM = { has_legitimacy < 30 }
		}
		
		target_array = allies
		
		target_root_trigger = {
			is_major = yes
			has_capitulated = no
		}
		
		target_trigger = {
			FROM = {
				is_in_faction_with = ROOT
				is_government_in_exile = yes
				var:host = {
					is_faction_leader = yes
				}
			}
		}
		
		modifier = {
		}

		targeted_modifier = {
			tag = FROM
			targeted_legitimacy_daily = 0.05
		}
		
		cost = 10
		days_remove = 120
		days_re_enable = 30

		ai_will_do = {
			factor = 0
		}
	}

	exile_recruitment_campaign = {

		icon = eng_propaganda_campaigns

		cost = 25
		
		days_remove = 90
		days_re_enable = 90

		available = {
		    FROM = {
		    	has_legitimacy > 20
		    }
		    FROM = { any_war_score > 4 }
		}

		visible = {
			FROM = { is_hosting_exile = ROOT }
		    FROM = { has_legitimacy > 17 }
		    FROM = { any_war_score > 4 }
		}

		targets = { host }

		target_trigger = {
			FROM = { is_hosting_exile = ROOT }
			FROM = { NOT = { original_tag = POL } }
		}
		
		modifier = {
			exile_manpower_factor = 2.0
		}

		ai_will_do = {
			factor = 15
		}
	}

	exile_extraction_campaign = {
		
		icon = oppression


		days_remove = 90
		days_re_enable = 180

		custom_cost_trigger = {
			command_power > 25
		}

		custom_cost_text = custom_cost_joint_training_exercise

		available = {
		    FROM = {
		    	has_legitimacy > 50
		    }
		    FROM = {
		    	any_war_score > 9
		    }
		}

		visible = {
			has_war = yes
			FROM = { is_exiled_in = ROOT }
		    FROM = {
		    	has_legitimacy > 49
		    	any_war_score > 8
		    }
		}

		target_trigger = {
			FROM = { is_exiled_in = ROOT }
			FROM = { NOT = { original_tag = POL } }
		}
		
		targeted_modifier = {
			tag = FROM
			exile_manpower_factor = 1.5
		}

		complete_effect = {
			hidden_effect = {
				add_command_power = -25
			}
		}

		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0 # Save for more immediately useful stuff
				command_power < 50
			}
			modifier = {
				factor = 5
				command_power > 90 # Not doing you any good so spend it
			}
		}
	}

	purge_infiltrators = {

		icon = generic_political_discourse

		available = {
		    FROM = { has_legitimacy > 25 }
		    FROM = { OR = { fascism > 0.25 communism > 0.25 } }
			ROOT = { has_government = democratic }
		}
		
		cost = 50
		
		visible = {
			FROM = { is_exiled_in = ROOT has_legitimacy > 24 }
			ROOT = { has_government = democratic }
		    FROM = { OR = { fascism > 0.2 communism > 0.2 } }
		}

		target_trigger = {
			FROM = { is_exiled_in = ROOT }
			FROM = { has_legitimacy > 49 }
		    FROM = { OR = { fascism > 0.2 communism > 0.2 } }
		}
				
		targeted_modifier = {
			tag = FROM
			targeted_legitimacy_daily = -0.1
			democratic_drift = 0.03
			communism_drift = -0.01
			fascism_drift = -0.01
			neutrality_drift = -0.01
		}

		remove_effect = {
			add_political_power = 50
		}

		days_remove = 90
		days_re_enable = 365

		ai_will_do = {
			factor = 0
		}
	}

	expatriate_donations = {
		
		icon = ger_military_buildup

		cost = 25

		days_remove = 365
		days_re_enable = 180
		
		available = {
		    FROM = { has_legitimacy > 60 }
		    FROM = { any_war_score > 24 }
		}

		visible = {
			FROM = { is_exiled_in = ROOT }
		    FROM = { has_legitimacy > 59 any_war_score > 23 }
		}

		target_trigger = { FROM = { is_exiled_in = ROOT } }
		
		modifier = {
			industrial_factory_donations = 2
			military_factory_donations = 2
		}
		
		complete_effect = { FROM = { add_legitimacy = -10 } }

		ai_will_do = {
			factor = 1
		}
	}

	request_control_of_navy = {
		
		icon = generic_naval

		cost = 25
		fire_only_once = yes

		available = {
		    FROM = {
		    	has_legitimacy < 80
		    }
		}
		visible = {
			FROM = { is_exiled_in = ROOT }
		}

		target_trigger = {
			FROM = {
				is_exiled_in = ROOT
				has_navy_size = {
				    size > 3
				}
			}
		}

		complete_effect = {
			effect_tooltip = {
				FROM = {
					transfer_navy = { target = ROOT is_government_in_exile = yes }
					add_legitimacy = -15
				}
			}
			custom_effect_tooltip = HOL_request_equipment_tt_2
			FROM = { country_event = { id = mtg_exile_government.3 hours = 12 } }
		}

		ai_will_do = {
			factor = 5
		}
	}
}

category_exile_forces = {

	weapons_for_the_resistance = {

		icon = generic_ignite_civil_war

		cost = 25
		
		available = {
			hidden_trigger = {
				FROM = {
					set_temp_variable = { resistance_equipment_needed = num_owned_states }
					subtract_from_temp_variable = { resistance_equipment_needed = num_owned_controlled_states }
				}
				multiply_temp_variable = { resistance_equipment_needed = 60 }
			}
		    has_equipment = { infantry_equipment > resistance_equipment_needed }
		    FROM = {
		    	has_legitimacy > 25
		    }
			ROOT = {
				has_government = democratic
		    }
		}

		visible = {
		    FROM = { has_legitimacy > 25 is_exiled_in = ROOT }
		    FROM = { any_war_score > 1 }
			any_enemy_country = { any_owned_state = { is_controlled_by = PREV.PREV } }
		}

		target_array = exiles
		target_trigger = {
			FROM = { is_exiled_in = ROOT }

		}
		
		days_remove = 120
		days_re_enable = 180

		complete_effect = {
			hidden_effect = {
				FROM = {
					set_temp_variable = { resistance_equipment_needed = num_owned_states }
					subtract_from_temp_variable = { resistance_equipment_needed = num_owned_controlled_states }
				}
				multiply_temp_variable = { resistance_equipment_needed = -59 }
			}
			add_equipment_to_stockpile = {
				type = infantry_equipment
				amount = resistance_equipment_needed
			}
			FROM = {
				add_timed_idea = {
					idea = idea_weapons_for_the_resistance
					days = 120
				}
			}
			FROM = { add_legitimacy = -1 }
		}

		ai_will_do = {
			factor = 1
		}
	}

	unity_parade = {

		icon = generic_nationalism

		cost = 10

		available = {
			has_war_support < 0.5
			has_war = yes
		    FROM = {
		    	has_legitimacy > 50
		    }
		    FROM = {
		    	any_war_score > 15
		    }
		}

		visible = {
			has_war_support < 0.51
			FROM = { is_exiled_in = ROOT }
		    FROM = {
		    	has_legitimacy > 49
		    	any_war_score > 14
		    }
		}

		target_trigger = { FROM = { is_exiled_in = ROOT } }
				
		targeted_modifier = {
			tag = FROM
			targeted_legitimacy_daily = -0.1
		}

		modifier = {
			war_support_weekly = 0.001
		}

		days_remove = 60
		days_re_enable = 180

		ai_will_do = {
			factor = 1
			modifier = {
				has_war_support < 0.30
				factor = 2
			}
		}
	}

	joint_training_exercise = {

		icon = eng_blackshirt_march

		cost = 0

		days_re_enable = 180

		custom_cost_trigger = {
			command_power > 25
		}

		custom_cost_text = custom_cost_joint_training_exercise

		available = {
		    FROM = {
		    	has_legitimacy > 39
		    }
		    FROM = {
		    	any_war_score > 20
		    }
		}

		visible = {
			FROM = { is_exiled_in = ROOT }
		    FROM = {
		    	has_legitimacy > 36
		    }
		    FROM = {
		    	any_war_score > 18
		    }
		}

		target_trigger = { FROM = { is_exiled_in = ROOT } }
		
		complete_effect = {
			army_experience = 10
			air_experience = 5
			navy_experience = 5

			FROM = {
				army_experience = 10
				air_experience = 5
				navy_experience = 5
				add_legitimacy = -1
			}
			
			hidden_effect = {
				add_command_power = -10
			}
		}

		ai_will_do = {
			factor = 0
		}
	}
}

