####################################
# Reconquista = 4 Missions
####################################

finish_reconquista = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		war = no
		iberian_peninsula = {
			owner = { religion_group = muslim }
		}
	}
	abort = {
		OR = {
			not = { religion = catholic }
			AND = {
				not = { iberian_peninsula = { not = { owner = { religion = catholic } } } }
				NOT = { andalusia = { owned_by = THIS } }
			}
		}
	}
	success = {
		not = { iberian_peninsula = { not = { owner = { religion = catholic } } } }
		NOT = { andalusia = { NOT = { owned_by = THIS } } } 
	}
	
	immediate = {
		andalusia = { 
			limit = { NOT = { owned_by = THIS } }
			add_temp_claim = THIS
		}
		iberian_peninsula = {
			limit = { NOT = { owner = { religion = catholic } } } 
			add_temp_claim = THIS
		}
	}
	abort_effect = {
		andalusia = {
			remove_temp_claim = THIS
		}
		iberian_peninsula = {
			remove_temp_claim = THIS
		}
	}

	chance = {
		factor = 1000
		modifier = {
			factor = 10
			exists = GRA
		}
	}
	effect = {
		army_tradition = 0.5
		infamy = -20
	}
}

no_truce_with_the_moors = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		religion = catholic
		war = no
		exists = GRA
		is_subject = no
		is_lesser_in_union = no
	}
	abort = {
		or = {
			NOT = {	exists = GRA } 
			not = { religion = catholic }
			is_subject = yes
			is_lesser_in_union = yes
		}
	}
	
	success = {
		war_with = GRA
	}

	chance = {
		factor = 1000
	}
	effect = {
		stability = 1
	}
}

spain_must_be_christian = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		religion = catholic
		iberian_peninsula = {
			owned_by =  THIS
			NOT = { religion_group = christian }
		}
		NOT = {	exists = GRA } 
		war = no
	}
	abort = {
		NOT = {	religion = catholic  }
	}
	
	success = {
		religion = catholic
		NOT = {
			iberian_peninsula = {
				owned_by =  THIS
				NOT = { religion_group = christian }
			}
		}
	}

	chance = {
		factor = 1000
		modifier = {
			factor = 2
			ADM = 6
		}
		modifier = {
			factor = 0.6
			not = { innovative_narrowminded = 0 }
		}
	}
	effect = {
		innovative_narrowminded = 2
		treasury = 500
	}
}

continue_reconquista = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		
		religion = catholic
		war = no
		
		#no muslims in spain.
		NOT = {
			iberian_peninsula = {
				owner = { religion_group = muslim }
			}
		}
		226 = { owned_by = THIS } 	#We must own Gibraltar.
		334 = { owner = { not = { religion_group = christian } } }	#Tangiers
		335 = { owner = { not = { religion_group = christian } } }	#Melilla
		1751 = { owner = { not = { religion_group = christian } } }	#Ceuta
	}
	abort = {
		335 = { owner = { religion_group = christian } }	#Melilla
		334 = { owner = { religion_group = christian } }	#Tangiers
		1751 = { owner = { religion_group = christian } }	#Ceuta		
		or = {
			335 = { not = { owned_by = this } }	#Melilla
			334 = { not = { owned_by = this } }	#Tangiers
			1751 = { not = { owned_by = this } } #Ceuta
		}
	}
	success = {
		334 = { owned_by = THIS }	#Tangiers
		335 = { owned_by = THIS }	#Melilla
		1751 = { owned_by = THIS }	#Ceuta
	}
	
	immediate = {
		add_temp_claim = 334
		add_temp_claim = 335
		add_temp_claim = 1751
	}
	abort_effect = {
		remove_temp_claim = 334
		remove_temp_claim = 335
		remove_temp_claim = 1751
	}
	
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			MIL = 6
		}
		modifier = {
			factor = 2
			MIL = 7
		}
		modifier = {
			factor = 2
			MIL = 8
		}
		modifier = {
			factor = 10
			idea = deus_vult
		}		
	}
	effect = {
		army_tradition = 0.1
		infamy = -5
	}	
}

