#Early Aztecs Events

namespace = ea

province_event = { #MODIFIED SSI.1
	id = ea.1
	hide_window = yes
	
	has_dlc = "Sunset Invasion"
	
	trigger = {
		has_game_rule = {
			name = early_aztecs
			value = on
		}
		NOR = {
			has_global_flag = aztec_explorers
			has_global_flag = demon_child_to_aztecs
		}
		NOT = {
			has_game_rule = {
				name = aztec_invasion
				value = off
			}
		}
		OR = {
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = vestisland
				}
				province_id = 1 # Vestisland
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = connacht
				}
				province_id = 9 # Connacht
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = innse_gall
				}
				province_id = 35 # Inse Gall
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = cornwall
				}
				province_id = 31 # Cornwall
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = cornouaille
				}
				province_id = 104 # Cornouaille
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = bordeaux
				}
				province_id = 149 # Bordeaux
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = coruna
				}
				province_id = 156 # Coruna
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = silves
				}
				province_id = 162 # Silves
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = tangier
				}
				province_id = 841 # Tangier
			}
			AND = {
				has_game_rule = {
					name = early_aztecs_start
					value = anti-atlas
				}
				province_id = 845 # Anti-Atlas
			}
		}
	}
	
	immediate = {
		log = "AZTEC INVASION IMMEDIATE 5532432005"
		set_global_flag = aztec_explorers
		set_province_flag = aztec_explorers
		activate_title = { title = e_mexikha status = yes }
		owner = { character_event = { id = SSI.74 } }
		
		k_papal_state = {
			holder_scope = {
				create_random_soldier = {
					dynasty = 1035000 # Acatl
					random_traits = yes
					culture = nahuatl
					religion = aztec
				}
				new_character = {
					e_mexikha = {
						grant_title = PREV
					}
					set_government_type = feudal_government
					e_mexikha = {
						add_law = succ_primogeniture
						add_law = agnatic_succession
						if = {
							limit = {
								has_dlc = "Zeus"
							}
							add_law = revoke_title_law_2
						}
						if = {
							limit = {
								NOT = { has_dlc = "Zeus" }
							}
							add_law = crown_authority_1
						}
					}
					set_defacto_liege = THIS
					narrative_event = { id = ea.2 days = 7 }
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_SSI_001
	}
}

narrative_event = { #MODIFIED SSI.2
	id = ea.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
	
	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
			}
		}
	}
}

province_event = { #MODIFIED SSI.3
	id = ea.3
	desc = EVTDESC_SSI_003
	
	picture = GFX_evt_battle_mesoamerican
	border = GFX_event_normal_frame_war
	
	trigger = {
		has_game_rule = {
			name = early_aztecs
			value = on
		}
		NOT = { has_global_flag = aztec_arrival }
		had_province_flag = { flag = aztec_explorers days = 14 }
	}
	
	immediate = {
		set_global_flag = aztec_arrival
		#culture = nahuatl
		#religion = aztec
		e_mexikha = {
			holder_scope = {
				narrative_event = { id = ea.4 }
			}
		}
	}
	
	option = {
		name = EVTOPTA_SSI_003
	}
}

narrative_event = { #COPIED SSI.4
	id = ea.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 = 10000
		FROM = {
			kingdom = {
				ROOT = {
					war = {
						casus_belli = tribal_invasion
						target = PREVPREV # The top liege of the province owner
						thirdparty_title = PREV # The de jure kingdom
					}
				}
			}
		}
		
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops = 
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 25
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 22
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 31
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 24
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 23
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 25
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 22
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 18
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 28
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = no
			age = 29
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = FROM
				home = FROM
				troops =
				{
					heavy_infantry = { 2800 2800 }
					light_infantry = { 1400 1300 }
					archers = { 1400 1300 }
				}
			}
		}
		
		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 30
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 25
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 22
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
		}
		
		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 30
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 25
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 22
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
		}
		
		random = {
			chance = 50
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 30
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 25
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = aztec
				culture = nahuatl
				female = no
				age = 22
				attributes = {
					martial = 12
				}
				trait = brilliant_strategist
			}
			new_character = {
				spawn_unit = {
					province = FROM
					home = FROM
					troops =
					{
						heavy_infantry = { 2800 2800 }
						light_infantry = { 1400 1300 }
						archers = { 1400 1300 }
					}
				}
			}
		}
		
		# 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 = 16
		}
		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 = 16
		}
		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 = 16
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 16
		}
		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 = 16
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = aztec
			culture = nahuatl
			female = yes
			age = 16
		}

		any_playable_ruler = {
			limit = { ai = no }
			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_004

		trigger = {
			has_power_omen_modifier_trigger = no
			has_battle_omen_modifier_trigger = no
		}
	}

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

		if = { # for safety
			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...
		}

		calculate_scrying_outcome_effect = yes
		remove_scrying_omen_modifiers_effect = yes

		tooltip_info = yes
		trigger = {
			OR = {
				has_power_omen_modifier_trigger = yes
				has_battle_omen_modifier_trigger = yes
			}
		}
	}
}
