########################################
# Major Flavor Events                  #
########################################

namespace = flavor_spa
normal_or_historical_nations = yes

# The Iberian Wedding
country_event = {
	id = flavor_spa.3716
	title = "flavor_spa.EVTNAME3716"
	desc = "flavor_spa.EVTDESC3716"
	picture = DIPLOMACY_eventPicture

	major = yes
	
	fire_only_once = yes
	
	
	trigger = {
		NOT = { exists = SPA }
		OR = {
			AND = {
				tag = CAS
				NOT = { war_with = ARA }
				is_subject = no
				ARA = {
					exists = yes
					ai = yes
					was_player = no
					is_subject = no
					is_neighbor_of = ROOT
					NOT = { is_in_war = { attacker_leader = ARA } }
					NOT = { is_in_war = { defender_leader = ARA } }
					NOT = { is_in_war = { casus_belli = cb_independence_war } }
					government = monarchy
				}
				num_of_cities = 25
			}
			AND = {
				tag = ARA
				NOT = { war_with = CAS }
				is_subject = no
				ai = no
				CAS = {
					exists = yes
					ai = yes
					was_player = no
					is_subject = no
					is_neighbor_of = ROOT
					NOT = { is_in_war = { attacker_leader = CAS } }
					NOT = { is_in_war = { defender_leader = CAS } }
					NOT = { is_in_war = { casus_belli = cb_independence_war } }
					government = monarchy
				}
				num_of_cities = 16
			}
		}
		government = monarchy
		is_year = 1450
		NOT = { is_year = 1530 }
		is_subject = no
		num_of_cities = 10
		OR = {
			AND = {
				CAS = { is_female = yes }
				ARA = { is_female = no }
			}
			AND = {
				CAS = { is_female = no }
				ARA = { is_female = yes }
			}
			ARA = {
				ai = yes
				has_regency = yes
			}
			CAS = {
				ai = yes
				has_regency = yes
			}
		}
	}

	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 0.1
			OR = {
				AND = {
					tag = CAS
					ARA = {
						has_regency = no 
					}
				}
				AND = {
					tag = ARA
					CAS = { 
						has_regency = no 
					}
				}
			}
		}
	}
	
	
	option = {		# Let us bind their Dynasty to ours
		name = "flavor_spa.EVTOPTA3716"
		ai_chance = { factor = 90 }
		if = {
			limit = { tag = CAS }
			create_union = ARA
			add_opinion = {
				who = ARA
				modifier = spa_iberian_wedding
			}
			ARA = {
				add_opinion = {
					who = ROOT
					modifier = spa_iberian_wedding
				}
				add_liberty_desire = -50
			}
			every_known_country = {
				limit = {
					marriage_with = ARA
				}
				add_opinion = {
					who = ROOT
					modifier = spa_iberian_wedding_negative
				}
			}
		}
		if = {
			limit = { tag = ARA }
			create_union = CAS
			add_opinion = {
				who = CAS
				modifier = spa_iberian_wedding
			}
			CAS = {
				add_opinion = {
					who = ROOT
					modifier = spa_iberian_wedding
				}
				add_liberty_desire = -50
			}
			every_known_country = {
				limit = {
					marriage_with = CAS
				}
				add_opinion = {
					who = ROOT
					modifier = spa_iberian_wedding_negative
				}
			}
		}
		random_owned_province = {
			limit = {
				is_capital = no
			}
			spawn_rebels = {
				type = noble_rebels
				size = 2
			}
		}
	}
	option = {		# No let us marry a local talent instead
		name = "flavor_spa.EVTOPTB3716"
		ai_chance = { factor = 10 }
		add_stability_or_adm_power = yes
		if = {
			limit = { tag = CAS }
			ARA = {
				add_opinion = {
					who = ROOT
					modifier = spa_declined_iberian_wedding
				}
			}
		}
		if = {
			limit = { tag = ARA }
			CAS = {
				add_opinion = {
					who = ROOT
					modifier = spa_declined_iberian_wedding
				}
			}
		}
		if = {
			limit = {
				has_regency = no
				has_consort = no
				has_government_attribute = queen
			}
			define_consort = {
				ADM = 2
				MIL = 2
				DIP = 2
			}
		}
	}
}

# Torquemada and the Conversion of the Moors
country_event = {
	id = flavor_spa.3150
	title = "flavor_spa.EVTNAME3150"
	desc = "flavor_spa.EVTDESC3150"
	picture = ADVISOR_eventPicture
	
	fire_only_once = yes

	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		NOT = { exists = GRA }
		religion = catholic
		is_at_war = no
		any_owned_province = {
			region = iberia_region
			religion_group = muslim
		}
	}

	mean_time_to_happen = {
		months = 12
	}
	
	immediate = {
		hidden_effect = {
			set_country_flag = spa_holy_inquisition
		}
	}

	option = {		# Let us make a clean sweep for the Glory of God
		name = "flavor_spa.EVTOPTA3150"
		define_advisor = {
			type = inquisitor
			name = "Toms de Torquemada"
			location = 215 # Castilla La Vieja 
			discount = yes
			skill = 1
		}
		
		every_owned_province = {
			limit = {
				region = iberia_region
				religion_group = muslim
			}
			change_religion = catholic
			add_province_modifier = {
				name = forced_conversion
				duration = 3650
			}
		}	
		random_country = {
			limit = {
				religion_group = muslim
				any_owned_province = {
					sea_zone = {
						any_neighbor_province = {
							owned_by = ROOT
						}
					}
				}
			}
			country_event = {  id = flavor_spa.3151 days = 10 tooltip = "flavor_spa.EVTTOOLTIP3150" }
		}
		set_country_flag = torquemada_expelled
		add_reform_desire = 0.02

	}
	option = {		# Toleration is key to the nation's prosperity
		name = "flavor_spa.EVTOPTC3150"
		ai_chance = { factor = 0 }
		custom_tooltip = flavor_spa.c.3150.tt
		add_reform_desire = -0.01
		add_stability_or_adm_power = yes
		add_ruler_modifier = {
			name = religious_tolerance
		}
	}
}

# Expulsion of the Moors
country_event = {
	id = flavor_spa.3151
	title = "flavor_spa.EVTNAME3151"
	desc = "flavor_spa.EVTDESC3151"
	picture = ECONOMY_eventPicture

	is_triggered_only = yes

	option = {		# They are a welcome addition
		name = "flavor_spa.EVTOPTA3151"
		ai_chance = { factor = 90 }
		random_owned_province = {
			add_base_tax = 1
		}
	}

}

# Christopher Columbus
country_event = {
	id = flavor_spa.1
	title = "flavor_spa.EVTNAME1"
	desc = "flavor_spa.EVTDESC1"
	picture = SHIP_SAILING_eventPicture

	is_triggered_only = yes
	
	trigger = {
		NOT = { has_global_flag = columbus_happened }
		has_idea = quest_for_the_new_world
		OR = {
			NOT = {
				north_america = {
					has_discovered = ROOT
				}
			}
			NOT = {
				south_america = {
					has_discovered = ROOT
				}
			}
			NOT = {
				any_known_country = {
					north_america = {
						has_discovered = PREV
					}
				}
			}
			NOT = {
				any_known_country = {
					south_america = {
						has_discovered = PREV
					}
				}
			}
		}
	}

	option = {		# Reject his proposal
		name = "flavor_spa.EVTOPTA1"
		ai_chance = { factor = 10 }
		set_country_flag = turned_down_columbus
		random_known_country = {
			limit = {
				NOT = { has_country_flag = turned_down_columbus }
				religion = catholic
				has_idea = quest_for_the_new_world
			}
			country_event = { id = flavor_spa.1 }
		}
	}
	option = {		# Hire Columbus
		name = "flavor_spa.EVTOPTB1"
		ai_chance = { factor = 90 }
		add_years_of_income = -0.25
		set_global_flag = columbus_happened
		define_explorer = {
			name = "NAME_CRISTOBAL_COLON"
			fire = 2
			shock = 2
			manuever = 6
			siege = 0
		}
	}
}

