#LAE addon-missions to Emperor Crusader missions. They require the Emperor DLC because they would be impossible to complete without the EMP tree which is DLC.
Resurgent_LAE_1 = {
	slot = 1
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Emperor"
	}
	potential = {
		has_dlc = "Emperor"
		tag = LAE
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	lae_convert_egypt = {
		icon = show_piety
		required_missions = { EMP_crusader_convert_the_holy_land EMP_crusader_egypt }
		position = 5
		
		provinces_to_highlight = { #Shall follow EMP_crusader_egypt. Tweak if that one gets tweaked.
			OR = {
				AND = {
					OR = { 
						region = egypt_region
						area = cyrenaica_area
					}
					NOT = {
						country_or_non_sovereign_subject_holds = ROOT
						religion = ROOT
					}
				}
				AND = {
					province_id = 358
					NOT = { religion = ROOT }
				}
			}
			is_wasteland = no
		
		}
		
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				value = 27
				religion = ROOT
				OR = {
					region = egypt_region
					area = cyrenaica_area
				}
			}
			358 = { religion = ROOT }
		}
		
		effect = {
			arabia_region = {
				limit = {
					NOT = { is_permanent_claim = ROOT	}
					NOT = { is_core = ROOT	}
				}
				add_permanent_claim = ROOT
			}
			add_country_modifier = {
				name = "lae_custodian_of_egypt"
				duration = -1
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_defile_mecca = {
		icon = mission_into_arabia
		required_missions = { lae_convert_egypt }
		position = 6
		
		provinces_to_highlight = {
		
		}
		
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				value = 14
				region = arabia_region
			}
			385 = {
				owned_by = ROOT
			}
		}
		
		effect = {
			add_years_of_income = 2
			#Derping in KoK's KoKy Kaaba code
			custom_tooltip = " "
			
			country_event_with_option_insight = {
				id = MEE_Byzantine_Events.9
				option_1 = "
					add_adm_power = 100
					custom_tooltip = \" \"
					385 = {
						if = {
							limit = {
								NOT = { has_tax_building_trigger = yes }
							}
							add_building = cathedral
						}
						else = {
							add_or_upgrade_tax_building = yes
						}
					}
					if = {
						limit = {
							BYZ_has_leviathan = yes
						}
						custom_tooltip = \" \"
						custom_tooltip = BYZ_kaaba_but_only_gives_prestige_and_half_of_religious_unity
					}
				"
				option_2 = "
					add_dip_power = 100
					custom_tooltip = \" \"
					custom_tooltip = BYZ_relations
					custom_tooltip = \" \"
					385 = {
						add_province_modifier = {
							name = BYZ_masjid_local_pilgrimages
							duration = -1
						}
					}
				"
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}
}

Resurgent_LAE_3 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Emperor"
	}
	potential = {
		has_dlc = "Emperor"
		tag = LAE
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	lae_convert_constantinople = {
		icon = mission_religious
		required_missions = { }
		position = 5
		
		provinces_to_highlight = {
			province_id = 151
			NOT = { religion = ROOT }
		}
		
		trigger = {
			151 = { religion = ROOT }
		}
		
		effect = {
			custom_tooltip = lae_enable_holy_orders_tt
			set_country_flag = enable_holy_orders_flag
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_restore_constantinople = {
		icon = take_constantinople
		required_missions = { lae_convert_constantinople }
		position = 6
		
		provinces_to_highlight = {
			province_id = 151
		}
		
		trigger = { #Identical to City of Cities mission for Byz
			151 = {
				if = {
					limit = {
						has_dlc = "Leviathan"
					}
					development = 75 #Because this is the capital and dev in capital in Leviathan is craycray
					OR = {
						has_great_project = {
							type = hagia_sophia
							tier = 3
						}
						has_great_project = {
							type = theodosian_walls
							tier = 3
						}
					}
					num_of_times_expanded_infrastructure = 2
				}
				else = {
					development = 50
				}
			}
		
		}
		
		effect = {
			custom_tooltip = lae_restore_constantinople_tt
			hidden_effect = {
				swap_free_idea_group = yes
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_tale_of_two_romes = {
		icon = mission_dismantle_hre
		required_missions = { lae_restore_constantinople }
		position = 8
		
		provinces_to_highlight = {
			is_capital = yes
			owned_by = emperor
		}
		
		trigger = {
			custom_trigger_tooltip = {
				tooltip = restore_roman_empire_byzantium_dismantle_hre_tooltip
				NOT = { hre_size = 1 }
			}
		}
		
		effect = {
			add_permanent_power_projection = {
				type = 25_permanent_power_projection
				amount = 25
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_true_rome = {
		icon = mission_administrating_a_roman_empire
		required_missions = { lae_tale_of_two_romes }
		position = 9
		
		provinces_to_highlight = {
			province_id = 118
		}
		
		trigger = {
			OR = {
				is_claim = 118
				is_permanent_claim = 118
			}
		}
		
		effect = {
			italy_region = {
				limit = {
					NOT = { is_permanent_claim = ROOT	}
					NOT = { is_core = ROOT	}
				}
				add_permanent_claim = ROOT
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}
}

Resurgent_LAE_4 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Emperor"
	}
	potential = {
		has_dlc = "Emperor"
		tag = LAE
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	lae_venture_further_east = {
		icon = mission_mesopotamia
		required_missions = { EMP_crusader_catholic }
		position = 5
		
		provinces_to_highlight = {
			region = mesopotamia_region
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				value = 35
				region = mesopotamia_region
			}
			408 = { country_or_non_sovereign_subject_holds = ROOT }
			
		}
		
		effect = {
			add_country_modifier = {
				name = "lae_eastern_missions"
				duration = 7300
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_reward_knights = {
		icon = reform_bergordnung
		required_missions = {  }
		position = 6
		
		provinces_to_highlight = {
			
		}
		
		trigger = {
			has_reform = latin_knights_reform
		}
		
		effect = {
			add_country_modifier = {
				name = "lae_imperial_land_praemia"
				duration = -1
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_establish_orders = {
		icon = support_the_orders
		required_missions = { lae_reward_knights }
		position = 7
		
		provinces_to_highlight = {
		
		}
		
		trigger = {
			byz_crusader_vassal = 10
		}
		
		effect = {
			custom_tooltip = lae_establish_orders_tt
			hidden_effect = {
				remove_country_modifier = lae_imperial_land_praemia
				add_country_modifier = {
					name = "lae_imperial_land_praemia_2"
					duration = -1
				}
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_amass_orders = {
		icon = league_of_the_public_weal
		required_missions = { lae_establish_orders }
		position = 8
		
		provinces_to_highlight = {
		
		}
		
		trigger = {
			byz_crusader_vassal = 30
		}
		
		effect = {
			custom_tooltip = lae_amass_orders_tt
			set_country_flag = estate_nobles_right_of_counsel_no_absolutism_privilege_cost
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}
}

Resurgent_LAE_5 = {
	slot = 5
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Emperor"
	}
	potential = {
		has_dlc = "Emperor"
		tag = LAE
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	lae_christian_india = {
		icon = mission_embassy_to_the_west
		required_missions = { lae_venture_further_east }
		position = 6
		
		provinces_to_highlight = {
			superregion = india_superregion
			has_discovered = ROOT
			is_wasteland = no
		}
		
		trigger = {
			custom_trigger_tooltip = {
				tooltip = emp_pap_mission_to_india_tt
				india_superregion = {
					has_discovered = ROOT
				}
			}
			calc_true_if = {
				desc = emp_pap_mission_to_india_tt2
				india_superregion = {
					type = all
					owner = { religion = catholic }
				}
				amount = 6 # Get an Indian foothold.
			}
		}
		
		effect = {
			custom_tooltip = emp_pap_mission_to_india_noncatholic_tt
			hidden_effect = {
				every_province = {
					limit = {
						superregion = india_superregion
						owner = {
							religion = catholic
						}
						NOT = { religion = catholic }
					}
					add_province_modifier = {
						name = pap_indian_jesuits_noncatholic
						duration = 7300
					}
				}
			}
			custom_tooltip = emp_pap_mission_to_india_catholic_tt
			hidden_effect = {
				every_province = {
					limit = {
						superregion = india_superregion
						owner = {
							religion = catholic
						}
						religion = catholic
					}
					add_province_modifier = {
						name = pap_indian_jesuits_catholic
						duration = 7300
					}
				}
			}
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_christian_far_east = {
		icon = mission_to_china
		required_missions = { lae_christian_india }
		position = 7
		
		provinces_to_highlight = {
			OR = {
				region = north_china_region
				region = south_china_region
			}
			has_discovered = ROOT
			is_wasteland = no
		}
		
		trigger = {
			custom_trigger_tooltip = {
				tooltip = emp_pap_mission_to_china_tt
				north_china_region = {
					has_discovered = ROOT
				}
				south_china_region = {
					has_discovered = ROOT
				}
			}
			calc_true_if = {
				desc = emp_pap_mission_to_china_tt2
				north_china_region = {
					type = all
					owner = { religion = catholic }
				}
				south_china_region = {
					type = all
					owner = { religion = catholic }
				}
				amount = 6 # Taiwan is three provinces, so at least one non-Taiwanese province must be taken
			}
		}
		
		effect = {
			custom_tooltip = emp_pap_mission_to_china_noncatholic_tt
			hidden_effect = {
				every_province = {
					limit = {
						OR = {
							region = north_china_region
							region = south_china_region
						}
						owner = {
							religion = catholic
						}
						NOT = { religion = catholic }
					}
					add_province_modifier = {
						name = pap_chinese_jesuits_noncatholic
						duration = 7300
					}
				}
			}
			custom_tooltip = emp_pap_mission_to_china_catholic_tt
			hidden_effect = {
				every_province = {
					limit = {
						OR = {
							region = north_china_region
							region = south_china_region
						}
						owner = {
							religion = catholic
						}
						religion = catholic
					}
					add_province_modifier = {
						name = pap_chinese_jesuits_catholic
						duration = 7300
					}
				}
			}
			if = {
				limit = {
					exists = MNG
					MNG = {
						NOT = {
							OR = {
								has_country_flag = mng_accepted_jesuits
								has_country_flag = mng_rejects_jesuits
							}
						}
					}
				}
				MNG = {
					country_event = { id = flavor_mng.7 }
				}
			}
			else_if = {
				limit = {
					exists = MNG
					MNG = {
						OR = {
							has_country_flag = mng_accepted_jesuits
							has_country_flag = mng_rejects_jesuits
						}
					}
				}
				MNG = {
					country_event = { id = flavor_pap.13 }
				}
			}
			else_if = {
				limit = {
					NOT = { exists = MNG }
					any_country = {
						is_emperor_of_china = yes
					}
				}
				every_country = {
					limit = { is_emperor_of_china = yes }
					country_event = { id = flavor_pap.14 }
				}
			}
			else_if = {
				limit = {
					NOT = { exists = MNG }
					any_country = {
						NOT = { is_emperor_of_china = yes }
					}
					1816 = { NOT = { owned_by = PAP } }
				}
				every_country = {
					limit = { owns = 1816 }
					country_event = { id = flavor_pap.14 }
				}
			}
			else = {
				add_adm_power = 100
			}
		
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}

	lae_enforce_authority = {
		icon = holy_state
		required_missions = { lae_establish_orders }
		position = 8
		
		provinces_to_highlight = {
		
		}
		
		trigger = {
			has_government_power = {
				mechanic_type = latin_imperial_authority_mechanic
				power_type = latin_imperial_authority
				value = 100
			}
		}
		
		effect = {
			freeze_government_power = {
				mechanic_type = latin_imperial_authority_mechanic
				power_type = latin_imperial_authority
			}
			custom_tooltip = lae_enforce_authority_tt
			set_country_flag = lae_can_inherit_knightly_orders
		}
		
		ai_weight = {
			factor = 500	#Natural conquest
		}
	}
}