WoC_maya_generic_1 = {
	slot = 1
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_highlander_resistance = {
		icon = mission_ne_palisades
		required_missions = { MAY_collapse_of_mayapan }
		position = 2 
		provinces_to_highlight = {
			OR = {
				area = guatemala_area
				province_id = 2637
				province_id = 2638
			}
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				OR = {
					area = guatemala_area
					province_id = 2637
					province_id = 2638
				}
				value = 4
			}
		}
		effect = {
			add_country_modifier = {
				name = MAY_resistance
				duration = 9125
			}
			
			add_yearly_manpower = 1
			
			add_army_tradition_or_mil_power = { amount = 10 }
		}
	}
}

WoC_maya_generic_2 = {
	slot = 2
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_collapse_of_mayapan = {
		icon = mission_mayapan
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			OR = {
				num_of_cities = 4
				is_at_war = yes
			}
			army_size_percentage = 0.9
		}
		effect = {
			give_claims = { region = central_america_region }
			give_claims = { id = 2631 }
			give_claims = { id = 2630 }
			
			custom_tooltip = " "
			
			country_event_with_option_insight = {
				id = flavor_may.8
				option_1 = "
					add_yearly_manpower = 1
		
					custom_tooltip = \" \"
					
					add_country_modifier = {
						name = MAY_to_war
						duration = 5475
					}
				"
				option_2 = "
					add_years_of_income = 1
		
					custom_tooltip = \" \"
					
					add_stability_or_adm_power = yes
				"
				option_3 = "
					capital_scope = {
						add_base_manpower = 2
					}
					
					custom_tooltip = \" \"
					
					add_country_modifier = {
						name = MAY_building_up_the_city
						duration = 7300
					}
				"
			}
		}
	}
	
	MAY_ancient_ruins = {
		icon = mission_tikal
		required_missions = { MAY_collapse_of_mayapan }
		position = 2 
		provinces_to_highlight = {
			OR = {
				area = guatemala_lowlands_area
				province_id = 4588 
				province_id = 2635
				province_id = 4585
				province_id = 4586
			}
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				OR = {
					area = guatemala_lowlands_area
					province_id = 4588 
					province_id = 2635
					province_id = 4585
					province_id = 4586
				}
				value = 7
			}
		}
		effect = {
			add_country_modifier = {
				name = MAY_visiting_ancient_temples
				duration = 7300 
			}
			
			add_mil_power = 100
			
			create_general_with_pips = {
				tradition = 40
				add_manuever = 2
			}
		}
	}
	
	MAY_reform_the_league = {
		icon = native_royal_marriage
		required_missions = { MAY_highlander_resistance MAY_ancient_ruins MAY_yucatan_renaissance }
		position = 3
		provinces_to_highlight = {
		}
		trigger = {
			tag = MAY
		}
		effect = {
			give_claims = { area = mixteca_area }
			give_claims = { area = oaxaca_area }
			give_claims = { area = eastern_mexico_area }
			give_claims = { area = huasteca_area }
			
			custom_tooltip = " "
			
			set_country_flag = MAY_may_annex_tributaries_with_no_penalty_flag
			custom_tooltip = MAY_may_annex_tributaries_with_no_penalty
			
			if = {
				limit = {
					has_estate = estate_nobles
				}
				custom_tooltip = " "
			
				complex_dynamic_effect = {
					first_custom_tooltip = MAY_if_we_have_primacy
					first_limit = "
						has_estate_privilege = estate_nobles_nobility_primacy
					"
					first_effect = "
						change_estate_land_share = {
							estate = estate_nobles
							share = -10
						}
					"
				}
			}
		}
	}
	
	MAY_zapotec_and_mixtec = {
		icon = mission_mayan_conquest
		required_missions = { MAY_reform_the_league }
		position = 4
		provinces_to_highlight = {
			OR = {
				area = oaxaca_area
				area = mixteca_area
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			oaxaca_area = {
				type = all 
				country_or_non_sovereign_subject_holds = ROOT
			}
			mixteca_area = {
				type = all
				country_or_non_sovereign_subject_holds = ROOT
			}
		}
		effect = {
			add_country_modifier = {
				name = MAY_conquest_of_mesoamerica_1
				duration = -1
			}
			
			add_country_modifier = {
				name = MAY_zapotec_and_mixtec_modifier
				duration = -1
			}
			
			# add_years_of_owned_provinces_production_income = {
				# years = 10
				# trigger = {
					# trade_goods = gold #not much gold in Mixtec area
				# }
				# custom_tooltip = MAY_prod_from_gold
			# }
			add_years_of_income = 0.5
		}
	}
}