# Discovery of the New World!
country_event = {
	id = flavor_spa.1005
	title = "flavor_spa.EVTNAME1005"
	desc = "flavor_spa.EVTDESC1005"
	picture = COLONIZATION_eventPicture
	
	
	fire_only_once = yes
	
	trigger = {
		NOT = { has_global_flag = new_world_discovered }
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		OR = {
			north_america = {
				has_discovered = ROOT
			}
			south_america = {
				has_discovered = ROOT
			}
			new_world = {
				has_discovered = ROOT
			}
		}
	}

	mean_time_to_happen = {
		months = 1
	}
	
	immediate = {
		set_global_flag = new_world_discovered
	}

	option = {		# Now so have we!
		name = "flavor_spa.EVTOPTA1005"
		add_prestige = 50
		add_innovativeness_small_effect = yes
	}
}

# Ignacio de Loyola
country_event = {
	id = flavor_spa.1011
	title = "flavor_spa.EVTNAME1011"
	desc = "flavor_spa.EVTDESC1011"
	picture = ADVISOR_eventPicture


	fire_only_once = yes

	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		religion = catholic
		is_year = 1521
		NOT = { is_year = 1556 }
	}

	mean_time_to_happen = {
		months = 100
	}
	

	option = {		# An Excellent Minister!
		name = "EXCELLENTMINISTER"
		add_adm_power = 50
		add_papal_influence = 25
		define_advisor = {
			type = theologian 
			culture = basque
			religion = catholic
			name = "Ignacio de Loyola"
			discount = yes
			skill = 2
		}
	}
}

# The Quest for the New World
country_event = {
	id = flavor_spa.3152
	title = "flavor_spa.EVTNAME3152"
	desc = "flavor_spa.EVTDESC3152"
	picture = EXPLORERS_eventPicture

	fire_only_once = yes	

	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		religion = catholic
		OR = {
			north_america = {
				has_discovered = ROOT
			}
			south_america = {
				has_discovered = ROOT
			}
		}

	}

	mean_time_to_happen = {
		months = 64
	}


	option = {		# A New Reconquista! We need Conquistadors
		name = "flavor_spa.EVTOPTA3152"
		ai_chance = { factor = 45 }
		define_conquistador = {
			fire = 2
			shock = 2
			manuever = 5
		}
		add_mil_power = 50
	}
	option = {		# A New Reconquista! We need Explorers
		name = "flavor_spa.EVTOPTB3152"
		ai_chance = { factor = 45 }
		define_explorer = {
			fire = 2
			shock = 2
			manuever = 5
		}
		add_mil_power = 50
	}

}

# Crusade against Oran
country_event = {
	id = flavor_spa.1000
	title = "flavor_spa.EVTNAME1000"
	desc = "flavor_spa.EVTDESC1000"
	picture = BATTLE_eventPicture

	fire_only_once = yes	
	
	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		337 = {
			owned_by = ROOT
		}
	}

	mean_time_to_happen = {
		months = 100
	}
	

	option = {		# Expansion in North Africa seems prosperous
		name = "flavor_spa.EVTOPTA1000"
		add_prestige = 10
		add_years_of_income = 0.05
	}
}

# Laws of Burgos
country_event = {
	id = flavor_spa.1001
	title = "flavor_spa.EVTNAME1001"
	desc = "flavor_spa.EVTDESC1001"
	picture = REFORM_eventPicture
	
	fire_only_once = yes	
	
	trigger = {
		tag = SPA

		is_year = 1500
		NOT = { is_year = 1600 }
		colony = 3
		
	}

	mean_time_to_happen = {
		months = 100
	}
	

	option = { # Enforce these laws!
		name = "flavor_spa.EVTOPTA1001"
		ai_chance = { factor = 75 }
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		every_subject_country = {
			limit = {
				is_colonial_nation_of = ROOT
			}
			add_country_modifier = {
				name = laws_of_the_burgos
				duration = -1
			}
		}
		
	}
	option = { # We rule by the right of Conqueror!
		name = "flavor_spa.EVTOPTB1001"
		ai_chance = { factor = 25 }
		add_prestige = 25
	}
}


# Casa de Contratacin
country_event = {
	id = flavor_spa.1003
	title = "flavor_spa.EVTNAME1003"
	desc = "flavor_spa.EVTDESC1003"
	picture = COLONIZATION_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			AND = {
				NOT = { has_dlc = "Golden Century" }
				OR = {
					AND = {
						tag = CAS
						NOT = { exists = SPA }
					}
					tag = SPA
				}
				num_of_colonists = 2
			}
			has_country_flag = spa_house_of_trade_flag
		}
	}

	mean_time_to_happen = {
		months = 120
	}


	option = {		# We should establish it
		name = "flavor_spa.EVTOPTA1003"
		ai_chance = { factor = 90 }
		add_country_modifier = {
			name = casa_de_contratacion
			duration = -1
		}
		clr_country_flag = spa_house_of_trade_flag
	}
}

# The Sun Never Sets
country_event = {
	id = flavor_spa.1004
	title = "flavor_spa.EVTNAME1004"
	desc = "flavor_spa.EVTDESC1004"
	picture = COURT_eventPicture
	
	
	fire_only_once = yes
	trigger = {

		tag = SPA

		europe = {
			country_or_vassal_holds = ROOT
		}		
		north_america = {
			country_or_vassal_holds = ROOT
		}		
		south_america = {
			country_or_vassal_holds = ROOT
		}
		africa = {
			country_or_vassal_holds = ROOT
		}
		asia = {
			country_or_vassal_holds = ROOT
		}
	}

	mean_time_to_happen = {
		months = 64
	}
	

	option = {		# We truly rule the world!
		name = "flavor_spa.EVTOPTA1004"
		add_prestige = 25
		add_legitimacy = 25
		add_papal_influence = 100
	}
}

# The Trade Center of Sevilla
country_event = {
	id = flavor_spa.3153
	title = "flavor_spa.EVTNAME3153"
	desc = "flavor_spa.EVTDESC3153"
	picture = MERCHANTS_TALKING_eventPicture

	fire_only_once = yes

	trigger = {
		OR = {
			AND = {
				NOT = { has_dlc = "Golden Century" }
				tag = SPA

				owns = 224	# Andalucia
				colony = 3
			}
			has_country_flag = sevilla_trade_center_flag
		}
	}

	mean_time_to_happen = {
		months = 120
	}
	

	option = {		# We now have control of our Oversea Trade
		name = "flavor_spa.EVTOPTA3153"
		224 = {
			add_province_modifier = {
				name = port_to_the_new_world
				duration = -1
			}
		}
	}
}

# The Fuggers
country_event = {
	id = flavor_spa.3154
	title = "flavor_spa.EVTNAME3154"
	desc = "flavor_spa.EVTDESC3154"
	picture = COURT_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = SPA
		is_year = 1500
		NOT = { is_year = 1600 }
	}

	mean_time_to_happen = {
		months = 240
	}
	

	option = {		# Let the Fuggers run our Finances
		name = "flavor_spa.EVTOPTA3154"
		add_ruler_modifier = {
			name = the_fuggers
		}
	}
	option = {		# Turn the Fuggers offer down
		name = "flavor_spa.EVTOPTB3154"
		add_legitimacy = 5
	}
}

