mam_missions_1 = {
	slot = 1
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "King of Kings"
	}
	potential = {
		OR = {
			tag = EGY
			tag = MAM
		}
		has_dlc = "King of Kings"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	mam_mercantile_relationship = {
		icon = mam_mercantile_relationship
		required_missions = {  }
		position = 1
		trigger = {
			if = {
				limit = {
					VEN = { exists = yes }
				}
				root = {
					navy_size = VEN
				}
				OR = {
					AND = {
						VEN = {
							NOT = { alliance_with = ROOT }
							custom_trigger_tooltip = {
								tooltip = has_been_insulted_by_root
								OR = {
									has_opinion_modifier = {
										who = ROOT
										modifier = insulted
									}
									has_opinion_modifier = {
										who = ROOT
										modifier = scornfully_insulted
									}
								}
							}
						}
					}
					AND = {
						VEN = {
							alliance_with = ROOT 
							OR = {
								has_opinion = {
									who = ROOT 
									value = 150
								}
								trust = { who = ROOT value = 60 }
								custom_trigger_tooltip = {
									tooltip = has_grain_export_tt
									has_ruler_modifier = grain_trade_imports_modifier
								}
							}
						}
					}
				}
			}
			else = {
				num_of_galley = 20
				naval_reformer = 1
			}
		}
		effect = {
			if = {
				limit = { alliance_with = VEN }
				if = {
					limit = { has_dlc = "Domination" }
					custom_tooltip = mam_reward_alliance_yes_tt
				}
				else = { custom_tooltip = mam_reward_alliance_yes_tt_no_dlc }
				tooltip = {
					358 = {
						if = {
							limit = {
								owned_by = ROOT 
								has_shipyard_building_trigger = no
							}
							add_building = shipyard
						}
					}
					VEN = {
						add_dip_power = 100 
						change_ruler_stat = {
							type = dip
							amount = 1
						}
					}
				}
			}
			else_if = {
				limit = {
					NOT = { alliance_with = VEN }
				}
				if = {
					limit = { has_dlc = "Domination" }
					custom_tooltip = mam_reward_alliance_no_tt
				}
				else = { custom_tooltip = mam_reward_alliance_no_tt_no_dlc }
				tooltip = {
					358 = {
						if = {
							limit = {
								owned_by = ROOT 
								has_shipyard_building_trigger = no
							}
							add_building = shipyard
						}
					}
					VEN = {
						add_dip_power = 100 
						change_ruler_stat = {
							type = dip
							amount = 1
						}
					}
				}
			}
			if = {
				limit = {
					NOT = { alliance_with = VEN }
					has_dlc = "Domination"
				}
				custom_tooltip = mam_reward_rival_yes_tt 
				tooltip = {
					home_trade_node_effect_scope = {
						add_trade_modifier = {
							who = ROOT
							duration = 7300
							power = 100
							key = strong_mamluk_regulations_key
						}
					}
					add_mercantilism = 3
				}
			}
			else_if = {
				limit = {
					has_dlc = "Domination"
				}
				custom_tooltip = mam_reward_rival_no_tt
				tooltip = {
					home_trade_node_effect_scope = {
						add_trade_modifier = {
							who = ROOT
							duration = 7300
							power = 100
							key = strong_mamluk_regulations_key
						}
					}
					add_mercantilism = 3
				}
			}
			else_if = {
				limit = {
					NOT = { has_dlc = "Domination" }
				}
				add_mercantilism = 3
				add_dip_power = 100
				change_ruler_stat = {
					type = dip
					amount = 1
				}
			}
			hidden_effect = {
				if = {
					limit = { alliance_with = VEN }
					VEN = {
						add_dip_power = 100 
						change_ruler_stat = {
							type = dip
							amount = 1
						}
					}
					if = {
						limit = { has_dlc = "Domination" }
						add_country_modifier = {
							name = mam_ven_cooperation_modifier 
							duration = -1
							hidden = yes
						}
					}
					358 = {
						if = {
							limit = {
								owned_by = ROOT 
								has_shipyard_building_trigger = no
							}
							add_building = shipyard
						}
					}
				}
				else = {
					home_trade_node_effect_scope = {
						add_trade_modifier = {
							who = ROOT
							duration = 7300
							power = 100
							key = strong_mamluk_regulations_key
						}
					}
					add_mercantilism = 3
				}
			}
		}
	}

	mam_establish_merchant_escorts = {
		icon = mission_arabian_sea_trade
		required_missions = { mam_mercantile_relationship mam_naval_enterprise }
		position = 2
		provinces_to_highlight = {
			owned_by = ROOT
			num_free_building_slots = 1 
			has_port = yes 
		}
		trigger = {
			num_of_owned_provinces_with = {
				value = 3
				has_coast_defense_building_trigger = yes 
			}
			num_of_light_ship = 25
		}
		effect = {
			if = {
				limit = {
					tag = MAM 
				}
				custom_tooltip = mam_upgrade_national_idea_tt 
				set_country_flag = mam_upgrade_national_idea_flag
				hidden_effect = {
					swap_free_idea_group = yes
				}
			}
			else = { add_dip_power = 100 }
			create_admiral = { tradition = 70 }
		}
	}

	kok_mam_holy_cities = {
		icon = kok_mam_holy_cities
		required_missions = {  }
		position = 4
		provinces_to_highlight = {
			OR = {
				province_id = 384
				province_id = 385
			}
			NOT = {
				country_or_non_sovereign_subject_holds = ROOT
			}
		}
		trigger = {
			384 = {
				country_or_non_sovereign_subject_holds = ROOT
			}
			385 = {
				country_or_non_sovereign_subject_holds = ROOT
			}
		}
		effect = {
			arabia_region = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			country_event = { id = flavor_mam.23 }
			custom_tooltip = flavor_mam.23_tt
			custom_tooltip = enable_sponsor_hajj_dip_action_tt
			set_country_flag = sponsor_hajj_dip_action_flag
		}
	}

	mam_yemen = {
		icon = mam_yemen
		required_missions = { kok_mam_holy_cities }
		position = 5
		provinces_to_highlight = {
			OR = {
				area = tihama_al_yemen_area
				area = upper_yemen_area
				area = yemen_area
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				OR = {
					area = tihama_al_yemen_area
					area = upper_yemen_area
					area = yemen_area
				}
				value = 6
			}
			4280 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			country_event = { id = flavor_mam.105 }
			custom_tooltip = flavor_mam.105_tt
		}
	}

	mam_ethiopia = {
		icon = mam_ethiopia
		required_missions = { mam_yemen }
		position = 7
		provinces_to_highlight = {
			region = horn_of_africa_region
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				region = horn_of_africa_region
				value = 20
			}
			1227 = { country_or_non_sovereign_subject_holds = ROOT }
			1224 = { country_or_non_sovereign_subject_holds = ROOT }
		} 
		effect = {
			country_event = { id = flavor_mam.106 }
			custom_tooltip = flavor_mam.106_tt
			if = {
				limit = {
					ETH = {
						has_opinion = {
							who = ROOT 
							value = 100
						}
						OR = {
							is_subject_of = ROOT
							alliance_with = ROOT 
						}
					}
				}
				custom_tooltip = mam_eth_friendship_tt
			}
			else = {
				custom_tooltip = mam_eth_no_friendship_tt
			}
		}
	}

	mam_recruit_the_mamluks = {
		icon = mam_recruit_the_mamluks
		required_missions = {  }
		position = 8
		trigger = {
			mamluks_percentage = 0.1
		}
		effect = {
			custom_tooltip = mam_access_new_agendas_about_mamluks_tt
			set_country_flag = mam_access_new_agendas_about_mamluks_flag
			
			tripolitania_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			djerba_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			tunisia_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
		}
	}

	mam_refine_the_furusiyya = {
		icon = mam_refine_the_furusiyya
		required_missions = { mam_recruit_the_mamluks }
		position = 9
		provinces_to_highlight = {
			
		}
		trigger = {
			if = {
				limit = { has_dlc = "Cradle of Civilization" }
				OR = {
					army_tradition = 50 
					army_professionalism = 0.3
				}
			}
			else = { army_tradition = 50 }
			#mamluks_percentage = 0.25 TODO 
			reform_level = 5
		}
		effect = {
			unlock_government_reform = {
				government_reform = modernized_furusiyya_reform
			}
			change_government_reform_progress = 50
		}
	}

	mam_colonize_spice_islands = {
		icon = mission_rb_colonise_spice_islands
		required_missions = { mam_karimi_merchants }
		position = 11
		provinces_to_highlight = {
			OR = {
				province_id = 650
				province_id = 649
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			650 = { country_or_non_sovereign_subject_holds = ROOT }
			649 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			if = {
				limit = {
					648 = { is_empty = yes }
				}
				648 = {
					add_core = ROOT
					cede_province = ROOT
					change_trade_goods = cloves
				}
			}
			custom_tooltip = mam_1_merc_for_every_cloves_province_tt
			hidden_effect = {
				if = {
					limit = {
						tag = MAM 
					}
					every_province = {
						limit = {
							country_or_non_sovereign_subject_holds = ROOT
							trade_goods = cloves
						}
						MAM = { add_mercantilism = 1 }
					}
				}
				else_if = {
					limit = {
						tag = EGY 
					}
					every_province = {
						limit = {
							country_or_non_sovereign_subject_holds = ROOT
							trade_goods = cloves
						}
						EGY = { add_mercantilism = 1 }
					}
				}
			}
		}
	}
}