WoC_maya_generic_reform_1 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		NOT = { num_of_maya_religious_reforms = { amount = 1 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes

	MAY_venus_1 = {
		icon = mission_venus
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_venus_trigger = yes
		}
		effect = {
			MAY_venus_effect = yes
		}
	}
}

WoC_maya_generic_reform_2 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		num_of_maya_religious_reforms = { amount = 1 }
		NOT = { num_of_maya_religious_reforms = { amount = 2 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_venus_2 = {
		icon = mission_venus
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_venus_trigger = yes
		}
		effect = {
			MAY_venus_effect = yes
		}
	}
}

WoC_maya_generic_reform_3 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		num_of_maya_religious_reforms = { amount = 2 }
		NOT = { num_of_maya_religious_reforms = { amount = 3 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_venus_3 = {
		icon = mission_venus
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_venus_trigger = yes
		}
		effect = {
			MAY_venus_effect = yes
		}
	}
}

WoC_maya_generic_reform_4 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		num_of_maya_religious_reforms = { amount = 3 }
		NOT = { num_of_maya_religious_reforms = { amount = 4 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_venus_4 = {
		icon = mission_venus
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_venus_trigger = yes
		}
		effect = {
			MAY_venus_effect = yes
		}
	}
}

WoC_maya_generic_reform_5 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		num_of_maya_religious_reforms = { amount = 4 }
		NOT = { num_of_maya_religious_reforms = { amount = 5 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_venus_5 = {
		icon = mission_venus
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_venus_trigger = yes
		}
		effect = {
			MAY_venus_effect = yes
		}
	}
}

WoC_maya_generic_3 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_yucatan_renaissance = {
		icon = mission_ne_birch_bark_canoes
		required_missions = { MAY_collapse_of_mayapan }
		position = 2 
		provinces_to_highlight = {
			OR = {
				area = yucatan_area
				area = east_yucatan_area
				area = campeche_area
			}
			NOT = { province_id = 4588 }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				OR = {
					area = yucatan_area
					area = east_yucatan_area
					area = campeche_area
				}
				NOT = { province_id = 4588 }
				value = 8
			}
		}
		effect = {
			add_country_modifier = {
				name = MAY_ashes_of_mayapan
				duration = 10950
			}
			
			1551 = {
				add_trade_modifier = {
					who = ROOT
					duration = 9125
					power = 15
					key = MAY_coastal_networks
				}
			}
		}
	}
	
	MAY_wastek = {
		icon = mission_nah_ravine_dwellers
		required_missions = { MAY_reform_the_league }
		position = 4
		provinces_to_highlight = {
			OR = {
				province_id = 858
				province_id = 2641
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			858 = {
				country_or_non_sovereign_subject_holds = ROOT
			}
			2641 = {
				country_or_non_sovereign_subject_holds = ROOT 
			}
		}
		effect = {
			858 = {
				add_nationalism = -20
				add_local_autonomy = -25
			}
			2641 = {
				add_nationalism = -20
				add_local_autonomy = -25
			}
			
			custom_tooltip = " "
			
			add_country_modifier = {
				name = MAY_unifying_maya_people
				duration = -1
			}
		}
	}
}

WoC_maya_generic_reform_2_1 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		NOT = { num_of_maya_religious_reforms = { amount = 1 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes

	MAY_realm_size_1 = {
		icon = mission_mesoamerican_soldiers_training
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_realm_size_trigger = yes
		}
		effect = {
			MAY_realm_size_effect = yes
		}
	}
	
	MAY_pass_reform_1 = {
		icon = mission_blood_sacrifices
		required_missions = { MAY_venus_1 MAY_realm_size_1 }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_pass_reform_trigger = { amount = 1 }
		}
		effect = {
			MAY_pass_reform_effect = { amount = 1 }
		}
	}
}

WoC_maya_generic_reform_2_2 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		num_of_maya_religious_reforms = { amount = 1 }
		NOT = { num_of_maya_religious_reforms = { amount = 2 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_realm_size_2 = {
		icon = mission_mesoamerican_soldiers_training
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_realm_size_trigger = yes
		}
		effect = {
			MAY_realm_size_effect = yes
		}
	}
	
	MAY_pass_reform_2 = {
		icon = mission_blood_sacrifices
		required_missions = { MAY_venus_2 MAY_realm_size_2 }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_pass_reform_trigger = { amount = 2 }
		}
		effect = {
			MAY_pass_reform_effect = { amount = 2 }
		}
	}
}

WoC_maya_generic_reform_2_3 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		num_of_maya_religious_reforms = { amount = 2 }
		NOT = { num_of_maya_religious_reforms = { amount = 3 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_realm_size_3 = {
		icon = mission_mesoamerican_soldiers_training
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_realm_size_trigger = yes
		}
		effect = {
			MAY_realm_size_effect = yes
		}
	}
	
	MAY_pass_reform_3 = {
		icon = mission_blood_sacrifices
		required_missions = { MAY_venus_3 MAY_realm_size_3 }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_pass_reform_trigger = { amount = 3 }
		}
		effect = {
			MAY_pass_reform_effect = { amount = 3 }
		}
	}
}