# The Communeros
country_event = {
	id = flavor_spa.3155
	title = "flavor_spa.EVTNAME3155"
	desc = "flavor_spa.EVTDESC3155"
	picture = ANGRY_MOB_eventPicture


	fire_only_once = yes

	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		is_year = 1500
		NOT = { is_year = 1600 }
	}

	mean_time_to_happen = {
		months = 300
	}
	

	option = {		# Crush the Rebellion
		name = "flavor_spa.EVTOPTA3155"
		every_owned_province = {
			limit = {
				region = iberia_region
			}
			add_unrest = 10
		}
	}
	option = {		# Give concessions to the Peasantry
		name = "flavor_spa.EVTOPTB3155"
		add_ruler_modifier = {
			name = concessions_to_the_peasantry
		}
	}
}


# State Bankruptcy
country_event = {
	id = flavor_spa.3158	
	title = "flavor_spa.EVTNAME3158"
	desc = "flavor_spa.EVTDESC3158"
	picture = BANKRUPTCY_eventPicture


	fire_only_once = yes


	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		is_bankrupt = yes
		NOT = { is_year = 1590 }
	}

	mean_time_to_happen = {
		months = 12
	}
	

	option = {		# Do we ever learn from history?
		name = "flavor_spa.EVTOPTA3158"
		add_legitimacy = -5
	}
}

# The Expulsion of the Moriscos
country_event = {
	id = flavor_spa.3160	
	title = "flavor_spa.EVTNAME3160"
	desc = "flavor_spa.EVTDESC3160"
	picture = ANGRY_MOB_eventPicture
	
	
	fire_only_once = yes

	trigger = {
		tag = SPA
		religion = catholic
		NOT = { primary_culture = andalucian }
		NOT = { exists = GRA }
		is_year = 1600
		
		any_owned_province = {
			culture = andalucian	
		}
		NOT = { has_dlc = "Golden Century" }
	}
	
	immediate = {
		hidden_effect = {
			set_global_flag = expulsion_of_the_moriscos_flag
		}
	}

	mean_time_to_happen = {
		months = 140
	}

	option = {		# Force them to become Good Catholic Spaniards
		name = "flavor_spa.EVTOPTA3160"
		ai_chance = { factor = 90 }
		add_papal_influence = 25

		every_owned_province = {
			limit = {
				culture = andalucian	
			}
			add_unrest = 5
		}
		random_country = {
			limit = {
				religion_group = muslim
				any_owned_province = {
					sea_zone = {
						any_neighbor_province = {
							owned_by = ROOT
						}
					}
				}
			}
			country_event = {  id = flavor_spa.3161 days = 10 tooltip = "flavor_spa.EVTTOOLTIP3160" }
		}
	}
	option = {		# Let them be as they are needed for the economy
		name = "flavor_spa.EVTOPTB3160"
		add_papal_influence = -25
	}
}

# Expulsion of the Moriscos
country_event = {
	id = flavor_spa.3161
	title = "flavor_spa.EVTNAME3161"
	desc = "flavor_spa.EVTDESC3161"
	picture = ECONOMY_eventPicture

	is_triggered_only = yes

	option = {		# They are a welcome addition
		name = "flavor_spa.EVTOPTA3161"
		ai_chance = { factor = 90 }
		random_owned_province = {
			add_base_tax = 1
		}
	}

}

# Baltasar de Zuniga
country_event = {
	id = flavor_spa.3710
	title = "flavor_spa.EVTNAME3710"
	desc = "flavor_spa.EVTDESC3710"
	picture = ADVISOR_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		is_year = 1591
		NOT = { is_year = 1622 }
	}

	mean_time_to_happen = {
		months = 100
	}



	option = {			# An Excellent Minister!
		name = "EXCELLENTMINISTER"
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		add_adm_power = 40
		add_dip_power = 40
		add_mil_power = 40
		define_advisor = {
			type = statesman
			name = "Baltasar de Zuniga"
			discount = yes
			skill = 3
		}
	}
}

# Olivares
country_event = {
	id = flavor_spa.3711
	title = "flavor_spa.EVTNAME3711"
	desc = "flavor_spa.EVTDESC3711"
	picture = ADVISOR_eventPicture
	
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		is_year = 1617
		NOT = { is_year = 1645 }
	}

	mean_time_to_happen = {
		months = 64
	}

	immediate = {
		set_country_flag = SPA_had_event_3711
	}

	option = {			# An Excellent Minister!
		name = "EXCELLENTMINISTER"
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		add_adm_power = 100
		add_dip_power = 100
		add_mil_power = 100
		define_advisor = {
			type = statesman
			name = "Conde-Duque Olivares"
			culture = umbrian
			discount = yes
			skill = 3
		}
	}
}

# The Portuguese Crown
country_event = {
	id = flavor_spa.3162	
	title = "flavor_spa.EVTNAME3162"
	desc = "flavor_spa.EVTDESC3162"
	picture = COURT_eventPicture

	fire_only_once = yes

	trigger = {
		tag = SPA
		marriage_with = POR
		is_subject = no
		POR = {
			exists = yes
			ai = yes
			was_player = no
			is_subject = no
			has_regency = yes
			religion = ROOT
			NOT = { is_rival = SPA }
			has_opinion = { who = ROOT value = 150 }
		}
		is_year = 1550
		NOT = { is_year = 1650 }
	}

	mean_time_to_happen = {
		months = 2000
	}
	

	option = {		# One King, Two Kingdoms
		name = "flavor_spa.EVTOPTB3162"
		ai_chance = { factor = 90 }
		create_union = POR
	}
	option = {		# The extra burden is not worth it
		name = "flavor_spa.EVTOPTC3162"
		ai_chance = { factor = 10 }
		add_prestige = 1
	}
}


# State Bankruptcy
country_event = {
	id = flavor_spa.3164	
	title = "flavor_spa.EVTNAME3164"
	desc = "flavor_spa.EVTDESC3164"
	picture = BANKRUPTCY_eventPicture


	fire_only_once = yes
	trigger = {
		tag = SPA
		is_year = 1590
		is_bankrupt = yes
	}

	mean_time_to_happen = {
		months = 12
	}
	
	option = {		# Do we ever learn from history?
		name = "flavor_spa.EVTOPT3164"
		add_prestige = -5
	}
}

# Epidemic Plague
country_event = {
	id = flavor_spa.3165	
	title = "flavor_spa.EVTNAME3165"
	desc = "flavor_spa.EVTDESC3165"
	picture = PLAGUE_eventPicture


	fire_only_once = yes
	trigger = {
		tag = SPA
		num_of_cities = 4
		iberia_region = {
			owned_by = ROOT
		}
		is_year = 1550
		NOT = { is_year = 1700 }		
	
	}

	mean_time_to_happen = {
		months = 120
	}
	

	option = {		# We will recover
		name = "flavor_spa.EVTOPTA3165"
		add_country_modifier = { 
			name = severe_plague 
			duration = 1825
		}		
	}
}

# The Iberian Revolts
country_event = {
	id = flavor_spa.3169
	title = "flavor_spa.EVTNAME3169"
	desc = "flavor_spa.EVTDESC3169"
	picture = ANGRY_MOB_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = SPA

		num_of_cities = 10
		
		is_year = 1600
		NOT = { is_year = 1700 }


		NOT = { primary_culture = catalan }
		any_owned_province = {
			culture = catalan
		}
	}

	mean_time_to_happen = {
		months = 400
	}
	

	option = {		# Put it down!
		name = "flavor_spa.EVTOPTA3169"
		every_owned_province = {
			limit = {
				culture = catalan
			}
			add_unrest = 20
		}
	}
	option = {		# Appease them!
		name = "flavor_spa.EVTOPTB3169"
		every_owned_province = {
			limit = {
				culture = catalan
			}
			add_local_autonomy = 25
		}
	}
}