##############################################
# New World = 6 Missions
##############################################


spain_discover_america = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		idea = quest_for_the_new_world
		NOT = {
			the_carribean = {
				has_discovered = THIS
			}
		}
		the_carribean = { range = yes }
	}
	abort = {
		or = {
			NOT = {	idea = quest_for_the_new_world  }
			not = { num_of_ports = 1 }
		}
	}
	success = {
		the_carribean = {
			has_discovered = THIS
		}
	}

	chance = {
		factor = 1000
		modifier = {
			factor = 2
			ADM = 6
		}
		modifier = {
			factor = 2
			ADM = 7
		}		
		modifier = {
			factor = 2
			ADM = 8
		}	}
	effect = {
		treasury = 100
		colonists = 4
	}	

}

establish_spanish_carribean = {
	type = country
	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		idea = quest_for_the_new_world
		NOT = {
			the_carribean = {
				owned_by =  THIS
			}
		}
		the_carribean = {
			has_discovered = THIS
			empty = yes
		}
		is_subject = no
		is_lesser_in_union = no
	}
	abort = {
		or = {
			NOT = {
				the_carribean = {
					has_discovered = THIS
					empty = yes
				}
			}
			not = { num_of_ports = 1 }
			is_subject = yes
			is_lesser_in_union = yes
		}
	}
	success = {
		the_carribean = {
			owned_by = THIS
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			ADM = 7
		}
		modifier = {
			factor = 0.1
			war = yes
		}		
	}
	effect = {
		prestige = 0.1
	}
}

discover_spanish_main = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		idea = quest_for_the_new_world
		NOT = {
			the_spanish_main = {
				has_discovered = THIS
			}
		}
		the_spanish_main = { range = yes }
		the_carribean = {
			has_discovered = THIS
		}	
	}
	abort = {
		or = {
			NOT = {	idea = quest_for_the_new_world  }
			not = { num_of_ports = 1 }
		}
	}
	success = {
		the_spanish_main = {
			has_discovered = THIS
		}
	}

	chance = {
		factor = 1000
		modifier = {
			factor = 2
			ADM = 6
		}
		modifier = {
			factor = 2
			ADM = 7
		}		
		modifier = {
			factor = 2
			ADM = 8
		}	}
	effect = {
		treasury = 100
		colonists = 4
	}
}



establish_spanish_main = {
	type = country
	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		idea = quest_for_the_new_world
		NOT = {
			the_spanish_main = {
				owned_by =  THIS
			}
		}
		the_spanish_main = {
			has_discovered = THIS
			empty = yes
		}
		is_subject = no
		is_lesser_in_union = no
	}
	abort = {
		or = {
			NOT = {
				the_spanish_main = {
					has_discovered = THIS
					empty = yes
				}
			}
			not = { num_of_ports = 1 }
			is_subject = yes
			is_lesser_in_union = yes
		}
	}
	success = {
		the_spanish_main = {
			owned_by = THIS
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			ADM = 7
		}
		modifier = {
			factor = 0.1
			war = yes
		}		
	}
	effect = {
		prestige = 0.1
	}
}

discover_la_plata = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		idea = quest_for_the_new_world
		NOT = {
			la_plata_region = {
				has_discovered = THIS
			}
		}
		la_plata_region = { range = yes }
	}
	abort = {
		or = {
			NOT = {	idea = quest_for_the_new_world  }
			not = { num_of_ports = 1 }
		}
	}
	success = {
		la_plata_region = {
			has_discovered = THIS
		}
	}

	chance = {
		factor = 1000
		modifier = {
			factor = 2
			ADM = 6
		}
		modifier = {
			factor = 2
			ADM = 7
		}		
		modifier = {
			factor = 2
			ADM = 8
		}	}
	effect = {
		treasury = 100
		colonists = 4
	}
}