WoC_maya_generic_reform_2_4 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		num_of_maya_religious_reforms = { amount = 3 }
		NOT = { num_of_maya_religious_reforms = { amount = 4 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_realm_size_4 = {
		icon = mission_mesoamerican_soldiers_training
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_realm_size_trigger = yes
		}
		effect = {
			MAY_realm_size_effect = yes
		}
	}
	
	MAY_pass_reform_4 = {
		icon = mission_blood_sacrifices
		required_missions = { MAY_venus_4 MAY_realm_size_4 }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_pass_reform_trigger = { amount = 4 }
		}
		effect = {
			MAY_pass_reform_effect = { amount = 4 }
		}
	}
}

WoC_maya_generic_reform_2_5 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		num_of_maya_religious_reforms = { amount = 4 }
		NOT = { num_of_maya_religious_reforms = { amount = 5 } }
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_realm_size_5 = {
		icon = mission_mesoamerican_soldiers_training
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_realm_size_trigger = yes
		}
		effect = {
			MAY_realm_size_effect = yes
		}
	}
	
	MAY_pass_reform_5 = {
		icon = mission_blood_sacrifices
		required_missions = { MAY_venus_5 MAY_realm_size_5 }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			MAY_pass_reform_trigger = { amount = 5 }
		}
		effect = {
			MAY_pass_reform_effect = { amount = 5 }
		}
	}
}

WoC_maya_generic_4 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_obsidian_weapons = {
		icon = mission_obsidian_blades
		required_missions = { }
		position = 3
		provinces_to_highlight = {
			has_province_modifier = MAY_active_obsidian_source
		}
		trigger = {
			army_tradition = 30
			num_of_battles = {
				amount = 25
			}
			has_obsidian_source_trigger = yes
		}
		effect = {
			add_country_modifier = {
				name = MAY_supply_of_obsidian_weapons
				duration = 10950
			}
			
			capital_scope = { 
				add_base_manpower = 2
			}
			
			if = {
				limit = {
					has_estate = estate_nobles
				}
				custom_tooltip = " "
			
				custom_tooltip = MAY_upgrade_obsidian_privilege
			}
			else = { 
				add_mil_power = 100
			}
			set_country_flag = MAY_upgrade_obsidian_privilege_flag
		}
	}
	
	MAY_reform_religion = {
		icon = mission_aztec_city_alliance
		required_missions = { MAY_hegemonic_ambitions MAY_obsidian_weapons }
		position = 4
		provinces_to_highlight = {
		}
		trigger = {
			num_of_maya_religious_reforms = { amount = 5 }
		}
		effect = {
			add_country_modifier_for_age = {
				age = age_of_discovery
				name = MAY_religion_reformed
				else = "
					change_government_reform_progress = 50
					custom_tooltip = \" \"
				"
			}
			
			if = {
				limit = {
					uses_legitimacy = yes
				}
				custom_tooltip = MAY_for_every_5_legitimacy
				hidden_effect = {
					if = {
						limit = {
							legitimacy = 100 
						}
						add_adm_power = 100
					}
					else_if = {
						limit = {
							legitimacy = 95 
						}
						add_adm_power = 95
					}
					else_if = {
						limit = {
							legitimacy = 90
						}
						add_adm_power = 90
					}
					else_if = {
						limit = {
							legitimacy = 85 
						}
						add_adm_power = 85
					}
					else_if = {
						limit = {
							legitimacy = 80
						}
						add_adm_power = 80
					}
					else_if = {
						limit = {
							legitimacy = 75 
						}
						add_adm_power = 75
					}
					else_if = {
						limit = {
							legitimacy = 70
						}
						add_adm_power = 70
					}
					else_if = {
						limit = {
							legitimacy = 65 
						}
						add_adm_power = 65
					}
					else_if = {
						limit = {
							legitimacy = 60 
						}
						add_adm_power = 60
					}
					else_if = {
						limit = {
							legitimacy = 55 
						}
						add_adm_power = 55
					}
					else_if = {
						limit = {
							legitimacy = 50
						}
						add_adm_power = 50
					}
					else_if = {
						limit = {
							legitimacy = 45 
						}
						add_adm_power = 45
					}
					else_if = {
						limit = {
							legitimacy = 40
						}
						add_adm_power = 40
					}
					else_if = {
						limit = {
							legitimacy = 35 
						}
						add_adm_power = 35
					}
					else_if = {
						limit = {
							legitimacy = 30
						}
						add_adm_power = 30
					}
					else_if = {
						limit = {
							legitimacy = 25 
						}
						add_adm_power = 25
					}
					else_if = {
						limit = {
							legitimacy = 20 
						}
						add_adm_power = 20
					}
					else_if = {
						limit = {
							legitimacy = 15 
						}
						add_adm_power = 15
					}
					else_if = {
						limit = {
							legitimacy = 10
						}
						add_adm_power = 10
					}
					else_if = {
						limit = {
							legitimacy = 5
						}
						add_adm_power = 5
					}
					else = { }
				}
			}
			
			if = {
				limit = {
					has_estate = estate_church
				}
				custom_tooltip = " "
			
				complex_dynamic_effect = {
					first_custom_tooltip = MAY_if_we_have_religious_state
					first_limit = "
						has_estate_privilege = estate_church_religious_state
					"
					first_effect = "
						change_estate_land_share = {
							estate = estate_church
							share = -10
						}
					"
				}
			}
		}
	}
}