# National revolt in Portugal
country_event = {
	id = flavor_spa.3168	
	title = "flavor_spa.EVTNAME3168"
	desc = "flavor_spa.EVTDESC3168"
	picture = DIPLOMACY_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = SPA

		num_of_cities = 10
		
		is_year = 1600
		NOT = { is_year = 1700 }


		NOT = { primary_culture = portugese }
		any_owned_province = {
			culture = portugese
		}
	}

	mean_time_to_happen = {
		months = 400
	}
	
	option = {		# Put it down!
		name = "flavor_spa.EVTOPTA3168"
		every_owned_province = {
			limit = {
				culture = portugese
			}
			add_unrest = 20
		}
	}
	option = {		# Appease them!
		name = "flavor_spa.EVTOPTB3168"
		every_owned_province = {
			limit = {
				culture = portugese
			}
			add_local_autonomy = 25
		}
	}	
	
}

# The Italian Revolts
country_event = {
	id = flavor_spa.3170
	title = "flavor_spa.EVTNAME3170"
	desc = "flavor_spa.EVTDESC3170"
	picture = ANGRY_MOB_eventPicture
	
	fire_only_once = yes

	trigger = {
		tag = SPA

		num_of_cities = 10
		
		is_year = 1600
		NOT = { is_year = 1700 }


		any_owned_province = {
			region = italy_region
		}
	}

	mean_time_to_happen = {
		months = 400
	}
	

	option = {		# Put it down!
		name = "flavor_spa.EVTOPTA3170"
		every_owned_province = {
			limit = {
				region = italy_region
			}
			add_unrest = 20
		}
	}
	option = {		# Appease them!
		name = "flavor_spa.EVTOPTB3170"
		every_owned_province = {
			limit = {
				region = italy_region
			}
			add_local_autonomy = 25
		}
	}	
	

}

# Giulio Alberoni
country_event = {
	id = flavor_spa.3712
	title = "flavor_spa.EVTNAME3712"
	desc = "flavor_spa.EVTDESC3712"
	picture = ADVISOR_eventPicture
	
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		is_year = 1694
		NOT = { is_year = 1752 }
	}

	mean_time_to_happen = {
		months = 150
	}

	
	option = {			# An Excellent Minister!
		name = "EXCELLENTMINISTER"
		add_dip_power = 100
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		define_advisor = {
			type = statesman
			culture = romagnan
			religion = catholic
			name = "Giulio Alberoni"
			discount = yes
			skill = 2
		}
	}
}

# Jos Monino
country_event = {
	id = flavor_spa.3094
	title = "flavor_spa.EVTNAME3094"
	desc = "flavor_spa.EVTDESC3094"
	picture = ADVISOR_eventPicture
	
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		is_year = 1758
		NOT = { is_year = 1808 }
	}

	mean_time_to_happen = {
		months = 120
	}
	
	option = {			# An Excellent Minister!
		name = "EXCELLENTMINISTER"
		add_adm_power = 100
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		define_advisor = {
			type = statesman
			name = "Jos Monino"
			culture = andalucian
			discount = yes
			skill = 3
		}
	}
}

# The Constitution of 1812
country_event = {
	id = flavor_spa.3095
	title = "flavor_spa.EVTNAME3095"
	desc = "flavor_spa.EVTDESC3095"
	picture = DEBATE_REPUBLICAN_eventPicture
	
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		is_year = 1800
		NOT = { has_reform = parliamentary_reform }
		NOT = { has_reform = celestial_empire }
		government = monarchy
	}

	mean_time_to_happen = {
		months = 10
	}

	option = {		# Follow the Cortes
		name = "flavor_spa.EVTOPTA3095"
		ai_chance = { factor = 75 }
		add_government_reform = parliamentary_reform
		#set_legacy_government = constitutional_monarchy
	}
	option = {		# Resist these liberals!
		name = "flavor_spa.EVTOPTB3095"
		ai_chance = { factor = 25 }
		add_stability = -1
	}
}



########################################
# Minor Flavor Events                  #
########################################

# Miguel de Cervantes
country_event = {
	id = flavor_spa.1100
	title = "flavor_spa.EVTNAME1100"
	desc = "flavor_spa.EVTDESC1100"
	picture = ADVISOR_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = SPA
		is_year = 1577
		NOT = { is_year = 1616 }
	}

	mean_time_to_happen = {
		months = 100
	}
	
	option = {		# Excellent
		name = "EXCELLENT"
		add_dip_power = 50
		
	}
}

# Toms Luis de Victoria
country_event = {
	id = flavor_spa.1101
	title = "flavor_spa.EVTNAME1101"
	desc = "flavor_spa.EVTDESC1101"
	picture = THEATRE_eventPicture
	
	fire_only_once = yes
	trigger = {
		tag = SPA
		is_year = 1578
		NOT = { is_year = 1611 }
	}

	mean_time_to_happen = {
		months = 100
	}
	
	immediate = {
		set_country_flag = SPA_had_event_1101
	}

	option = {		# Excellent
		name = "EXCELLENT"
		add_prestige = 25
	}
}

########################################
# The Italian Wars
########################################

# The Italian Wars
country_event = {
	id = flavor_spa.1007
	title = "flavor_spa.EVTNAME1007"
	desc = "flavor_spa.EVTDESC1007"
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = ITALIAN_wars_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = MILITARY_CAMP_eventPicture
	}
	
	fire_only_once = yes
	
	
	trigger = {
		tag = SPA
		exists = FRA
		is_year = 1490
		NOT = { is_year = 1590 }
		NOT = { alliance_with = FRA }
		NOT = { is_subject_of = FRA }
		NOT = { war_with = FRA }
		italy_region = {
			is_part_of_hre = yes
		}
		italy_region = {
			owned_by = FRA
		}
	}
	
	


	mean_time_to_happen = {
		months = 100
	}
	
	

	option = {		# Claim all French land in Italy!
		name = "flavor_spa.EVTOPTA1007"
		ai_chance = { factor = 90 }
		FRA = {
			add_opinion = {
				who = ROOT
				modifier = claimed_italy
			}
			every_owned_province = {
				limit = {
					region = italy_region
				}
				add_claim = ROOT
			}
			hidden_effect = {
				country_event = { id = flavor_spa.1008 days = 10 }
			}
		}
	}
	option = {		# Italy lies outside our sphere of interest
		name = "flavor_spa.EVTOPTB1007"
		ai_chance = { factor = 10 }
		add_prestige = -10
	}
}




# The Italian Wars
country_event = {
	id = flavor_spa.1008
	title = "flavor_spa.EVTNAME1008"
	desc = "flavor_spa.EVTDESC1008"
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = ITALIAN_wars_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = MILITARY_CAMP_eventPicture
	}
	
	is_triggered_only = yes
	
	option = {		# Then counter-claim all ADJECTIVE provinces!
		name = "flavor_spa.EVTOPTA1008"
		ai_chance = { factor = 90 }
		FROM = {
			every_owned_province = {
				limit = {
					region = italy_region
				}
				add_claim = ROOT
			}
			tooltip = {
				add_opinion = {
					who = ROOT
					modifier = claimed_italy
				}
			}
			hidden_effect = {
				country_event = { id = flavor_spa.1009 days = 10 }
			}
		}
	}
	option = {		# We should back down in Italy
		name = "flavor_spa.EVTOPTB1008"
		ai_chance = { factor = 10 }
		add_prestige = -10
	}
}