establish_spanish_la_plata = {
	type = country
	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		idea = quest_for_the_new_world
		NOT = {
			la_plata_region = {
				owned_by =  THIS
			}
		}
		la_plata_region = {
			has_discovered = THIS
			empty = yes
		}
		is_subject = no
		is_lesser_in_union = no
	}
	abort = {
		or = {
			NOT = {
				la_plata_region = {
					has_discovered = THIS
					empty = yes
				}
			}
			not = { num_of_ports = 1 }
			is_subject = yes
			is_lesser_in_union = yes
		}
	}
	success = {
		la_plata_region = {
			owned_by = THIS
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			ADM = 7
		}
		modifier = {
			factor = 0.1
			war = yes
		}		
	}
	effect = {
		prestige = 0.1
	}
}

##############################################
# Conquer the Indian nations = 3 Missions
##############################################

conquer_incas = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		war = no
		neighbour = INC
		exists = INC
	}
	abort = {
		NOT = { exists = INC }
	}
	
	success = {
		NOT = { exists = INC }
		808 = { owned_by = THIS }
	}

	chance = {
		factor = 1000
		modifier = {
			factor = 2
			MIL = 10
		}
		modifier = {
			factor = 2
			ADM = 7
		}		
		modifier = {
			factor = 2
			ADM = 8
		}	
	}
	effect = {
		treasury = 1000
		infamy = -5
	}
}

conquer_aztecs = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		war = no
		neighbour = AZT
		exists = AZT
	}
	
	abort = {
		NOT = { exists = AZT }
	}
	success = {
		NOT = { exists = AZT }
		852 = { owned_by = THIS }
	}

	chance = {
		factor = 1000
		modifier = {
			factor = 2
			MIL = 10
		}
		modifier = {
			factor = 2
			ADM = 7
		}		
		modifier = {
			factor = 2
			ADM = 8
		}	
	}
	effect = {
		treasury = 1000
		infamy = -5
	}
}



conquer_zapotecs = {
	type = country

	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		war = no
		neighbour = ZAP
		exists = ZAP
	}
	
	abort = {
		NOT = { exists = ZAP }
	}
	success = {
		NOT = { exists = ZAP }
		847 = { owned_by = THIS }
	}

	chance = {
		factor = 1000
		modifier = {
			factor = 2
			MIL = 10
		}
		modifier = {
			factor = 2
			ADM = 7
		}		
		modifier = {
			factor = 2
			ADM = 8
		}	
	}
	effect = {
		treasury = 1000
		infamy = -5
	}
}


###################################################
# Dutch Revolt - 3 Missions
###################################################
no_surrender_to_the_dutch = {
	type = country
	allow = {
		NOT = { year = 1648 }
		tag = SPA
		neighbour = NED
		exists = NED
		war_with = NED
		is_subject = no
		is_lesser_in_union = no
		NED = {
			is_subject = no
			is_lesser_in_union = no		
		}
		spanish_netherlands = {
			owned_by = THIS
		}
	}
	abort = {
		or = {
			NOT = { war_with = NED }
			is_subject = yes
			is_lesser_in_union = yes
			NED = {
				is_subject = yes
				not = { vassal_of = SPA }
			}
			NED = {
				is_lesser_in_union = yes
				not = { junior_union_with = SPA }				
			}
			and = {
				not = { spanish_netherlands = { owned_by = NED } }
				not = { spanish_netherlands = { owned_by = SPA } }
			}
		}
	}
	success = {
		NOT = { war_with = NED }
		NOT = {
			spanish_netherlands = {
				owned_by = NED
			}
		}
	}
	chance = {
		factor = 1000
	}
	effect = {
		war_exhaustion = -5
		infamy = -5
		prestige = 0.05
	}
}