WoC_maya_generic_5 = {
	slot = 5
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		has_generic_maya_missions = yes
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_intercity_politics = {
		icon = mission_aztecs_flower_wars
		required_missions = { }
		position = 1
		provinces_to_highlight = {
		}
		trigger = {
			OR = {
				num_of_subjects = 1
				calc_true_if = {
					all_ally = {
						has_opinion = {
							who = ROOT 
							value = 100
						}
					}
					amount = 2
				}
			}
		}
		effect = {
			complex_dynamic_effect = {
				first_custom_tooltip = MAY_if_done_via_subjects
				first_limit = "
					num_of_subjects = 1
				"
				first_effect = "
					add_country_modifier = {
						name = MAY_building_up_hegemon_network
						duration = 10950
					}
					custom_tooltip = MAY_gain_5_power_project_for_each_subjects
					hidden_effect = {
						if = {
							limit = { num_of_subjects = 4 }
							add_power_projection_mission = { amount = 20 }
						}
						else = {
							every_subject_country = {
								ROOT = { add_power_projection_mission = { amount = 5 } }
							}
						}
					}
				"
				second_custom_tooltip = MAY_if_done_via_alliances
				second_limit = "
					calc_true_if = {
						all_ally = {
							has_opinion = {
								who = ROOT 
								value = 100
							}
						}
						amount = 2
					}
				"
                second_effect = "
                    add_country_modifier = {
                        name = MAY_marriage_and_intimidation
                        duration = 9125
                    }
                    if = {
                        limit = { has_dlc = \"The Cossacks\" }
                        custom_tooltip = MAY_gain_10_favors_with_each_ally
                        hidden_effect = { every_ally = { ROOT = { add_favors = { who = PREV amount = 10 } } } }
                    }
                " 
			}
		}
	}
	
	MAY_batob = {
		icon = mission_mayan_warriors
		required_missions = { MAY_intercity_politics }
		position = 2
		provinces_to_highlight = {
			OR = {
				is_claim = ROOT
				is_permanent_claim = ROOT
				is_core = ROOT
			}
			NOT = { owned_by = ROOT }
		}
		trigger = {
			grown_by_development = 30
		}
		effect = {
			add_country_modifier = {
				name = MAY_expansion_of_the_realm
				duration = 7300
			}
			
			define_advisor = {
				type = treasurer
				skill = 1
				culture = ROOT
				religion = ROOT
				cost_multiplier = 0.4
			}
			
			custom_tooltip = " "
			
			custom_tooltip = MAY_for_every_point_of_stability
			hidden_effect = {
				if = {
					limit = {
						stability = 3
					}
					every_owned_province = {
						add_local_autonomy = -30
					}
				}
				else_if = {
					limit = {
						stability = 2
					}
					every_owned_province = {
						add_local_autonomy = -20
					}
				}
				else_if = {
					limit = {
						stability = 1
					}
					every_owned_province = {
						add_local_autonomy = -10
					}
				}
				else = { }
			}
		}
	}
	
	MAY_hegemonic_ambitions = {
		icon = mission_mesoamerican_tributes
		required_missions = { MAY_batob }
		position = 3
		provinces_to_highlight = {
		}
		trigger = {
			OR = {
				num_of_cities = 10
				num_of_subjects = 2
			}
			num_of_maya_religious_reforms = { amount = 3 }
		}
		effect = {
			if = {
				limit = {
					has_estate = estate_nobles
				}
				custom_tooltip = MAY_unlock_privilege_for_tributaries
				custom_tooltip = " "
			}
			set_country_flag = MAY_unlock_privilege_for_tributaries_flag
			
			# set_country_flag = MAY_chontals_merc_company_flag
			custom_tooltip = MAY_chontals_merc_company
		}
	}
}

WoC_maya_1 = {
	slot = 1
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		tag = MAY
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_defeat_tenochtitlan = {
		icon = mission_eagle_knight
		required_missions = { MAY_zapotec_and_mixtec }
		position = 5
		provinces_to_highlight = {
			OR = {
				area = mexico_area
				area = puebla_area
			}
			NOT = { country_or_non_sovereign_subject_holds = ROOT }
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				OR = {
					area = mexico_area
					area = puebla_area
				}
				value = 6
			}
			852 = { country_or_non_sovereign_subject_holds = ROOT }
		}
		effect = {
			custom_tooltip = MAY_conquest_of_mesoamerica_1_2
			hidden_effect = {
				add_country_modifier = {
					name = MAY_conquest_of_mesoamerica_2
					duration = -1
				}
				remove_country_modifier = MAY_conquest_of_mesoamerica_1
			}
			
			custom_tooltip = " "
			
			add_permanent_power_projection = {
				type = MAY_defeat_of_tenochtitlan
				amount = 5
			}
			
			custom_tooltip = " "
			
			add_years_of_owned_provinces_production_income = {
				years = 10
				trigger = {
					trade_goods = gold
				}
				custom_tooltip = MAY_prod_from_gold
			}
		}
	}
}