# The Italian Wars
country_event = {
	id = flavor_spa.1009
	title = "flavor_spa.EVTNAME1009"
	desc = "flavor_spa.EVTDESC1009"
	picture = {	
		trigger = {
			has_dlc = "Emperor"
		}
		picture = ITALIAN_wars_eventPicture
	}
	picture = {	
		trigger = {
			NOT = { has_dlc = "Emperor" }
		}
		picture = MILITARY_CAMP_eventPicture
	}
	
	is_triggered_only = yes
	
	option = {		# How dare they?! Italy is ours!
		name = "flavor_spa.EVTOPTA1009"
		add_opinion = {
			who = FROM
			modifier = claimed_italy
		}
	}
}

###################################
# Additional Flavor Events
# Scripted by Henrik Lohmander
###################################

#Valladolid Debate
country_event = {
	id = flavor_spa.2
	title = "flavor_spa.2.t"
	desc = "flavor_spa.2.d"
	picture = UNIVERSITY_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		religion = catholic
		is_year = 1540
		NOT = { is_year = 1570 }
		colony = 3 #colonial aristocracy exists
		OR = {
			north_america = {
				country_or_vassal_holds = ROOT
			}		
			south_america = {
				country_or_vassal_holds = ROOT
			}
		}
		owns = 215 #Valladolid
	}
	
	mean_time_to_happen = {
		months = 90
	}
	
	

	option = {		# Allow Seplveda's arguments to shape our policies
		name = "flavor_spa.2.a"
		ai_chance = {
			factor = 15
			modifier = {
				factor = 2
				has_idea_group = religious_ideas
			}
		}
		add_country_modifier = {
			name = "valladolid_sepulveda_motherland"
			duration = 3650
		}
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		if = {
			limit = {
				any_subject_country = {
					is_colonial_nation = yes
				}
			}
			custom_tooltip = every_colonial_subject_gains_tt
			tooltip = {
				random_subject_country = {
					limit = {
						is_colonial_nation_of = ROOT
					}
					add_country_modifier = {
						name = "valladolid_sepulveda"
						duration = 3650
					}
				}
			}
			hidden_effect = {
				every_subject_country = {
					limit = {
						is_colonial_nation_of = ROOT
					}
					add_country_modifier = {
						name = "valladolid_sepulveda"
						duration = 3650
					}
				}
			}
		}
	}
	option = {		# Inconclusive result
		name = "flavor_spa.2.b"
		ai_chance = { factor = 70 }
		add_prestige = 10 #For holding the debate
	}
	option = {		# Let Las Casas Arguments shape our policies
		name = "flavor_spa.2.c"
		ai_chance = {
			factor = 15
			modifier = {
				factor = 2
				has_idea_group = humanist_ideas
			}
		}
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		if = {
			limit = {
				any_subject_country = {
					is_colonial_nation = yes
				}
			}
			custom_tooltip = every_colonial_subject_gains_tt
			tooltip = {
				random_subject_country = {
					limit = {
						is_colonial_nation_of = ROOT
					}
					add_country_modifier = {
						name = "valladolid_las_casas"
						duration = 3650
					}
					add_opinion = {
						who = ROOT
						modifier = "angered_colonial_land_owners"
					}
				}
			}
			hidden_effect = {
				every_subject_country = {
					limit = {
						is_colonial_nation_of = ROOT
					}
					add_country_modifier = {
						name = "valladolid_las_casas"
						duration = 3650
					}
					add_opinion = {
						who = ROOT
						modifier = "angered_colonial_land_owners"
					}
				}
			}
		}
	}
}

#Alhambra Decree
country_event = {
	id = flavor_spa.3
	title = "flavor_spa.3.t"
	desc = "flavor_spa.3.d"
	picture = REFORM_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		NOT = { exists = GRA }
		religion = catholic
		has_idea = spanish_inquisition
		is_at_war = no
		is_year = 1480
		NOT = {
			is_year = 1540
		}
	}
	
	mean_time_to_happen = {
		months = 180
	}
	

	option = {		# Extradition or Conversion
		name = "flavor_spa.3.a"
		ai_chance = {
			factor = 70
		}
		add_country_modifier = {
			name = "alhambra_decree"
			duration = 3650
		}
		PAP = {
			add_opinion = {
				who = ROOT
				modifier = "alhambra_decree_opinion"
			}
		}
	}
	option = {		# Let them Stay
		name = "flavor_spa.3.b"
		ai_chance = {
			factor = 30
			modifier = {
				factor = 2
				has_idea_group = humanist_ideas
			}
		}
		add_prestige = 10
		if = {
			limit = {
				has_dlc = "Leviathan"
			}
			add_country_modifier = {
				name = "alhambra_working_force"
				duration = 3650
			}
		}
	}
}

# Unification of Spain / Nueva Planta Decrees
country_event = {
	id = flavor_spa.4
	title = "flavor_spa.4.t"
	desc = "flavor_spa.4.d"
	picture = ELECTION_REPUBLICAN_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		tag = SPA #This one requires you to actually be Spain
		OR = {
			has_reform = constitutional_monarchy
			has_reform = constitutional_republic
			has_reform = parliamentary_reform
		}
		is_at_war = no
		NOT = { has_country_modifier = decentralization_modifier }
		owns_core_province = 1749
		owns_core_province = 206
		owns_core_province = 210
		owns_core_province = 220
		owns_core_province = 213
		owns_core_province = 214
		owns_core_province = 208
		owns_core_province = 217
		NOT = { exists = CAS }
		NOT = { exists = ARA }
		NOT = { exists = NAV }
		NOT = { exists = GAL }
		NOT = { exists = LON }
	}
	
	mean_time_to_happen = {
		months = 1	#Should trigger shortly after becoming a constitutional state.
	}
	

	option = {		# One Cortes for a united Spain
		name = "flavor_spa.4.a"
		ai_chance = {
			factor = 90
		}
		add_adm_power = -50
		add_country_modifier = {
			name = "unification_of_spain"
			duration = -1
		}
	}
	option = {		# Continue to be the ruler of all Spains
		name = "flavor_spa.4.b"
		ai_chance = {
			factor = 10
		}
		add_country_modifier = {
			name = "cortes_defended"
			duration = 3650
		}
		if = {
			limit = {
				has_dlc = "Common Sense"
			}
			every_owned_province = {
				limit = {
					OR = {
						province_id = 1749
						province_id = 206
						province_id = 210
						province_id = 220
						province_id = 213
						province_id = 214
						province_id = 208
						province_id = 217
					}
					has_seat_in_parliament = no
				}
				set_seat_in_parliament = yes #Has to placate all the local Cortes from now on.
			}
		}
		else = {
			every_owned_province = {
				limit = {
					OR = {
						province_id = 1749
						province_id = 206
						province_id = 210
						province_id = 220
						province_id = 213
						province_id = 214
						province_id = 208
						province_id = 217
					}
					is_capital = no
				}
				add_local_autonomy = 50
			}
		}
	}
}

# Grammar of the Castilian Language (localized to whatever culture formed Spain)
country_event = {
	id = flavor_spa.5
	title = "flavor_spa.5.t"
	desc = "flavor_spa.5.d"
	picture = BIG_BOOK_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		tag = SPA
		is_year = 1490
		num_of_cities = 25
	}
	
	mean_time_to_happen = {
		months = 150
	}
	

	option = {		# Promote the use of Castilian Language in government
		name = "flavor_spa.5.a"
		ai_chance = {
			factor = 90
		}
		add_ruler_modifier = {
			name = "castilian_grammar"
		}
	}
	option = {		# We must respect the many cultures of Spain
		name = "flavor_spa.5.b"
		ai_chance = {
			factor = 10
		}
		add_ruler_modifier = {
			name = "promote_regional_languages"
		}
	}
}

