###################################
#
# SUNSET INVASION
# - The Fantasy Menace
#
###################################

# Written by Henrik Fåhraeus and Henrik Eklund

namespace = SSI

# First Contact - Beads and Feathers
# (There is another version of this event: SoA.3081 - triggered by a Demon Child.)
province_event = {
	id = SSI.1
	desc = EVTDESC_SSI_001

	picture = GFX_evt_aztec_explorers
	border = GFX_event_normal_frame_war

	has_dlc = "Sunset Invasion"
	trigger = {
		OR = {
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = random
				}
				total_years_played = 50
			}
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = delayed_random
				}
				year = 1000
				total_years_played = 50
			}
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = plus
				}
				year = 1250
			}
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = historical
				}
				year = 1250
			}
		}
		NOR = {
			year = 1350
			has_global_flag = aztec_explorers 
			has_game_rule = {
				name = aztec_invasion
				value = off
			}
			has_global_flag = demon_child_to_aztecs
		}
		OR = {
			province_id = 1 # Vestisland
			province_id = 9 # Connacht
			province_id = 35 # Inse Gall
			province_id = 31 # Cornwall
			province_id = 104 # Cornouaille
			province_id = 149 # Bordeaux
			province_id = 156 # Coruna
			province_id = 162 # Silves
			province_id = 841 # Tangier
			province_id = 846 # Taroudant
		}
	}

	immediate = {
		set_global_flag = aztec_explorers
		set_province_flag = aztec_explorers
		activate_title = { title = e_mexikha status = yes }
		hidden_tooltip = {
			e_mexikha = {
				holder_scope = {
					narrative_event = { id = SSI.2 days = 7 }
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 720
		modifier = {
			factor = 0.5
			year = 1320
			has_global_flag = vanilla_aztecs
		}
		modifier = {
			factor = 75
			NOT = { has_global_flag = vanilla_aztecs }
		}
		modifier = {
			factor = 4
			has_game_rule = {
				name = aztec_invasion
				value = random
			}
		}
		modifier = {
			factor = 3
			has_game_rule = {
				name = aztec_invasion
				value = delayed_random
			}
		}
	}

	option = {
		name = EVTOPTA_SSI_001
	}
}

# Rumors of people from across the Atlantic
narrative_event = {
	id = SSI.2
	title = EVTNAME_SSI_002
	
	desc = {
		text = EVTDESC_SSI_002
		trigger = {
			NOT = { has_global_flag = demon_child_to_aztecs }
		}
	}
	
	desc = {
		text = EVTDESC_SSI_002_DEMON
		trigger = {
			has_global_flag = demon_child_to_aztecs
		}
	}
	
	major = yes
	hide_from = yes

	picture = GFX_evt_aztec_explorers
	border = GFX_event_narrative_frame_war

	is_triggered_only = yes

	major_trigger = {
		FROM = { owner = { NOT = { character = PREVPREV } } }
	}
	
	immediate = {
		e_mexikha = {
			holder_scope = {
				character_event = { id = CM.10018 }  # Chronicle
			}
		}
	}

	option = {
		name = {
			text = EVTOPTA_SSI_002
			trigger = {
				OR = {
					NOT = { has_global_flag = demon_child_to_aztecs }
					NOT = { society_member_of = the_satanists }
				}
			}
		}
		
		name = {
			text = EVTOPTA_SSI_002_SATANIC
			trigger = {
				has_global_flag = demon_child_to_aztecs
				society_member_of = the_satanists
			}
		}
	}
}

# First Landing of the Aztecs
province_event = {
	id = SSI.3
	desc = EVTDESC_SSI_003

	picture = GFX_evt_battle_mesoamerican
	border = GFX_event_normal_frame_war

	trigger = {
		OR = {
			has_global_flag = demon_child_to_aztecs
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = historical
				}
				year = 1250
			}
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = random
				}
				total_years_played = 50
			}
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = delayed_random
				}
				year = 1000
				total_years_played = 50
			}
		}
		NOT = { has_global_flag = aztec_arrival }
		had_province_flag = { flag = aztec_explorers days = 730 }
	}

	immediate = {
		set_global_flag = aztec_arrival
		#culture = nahuatl
		#religion = aztec
		create_character = {
			random_traits = yes
			dynasty = 1035000
			religion = aztec
			culture = nahuatl
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			prestige = 400 # They need 500 for invasion CB
			ROOT = {
				county = {
					gain_title = PREVPREV
					any_de_jure_vassal_title = {
						gain_title = PREVPREVPREV
					}
				}
			}
			e_mexikha = {
				gain_title = PREV
			}
			narrative_event = { id = SSI.4 }
		}
	}

	mean_time_to_happen = {
		months = 6
	}

	option = {
		name = EVTOPTA_SSI_003
	}
}