WoC_maya_2 = {
	slot = 2
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		tag = MAY
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_unite_mesoamerica = {
		icon = mission_mesoamerica
		required_missions = { MAY_zapotec_and_mixtec MAY_defeat_tenochtitlan }
		position = 6
		provinces_to_highlight = {
			is_in_mesoamerica_trigger = yes
		}
		trigger = {
			num_of_provinces_owned_or_owned_by_non_sovereign_subjects_with = {
				is_in_mesoamerica_trigger = yes
				value = 60
			}
		}
		effect = {
			custom_tooltip = MAY_conquest_of_mesoamerica_2_3
			hidden_effect = {
				add_country_modifier = {
					name = MAY_conquest_of_mesoamerica_3
					duration = -1
				}
				remove_country_modifier = MAY_conquest_of_mesoamerica_2
			}
			
			custom_tooltip = " "
			
			# replace with frontiers if possible
			add_country_modifier = {
				name = MAY_american_frontiers
				duration = -1
			}
			# set_country_flag = MAY_american_frontiers
			# custom_tooltip = MAY_establish_once_every_5_years
			
			custom_tooltip = " "
			
			add_power_projection_mission = { amount = 30 }
		}
	}
}

WoC_maya_3 = {
	slot = 3
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		tag = MAY
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_appease_gods = {
		icon = mission_hands_praying
		required_missions = { MAY_reform_religion }
		position = 5
		provinces_to_highlight = {
		}
		trigger = {
			OR = {
				theologian = 1
				inquisitor = 1
				has_adm_advisor_3 = yes
			}
			
			monthly_adm = 10
			custom_trigger_tooltip = {
				tooltip = MAY_has_5_tolerance_own
				has_global_modifier_value = {
					which = tolerance_own
					value = 5
				}
			}
			stability = 2
			
			if = {
				limit = {
					has_estate = estate_church
				}
				estate_loyalty = {
					estate = estate_church
					loyalty = 60
				}
			}
		}
		effect = {
			if = {
				limit = {
					has_estate = estate_church
				}
				custom_tooltip = MAY_upgrade_institutionalized_clergy_privilege
				custom_tooltip = " "
			}
			set_country_flag = MAY_upgrade_institutionalized_clergy_privilege_flag
			
			add_country_modifier = {
				name = MAY_priest_influence
				duration = -1
			}
			
			add_stability_or_adm_power = yes
		}
	}
	
	MAY_divine_kingship = {
		icon = mission_mesoamerican_divine_monarch
		required_missions = { MAY_appease_gods }
		position = 7
		provinces_to_highlight = {
			is_capital_of = ROOT
			NOT = { has_courthouse_building_trigger = yes }
		}
		trigger = {
			reform_level = 4
			num_of_owned_provinces_with = {
				has_tax_building_trigger = yes
				value = 10
			}
			capital_scope = {
				has_courthouse_building_trigger = yes
			}
			stability = 3
			is_ahead_of_time_in_technology = { tech = adm }
		}
		effect = {
			capital_scope = {
				add_or_upgrade_courthouse_building = yes
			}
			
			custom_tooltip = " "
			
			country_event_with_option_insight = {
				id = flavor_may.10
				option_1 = "
					custom_tooltip = MAY_we_will_become_monarchy_maya_confederation
				"
				option_2 = "
					custom_tooltip = MAY_we_will_become_monarchy_divine_kingship
				"
				option_3 = "
					custom_tooltip = MAY_we_will_become_oligarchy_republic
				"
				option_4 = "
					custom_tooltip = MAY_we_will_become_leading_clergy_theocracy 
				"
				option_5 = "
					change_government_reform_progress = 250
					
					custom_tooltip = \" \"
					
					add_stability_or_adm_power = yes
				"
			}
		}
	}
	
	MAY_chontal_maya = {
		icon = mission_mayan_canoes
		required_missions = { MAY_trading_society }
		position = 8
		provinces_to_highlight = {
		}
		trigger = {
			num_of_ports = 10
			OR = {
				navy_size = 20 # modified
				navy_size_percentage = 0.9
			}
		}
		effect = {
			set_country_flag = MAY_chontal_maya_priv_flag
			if = {
				limit = {
					has_estate = estate_burghers
				}
				custom_tooltip = MAY_chontal_maya_priv
			
				custom_tooltip = " "
			}
			
			add_years_of_trade_income = {
				years = 2
				custom_tooltip = BYZ_add_2_years_of_trade_income
			}
		}
	}
	
	MAY_maize = {
		icon = mission_maize
		required_missions = { MAY_trade_guilds }
		position = 9
		provinces_to_highlight = {
			owned_by = ROOT
			trade_goods = grain
			NOT = { 
				OR = {
					has_production_building_trigger = yes
					development = 15
				}
			}
		}
		trigger = {
			custom_trigger_tooltip = {
				tooltip = developed_provinces_at_least_30_times
				check_variable = {
					which = num_of_times_developed
					value = 30
				}
			}
			any_owned_province = {
				trade_goods = grain
				OR = {
					has_production_building_trigger = yes
					development = 15
				}
			}
		}
		effect = {
			add_country_modifier = {
				name = MAY_man_is_out_of_maize
				duration = -1
			}
			
			custom_tooltip = MAY_distribute_10_manpower
			hidden_effect = {
				for = {
					amount = 10
					effect = "
						random_owned_province = {
							add_base_manpower = 1
						}
					"
				}
			}
			
			custom_tooltip = " "
			
			add_mil_power = 75
		}
	}
}