mam_missions_2 = {
	slot = 2
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "King of Kings"
	}
	potential = {
		OR = {
			tag = EGY
			tag = MAM
		}
		has_dlc = "King of Kings"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes
	
	mam_naval_enterprise = {
		icon = mission_launch_a_flagship
		required_missions = {  }
		provinces_to_highlight = {
			
		}
		trigger = {
			navy_size_percentage = 0.9
			navy_size = 18 # modified
		}
		effect = {
			country_event = { id = flavor_mam.100 } 
			custom_tooltip = flavor_mam.100_tt		
		}
	}

	mam_rhodes = {
		icon = knights_of_the_new_world
		required_missions = { mam_naval_enterprise }
		position = 2
		provinces_to_highlight = {
			province_id = 320
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			320 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			add_army_tradition = 10
			if = {
				limit = {
					has_dlc = "Mandate of Heaven"
				}
				358 = { add_prosperity = 50 }
				4316 = { add_prosperity = 50 }
			}
			else = { 
				add_prestige_or_monarch_power = { amount = 15 }
			}
		}
	}

	mam_pearl_mediterranean = {
		icon = mission_rb_mediterranean_authority
		required_missions = { mam_establish_merchant_escorts }
		position = 3
		provinces_to_highlight = {
			OR = {
				AND = {
					is_capital = yes 
					owner = {
						NOT = { tag = ROOT }
						any_owned_province = {
							has_port = yes 
							sea_zone = {
								OR = {
									area = eastern_mediterrenean_area
									area = western_mediterrenean_area
								}
							}
						}
						navy_size = ROOT
					}
				}
				AND = {
					province_id = 358
					NOT = { owned_by = ROOT }
				}		
			}
		}
		trigger = {
			navy_size = 100 # modified
			OR = {
				has_reform = maritime_military_reform
				full_idea_group = naval_ideas
				full_idea_group = maritime_ideas
			}
			custom_trigger_tooltip = {
				tooltip = no_nation_med_stronger_navy_tt
				NOT = {
					any_known_country = {
						any_owned_province = {
							has_port = yes 
							sea_zone = {
								OR = {
									area = eastern_mediterrenean_area
									area = western_mediterrenean_area
								}
							}
						}
						navy_size = ROOT
					}
				}
			}
			358 = {
				owned_by = ROOT
				has_shipyard_building_trigger = yes
			}
		}
		effect = {
			if = {
				limit = { has_dlc = "Golden Century" }
				if = {
					limit = { has_reform = maritime_military_reform }
					custom_tooltip = mam_nav_prof_reward_yes_tt
				}
				else = { custom_tooltip = mam_navy_prof_reward_no_tt }
				if = {
					limit = { full_idea_group = naval_ideas }
					custom_tooltip = mam_naval_ideas_yes_tt
					tooltip = {
						358 = {
							create_flagship = { type = heavy_ship }
						}
					}
				}
				else = { 
					custom_tooltip = mam_naval_ideas_no_tt
					tooltip = {
						358 = {
							create_flagship = { type = heavy_ship }
						}
					}
				}
				if = {
					limit = { full_idea_group = maritime_ideas }
					custom_tooltip = mam_maritime_ideas_yes_tt
					tooltip = {
						358 = {
							create_flagship = { type = light_ship }
						}
					}
				}
				else = { 
					custom_tooltip = mam_maritime_ideas_no_tt
					tooltip = {
						358 = {
							create_flagship = { type = light_ship }
						}
					}
				}
				hidden_effect = {
					if = {
						limit = { has_reform = maritime_military_reform }
						set_country_flag = improve_nav_prof_flag
					}
					if = {
						limit = { full_idea_group = naval_ideas }
						358 = {
							create_flagship = { type = heavy_ship }
						}
					}
					if = {
						limit = { full_idea_group = maritime_ideas }
						358 = {
							create_flagship = { type = light_ship }
						}
					}
				}
			}
			else = {
				add_navy_tradition = 25
				add_mercantilism = 3
			}
		}	
	}

	mam_arabia = {
		icon = mam_arabia
		required_missions = { kok_mam_holy_cities }
		position = 5
		provinces_to_highlight = {
			region = arabia_region 
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				region = arabia_region
				value = 30
			}
		}
		effect = {
			unlock_estate_privilege = {
				estate_privilege = estate_burghers_hydraulic_rights
			}
			if = {
				limit = { 
					has_dlc = "Leviathan"
					403 = { country_or_non_sovereign_subject_holds = ROOT }
				}
				403 = { 
					add_great_project_tier = {
						type = nizwa_fort 
						tier = 1 
					}
				}
			}
			2999 = {
				if = {
					limit = {
						NOT = { is_core = ROOT }
						NOT = { is_permanent_claim = ROOT }
					}
					add_permanent_claim = ROOT
				}
			}
		}
	}

	mam_hormuz_straits = {
		icon = mam_hormuz_straits
		required_missions = { mam_arabia }
		position = 6
		provinces_to_highlight = {
			province_id = 2999
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			2999 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			persian_gulf_coast = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			mogostan_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			makran_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			2999 = {
				if = {
					limit = {
						NOT = { province_has_center_of_trade_of_level = 2 }
						has_dlc = "Dharma"
					}
					add_center_of_trade_level = 1
				}
				else = {
					add_base_production = 2
				}
			}
		}
	}

	mam_highway_empire = {
		icon = mam_highway_empire
		required_missions = { mam_alexandrian_trade }
		position = 9
		provinces_to_highlight = {
			OR = {
				province_id = 4316 
				province_id = 2315
			}
		}
		trigger = {
			if = {
				limit = { has_dlc = "Leviathan" }
				4316 = {
					owned_by = ROOT
					OR = {
						num_of_times_improved = 10
						has_great_project = { 
							type = suez_canal 
							tier = 3 
						}
					}
				}
				4316 = { has_any_ongoing_construction = no }
				4316 = {
					NOT = { num_free_building_slots = 1 } 
				}
			}
			else = {
				4316 = { 
					num_of_times_improved = 10 
					owned_by = ROOT
				}
			}
			4316 = { num_of_buildings_in_province = 5 }
			2315 = { owned_by = ROOT }
			4316 = { 
				owned_by = ROOT 
				controlled_by = ROOT
				has_siege = no
			}
			is_at_war = no			
		}
		effect = {
			if = {
				limit = { 
					has_dlc = "Leviathan" 
					4316 = {
						NOT = {
							has_great_project = { 
								type = suez_canal 
								tier = 3 
							}
						}
					}
					NOT = { adm_tech = 22 }
				}
				country_event = { id = flavor_mam.115 }
				custom_tooltip = flavor_mam.115_tt
			}
			else = {
				4316 = { add_base_production = 3 }
			}
			add_mercantilism = 3
		}
	}

	mam_karimi_merchants = {
		icon = mission_restore_trade_superiority
		required_missions = {  }
		position = 10
		provinces_to_highlight = {
			province_id = 358
		}
		trigger = {
			if = {
				limit = { ai = no }
				trader = 3
			}
			else = { trader = 1 }
			OR = {
				AND = {
					if = {
						limit = { ai = no }
						estate_loyalty = {
							estate = estate_burghers
							loyalty = 70
						}
					}
					else = {
						estate_loyalty = {
							estate = estate_burghers
							loyalty = 60
						}
					}
					has_estate_privilege = estate_burghers_fund_karimi
				}
				trading_bonus = {
					trade_goods = cloves
					value = yes
				}
				358 = { #Αλεξάνδρεια
					trade_share = {
						country = ROOT
						share = 51
					}
				}
			}
		}
		effect = {
			unlock_government_reform = {
				government_reform = karimi_stations_reform
			}
			361 = {
				change_trade_goods = cloves 
			}
		}
	}

	mam_harness_spice_trade = {
		icon = mam_harness_spice_trade
		required_missions = { mam_karimi_merchants }
		position = 11
		provinces_to_highlight = {
			province_id = 358
		}
		trigger = {
			OR = {
				exploration_ideas = 1
				mercantilism = 30
				full_idea_group = trade_ideas
			}
			OR = {
				custom_trigger_tooltip = {
					tooltip = no_westerner_trading_in_cloves_tt
					NOT = {
						any_known_country = {
							technology_group = western 
							trading_bonus = {
								trade_goods = cloves
								value = yes
							}
						}
					}
				}
				358 = { 
					trade_node_value = 30
				}
			}
		}
		effect = {
			create_explorer = { tradition = 75 }
			if = {
				limit = { has_estate = estate_burghers }
				add_estate_loyalty = {
					estate = estate_burghers
					loyalty = 20 
				}
			}
			else = { add_mercantilism = 2}
			unlock_estate_privilege = {
				estate_privilege = estate_burghers_foreign_expeditions
			}
		}
	}
}