# First Landing of the Aztecs
narrative_event = {
	id = SSI.4
	title = EVTNAME_SSI_004
	desc = EVTDESC_SSI_004
	major = yes
	hide_new = yes

	picture = GFX_evt_battle_mesoamerican
	border = GFX_event_narrative_frame_war

	is_triggered_only = yes

	major_trigger = {
		FROM = { owner = { NOT = { character = PREVPREV } } }
	}

	immediate = {
		any_playable_ruler = {
			limit = {
				ai = no
				capital_scope = {
					NOT = { region = world_india }
				}
			}
			character_event = { id = CM.10020 }  # Chronicle
		}
		
		wealth = 1000

		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			if = {
				limit = { has_global_flag = better_armies_mode }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
			}
			if = {
				limit = { NOT = { has_global_flag = better_armies_mode } }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}					
			}
		}

		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 25
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			if = {
				limit = { has_global_flag = better_armies_mode }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
			}
			if = {
				limit = { NOT = { has_global_flag = better_armies_mode } }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}					
			}
		}

		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 25
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			if = {
				limit = { has_global_flag = better_armies_mode }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
			}
			if = {
				limit = { NOT = { has_global_flag = better_armies_mode } }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}					
			}
		}

		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 24
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				if = {
					limit = { has_global_flag = better_armies_mode }
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}				

				}
				if = {
					limit = { NOT = { has_global_flag = better_armies_mode } }
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}	
				}
			}
		}

		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 25
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				if = {
					limit = { has_global_flag = better_armies_mode }
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}				

				}
				if = {
					limit = { NOT = { has_global_flag = better_armies_mode } }
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}	
				}
			}
		}

		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 28
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				if = {
					limit = { has_global_flag = better_armies_mode }
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}				

				}
				if = {
					limit = { NOT = { has_global_flag = better_armies_mode } }
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}	
				}
			}
		}

		# Ships
		if = {
			limit = {
				FROM = {
					OR = {
						province_id = 1 # Vestisland
						province_id = 9 # Connacht
						province_id = 35 # Inse Gall
						province_id = 31 # Cornwall
					}
				}
			}
			FROM = {
				sea_zone = {
					ROOT = {
						spawn_unit = {
							province = PREV
							home = FROM
							owner = ROOT
							earmark = aztec_invasion_fleet
							troops =
							{
								galleys = { 1000 1000 }
							}
						}
					}
				}
			}
		}

		# Some extra courtiers
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 24
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 20
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 25
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 26
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 28
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 20
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 17
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 17
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 17
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 17
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 20
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 17
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 17
		}

		if = {
			limit = {
				OR = {
					has_power_omen_modifier_trigger = yes
					has_battle_omen_modifier_trigger = yes
				}
			}
			set_character_flag = negative_event_flag # For the scrying outcome calculation...
		}
	}
	
	option = {
		name = EVTOPTA_SSI_072
		trigger = {
			has_landed_title = e_mexikha
		}
	}

	option = {
		name = "EVTOPTA_SSI_004"

		trigger = {
			has_power_omen_modifier_trigger = no
			has_battle_omen_modifier_trigger = no
			NOT = { has_landed_title = e_mexikha }
		}
	}

	option = { # Monks & Mystics - Hermetics Scrying reaction
		name = EVTOPTA_SSI_004

		calculate_scrying_outcome_effect = yes
		remove_scrying_omen_modifiers_effect = yes

		tooltip_info = yes
		trigger = {
			NOT = { has_landed_title = e_mexikha }
			OR = {
				has_power_omen_modifier_trigger = yes
				has_battle_omen_modifier_trigger = yes
			}
		}
	}
}