WoC_maya_4 = {
	slot = 4
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		tag = MAY
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_plaster_temples = {
		icon = mission_tenochtitlan
		required_missions = { MAY_restore_lowland_ruins MAY_appease_gods }
		position = 6
		provinces_to_highlight = {
			OR = {
				AND = {
					has_dlc = "Leviathan"
					OR = {
						AND = {
							province_id = 842
							NOT = {
								has_great_project = {
									type = tikal
									tier = 2
								}
							}
						}
						AND = {
							province_id = 846
							NOT = {
								has_great_project = {
									type = chichen_itza
									tier = 2
								}
							}
						}
						AND = {
							OR = {
								province_id = 846
								province_id = 842
							}
							NOT = {
								OR = {
									846 = {
										has_great_project = {
											type = chichen_itza
											tier = 3
										}
									}
									842 = {
										has_great_project = {
											type = tikal
											tier = 3
										}
									}
								}
							}
						}
					}
				}
				AND = {
					NOT = { has_dlc = "Leviathan" }
					owned_by = ROOT
					religion = ROOT
				}
			}
		}
		trigger = {
			if = {
				limit = {
					has_dlc = "Leviathan"
				}
				842 = { #Tikal in Peten
					owned_by = ROOT
					has_great_project = {
						type = tikal
						tier = 2
					}
				}
				846 = { #Chichen Itza in Sotuta
					owned_by = ROOT
					has_great_project = {
						type = chichen_itza
						tier = 2
					}
				}
				OR = {
					846 = {
						has_great_project = {
							type = chichen_itza
							tier = 3
						}
					}
					842 = {
						has_great_project = {
							type = tikal
							tier = 3
						}
					}
				}
			}
			else = {
				num_of_owned_provinces_with = {
					religion = ROOT
					development = 30
					value = 3
				}
			}
		}
		effect = {
			if = {
				limit = {
					has_dlc = "Leviathan"
				}
				add_country_modifier = {
					name = MAY_plastering_temples_dlc
					duration = -1
				}
				
				if = {
					limit = {
						has_dlc = "Mandate of Heaven"
					}
					custom_tooltip = MAY_upgrading_monuments_to_level_3_gives_splendor
					set_country_flag = MAY_upgrading_monuments_to_level_3_gives_splendor_flag
				
					custom_tooltip = " "
				}
				else = {
					add_stability_or_adm_power = yes
					custom_tooltip = " "
				}
			}
			else = {
				add_country_modifier = {
					name = MAY_plastering_temples_no_dlc
					duration = -1
				}
			}
			
			add_prestige_or_monarch_power = { amount = 40 }
		}
	}
	
	MAY_trading_society = {
		icon = mission_macehualtin
		required_missions = { }
		position = 7
		provinces_to_highlight = {
		}
		trigger = {
			share_of_starting_income = 3
			if = {
				limit = {
					trade_income_percentage = 0.01
				}
				monthly_trade_income = 5
			}
			
			OR = {
				trader = 1
				has_dip_advisor_2 = yes
			}
		}
		effect = {
			add_country_modifier_for_age = {
				name = MAY_mayan_canoes
				age = age_of_discovery
				else = "
					add_navy_tradition = 20
					
					custom_tooltip = \" \"
				"
			}
			
			home_trade_node_effect_scope = {
				add_trade_modifier = {
					who = ROOT
					duration = 5475
					power = 25
					key = MAY_trade
				}
			}
			
			custom_tooltip = " "
			
			add_dip_power = 100 
		}
	}
	
	MAY_trade_guilds = {
		icon = mission_ppolom
		required_missions = { MAY_trading_society }
		position = 8
		provinces_to_highlight = {
		}
		trigger = {
			num_of_owned_provinces_with = {
				has_production_building_trigger = yes
				value = 5
			}
			if = {
				limit = {
					production_income_percentage = 0.01 #to prevent crashes
				}
				custom_trigger_tooltip = {
					tooltip = BYZ_at_least_10_production_income
					variable_arithmetic_trigger = {
						export_to_variable = {
							which = current_production_income
							value = monthly_income
						}
						export_to_variable = {
							which = production_income_share
							value = trigger_value:production_income_percentage
						}
						multiply_variable = { which = current_production_income which = production_income_share }
						check_variable = { which = current_production_income value = 10 }
					}
				}
			}
			num_of_owned_provinces_with = {
				has_manufactory_trigger = yes
				value = 2
			}
		}
		effect = {
			if = {
				limit = {
					has_estate = estate_burghers
				}
				complex_dynamic_effect = {
					first_custom_tooltip = MAY_if_we_have_land_of_commerce
					first_limit = "
						has_estate_privilege = estate_burghers_land_of_commerce
					"
					first_effect = "
						change_estate_land_share = {
							estate = estate_burghers
							share = -10
						}
					"
				}
				custom_tooltip = " "
			}
			
			country_event_with_option_insight = {
				id = flavor_may.11
				option_1 = "
					if = {
						limit = {
							has_dlc = \"Cradle of Civilization\"
						}
						custom_tooltip = MAY_unlock_upgraded_establish_communities
						set_country_flag = enabled_trading_policy_establish_communities_upgraded
						custom_tooltip = \" \"
					}
					else = {
						add_country_modifier = {
							name = MAY_communities
							duration = -1
						}
					}
					
					add_country_modifier = {
						name = MAY_merchant_travels
						duration = -1
					}
				"
				option_2 = "
					custom_tooltip = MAY_every_province_with_a_manufactory
					add_province_modifier = {
						name = MAY_manufactory_buff
						duration = 10950
					}
					
					add_country_modifier = {
						name = MAY_production_efficiency
						duration = -1
					}
				"
			}
		}
	}
	
	MAY_environment = {
		icon = mission_jungle
		required_missions = { MAY_trade_guilds MAY_maize }
		position = 10
		provinces_to_highlight = {
			owned_by = ROOT
			has_terrain = jungle
		}
		trigger = {
			custom_trigger_tooltip = {
				tooltip = MAY_has_developed_jungle_provinces
				check_variable = {
					which = num_of_times_developed_jungles
					value = 40
				}
			}
			OR = {
				reform_level = 5 
				monthly_adm = 9
			}
		}
		effect = {
			if = {
				limit = {
					has_estate = estate_burghers
				}
				custom_tooltip = MAY_upgrade_privilege
				set_country_flag = MAY_upgraded_privilege
				hidden_effect = {
					if = {
						limit = {
							has_estate_privilege = estate_burghers_MAY_tropical_adaptation
						}
						every_owned_province = {
							limit = {
								has_province_modifier = MAY_jungle_reduction
							}
							remove_province_modifier = MAY_jungle_reduction
							add_province_modifier = {
								name = MAY_jungle_reduction_upgrade
								duration = -1
							}
						}
					}
				}
				
				custom_tooltip = " "
			}
			
			if = {
				limit = {
					has_dlc = "Mandate of Heaven"
				}
				custom_tooltip = MAY_every_province_with_jungle
				custom_tooltip = MAY_province_gets_25_prosperity
				hidden_effect = {
					every_owned_province = {
						limit = {
							has_terrain = jungle
						}
						add_prosperity = 25
					}
				}
				custom_tooltip = " "
			}
			
			add_country_modifier = {
				name = MAY_taming_the_jungle
				duration = 10950 
			}
		}
	}
}