# Slo Madrid es corte
country_event = {
	id = flavor_spa.6
	title = "flavor_spa.6.t"
	desc = "flavor_spa.6.d"
	picture = CITY_DEVELOPMENT_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		tag = SPA
		owns_core_province = 217 #Madrid
		NOT = { capital = 217 } #Madrid
		num_of_cities = 25
		government = monarchy
		is_year = 1520
		NOT = { is_year = 1580 }
	}
	
	mean_time_to_happen = {
		months = 180
	}
	

	option = {		# Move the Court to Madrid
		name = "flavor_spa.6.a"
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { primary_culture = castillian }
			}
		}
		set_capital = 217
		217 = {
			add_province_modifier = {
				name = "solo_madrid_es_corte"
				duration = 3650
			}
			if = { 
				limit = { 
					NOT = { trade_goods = glass }
				}
				change_trade_goods = glass
			}
		}
	}
	option = {		# X remains a fine capital.
		name = "flavor_spa.6.b"
		ai_chance = {
			factor = 10
		}
		add_stability_or_adm_power = yes
	}
}

# War of Las Alpujarras
country_event = {
	id = flavor_spa.7
	title = "flavor_spa.7.t"
	desc = "flavor_spa.7.d"
	picture = BORDER_TENSION_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		religion = catholic
		NOT = { is_year = 1600 } #Resurgent Granada unlikely
		has_country_flag = spa_holy_inquisition
		NOT = { exists = GRA }
		owns = 223 #Granada
		any_owned_province = {
			NOT = { has_province_modifier = forced_conversion }
			region = iberia_region
			culture = andalucian
			is_core = GRA
		}
		OR = {
			has_country_flag = torquemada_expelled
			AND = {
				NOT = { has_country_flag = torquemada_expelled }
				any_owned_province = {
					is_core = GRA
					has_missionary = yes #Persecution despite choosing tolerance
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 60
	}
	
	immediate = {
		hidden_effect = {
			random_owned_province = {
				limit = {
					region = iberia_region
					is_core = GRA
					OR = {
						fort_level = 1
						province_id = 223
					}
				}
				set_province_flag = alpujarras_centre_of_revolt
			}
			every_owned_province = {
				limit = {
					region = iberia_region
					is_core = GRA
					NOT = { has_province_flag = alpujarras_centre_of_revolt }
				}
				set_province_flag = alpujarras_revolt
			}
		}
	}
	
	option = {		# Ok.
		name = "flavor_spa.7.a"
		add_stability = -1
		set_country_flag = alpujarras_revolt_happened
		random_owned_province = {
			limit = {
				has_province_flag = alpujarras_centre_of_revolt
			}
			if = {
				limit = { NOT = { religion = sunni } }
				change_religion = sunni #Crypto-Muslims
			}
			spawn_rebels = {
				type = nationalist_rebels
				leader = "Abn Umayyad"
				friend = GRA
				size = 2
				win = yes
			}
			clr_province_flag = alpujarras_centre_of_revolt
		}
		every_owned_province = {
			limit = {
				has_province_flag = alpujarras_revolt
			}
			if = {
				limit = { NOT = { religion = sunni } }
				change_religion = sunni #Crypto-Muslims
			}
			spawn_rebels = {
				type = nationalist_rebels
				friend = GRA
				size = 1
			}
			clr_province_flag = alpujarras_revolt
		}
	}
}

#Fate of the Kingdom of Granada
country_event = {
	id = flavor_spa.8
	title = "flavor_spa.8.t"
	desc = "flavor_spa.8.d"
	picture = MILITARY_CAMP_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		OR = {
			has_country_flag = fate_of_granada_mission_flag
			AND = {
				NOT = { has_dlc = "Golden Century" }
				OR = {
					AND = {
						tag = CAS
						NOT = { exists = SPA }
					}
					tag = SPA
				}
				has_country_flag = alpujarras_revolt_happened
				NOT = { has_country_flag = end_of_granada }
				NOT = { exists = GRA }
				owns = 223 #Granada
				NOT = {
					any_owned_province = {
						is_core = GRA
						controlled_by = REB
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 12
	}
	
	option = {		# Expulsion or conversion!
		name = "flavor_spa.8.a"
		ai_chance = {
			factor = 1
		}
		set_country_flag = end_of_granada
		add_papal_influence = 25
		add_stability = -1
		every_owned_province = {
			limit = {
				is_core = GRA
			}
			change_religion = catholic
			remove_core = GRA
		}
		#Repeat of effect from earlier persecutions:
		random_country = {
			limit = {
				religion_group = muslim
				any_owned_province = {
					sea_zone = {
						any_neighbor_province = {
							owned_by = ROOT
						}
					}
				}
			}
			country_event = {  id = flavor_spa.3151 days = 10 tooltip = "flavor_spa.EVTTOOLTIP3150" }
		}
	}
	option = {		# We must mend these wounds not cut off the limb itself.
		name = "flavor_spa.8.b"
		if = {
			limit = { NOT = { stability = 3 } }
			add_stability_or_adm_power = yes
		}
		add_papal_influence = -25
		if = {
			limit = { stability = 3 }
			every_owned_province = {
				limit = {
					is_core = GRA
				}
				add_unrest = -2
			}
		}
		ai_chance = {
			factor = 0
		}
	}
}

# New Testament Translated into Spanish
country_event = {
	id = flavor_spa.9
	title = "flavor_spa.9.t"
	desc = "flavor_spa.9.d"
	picture = BIG_BOOK_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		is_religion_enabled = protestant
		government = monarchy
		religion = catholic
		is_year = 1530
		NOT = { is_year = 1560 }
		NOT = {
			iberia_region = {
				is_reformation_center = yes
			}
		}
		NOT = {
			num_of_owned_provinces_with = {
				value = 4
				region = iberia_region
				OR = {
					religion = reformed
					religion = protestant
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 90
	}
	
	option = {		# Best to nip this in the bud.
		name = "flavor_spa.9.a"
		ai_chance = {
			factor = 9
			modifier = {
				factor = 0.1
				has_idea_group = humanist_ideas
			}
		}
		add_ruler_modifier = {
			name = "supressing_spanish_protestantism"
		}
	}
	option = {		# Let us not stifle free thought, this is a fine humanist work.
		name = "flavor_spa.9.b"
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				has_country_modifier = counter_reformation
			}
		}
		add_country_modifier = {
			name = "spanish_bible_translation"
			duration = 7300
		}
	}
}

# Ottoman Encroachment in the Mediterrenean
# Deposed Hafsid ruler seeks Spanish Aid
country_event = {
	id = flavor_spa.10
	title = "flavor_spa.10.t"
	desc = "flavor_spa.10.d"
	picture = NAVAL_MILITARY_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		OR = {
			AND = {
				tag = CAS
				NOT = { exists = SPA }
			}
			tag = SPA
		}
		religion = catholic
		OR = {
			NOT = { exists = TUN }
			TUN = { vassal_of = ROOT }
		}
		TUR = {
			NOT = { alliance_with = ROOT }
			NOT = { war_with = ROOT }
			num_of_cities = 40
			NOT = { religion_group = christian }
			owns = 341 #Tunis
		}
	}
	
	mean_time_to_happen = {
		months = 24
	}
	
	option = {		# We must act to contain this threat!
		name = "flavor_spa.10.a"
		ai_chance = {
			factor = 1
		}
		TUR = {
			add_opinion = {
				who = ROOT
				modifier = supporting_tunisian_claimant
			}
		}
		341 = {
			add_claim = ROOT
		}
	}
	option = {		# Our interests lie elsewhere.
		name = "flavor_spa.10.b"
		add_prestige = -5
		TUR = {
			add_opinion = {
				who = ROOT
				modifier = turned_down_tunisian_claimant
			}
		}
		ai_chance = {
			factor = 0
		}
	}
}

# Reforming the Colonial Administration (Bourbon Reforms)
country_event = {
	id = flavor_spa.11
	title = "flavor_spa.11.t"
	desc = "flavor_spa.11.d"
	picture = GOOD_WITH_MONARCH_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		tag = SPA
		is_year = 1700
		government = monarchy
		colony = 3
	}
	
	mean_time_to_happen = {
		months = 150
	}
	
	option = {		# Reform our colonial administration.
		name = "flavor_spa.11.a"
		ai_chance = {
			factor = 1
		}
		add_adm_power = -75
		add_country_modifier = {
			name = "spa_new_colonial_reforms"
			duration = -1
		}
		every_subject_country = {
			limit = {
				is_colonial_nation_of = ROOT
			}
			add_country_modifier = {
				name = "spa_new_colonial_reforms_subject"
				duration = 7300
			}
			add_opinion = {
				who = ROOT
				modifier = "spa_colonial_reforms"
			}
		}
	}
	option = {		# Let us not rock the boat.
		name = "flavor_spa.11.b"
		ai_chance = {
			factor = 0
		}
		every_subject_country = {
			limit = {
				is_colonial_nation_of = ROOT
			}
			add_liberty_desire = -5
			add_opinion = {
				who = ROOT
				modifier = "colonial_privileges_kept"
			}
		}
	}
}

# Supression of the Society of Jesus
country_event = {
	id = flavor_spa.12
	title = "flavor_spa.12.t"
	desc = "flavor_spa.12.d"
	picture = POPE_PREACHING_eventPicture
	
	fire_only_once = yes
	
	
	trigger = {
		tag = SPA 
		religion = catholic
		colony = 3
		is_year = 1750
		government = monarchy
		has_country_modifier = the_societas_jesu
	}
	
	mean_time_to_happen = {
		months = 150
	}
	
	option = {		#Expel all Jesuits and auction of their property - Sacrifice tech and missionary strength of colonial vassals for a one time money boost post 1750.
		name = "flavor_spa.12.a"
		ai_chance = {
			factor = 1
		}
		add_years_of_income = 0.25 #Auctioning of Reductions and other property
		add_prestige = -10
		remove_country_modifier = the_societas_jesu
		every_subject_country = {
			limit = {
				is_colonial_nation_of = ROOT
				religion = catholic
			}
			every_owned_province = {
				limit = { has_province_modifier = jesuit_mission }
				remove_province_modifier = jesuit_mission
			}
			add_years_of_income = 0.25 #Auctioning of Reductions and other property
			add_country_modifier = {
				name = "jesuits_expelled" #Long term effects of expulsion
				duration = -1
			}
			add_liberty_desire = -5 #Jesuits support colonial autonomy.
		}
	}
	option = {		# Their contributions to our Society has been too great to measure.
		name = "flavor_spa.12.b"
		add_prestige = 25
		ai_chance = {
			factor = 0
		}
	}
}


#A Habsburg Heir in Spain
country_event = {
	id = flavor_spa.13
	title = flavor_spa.13.t
	desc = flavor_spa.13.d
	picture = NEW_HEIR_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			tag = SPA
			AND = {
				tag = CAS
				NOT = {
					exists = SPA
				}
			}
		}
		has_heir = no
		is_lesser_in_union = no
		marriage_with = HAB
		HAB = {
			dynasty = "0000000000"
			OR = {
				NOT = {
					has_country_flag = bur_marriage_successor
				}
				ai = no
			}
		}
		NOT = {
			dynasty = HAB
		}
		FRA = {
			is_rival = HAB
			is_rival = ROOT
		}
		NOT = {
			OR = {
				is_rival = HAB
				war_with = HAB
				HAB = {
					is_rival = SPA
				}
				AND = {
					HAB = {
						is_rival = CAS
					}
					NOT = {
						exists = SPA
					}
				}
			}
		}
		NOT = {
			dynasty = FRA
		}
		ruler_age = 20
		has_government_attribute = heir
	}
	
	mean_time_to_happen = {
		months = 6
	}
	
	option = {
		name = flavor_spa.13.a
		define_heir = {
			claim = 100
			dynasty = "0000000000"
		}
		hidden_effect = {
			HAB = {
				country_event = { id = flavor_spa.14 }
			}
		}
	}
}

#Habsburg in Spain notification for Austria
country_event = {
	id = flavor_spa.14
	title = flavor_spa.14.t
	desc = flavor_spa.14.d
	picture = NEW_HEIR_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = flavor_spa.14.a
		add_prestige = 5
	}
}