bring_the_dutch_back_to_catholisism = {
	type = country
	allow = {
		NOT = { year = 1648 }
		tag = SPA
		is_subject = no
		is_lesser_in_union = no
		religion = catholic
		neighbour = NED
		exists = NED
		NOT = { NED = { religion = THIS } }
		spanish_netherlands = {
			owned_by = THIS
		}
		NED = {
			is_subject = no
			is_lesser_in_union = no
		}
	}
	abort = {
		or = {
			NOT = {
				spanish_netherlands = {
					owned_by = THIS
				}
			}
			is_subject = yes
			is_lesser_in_union = yes
			not = { religion = catholic }
		}
	}
	success = {
		NED = { religion = THIS }
	}
	chance = {
		factor = 1000
	}
	effect = {
		prestige = 0.5
		stability = 2
	}	
}

spanish_netherlands_should_be_catholic = {
	type = country
	allow = {
		tag = SPA
		war = no
		religion = catholic 
		spanish_netherlands = {
			owned_by = THIS
			NOT = { religion = catholic }
		}
	}
	abort = {
		or = {
			war = yes
			not = { religion = catholic }
		}
	}
	success = {
		NOT = {
			spanish_netherlands = {
				owned_by =  THIS
				NOT = { religion = catholic }
			}
		}	
	}
	chance = {
		factor = 1000
	}
	effect = {
		stability = 1
		prestige = 0.2
	}
}


###################################################
# Misc Spanish - 2 Missions
###################################################
castille_aragon_relations = {
	type = country
	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		ARA = {
			is_subject = no
			government = monarchy
		}
		exists = ARA
		NOT = { war_with = ARA }
		NOT = { marriage_with = ARA }
		government = monarchy
	}
	abort = {
		or = {
			war_with = ARA
			not = { exists = ARA }
			ARA = {
				not = { government = monarchy }
			}
			not = { government = monarchy }
		}
	}
	success = {
		relation = { who = ARA value = 100 }
		marriage_with = ARA
	}
	chance = {
		factor = 1000
	}
	effect = {
		stability = 1
	}
}

spanish_portugese_relations = {

	type = country
	allow = {
		OR = {
			tag = CAS
			tag = SPA
		}
		exists = POR
		POR = {
			is_subject = no
			government = monarchy
		}
		NOT = { war_with = POR }
		NOT = { marriage_with = POR }
		government = monarchy
	}
	abort = {
		or = {
			war_with = POR
			not = { exists = POR }
			POR = {
				not = { government = monarchy }
			}
			not = { government = monarchy }
		}
	}
	success = {
		relation = { who = POR value = 100 }
		marriage_with = POR
	}

	chance = {
		factor = 1000
	}
	effect = {
		stability = 1

	}
}

###################################################
# Misc Spanish - 2 Missions
###################################################


mediterranean_christian_fleet = {
	type = country
	allow = {
		tag = SPA
		NOT = { year = 1700 }
		126 = { OR = { owned_by = THIS owned_by = KNI } }
		exists = TUR
		TUR = {
			galley = 10
			num_of_ports = 10
			galley = THIS
		}		
	}
	abort = {
		NOT = { exists = TUR }
	}
	success = {
		TUR = {
			NOT = { galley = THIS }
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			MIL = 7
		}	
	}
	effect = {
		war_exhaustion = -1
		navy_tradition = 0.5
	}
}

no_territory_to_france = {
	type = country
	allow = {
		tag = SPA
		war_with = FRA
		NOT = { iberian_peninsula = { owned_by = FRA } }
		FRA = { infantry = THIS cavalry = THIS }		#vs a stronger france.
		FRA = { neighbour = this }
	}
	abort = {
		NOT = { war_with = FRA }
	}
	success = {
		NOT = { war_with = FRA }
		NOT = { iberian_peninsula = { owned_by = FRA } }
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			MIL = 7
		}	
	}
	effect = {
		stability = 3
		war_exhaustion = -5
	}
}