WoC_maya_5 = {
	slot = 5
	generic = no
	ai = yes
	potential_on_load = {
		has_dlc = "Winds of Change"
	}
	potential = {
		tag = MAY
		NOT = { map_setup = map_setup_random }
		has_dlc = "Winds of Change"
		is_random_new_world = no
	}
	has_country_shield = yes
	
	MAY_restore_lowland_ruins = {
		icon = mission_develop_the_capital
		required_missions = { MAY_reform_religion }
		position = 5
		provinces_to_highlight = {
			owned_by = ROOT
			OR = {
				development = 25
				num_of_buildings_in_province = 3
			}
			NOT = {
				AND = {
					development = 25
					num_of_buildings_in_province = 3
				}
			}
		}
		trigger = {
			num_of_owned_provinces_with = {
				development = 25
				num_of_buildings_in_province = 3
				value = 3 
			}
		}
		effect = {
			custom_tooltip = GER_3_most_developed_provinces
			tooltip = {
				add_province_modifier = {
					name = MAY_restoring_maya_golden_age
					duration = -1
				}
			}
			hidden_effect = {
				country_event = { id = flavor_may.12 }
			}
			
			if = {
				limit = {
					has_dlc = "Leviathan"
				}
				842 = { add_province_triggered_modifier = MAY_restoration }
				846 = { add_province_triggered_modifier = MAY_restoration }
				
				custom_tooltip = " "
			}
			
			if = {
				limit = {
					has_estate = estate_burghers 
				}
				add_estate_loyalty_modifier = {
					estate = estate_burghers
					desc = MAY_restoring_cities
					loyalty = 5
					duration = -1
				}
			}
		}
	}
	
	MAY_trade_2 = {
		icon = mission_sio_sun_dance
		required_missions = { MAY_trading_society }
		position = 8
		provinces_to_highlight = {
			owned_by = ROOT
			province_has_center_of_trade_of_level = 1
			NOT = { has_trade_building_trigger = yes }
		}
		trigger = {
			home_trade_node = {
				trade_share = {
					country = ROOT
					share = 75
				}
				trade_node_value = 15
			}
			
			num_of_owned_provinces_with = {
				has_trade_building_trigger = yes
				province_has_center_of_trade_of_level = 1
				value = 3
			}
		}
		effect = {
			custom_tooltip = MAY_3_most_dev_cots
			tooltip = {
				add_or_upgrade_trade_building = yes
			}
			hidden_effect = { 
				country_event = { id = flavor_may.13 }
			}
			
			custom_tooltip = " "
			
			add_years_of_income = 1
			
			custom_tooltip = " "
			
			if = {
				limit = {
					has_estate  = estate_burghers
				}
				custom_tooltip = MAY_upgrade_privilege_of_burghers
			}
			else = {
				add_years_of_income = 0.5
			}
			set_country_flag = MAY_upgrade_privilege_of_burghers_flag
			
			custom_tooltip = " "
			
			complex_dynamic_effect = {
				first_custom_tooltip = MAY_if_we_have_good_relations_with_europeans
				first_limit = "
					any_known_country = {
						technology_group = western
						has_opinion = {
							who = ROOT
							value = 75
						}
					}
				"
				first_effect = "
					custom_tooltip = MAY_get_a_50_off_trader
					hidden_effect = {
						every_known_country = {
							limit = {
								technology_group = western
								has_opinion = {
									who = ROOT
									value = 75
								}
							}
							ROOT = {
								define_advisor = {
									type = trader
									skill = 3
									culture = PREV
									religion = PREV
									cost_multiplier = 0.5
								}
							}
						}
					}
				"
			}
		}
	}
	
	MAY_cocoa = {
		icon = mission_cocoa
		required_missions = { MAY_trade_guilds }
		position = 9
		provinces_to_highlight = {
			trade_goods = cocoa
			owned_by = ROOT
		}
		trigger = {
			trade_goods_produced_amount = {
				trade_goods = cocoa
				amount = 5
			}
			
			production_leader = {
				trade_goods = cocoa
			}
		}
		effect = {
			add_country_modifier = {
				name = MAY_cocoa_barter
				duration = 10950
			}
			
			if = {
				limit = {
					has_estate = estate_church
				}
				custom_tooltip = MAY_cocoa_monopoly
				custom_tooltip = " "
			}
			else = {
				add_adm_power = 100
				custom_tooltip = " "
			}
			set_country_flag = MAY_cocoa_monopoly_flag
			
			custom_tooltip = " "
			
			add_years_of_owned_provinces_production_income = {
				years = 10
				trigger = {
					trade_goods = cocoa
				}
				custom_tooltip = MAY_prod_from_cocoa
			}
		}
	}
}