mam_missions_3 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "King of Kings"
	}
	potential = {
		OR = {
			tag = EGY
			tag = MAM
		}
		has_dlc = "King of Kings"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	mam_cyprus = {
		icon = kingdom_of_cyprus
		required_missions = { mam_naval_enterprise }
		position = 2
		provinces_to_highlight = {
			province_id = 321
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			321 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			if = { 
				limit = { has_dlc = "Mandate of Heaven" }
				add_splendor = 100
			}
			else = { add_mil_power = 50 }
			thrace_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			change_ruler_stat = {
				type = dip
				amount = 1
			}
		}
	}

	mam_great_power = {
		icon = mam_great_power
		required_missions = { mam_pearl_mediterranean mam_constantinople }
		position = 4
		
		trigger = {
			if = {
				limit = { 
					OR = {
						has_dlc = "Rights of Man"
						has_dlc = "Emperor"
					}
					has_dlc = "Emperor"
				}
				OR = {
					is_hegemon = yes 
					NOT = { great_power_rank = 2 }
				}
			}
			else_if = {
				limit = { has_dlc = "Rights of Man" }
				NOT = { great_power_rank = 2 }
			} 
			else = { total_development = 1500 }
		}
		effect = {
			if = {
				limit = { 
					tag = MAM 
					has_government_mechanic = mamluk_mechanic 
				}
				custom_tooltip = promote_culture_government_duration_doubled_tt
				set_country_flag = promote_culture_government_duration_doubled_flag
				add_government_power = { 
					mechanic_type = mamluk_mechanic
					power_type = mamluk_adm_power
					value = 50
				} 
				add_government_power = { 
					mechanic_type = mamluk_mechanic
					power_type = mamluk_dip_power
					value = 50
				} 
				add_government_power = { 
					mechanic_type = mamluk_mechanic
					power_type = mamluk_mil_power
					value = 50
				} 
			}
			else_if = {
				limit = { 
					tag = MAM 
					NOT = { has_government_mechanic = mamluk_mechanic }
				}
				add_prestige_or_monarch_power = { amount = 50 }
				change_ruler_stat = {
					type = adm
					amount = 1
				}
				change_ruler_stat = {
					type = dip
					amount = 1
				}
				change_ruler_stat = {
					type = mil
					amount = 1
				}
			}
			if = {
				limit = { 
					tag = EGY 
					has_government_mechanic = egyptian_westernization
				}
				if = {
					limit = { has_dlc = "Rule Britannia" }
					change_innovativeness = 5
				}
				custom_tooltip = egyptian_westernization_costs_less_tt
				set_country_flag = egyptian_westernization_costs_less_flag
				add_government_power = { 
					mechanic_type = egyptian_westernization
					power_type = egyptian_westernization
					value = 25
				} 
			}
			else_if = {
				limit = { 
					tag = EGY 
					NOT = { has_government_mechanic = egyptian_westernization }
				}
				add_prestige_or_monarch_power = { amount = 50 }
				change_ruler_stat = {
					type = adm
					amount = 1
				}
				change_ruler_stat = {
					type = dip
					amount = 1
				}
				change_ruler_stat = {
					type = mil
					amount = 1
				}
			}
		}
	}

	mam_baghdad = {
		icon = mam_baghdad
		required_missions = {  }
		position = 5
		provinces_to_highlight = {
			OR = { 
				area = al_jazira_area
				area = iraq_arabi_area
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			al_jazira_area = {
				type = all 
				country_or_non_sovereign_subject_holds = ROOT 
			}
			iraq_arabi_area = {
				type = all 
				country_or_non_sovereign_subject_holds = ROOT 
			}
		}
		effect = {
			if = {
				limit = { 
					religion_group = muslim 
					has_dlc = "Cradle of Civilization"
				}
				if = {
					limit = { piety = 0 }
					add_piety = 0.1
				}
				else = { add_piety = -0.1 }
			}
			else = { add_prestige_or_monarch_power = { amount = 15 } }
			basra_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			khuzestan_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			shahrizor_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			tabriz_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			
			define_advisor = {
				type = natural_scientist
				cost_multiplier = 0.5
				skill = 3
			}
		}
	}

	mam_basrah = {
		icon = mam_basrah
		required_missions = { mam_baghdad }
		position = 6
		provinces_to_highlight = {
			OR = {
				area = khuzestan_area
				area = basra_area
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			OR = {
				1335 = {
					trade_share = {
						country = ROOT
						share = 40
					}
				}
				AND = {
					khuzestan_area = {
						type = all 
						country_or_non_sovereign_subject_holds = ROOT 
					}
					basra_area = {
						type = all 
						country_or_non_sovereign_subject_holds = ROOT 
					}
				}
			}
		}
		effect = {
			add_country_modifier = {
				name = mam_goods_from_the_east_modifier
				duration = 7300
			}
			add_mercantilism = 3
		}
	}

	mam_alexandrian_trade = {
		icon = mission_conquer_alexandria
		required_missions = {  }
		position = 8
		provinces_to_highlight = {
			OR = {
				province_id = 358
				province_id = 362
				province_id = 363
			}
			OR = {
				NOT = { owned_by = ROOT }
				has_trade_building_trigger = no 
			}
		}
		trigger = {
			358 = { owned_by = ROOT has_trade_building_trigger = yes }
			362 = { owned_by = ROOT has_trade_building_trigger = yes }
			363 = { owned_by = ROOT has_trade_building_trigger = yes }
		}
		effect = {
			custom_tooltip = mam_indebted_privilege_no_merc_loss_tt
			set_country_flag = no_mercantilism_loss_estate_privilege_flag

			if = {
				limit = { has_dlc = "Mandate of Heaven" }
				custom_tooltip = mam_trade_building_prosperity_tt
				set_country_flag = mam_trade_building_prosperity_flag
			}
			else = { add_years_of_estate_land_income = 0.25 }
		}
	}

	mam_father_african_rivers = {
		icon = mission_se_along_the_river
		required_missions = { mam_alexandrian_trade }
		position = 9
		provinces_to_highlight = {
			OR = {
				province_id = 362
				province_id = 363
				province_id = 2316
				province_id = 361
				province_id = 359
				area = vostani_area
				area = said_area
			}
			owned_by = ROOT
			if = {
				limit = { has_dlc = "Mandate of Heaven" }
				OR = {
					is_prosperous = no 
					NOT = { num_of_times_improved = 1 }
					NOT = { num_of_buildings_in_province = 1 }
				}
			}
			else = {
				OR = {
					NOT = { num_of_times_improved = 1 }
					NOT = { num_of_buildings_in_province = 1 }
				}
			}
		}
		trigger = {
			custom_trigger_tooltip = {
				tooltip = mam_every_province_nile_tt
				362 = {
					owned_by = ROOT
					OR = {
						num_of_buildings_in_province = 1
						num_of_times_improved = 1
						is_prosperous = yes
					}
				}
				363 = {
					owned_by = ROOT
					OR = {
						num_of_buildings_in_province = 1
						num_of_times_improved = 1
						is_prosperous = yes
					}
				}
				2316 = {
					owned_by = ROOT
					OR = {
						num_of_buildings_in_province = 1
						num_of_times_improved = 1
						is_prosperous = yes
					}
				}
				361 = {
					owned_by = ROOT
					OR = {
						num_of_buildings_in_province = 1
						num_of_times_improved = 1
						is_prosperous = yes
					}
				}
				359 = {
					owned_by = ROOT
					OR = {
						num_of_buildings_in_province = 1
						num_of_times_improved = 1
						is_prosperous = yes
					}
				}
				vostani_area = {
					owned_by = ROOT
					type = all 
					OR = {
						num_of_buildings_in_province = 1
						num_of_times_improved = 1
						is_prosperous = yes
					}
				}
				said_area = {
					owned_by = ROOT
					type = all
					OR = {
						num_of_buildings_in_province = 1
						num_of_times_improved = 1
						is_prosperous = yes
					}
				}
			}
		}
		effect = {
			custom_tooltip = mam_every_province_across_nile_tt
			unlock_estate_privilege = {
				estate_privilege = estate_burghers_nile_goods_transport
			}
			hidden_effect = {
				every_owned_province = {
					limit = {
						OR = { 
							province_id = 362
							province_id = 363
							province_id = 2316
							province_id = 361
							province_id = 359
							area = vostani_area
							area = said_area
						}
					}
					add_base_production = 1
				}
			}
		}
	}

	mam_dar_al_hadith_turba = {
		icon = reform_the_nomocanon
		required_missions = {  }
		position = 11
		trigger = {
			if = {
				limit = {
					has_dlc = "Rule Britannia"
					has_estate = estate_church
				}
				OR = {
					innovativeness = 20
					AND = {
						estate_loyalty = {
							estate = estate_church 
							loyalty = 60 
						}
						OR = {
							has_estate_privilege = estate_church_fund_dar_al_hadith
							has_estate_privilege = estate_church_fund_madrasas
						} 
					}
				}
			}
			else_if = {
				limit = {
					has_dlc = "Rule Britannia"
					NOT = { has_estate = estate_church }
				}
				innovativeness = 20
				stability = 2
			}
			else_if = {
				limit = {
					NOT = { has_dlc = "Rule Britannia" }
					has_estate = estate_church
				}
				adm_tech = 7
				AND = {
					estate_loyalty = {
						estate = estate_church 
						loyalty = 60 
					}
					OR = {
						has_estate_privilege = estate_church_fund_dar_al_hadith
						has_estate_privilege = estate_church_fund_madrasas
					} 
				}
			}
			else = {
				stability = 2
				prestige = 30
			}
			years_of_income = 2
		}
		effect = {
			country_event = { id = flavor_mam.101 }
			custom_tooltip = flavor_mam.101_tt
		}
	}
}

mam_missions_4 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "King of Kings"
	}
	potential = {
		OR = {
			tag = EGY
			tag = MAM
		}
		has_dlc = "King of Kings"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes

	mam_reincorporate_northern_territories = {
		icon = mam_reincorporate_northern_territories
		required_missions = {  }
		position = 1
		provinces_to_highlight = {
			OR = {
				area = syria_area
				province_id = 1849 
				province_id = 2313 
				province_id = 377 
			}
		}
		trigger = {
			if = {
				limit = {
					NOT = { is_year = 1446 }
				}
				custom_trigger_tooltip = { 
					tooltip = mam_had_administration_syria_event_tt
					has_country_flag = mam_had_administration_syria_event_flag
				}
			}
			OR = {
				if = {
					limit = { 
						OR = { 
							has_dlc = "Res Publica"
							has_dlc = "Common Sense"
						}
					}
					national_focus = ADM
				}
				has_adm_advisor = yes 
				stability = 1
			}
			syria_area = {
				type = all 
				country_or_non_sovereign_subject_holds = ROOT 
			}
			aleppo_area = {
				type = all 
				OR = {
					country_or_non_sovereign_subject_holds = ROOT
					province_id = 4298
				} 
			}
			if = {
				limit = {
					SYR = { is_subject_of = ROOT }
					has_country_flag = mam_intervened_syria
				}
				SYR = {
					NOT = { liberty_desire = 50 }
				}
			}
			else_if = {
				limit = {
					SYR = { is_subject_of = ROOT }
				}
				SYR = {
					NOT = { liberty_desire = 25 }
				}
			}
			syria_area = {
				type = all
				country_or_non_sovereign_subject_holds = ROOT
			}
			aleppo_area = {
				type = all
				OR = {
					country_or_non_sovereign_subject_holds = ROOT
					province_id = 4298
				}
			}
		}
		effect = {
			clr_country_flag = mam_intervened_syria
			dulkadir_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			germiyan_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			karaman_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			cukurova_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			aydin_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			hudavendigar_area = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			if = {
				limit = {
					4298 = {
						NOT = { is_core = ROOT }
						NOT = { is_permanent_claim = ROOT }
					}
				}
				4298 = { add_permanent_claim = ROOT }
			}
			if = {
				limit = { has_dlc = "Mandate of Heaven" }
				syria_area = { add_prosperity = 100 }
				aleppo_area = { add_prosperity = 100 }
			}
			else = {
				382 = { add_random_development = 1 }
				377 = { add_random_development = 1 }
			}
		}
	}

	mam_anatolia = {
		icon = anatolian_frontier
		required_missions = { mam_reincorporate_northern_territories }
		position = 2
		provinces_to_highlight = {
			region = anatolia_region
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				value = 20
				region = anatolia_region
			}
		}
		effect = {
			balkan_region = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			change_ruler_stat = {
				type = mil
				amount = 1
			}
		}
	}
	mam_constantinople = {
		icon = mission_constantinople
		required_missions = { mam_cyprus mam_anatolia }
		position = 3
		provinces_to_highlight = {
			area = thrace_area 
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			thrace_area = {
				type = all 
				country_or_non_sovereign_subject_holds = ROOT
			}
		}
		effect = {
			country_event = { id = flavor_mam.112 }
			custom_tooltip = flavor_mam.112_tt
		}
	}

	mam_tabriz = {
		icon = mam_tabriz
		required_missions = {  }
		position = 5
		provinces_to_highlight = {
			area = tabriz_area
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			tabriz_area = {
				type = all 
				country_or_non_sovereign_subject_holds = ROOT
			}
		}
		effect = {
			persia_region = {
				limit = {
					NOT = { is_core = ROOT }
					NOT = { is_permanent_claim = ROOT }
				}
				add_permanent_claim = ROOT
			}
			if = { 
				limit = { 
					has_dlc = "Rights of Man" 
					NOT = { num_of_ruler_traits = { amount = 3 } }
				} 
				add_ruler_personality = strict_personality
			}
			else = { add_army_tradition = 10 } 
		}
	}

	mam_persia = {
		icon = mam_persia
		required_missions = { mam_tabriz }
		position = 6
		provinces_to_highlight = {
			region = persia_region 
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				region = persia_region 
				value = 25 
			}
			428 = { country_or_non_sovereign_subject_holds = ROOT }
			429 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			country_event = { id = flavor_mam.114 }
			custom_tooltip = flavor_mam.114_tt
		}
	}

	mam_unify_islam = {
		icon = mission_islamic_golden_age
		position = 7
		required_missions = { mam_basrah mam_persia mam_morocco }
		provinces_to_highlight = {
			OR = {
				province_id = 504
				province_id = 225
				province_id = 151
				province_id = 410
				province_id = 385
				province_id = 384
				province_id = 124
				province_id = 125
				province_id = 425
				province_id = 382
				province_id = 454
				province_id = 347
				province_id = 388
				province_id = 400				
			}
			OR = {
				NOT = { country_or_non_sovereign_subject_holds = ROOT }
			}
		}
		trigger = {
			if = {
				limit = {
					NOT = { 
						has_dlc = "Star and Crescent"
					}
				}
				religion_group = muslim
				owns_or_non_sovereign_subject_of = 504
				owns_or_non_sovereign_subject_of = 225
				owns_or_non_sovereign_subject_of = 151
				owns_or_non_sovereign_subject_of = 410
				owns_or_non_sovereign_subject_of = 385
				owns_or_non_sovereign_subject_of = 384
				owns_or_non_sovereign_subject_of = 124
				owns_or_non_sovereign_subject_of = 125
				owns_or_non_sovereign_subject_of = 425
				owns_or_non_sovereign_subject_of = 382
				owns_or_non_sovereign_subject_of = 454
				owns_or_non_sovereign_subject_of = 347
				owns_or_non_sovereign_subject_of = 388
				owns_or_non_sovereign_subject_of = 400
			}
			else = { 
				custom_trigger_tooltip = {
					tooltip = unified_islam_tt
					has_country_modifier = unified_islam
				}
			}
		}
		effect = {
			add_country_modifier = {
				name = protector_of_the_islamic_realm_modifier
				duration = -1
			}
		}
	}

	mam_cultivate_the_delta = {
		icon = mission_clear_the_delta
		required_missions = { mam_alexandrian_trade }
		position = 9
		provinces_to_highlight = {
			if = {
				limit = { has_dlc = "Mandate of Heaven" }
				OR = {
					province_id = 362 
					province_id = 363
					province_id = 4316 
					province_id = 2316 
				}
				OR = {
					NOT = { owned_by = ROOT }
					NOT = { num_of_times_improved = 4 }
					is_prosperous = no
				}
			}
			else = {
				OR = {
					province_id = 362 
					province_id = 363
					province_id = 4316 
					province_id = 2316 
				}
				OR = {
					NOT = { owned_by = ROOT }
					NOT = { num_of_times_improved = 4 }
				}
			}
		}
		trigger = {
			if = {
				limit = { has_dlc = "Mandate of Heaven" }
				362 = {
					OR = {
						is_prosperous = yes 
						num_of_times_improved = 4
					}
					owned_by = ROOT
				}
				2316 = {
					OR = {
						is_prosperous = yes 
						num_of_times_improved = 4
					}
					owned_by = ROOT
				}
				363 = {
					OR = {
						is_prosperous = yes 
						num_of_times_improved = 4
					}
					owned_by = ROOT
				}
				4316 = {
					OR = {
						is_prosperous = yes 
						num_of_times_improved = 4
					}
					owned_by = ROOT
				}
				2316 = {
					OR = {
						is_prosperous = yes 
						num_of_times_improved = 4
					}
					owned_by = ROOT
				}
			}
			else = {
				362 = {
					num_of_times_improved = 4
					owned_by = ROOT
				}
				2316 = {
					num_of_times_improved = 4
					owned_by = ROOT
				}
				363 = {
					num_of_times_improved = 4
					owned_by = ROOT
				}
				4316 = {
					num_of_times_improved = 4
					owned_by = ROOT
				}
				2316 = {
					num_of_times_improved = 4
					owned_by = ROOT
				}
			}
		}
		effect = {
			country_event = { id = flavor_mam.102 }
			custom_tooltip = flavor_mam.102_tt
		}
	}

	mam_aden_trade = {
		icon = mission_the_tamil_trade_guilds
		required_missions = { mam_father_african_rivers }
		position = 10
		provinces_to_highlight = {
			OR = {
				province_id = 4346
				AND = {
					province_id = 388
					OR = {
						country_or_non_sovereign_subject_holds = ROOT
						has_trade_building_trigger = no
						NOT = { province_has_center_of_trade_of_level = 2 }
					}
				}
			}
		}
		trigger = {
			4346 = {
				trade_share = {
					country = ROOT
					share = 51
				}
			}
			388 = {
				country_or_non_sovereign_subject_holds = ROOT
				OR = {
					has_trade_building_trigger = yes
					province_has_center_of_trade_of_level = 2
				}
			}
		}
		effect = {
			custom_tooltip = mam_upgrade_private_trade_fleets_tt
			set_country_flag = mam_upgrade_private_trade_fleets_flag

			add_mercantilism = 3
		}
	}

	mam_kashifs_egypt = {
		icon = mission_muslim_administrators
		required_missions = { mam_khass_al_sultan }
		position = 11
		trigger = {
			OR = {
				full_idea_group = administrative_ideas
				adm = 6
				AND = {
					crown_land_share = 50 
					has_reform = centralize_empire_reform
				}
			}
			OR = {
				adm_tech = 12
				NOT = { average_autonomy_above_min = 5 }
			}
			if = {
				limit = { num_of_subjects = 1 }
				NOT = { 
					any_subject_country = {
						liberty_desire = 10
					}
				}
			}
			is_at_war = no 
		}
		effect = {
			country_event = { id = flavor_mam.103 }

			custom_tooltip = flavor_mam.103_tt
		}
	}

	mam_center_arab_islamic_world = {
		icon = mission_restore_faith_in_the_throne
		required_missions = { mam_dar_al_hadith_turba mam_kashifs_egypt mam_assign_waqf }
		position = 12
		provinces_to_highlight = {
			if = {
				limit = {
					MAM = {
						exists = yes 
					}
				}
				culture_group = turko_semitic
				NOT = {
					OR = {
						owned_by = ROOT
						OR = {
							owner = {
								is_subject_of = ROOT
								OR = {
									is_subject_of_type = colony
									is_subject_of_type = crown_colony
									is_subject_of_type = private_enterprise
									is_subject_of_type = self_governing_colony
								}
							}
							owner = {
								OR = {
									is_subject_of_type = colony
									is_subject_of_type = crown_colony
									is_subject_of_type = private_enterprise
									is_subject_of_type = self_governing_colony
								}
								overlord = {
									is_subject_of = ROOT
								}
							}
						}
					}
				}
			}
		}
		trigger = {
			if = {
				limit = { 
					tag = EGY 
					has_government_mechanic = egyptian_westernization
				}
				has_government_power = {
					mechanic_type = egyptian_westernization
					power_type = egyptian_westernization
					value = 90
				}
				has_better_tech_than_westerns = yes
				has_more_institutions_than_westerns = yes
				OR = {
					num_accepted_cultures = 8
					full_idea_group = innovativeness_ideas
				}
			}
			else = {
				custom_trigger_tooltip = {
					tooltip = has_unified_all_culture_fr_fr_tt
					NOT = {
						any_province = {
							culture_group = turko_semitic
							NOT = {
								OR = {
									owned_by = ROOT
									OR = {
										owner = {
											is_subject_of = ROOT
											OR = {
												is_subject_of_type = colony
												is_subject_of_type = crown_colony
												is_subject_of_type = private_enterprise
												is_subject_of_type = self_governing_colony
											}
										}
										owner = {
											OR = {
												is_subject_of_type = colony
												is_subject_of_type = crown_colony
												is_subject_of_type = private_enterprise
												is_subject_of_type = self_governing_colony
											}
											overlord = {
												is_subject_of = ROOT
											}
										}
									}
								}
							}
						}
					}
				}
				if = {
					limit = { has_dlc = "Mandate of Heaven" }
					OR = {
						in_golden_age = yes  
						has_had_golden_age = yes
					} 
				}
				else = { stability = 3 }
			}
		}
		effect = {
			if = {
				limit = { 
					tag = EGY 
					has_dlc = "Rights of Man"
				}
				custom_tooltip = egy_better_traits_rulers_tt
				set_country_flag = egypt_better_traits_flag
				if = {
					limit = { has_dlc = "Rule Britannia" }
					change_innovativeness = 5
				}
				else = { add_adm_power = 100 add_dip_power = 100 }
			}
			else_if = { 
				limit = { has_dlc = "Mandate of Heaven" }
				custom_tooltip = pol_if_used_ge_rest_else_30_years_extension_tt 
				if = {
					limit = { has_had_golden_age = yes } 
					reset_golden_age = yes 
				}
				else_if = {
					limit = { in_golden_age = yes } 
					extend_golden_age = 600
				}
			}
			else = {
				change_ruler_stat = {
					type = adm
					amount = 2
				}
				add_prestige_or_monarch_power = { amount = 25 }
			}
		}
	}
}