#The Low Countries Pass to Spain
country_event = {
	id = flavor_spa.15
	title = flavor_spa.15.t
	desc = flavor_spa.15.d
	picture = NEW_HEIR_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			tag = SPA
			AND = {
				tag = CAS
				NOT = {
					exists = SPA
				}
			}
		}
		has_heir = no
		is_lesser_in_union = no
		marriage_with = HAB
		is_at_war = no
		HAB = {
			ai = yes
			is_at_war = no
			OR = {
				any_subject_country = {
					any_owned_province = {
						OR = {
							region = low_countries_region
							area = picardy_area
						}
					}
				}
				any_owned_province = {
					OR = {
						region = low_countries_region
						area = picardy_area
					}
				}
			}
			dynasty = "0000000000"
		}
		ruler_age = 20
		NOT = { is_rival = HAB }
		NOT = { war_with = HAB }
		NOT = {
			HAB = {
				is_rival = ROOT
			}
		}
		has_government_attribute = heir
	}
	
	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 0.5
			NOT = {
				dynasty = HAB
			}
		}
		modifier = {
			factor = 0.5
			FRA = {
				is_rival = HAB
				is_rival = ROOT
			}
			NOT = {
				dynasty = FRA
			}
		}
		modifier = {
			factor = 0.5
			HAB = {
				dynasty = "0000000000"
			}
		}
		modifier = {
			factor = 0.5
			HAB = {
				OR = {
					any_subject_country = {
						num_of_owned_provinces_with = {
							OR = {
								region = low_countries_region
								area = picardy_area
							}
							value = 5
						}
					}
					num_of_owned_provinces_with = {
						OR = {
							region = low_countries_region
							area = picardy_area
						}
						value = 5
					}
				}
			}
		}
	}
	
	option = {
		name = flavor_spa.15.a
		ai_chance = {
			factor = 85
		}
		define_heir = {
			claim = 100
			dynasty = "0000000000"
			age = 0
		}
		custom_tooltip = flavor_spa.15.tt
		hidden_effect = {
			low_countries_region = {
				limit = {
					owner = {
						OR = {
							tag = HAB
							is_subject_of = HAB
						}
						ai = yes
					}
				}
				add_core = ROOT
				remove_core = HAB
				cede_province = ROOT
			}
			picardy_area = {
				limit = {
					owner = {
						OR = {
							tag = HAB
							is_subject_of = HAB
						}
						ai = yes
					}
				}
				add_core = ROOT
				remove_core = HAB
				cede_province = ROOT
			}
			HAB = {
				country_event = { id = flavor_spa.14 }
			}
		}
	}

	option = {
		name = flavor_spa.15.b
		ai_chance = {
			factor = 15
		}
		define_heir = {
			claim = 100
			dynasty = "0000000000"
			age = 0
		}
		hidden_effect = {
			HAB = {
				country_event = { id = flavor_spa.14 }
			}
		}
	}
}

# Merino Wool and the Mesta by Daniel Tolman