# Second Landing of the Aztecs
province_event = {
	id = SSI.5
	desc = EVTDESC_SSI_005

	picture = GFX_evt_aztec_arrival
	border = GFX_event_normal_frame_war

	has_global_flag = aztec_arrival
	
	trigger = {
		OR = {
			has_global_flag = player_aztec
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = historical
				}
				year = 1250
			}
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = random
				}
				total_years_played = 50
			}
			AND = {
				has_game_rule = {
					name = aztec_invasion
					value = delayed_random
				}
				year = 1000
				total_years_played = 50
			}
		}
		NOT = { has_global_flag = aztec_arrival_2 }
		OR = {
			province_id = 1 # Vestisland
			province_id = 9 # Connacht
			province_id = 35 # Inse Gall
			province_id = 31 # Cornwall
			province_id = 104 # Cornouaille
			province_id = 149 # Bordeaux
			province_id = 156 # Coruna
			province_id = 162 # Silves
			province_id = 841 # Tangier
			province_id = 846 # Taroudant
		}
		owner = {
			NOT = { religion = aztec }
		}
	}

	immediate = {
		set_global_flag = aztec_arrival_2
		set_province_flag = aztec_second_wave
#		culture = nahuatl
#		religion = aztec
		e_mexikha = {
			holder_scope = {
				ROOT = {
					county = {
						gain_title = PREVPREV
						any_de_jure_vassal_title = {
							gain_title = PREVPREVPREV
						}
					}
				}
				narrative_event = { id = SSI.6 }
			}
		}
	}

	mean_time_to_happen = {
		months = 12
	}

	option = {
		name = "EVTOPTA_SSI_005"
	}
}

# Second Landing of the Aztecs
narrative_event = {
	id = SSI.6
	title = "EVTNAME_SSI_006"
	desc = "EVTDESC_SSI_006"
	major = yes
	hide_new = yes

	picture = "GFX_evt_aztec_arrival"
	border = "GFX_event_narrative_frame_war"

	is_triggered_only = yes

	major_trigger = {
		FROM = { owner = { NOT = { character = PREVPREV } } }
	}

	immediate = {
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			if = {
				limit = { has_global_flag = better_armies_mode }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
			}
			if = {
				limit = { NOT = { has_global_flag = better_armies_mode } }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}					
			}
		}

		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 25
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			if = {
				limit = { has_global_flag = better_armies_mode }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
			}
			if = {
				limit = { NOT = { has_global_flag = better_armies_mode } }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}					
			}
		}

		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 25
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			if = {
				limit = { has_global_flag = better_armies_mode }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 1500 1500 }
						light_infantry = { 750 750 }
						archers = { 750 750 }
					}
				}
			}
			if = {
				limit = { NOT = { has_global_flag = better_armies_mode } }
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}
				spawn_unit = {
					province = FROM
					home = FROM
					troops = {
						heavy_infantry = { 2500 2500 }
						light_infantry = { 1250 1250 }
						archers = { 1250 1250 }
					}
				}					
			}
		}

		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 24
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				if = {
					limit = { has_global_flag = better_armies_mode }
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}				

				}
				if = {
					limit = { NOT = { has_global_flag = better_armies_mode } }
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}	
				}
			}
		}

		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 25
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				if = {
					limit = { has_global_flag = better_armies_mode }
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}				

				}
				if = {
					limit = { NOT = { has_global_flag = better_armies_mode } }
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}	
				}
			}
		}

		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 28
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				if = {
					limit = { has_global_flag = better_armies_mode }
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}
						spawn_unit = {
							province = FROM
							home = FROM
							troops = {
								heavy_infantry = { 1500 1500 }
								light_infantry = { 750 750 }
								archers = { 750 750 }
							}
						}				

				}
				if = {
					limit = { NOT = { has_global_flag = better_armies_mode } }
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}
					spawn_unit = {
						province = FROM
						home = FROM
						troops = {
							heavy_infantry = { 2500 2500 }
							light_infantry = { 1250 1250 }
							archers = { 1250 1250 }
						}
					}	
				}
			}
		}

		# Ships
		if = {
			limit = {
				FROM = {
					OR = {
						province_id = 1 # Vestisland
						province_id = 9 # Connacht
						province_id = 35 # Inse Gall
						province_id = 31 # Cornwall
					}
				}
			}
			FROM = {
				sea_zone = {
					ROOT = {
						spawn_unit = {
							province = PREV
							home = FROM
							owner = ROOT
							earmark = aztec_invasion_fleet
							troops =
							{
								galleys = { 1000 1000 }
							}
						}
					}
				}
			}
		}
		if = {
			limit = {
				OR = {
					has_power_omen_modifier_trigger = yes
					has_battle_omen_modifier_trigger = yes
				}
			}
			set_character_flag = negative_event_flag # For the scrying outcome calculation...
		}
	}

	option = {
		name = EVTOPTA_SSI_072
		trigger = {
			has_landed_title = e_mexikha
		}
	}
	
	option = {
		name = "EVTOPTA_SSI_006"

		trigger = {
			has_power_omen_modifier_trigger = no
			has_battle_omen_modifier_trigger = no
			NOT = { has_landed_title = e_mexikha }
		}
	}

	option = { # Monks & Mystics - Hermetics Scrying reaction
		name = EVTOPTA_SSI_006

		calculate_scrying_outcome_effect = yes
		remove_scrying_omen_modifiers_effect = yes

		tooltip_info = yes
		trigger = {
			NOT = { has_landed_title = e_mexikha }
			OR = {
				has_power_omen_modifier_trigger = yes
				has_battle_omen_modifier_trigger = yes
			}
		}
	}
}