mam_missions_5 = {
	slot = 5
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "King of Kings"
	}
	potential = {
		OR = {
			tag = EGY
			tag = MAM
		}
		has_dlc = "King of Kings"
		NOT = { map_setup = map_setup_random }
	}
	has_country_shield = yes
	
	kok_mam_subjugate_beyliks = {
		icon = mission_non-western_soldiers
		required_missions = { mam_reincorporate_northern_territories }
		position = 2
		provinces_to_highlight = {
			OR = {
				area = aleppo_area
				area = karaman_area
				area = dulkadir_area
				province_id = 327
				province_id = 2302
			}
			NOT = {
				country_or_non_sovereign_subject_holds = ROOT
			}
		}
		trigger = {
			aleppo_area = {
				type = all
				country_or_non_sovereign_subject_holds = ROOT
			}
			327 = {
				country_or_non_sovereign_subject_holds = ROOT
			}
			2302 = {
				country_or_non_sovereign_subject_holds = ROOT
			}
			karaman_area = {
				type = all
				country_or_non_sovereign_subject_holds = ROOT
			}
			dulkadir_area = {
				type = all
				country_or_non_sovereign_subject_holds = ROOT
			}
		}
		effect = {
			if = {
				limit = {
					has_government_mechanic = mamluk_mechanic
					has_dlc = "Cradle of Civilization"
				}
				custom_tooltip = mam_boost_recruit_from_culture_lands_tt
				set_country_flag = mam_boost_recruit_from_culture_lands_flag
			}
			else = {
				add_country_modifier = {
					name = "beyliks_subjugated"
					duration = 7300
				}
			}
			
			erzurum_area = {
				limit = {
					NOT = { is_permanent_claim = ROOT }
					NOT = { is_core = ROOT	}
				}
				add_permanent_claim = ROOT
			}
			armenia_area = {
				limit = {
					NOT = { is_permanent_claim = ROOT }
					NOT = { is_core = ROOT	}
				}
				add_permanent_claim = ROOT
			}
			change_ruler_stat = {
				type = adm
				amount = 1
			}
		}
	}

	mam_tunis = {
		icon = mission_conquer_tunisia
		required_missions = {  }
		position = 4
		provinces_to_highlight = {
			OR = {
				area = djerba_area
				area = tripolitania_area
				area = tunisia_area
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				OR = {
					area = djerba_area
					area = tripolitania_area
					area = tunisia_area
				}
				value = 6
			}
			341 = { country_or_non_sovereign_subject_holds = ROOT }
			4566 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			maghreb_region = {
				limit = {
					NOT = { is_permanent_claim = ROOT }
					NOT = { is_core = ROOT	}
				}
				add_permanent_claim = ROOT
			}
			if = {
				limit = { 
					has_dlc = "Leviathan"
				}
				4566 = {
					add_great_project_tier = {
						type = holy_city_kairouan 
						tier = 1 
					}
				}
			}
			else = {
				341 = {
					add_local_autonomy = -25
					add_nationalism = -10 
					add_base_production = 2 
					add_base_manpower = 2 
				}
			}
		}
	}

	mam_morocco = {
		icon = mission_new_world_power
		required_missions = { mam_tunis }
		position = 6
		provinces_to_highlight = {
			OR = {
				area = marrekesh_area
				area = western_morocco_area
				area = northern_morocco_area
				area = southern_morocco_area
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				OR = {
					area = marrekesh_area
					area = western_morocco_area
					area = northern_morocco_area
					area = southern_morocco_area
				}
				value = 12 
			}
			343 = { country_or_non_sovereign_subject_holds = ROOT }

		}
		effect = {
			country_event = { id = flavor_mam.113 }
			custom_tooltip = flavor_mam.113_tt
		}
	}

	mam_city_thousand_minarets = {
		icon = mam_city_thousand_minarets
		required_missions = {  }
		position = 8
		provinces_to_highlight = {
			province_id = 361 
		}
		trigger = {
			361 = { 
				owned_by = ROOT 
				OR = {
					num_of_times_improved = 8
					num_of_buildings_in_province = 3
				}
			}
		}
		effect = {
			if = {
				limit = {
					361 = {
						has_province_modifier = public_works_of_cairo 
					}
				}
				361 = { add_center_of_trade_level = 1 }
			}
			else = {
				country_event = { id = flavor_mam.2 }
				custom_tooltip = flavor_mam.2_tt 
			}
		}
	}

	mam_khass_al_sultan = {
		icon = mission_mal_riches_of_trade
		required_missions = { mam_city_thousand_minarets }
		position = 10
		provinces_to_highlight = {
			OR = {
				province_id = 362
				province_id = 363
				province_id = 2316
				province_id = 4316
			}
			OR = {
				has_production_building_trigger = no 
				NOT = { owned_by = ROOT }
			}
		}
		trigger = {
			OR = {
				crown_land_share = 40 
				has_reform = diwan_al_khass_reform
			}
			362 = {
				owned_by = ROOT 
				has_production_building_trigger = yes 
			}
			363 = {
				owned_by = ROOT 
				has_production_building_trigger = yes 
			}
			2316 = {
				owned_by = ROOT 
				has_production_building_trigger = yes 
			}
			4316 = {
				owned_by = ROOT 
				has_production_building_trigger = yes 
			}
		}
		effect = {
			custom_tooltip = add_5_crown_land_share
			hidden_effect = {
				change_estate_land_share = {
				estate = all
				share = -5
				}
			}
			custom_tooltip = enable_export_grain_dip_action_tt
			set_country_flag = enable_export_grain_dip_action_flag 
		}
	}

	mam_assign_waqf = {
		icon = mission_hands_praying
		required_missions = { mam_khass_al_sultan }
		position = 11
		trigger = {
			years_of_income = 2
			stability = 2
			OR = {
				full_idea_group = humanist_ideas 
				full_idea_group = religious_ideas
				has_estate_privilege = estate_church_sponsor_waqf_payments
			}
		}
		effect = {
			country_event = { id = flavor_mam.104 }
			custom_tooltip = flavor_mam.104_tt
		}
	}
}