# Merino Wool
country_event = {
	id = flavor_spa.16
	title = flavor_spa.16.t
	desc = flavor_spa.16.d
	picture = ECONOMY_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			tag = SPA
			AND = {
				tag = CAS
				NOT = {
					exists = SPA
				}
			}
		}
		NOT = { is_year = 1550 }
		any_owned_province = {
			region = iberia_region
			trade_goods = wool
		}
		has_estate = estate_church
		has_estate = estate_nobles
	}
	
	mean_time_to_happen = {
		months = 120
	}
	
	option = {
		name = "flavor_spa.16.a"
		every_owned_province = {
			limit = {
				region = iberia_region
				trade_goods = wool
			}
			add_province_modifier = {
				name = merino_wool
				duration = -1
			}
		}
		give_estate_land_share_medium = { estate = estate_nobles }
		give_estate_land_share_medium = { estate = estate_church }
	}
}

# The Mesta
country_event = {
	id = flavor_spa.17
	title = flavor_spa.17.t
	desc = flavor_spa.17.d
	picture = ECONOMY_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		is_year = 1550
		OR = {
			tag = SPA
			AND = {
				tag = CAS
				NOT = {
					exists = SPA
				}
			}
		}
		any_owned_province = {
			has_province_modifier = merino_wool
		}
	}
	
	mean_time_to_happen = {
		months = 120
	}
	
	option = {
		name = "flavor_spa.17.a"
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -10
		}
		take_estate_land_share_small = { estate = estate_nobles }
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -10
		}
		take_estate_land_share_small = { estate = estate_church }
		every_owned_province = {
			limit = {
				has_province_modifier = merino_wool
			}
			remove_province_modifier = merino_wool
			change_trade_goods = cloth
			add_province_modifier = {
				name = "mesta_privileged_revoked"
				duration = -1
			}
		}
	}
	option = {
		name = "flavor_spa.17.b"
		add_estate_loyalty = {
			estate = estate_church
			loyalty = 20
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = 20
		}
		every_owned_province = {
			limit = {
				has_province_modifier = merino_wool
			}
			add_local_autonomy = 5
		}
	}
}


#1.35 Events# 

country_event = { #The Infantes of Aragon
	id = flavor_spa.18
	title = flavor_spa.18.t
	desc = flavor_spa.18.d
	picture = DIPLOMACY_eventPicture
	fire_only_once = yes 
	is_triggered_only = yes 	
	
	option = { 
		name = flavor_spa.18.a 
		set_country_flag = cas_royalist_flag
		add_stability = -1
		random_owned_province = {
			limit = { 
				region = iberia_region 
				controlled_by = ROOT 
			}
			spawn_rebels = {
				type = noble_rebels
				size = 3
				win = yes 
				should_take_capital = yes
			}
		}
		random_owned_province = {
			limit = { 
				region = iberia_region 
				controlled_by = ROOT 
			}
			spawn_rebels = {
				type = noble_rebels
				size = 2
				win = yes 
				should_take_capital = yes
			}
		}
		custom_tooltip = cas_impact_mission_tt
	}
	
	option = { 
		name = flavor_spa.18.b
		set_country_flag = cas_infantes_flag
		
		random_owned_province = {
			limit = { 
				region = iberia_region 
				controlled_by = ROOT 
			}
			spawn_rebels = {
				type = noble_rebels
				size = 2
				leader = "Alvaro de Luna"
				win = yes 
				should_take_capital = yes
			}
		}
		hidden_effect = {
			if = {
				limit = {
					has_leader = "0000000000"
				}
				kill_leader = {
					type = "Alvaro de Luna"
				}
			}
		}
		custom_tooltip = cas_impact_mission_tt
	}
}

country_event = { # End of the Infantes 
	id = flavor_spa.20
	title = flavor_spa.20.t
	desc = flavor_spa.20.d
	picture = GOOD_WITH_MONARCH_eventPicture
	fire_only_once = yes 
	is_triggered_only = yes 
	immediate = {
		on_non_estate_disaster_end = yes
	}
	
	option = { 
		name = flavor_spa.20.a 
		
		add_legitimacy = 20 
		if = { 
			limit = { has_country_flag = cas_royalist_flag }
			change_estate_land_share = { 
				estate = all 
				share = -5
			}
		}
		else = { 
			add_estate_loyalty = {
				estate = estate_nobles 
				loyalty = 20 
			}
			custom_tooltip = spa_no_isabella_event_tt
			set_country_flag = no_isabella_event_flag
		}
		add_yearly_manpower = 2
		set_country_flag = ended_infantes_disaster_flag
	}    
}

# country_event = { #
	# id = flavor_spa.21
	# title = flavor_spa.21.t
	# desc = flavor_spa.21.d
	# picture = GOOD_WITH_MONARCH_eventPicture
	# fire_only_once = yes 
	# is_triggered_only = yes 
	
	# option = { 
		# name = flavor_spa.21.a 
		
		
	# }
# }

country_event = { #The Spanish Dollar
	id = flavor_spa.22
	title = flavor_spa.22.t
	desc = flavor_spa.22.d
	picture = MERCHANTS_TALKING_eventPicture
	fire_only_once = yes 
	is_triggered_only = yes 
	
	option = { 
		name = flavor_spa.22.a 
		
		add_country_modifier = {
			name = spa_spanish_dollar_modifier
			duration = 7300
		}
		
		change_ruler_stat = {
			type = adm
			amount = 1
		}
		
	}
}

country_event = { #San Lorenzo de El Escorial 
	id = flavor_spa.23
	title = flavor_spa.23.t
	desc = flavor_spa.23.d
	picture = GREAT_BUILDING_eventPicture
	fire_only_once = yes 
	is_triggered_only = yes 
	goto = 217
	option = { 
		name = flavor_spa.23.a 
		
		if = { 
			limit = { has_dlc = "Leviathan" } 
			217 = {
				add_great_project_tier = {
					type = el_escorial
					tier = 2 
				}
			}
		}
		else = {
			add_country_modifier = {
				name = spa_san_lorenzo_escorial_modifier
				duration = 9125
			}
			217 = {
				add_base_production = 2 
				add_base_manpower = 1
			}
		}
	}
}

country_event = { #Ferdinand Magellan
	id = flavor_spa.199
	title = flavor_spa.199.t
	desc = flavor_spa.199.d
	picture = HARBOUR_eventPicture
	is_triggered_only = yes 
	
	immediate = {
		set_country_flag = had_magellan_event_flag
	}
	
	option = { 
		name = flavor_spa.199.a 
		
		ai_chance = { factor = 5 }
		define_explorer = {
			name = "Ferdinand Magellan"
			fire = 4 
			shock = 4 
			manuever = 6
			siege = 1
			trait = great_explorer_personality
		}
		if = {
			limit = { has_dlc = "Rule Britannia" }
			change_innovativeness = 2
		}
		else = { add_adm_power = 25 add_dip_power = 25 }
	}
	
	option = {
		name = flavor_spa.199.b 
		ai_chance = { factor = 5 }
		add_prestige_or_monarch_power = { amount = 15 } 
		if = {
			limit = { has_estate = estate_church }
			add_estate_loyalty = {
				estate = estate_church 
				loyalty = 20 
			}
		}
		if = {
			limit = { 
				OR = { 
					tag = SPA 
					tag = CAS
				}
				POR = { 
					NOT = { has_country_flag = had_magellan_event_flag }
				}
			}
			POR = { 
				country_event = { id = flavor_spa.199 }
			}
		}
		else_if = {
			limit = { 
				tag = POR 
				SPA = { 
					exists = yes 
					NOT = { has_country_flag = had_magellan_event_flag }
				}
			}
			SPA = { 
				country_event = { id = flavor_spa.199 }
			}
		}
		else_if = {
			limit = { 
				tag = POR 
				CAS = { 
					exists = yes 
					NOT = { has_country_flag = had_magellan_event_flag }
				}
			}
			CAS = { 
				country_event = { id = flavor_spa.199 }
			}
		}
	}			
}
	
	
	