# Aztec Invasion Fleets disband
character_event = {
	id = SSI.100
	hide_window = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztec_invasion_fleet_disbanded }
		had_global_flag = { flag = aztec_arrival days = 18250 }
	}

	mean_time_to_happen = {
		months = 1
	}

	immediate = {
		disband_event_forces = aztec_invasion_fleet
		set_global_flag = aztec_invasion_fleet_disbanded
	}

	option = {
		name = "OK"
	}
}

# Aztecs Thrown Back Into the Sea
narrative_event = {
	id = SSI.105
	title = EVTNAME_SSI_105
	desc = EVTDESC_SSI_105

	hide_from = yes

	picture = GFX_evt_aztec_arrival
	border = GFX_event_narrative_frame_war

	major = yes

	has_global_flag = aztec_arrival_2
	only_playable = yes
	
	is_triggered_only = yes
	
	trigger = {		
		OR = {
			has_landed_title = k_papal_state
			has_landed_title = k_papal_chalcedon
			has_landed_title = k_chalcedonian
			has_landed_title = d_miaphysite
		}
		e_mexikha = { has_holder = no }
		NOT = { has_global_flag = aztecs_defeated }
	}

	major_trigger = {
		OR = {
			has_landed_title = k_papal_state
			has_landed_title = k_papal_chalcedon
			has_landed_title = k_chalcedonian
			has_landed_title = d_miaphysite
			ai = no
		}
	}

	immediate = {
		set_global_flag = aztecs_defeated
	}

	option = {
		name = "EVTOPTA_SSI_105"
	}
}

# Aztecs Fight Incas
narrative_event = {
	id = SSI.30
	title = EVTNAME_SSI_030
	desc = EVTDESC_SSI_030

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_narrative_frame_war

	major = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztec_incas }
		NOT = { has_global_flag = aztecs_defeated }
	}

	major_trigger = {
		ai = no
	}

	mean_time_to_happen = {
		months = 220
	}

	immediate = {
		set_global_flag = aztec_incas
	}

	option = {
		name = EVTOPTA_SSI_030
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_030
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Pacify Northern Plains
narrative_event = {
	id = SSI.31
	title = EVTNAME_SSI_031
	desc = EVTDESC_SSI_031

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_narrative_frame_war

	major = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztec_plains }
		NOT = { has_global_flag = aztecs_defeated }
	}

	major_trigger = {
		ai = no
	}

	mean_time_to_happen = {
		months = 220
	}

	immediate = {
		set_global_flag = aztec_plains
	}

	option = {
		name = EVTOPTA_SSI_031
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_031
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Food From the Americas
narrative_event = {
	id = SSI.35
	title = EVTNAME_SSI_035
	desc = EVTDESC_SSI_035

	picture = GFX_evt_aztec_explorers
	border = GFX_event_narrative_frame_war

	major = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztec_food }
		NOT = { has_global_flag = aztecs_defeated }
	}

	major_trigger = {
		ai = no
	}

	mean_time_to_happen = {
		months = 220
	}

	immediate = {
		set_global_flag = aztec_food
	}

	option = {
		name = EVTOPTA_SSI_035
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_035
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold Iceland
character_event = {
	id = SSI.40
	desc = EVTDESC_SSI_040

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztec_iceland }
		completely_controls = d_iceland
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_iceland
	}

	option = {
		name = EVTOPTA_SSI_040
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold Ireland
character_event = {
	id = SSI.41
	desc = EVTDESC_SSI_041

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztec_ireland }
		completely_controls = d_ulster
		completely_controls = d_connacht
		completely_controls = d_meath
		completely_controls = d_leinster
		completely_controls = d_munster
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_ireland
	}

	option = {
		name = EVTOPTA_SSI_041
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold Britain
character_event = {
	id = SSI.42
	desc = EVTDESC_SSI_042

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztec_britain }
		completely_controls = d_northumberland
		completely_controls = d_lancaster
		completely_controls = d_york
		completely_controls = d_norfolk
		completely_controls = d_oxford
		completely_controls = d_bedford
		completely_controls = d_hereford
		completely_controls = d_gloucester
		completely_controls = d_canterbury
		completely_controls = d_somerset
		completely_controls = d_gwynedd
		completely_controls = d_cornwall
		completely_controls = d_galloway
		completely_controls = d_western_isles
		completely_controls = d_lothian
		completely_controls = d_albany
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_britain
	}

	option = {
		name = EVTOPTA_SSI_042
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold London
character_event = {
	id = SSI.43
	desc = EVTDESC_SSI_043

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		completely_controls = c_middlesex
		NOT = { has_global_flag = aztec_london }
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_london
	}

	option = {
		name = EVTOPTA_SSI_043
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold Paris
character_event = {
	id = SSI.44
	desc = EVTDESC_SSI_044

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		completely_controls = c_ile_de_france
		NOT = { has_global_flag = aztec_paris }
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_paris
	}

	option = {
		name = EVTOPTA_SSI_043
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold Rome
character_event = {
	id = SSI.45
	desc = EVTDESC_SSI_045

	picture = GFX_evt_rome_falls
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		completely_controls = c_roma
		NOT = { has_global_flag = aztec_rome }
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_rome
	}

	option = {
		name = EVTOPTA_SSI_043
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold Constantinople
character_event = {
	id = SSI.46
	desc = EVTDESC_SSI_046

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		completely_controls = c_byzantion
		NOT = { has_global_flag = aztec_constantinople }
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_constantinople
	}

	option = {
		name = EVTOPTA_SSI_043
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold Cordoba
character_event = {
	id = SSI.47
	desc = EVTDESC_SSI_047

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		completely_controls = c_cordoba
		NOT = { has_global_flag = aztec_cordoba }
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_cordoba
	}

	option = {
		name = EVTOPTA_SSI_043
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Hold Cairo
character_event = {
	id = SSI.48
	desc = EVTDESC_SSI_048

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_normal_frame_war

	major = yes
	is_triggered_only = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		completely_controls = c_cairo
		NOT = { has_global_flag = aztec_cairo }
	}

	major_trigger = {
		ai = no
	}

	immediate = {
		set_global_flag = aztec_cairo
	}

	option = {
		name = EVTOPTA_SSI_043
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_040
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Sacrifice Prisoner
character_event = {
	id = SSI.60
	desc = EVTDESC_SSI_060

	picture = GFX_evt_bishop_aztec
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SSI_060
	}
}

# Aztecs Sacrifice Occupied Province Character
character_event = {
	id = SSI.61
	hide_window = yes

	ai = yes
	min_age = 16
	prisoner = no

	is_triggered_only = yes

	trigger = {
		in_command_trigger = no		
		is_adult = yes
		NOT = { religion = aztec }
		NOT = {
			any_liege = {
				has_landed_title = e_mexikha
			}
		}
		new_character = {
			OR = {
				has_landed_title = e_mexikha
				any_liege = {
					has_landed_title = e_mexikha
				}
			}
		}
	}

	immediate = {
		liege = {
			character_event = { id = SSI.62 }
		}
		death = { death_reason = death_sacrificed }
	}

	option = {
		name = "OK"
	}
}

# Liege Informed of Sacrifice
character_event = {
	id = SSI.62
	desc = EVTDESC_SSI_060

	picture = GFX_evt_bishop_aztec
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	option = {
		name = EVTOPTA_SSI_060
	}
}

# Aztecs Bring Syphilis
narrative_event = {
	id = SSI.70
	title = EVTNAME_SSI_070
	desc = EVTDESC_SSI_070

	picture = GFX_evt_aztec_explorers
	border = GFX_event_narrative_frame_war
	
	major = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztec_syphilis }
		NOT = { has_global_flag = aztecs_defeated }
	}

	major_trigger = {
		ai = no
	}

	mean_time_to_happen = {
		months = 150
	}

	immediate = {
		set_global_flag = aztec_syphilis
		activate_disease = syphilis
	}

	option = {
		name = EVTOPTA_SSI_070
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_070
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Struck by Smallpox
narrative_event = {
	id = SSI.71
	title = EVTNAME_SSI_071
	desc = EVTDESC_SSI_071

	picture = GFX_evt_throne_room_mesoamerican
	border = GFX_event_narrative_frame_war

	major = yes

	only_playable = yes
	has_global_flag = aztec_arrival
	
	trigger = {
		has_global_flag = aztec_syphilis
		has_landed_title = e_mexikha
		NOT = { has_global_flag = aztecs_defeated }
		NOT = { has_global_flag = aztec_smallpox }
	}

	major_trigger = {
		ai = no
	}

	mean_time_to_happen = {
		months = 150
	}

	immediate = {
		set_global_flag = aztec_smallpox
	}

	option = {
		name = EVTOPTA_SSI_071
		trigger = {
			NOT = { has_landed_title = e_mexikha }
		}
	}
	option = {
		name = EVTOPTB_SSI_071
		trigger = {
			has_landed_title = e_mexikha
		}
	}
}

# Aztecs Sacrifice Prisoner (Aztec perspective)
character_event = {
	id = SSI.72
	desc = EVTDESC_SSI_072
	
	picture = GFX_evt_bishop_aztec
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_SSI_072
	}
}

# Check for playable Aztec invasion
character_event = { 
	id = SSI.73

	hide_window = yes
	is_triggered_only = yes
	
	has_dlc = "Sunset Invasion"

	immediate = {
		random_player = {
			if = {
				limit = {
					religion = aztec
					culture = nahuatl
					OR = {
						any_demesne_province = { region = custom_north_sea_zone }
						any_demesne_province = { region = custom_atlantic_zone }
						
					}
				}
				character_event = { id = SSI.74 }
			}
		}
	}
}

# Ask player about becoming Aztec invader
character_event = {
	id = SSI.74
	desc = EVTDESC_SSI_74
	picture = GFX_evt_battle_mesoamerican
	
	is_triggered_only = yes
	hide_from = yes
	
	trigger = { NOT = { has_character_flag = aztec_player } }
	
	immediate = {
		set_character_flag = aztec_player
	}
	
	option = { # Give me the empire
		name = EVTOPTA_SSI_74
		activate_title = { title = e_mexikha status = yes }
		prestige = 500
		e_mexikha = {
			gain_title = PREV
		}
		any_demesne_title = {
			any_de_jure_vassal_title = {
				gain_title = PREVPREV
			}
		}
		hidden_tooltip = {
			e_mexikha = {
				add_law = crown_authority_2
				add_law = council_privileges_0
				add_law = succ_primogeniture
			}
			set_global_flag = player_aztec
			set_global_flag = aztec_arrival
			set_global_flag = aztec_explorers
			capital_scope = {
				set_province_flag = aztec_explorers
				province_event = { id = SSI.75 }
			}
		}
	}
	option = { # I don't want this
		name = EVTOPTB_SSI_74
	}
}

# Province Bounce Event
province_event = { 
	id = SSI.75

	hide_window = yes
	is_triggered_only = yes

	immediate = {
		holder_scope = {
			narrative_event = { id = SSI.4 }
		}
	}
}