anglo_portuguese_relations = {

	type = country
	
	allow = {
		tag = POR
		exists = ENG
		not = { war_with = ENG }
		not = { marriage_with = ENG }
		is_lesser_in_union = no
		is_subject = no
		government = monarchy
		ENG = {
			government = monarchy
			is_lesser_in_union = no
			is_subject = no
		}
	}
	abort = {
		or = {
			not = { exists = ENG }
			war_with = ENG
			is_lesser_in_union = yes
			is_subject = yes
			not = { government = monarchy }
			ENG = {
				or = {
					not = { government = monarchy }
					is_lesser_in_union = yes
					is_subject = yes
				}
			}
		}
	}
	success = {
		relation = { who = ENG value = 100 }
		marriage_with = ENG
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			not = { relation = { who = ENG value = 0 } }
		}
	}
	effect = {
		stability = 1
	}
}

monopolize_portuguese_cot = {
	
	type = country

	allow = {
		tag = POR
		trade_tech = 15
		merchants = 4
		portuguese_region = {
			cot = yes
			not = { placed_merchants = 6 }
		}
		not = { last_mission = monopolize_portuguese_cot }
	}
	abort = {
		not = { portuguese_region = { cot = yes } }
	}
	success = {
		portuguese_region = {
			cot = yes
			placed_merchants = 6
		}		
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			idea = national_trade_policy
		}	
	}
	effect = {
		treasury = 40
	}
}

# Castile
castilian_portuguese_relations = {

	type = country
	
	allow = {
		tag = POR
		exists = CAS
		not = { war_with = CAS }
		not = { marriage_with = CAS }
		is_lesser_in_union = no
		is_subject = no
		government = monarchy
		CAS = {
			government = monarchy
			is_lesser_in_union = no
			is_subject = no
		}
	}
	abort = {
		or = {
			not = { exists = CAS }
			war_with = CAS
			is_lesser_in_union = yes
			is_subject = yes
			not = { government = monarchy }
			CAS = {
				or = {
					not = { government = monarchy }
					is_lesser_in_union = yes
					is_subject = yes
				}
			}
		}
	}
	success = {
		relation = { who = CAS value = 100 }
		marriage_with = CAS
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			not = { relation = { who = CAS value = 0 } }
		}
	}
	effect = {
		stability = 1
	}
}

# Spain
spanish_portuguese_relations = {

	type = country
	
	allow = {
		tag = POR
		exists = SPA
		not = { war_with = SPA }
		not = { marriage_with = SPA }
		is_lesser_in_union = no
		is_subject = no
		government = monarchy
		SPA = {
			government = monarchy
			is_lesser_in_union = no
			is_subject = no
		}
	}
	abort = {
		or = {
			not = { exists = SPA }
			war_with = SPA
			is_lesser_in_union = yes
			is_subject = yes
			not = { government = monarchy }
			SPA = {
				or = {
					not = { government = monarchy }
					is_lesser_in_union = yes
					is_subject = yes
				}
			}
		}
	}
	success = {
		relation = { who = SPA value = 100 }
		marriage_with = SPA
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			not = { relation = { who = SPA value = 0 } }
		}
	}
	effect = {
		stability = 1
	}
}

portugal_discovers_the_azores = {

	type = country
	
	allow = {
		tag = POR
		war = no
		not = { 367 = { has_discovered =  this } }
		NOT = { idea = quest_for_the_new_world }
		year = 1425
		num_of_ports = 1
	}
	abort = {
		not = { num_of_ports = 1 }
	}
	success = {
		1567 = { units_in_province = this }
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			not = { innovative_narrowminded = 0 }
		}
	}
	effect = {
		367 = { discover = yes }
	}
}

portugal_discovers_madeira = {

	type = country
	
	allow = {
		tag = POR
		war = no
		not = { 368 = { has_discovered =  this } }
		not = { idea = quest_for_the_new_world }
		year = 1415
		num_of_ports = 1
	}
	abort = {
		not = { num_of_ports = 1 }
	}
	success = {
		OR = {
			not = { num_of_ports = 1 }
			1472 = { units_in_province = this }
			1471 = { units_in_province = this }
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			not = { innovative_narrowminded = 0 }
		}
	}
	effect = {
		368 = { discover = yes }
	}
}

portugal_discovers_the_west_african_coast = {

	type = country
	
	allow = {
		tag = POR
		not = { west_african_coast = { has_discovered =  this } }
		west_african_coast  = { range = yes }
		idea = quest_for_the_new_world
		num_of_ports = 1
	}
	abort = {
		or = {
			not = { num_of_ports = 1 }
			not = { idea = quest_for_the_new_world }
		}
	}
	success = {
		west_african_coast = { has_discovered =  this }
		or = {
			1462 = { units_in_province = this }
			1463 = { units_in_province = this }
			1464 = { units_in_province = this }
			1465 = { units_in_province = this }
			1466 = { units_in_province = this }
			1467 = { units_in_province = this }
			1468 = { units_in_province = this }
			1469 = { units_in_province = this }
			1470 = { units_in_province = this }
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			not = { innovative_narrowminded = 0 }
		}
		modifier = {
			factor = 2
			explorer = 1
		}
	}
	effect = {
		treasury = 50
	}
}

portuguese_colony_in_west_africa = {

	type = country
	
	allow = {
		tag = POR
		west_african_coast = {
			has_discovered = this
			empty = yes
		}
		not = { west_african_coast = { owned_by = this } }
		num_of_ports = 1
	}
	abort = {
		or = {
			not = { num_of_ports = 1 }
			and = {
				not = { west_african_coast = { empty = yes } }
				not = { west_african_coast = { owned_by = this } }
			}
		}
	}
	success = {
		west_african_coast = { owned_by = this }
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			adm = 7
		}
	}
	effect = {
		prestige = 0.1
	}
}

conquer_tangiers = {

	type = country

	allow = {
		tag = POR
		not = { owns = 334 }		# Tangiers
		334 = { owner = { religion_group = muslim } }
		is_lesser_in_union = no
		is_subject = no
	}
	abort = {
		or = {
			334 = { owner = { religion_group = christian } }
			is_lesser_in_union = yes
			is_subject = yes
		}
	}
	success = {
		owns = 334
	}
	immediate = {
		add_temp_claim = 334
	}
	abort_effect = {
		remove_temp_claim = 334
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			mil = 7
		}
	}
	effect = {
		prestige = 0.05
	}
}

conquer_the_north_african_coast = {

	type = country

	allow = {
		tag = POR
		owns = 334		# Tangiers
		not = { owns = 1751 }	# Ceuta
		not = { owns = 342 }	# Toubkhal
		342 = { owner = { religion_group = muslim } }
		1751 = { owner = { religion_group = muslim } }
		is_lesser_in_union = no
		is_subject = no
	}
	abort = {
		or = {
			is_lesser_in_union = yes
			is_subject = yes		
		}
	}
	success = {
		owns = 1751
		owns = 342	
	}
	
	immediate = {
		add_temp_claim = 1751
		add_temp_claim = 342
	}
	abort_effect = {
		remove_temp_claim = 1751
		remove_temp_claim = 342
	}
	
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			mil = 7
		}
	}
	effect = {
		prestige = 0.05
	}
}

portugal_discovers_south_america = {
	type = country

	allow = {
		tag = POR
		idea = quest_for_the_new_world
		not = { brazil_region = { has_discovered = this } }
		brazil_region = { range = yes }
		num_of_ports = 1
	}
	abort = {
		or = {
			not = { num_of_ports = 1 }
			not = {	idea = quest_for_the_new_world  }
		}
	}
	success = {
		brazil_region = { has_discovered = this }
		or = {
			1528 = { units_in_province = this }
			1529 = { units_in_province = this }
			1530 = { units_in_province = this }
			1531 = { units_in_province = this }
			1532 = { units_in_province = this }
			1533 = { units_in_province = this }
			1534 = { units_in_province = this }
			1535 = { units_in_province = this }
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			adm = 6
		}
		modifier = {
			factor = 2
			adm = 7
		}		
		modifier = {
			factor = 2
			adm = 8
		}
	}
	effect = {
		treasury = 100
		colonists = 4
	}
}

portuguese_brazil = {

	type = country
	
	allow = {
		tag = POR
		idea = quest_for_the_new_world
		brazil_region = {
			has_discovered = this
			empty = yes
		}
		not = { brazil_region = { owned_by = this } }
		num_of_ports = 1
	}
	abort = {
		or = {
			not = { num_of_ports = 1 }
			and = {
				not = { brazil_region = { empty = yes } }
				not = { brazil_region = { owned_by = this } }
			}
		}
	}
	success = {
		brazil_region = { owned_by = this }
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			adm = 7
		}
	}
	effect = {
		prestige = 0.1
	}
}

# Castile
brazil_belongs_to_portugal = {

	type = country
	
	allow = {
		tag = POR
		brazil_region = {
			has_discovered = this
			owned_by = this
		}
		exists = CAS
		brazil_region = { owned_by = CAS }
		war_with = CAS
	}
	abort = {
		or = {
			not = { war_with = CAS }
			not = { brazil_region = { owned_by = this } }
		}
	}
	success = {
		not = { brazil_region = { owned_by = CAS } }
		brazil_region = { owned_by = this }
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			mil = 7
		}
		modifier = {
			factor = 2
			CAS = { not = { mil = 4 } }
		}
	}
	effect = {
		prestige = 0.1
	}
}

# Spain
brazil_to_portugal = {

	type = country
	
	allow = {
		tag = POR
		brazil_region = {
			has_discovered = this
			owned_by = this
		}
		exists = SPA
		brazil_region = { owned_by = SPA }
		war_with = SPA
	}
	abort = {
		or = {
			not = { war_with = SPA }
			not = { brazil_region = { owned_by = this } }
		}
	}
	success = {
		not = { brazil_region = { owned_by = SPA } }
		brazil_region = { owned_by = THIS }
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			mil = 7
		}
		modifier = {
			factor = 2
			SPA = { not = { mil = 4 } }
		}
	}
	effect = {
		prestige = 0.1
	}
}

portugal_discovers_india = {
	
	type = country

	allow = {
		tag = POR
		idea = quest_for_the_new_world
		west_african_coast = { has_discovered =  this }
		NOT = { indian_coast = { has_discovered = this } }
		indian_coast = { range = yes }
		num_of_ports = 1
	}
	abort = {
		or = {
			not = { num_of_ports = 1 }
			not = {	idea = quest_for_the_new_world }
		}
	}
	success = {
		indian_coast = { has_discovered = this }
		or = {
			1337 = { units_in_province = this }
			1338 = { units_in_province = this }
			1339 = { units_in_province = this }
			1340 = { units_in_province = this }
			1614 = { units_in_province = this }
			1341 = { units_in_province = this }
			1342 = { units_in_province = this }
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			idea = land_of_opportunity
		}
		modifier = {
			factor = 2
			idea = colonial_ventures
		}
	}
	effect = {
		treasury = 50
		colonists = 3
	}
}

portuguese_control_of_indian_province = {
	
	type = country

	allow = {
		tag = POR
		indian_coast = { has_discovered = this }
		not = { indian_coast = { owned_by = this } }
		num_of_ports = 1
	}
	abort = {
		not = { num_of_ports = 1 }
	}
	success = {
		indian_coast = { owned_by = this }
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			idea = land_of_opportunity
		}
		modifier = {
			factor = 2
			idea = colonial_ventures
		}
	}
	immediate = {
		indian_coast = {
			limit = { port = yes range = yes has_discovered = THIS }
			add_temp_claim = THIS
		}
	}
	abort_effect = {
		indian_coast = {
			remove_temp_claim = THIS
		}
	}
	effect = {
		treasury = 50
	}
}

portugal_discovers_indonesia = {

	type = country
	
	allow = {
		tag = POR
		west_african_coast = { has_discovered =  this }
		not = { indonesian_region = { has_discovered =  this } }
		idea = quest_for_the_new_world
		indonesian_region = { range = yes }
		num_of_ports = 1
	}
	abort = {
		or = {
			not = { num_of_ports = 1 }
			not = { idea = quest_for_the_new_world }
		}
	}
	success = {
		indonesian_region = { has_discovered =  this }
		or = {
			1348 = { units_in_province = this }
			1349 = { units_in_province = this }
			1350 = { units_in_province = this }
			1351 = { units_in_province = this }
			1352 = { units_in_province = this }
			1353 = { units_in_province = this }
			1354 = { units_in_province = this }
			1355 = { units_in_province = this }
			1356 = { units_in_province = this }
			1363 = { units_in_province = this }
			1368 = { units_in_province = this }
			1393 = { units_in_province = this }
			1395 = { units_in_province = this }
			1396 = { units_in_province = this }
			1397 = { units_in_province = this }
			1401 = { units_in_province = this }
			1402 = { units_in_province = this }
			1403 = { units_in_province = this }
			1409 = { units_in_province = this }
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			not = { innovative_narrowminded = 0 }
		}
		modifier = {
			factor = 2
			explorer = 1
		}
	}
	effect = {
		treasury = 50
	}
}

portuguese_colony_in_indonesia = {
	
	type = country

	allow = {
		tag = POR
		indonesian_region = {
			has_discovered = this
			empty = yes
		}
		not = { indonesian_region = { owned_by =  this } }
		colonists = 1
		num_of_ports = 1
	}
	abort = {
		or = {
			not = { num_of_ports = 1 }
			and = {
				not = { indonesian_region = { empty = yes } }
				not = { indonesian_region = { owned_by = this } }
			}
		}
	}
	success = {
		indonesian_region = { owned_by =  this }
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			idea = land_of_opportunity
		}
		modifier = {
			factor = 2
			idea = colonial_ventures
		}
		modifier = {
			factor = 2
			colonists = 2
		}
		modifier = {
			factor = 2
			colonists = 3
		}
	}
	immediate = {
		indonesian_region = {
			limit = { port = yes range = yes has_discovered = THIS }
			add_temp_claim = THIS
		}
	}
	abort_effect = {
		indonesian_region = {
			remove_temp_claim = THIS
		}
	}
	effect = {
		prestige = 0.1
	}
}

establish_trade_in_indonesian_por_cot = {
	
	type = country

	allow = {
		tag = POR
		indonesian_region = {
			has_discovered = this
			cot = yes
			not = { placed_merchants = 1 }
		}
		not = { last_mission = establish_trade_in_indonesian_cot }
	}
	abort = {
		not = { indonesian_region = { cot = yes } }
	}
	success = {
		indonesian_region = {
			cot = yes
			placed_merchants = 5
		}	
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			idea = land_of_opportunity
		}
		modifier = {
			factor = 2
			idea = shrewd_commerce_practise
		}
	}
	effect = {
		treasury = 40
		merchants = 4
	}
}

portugal_discovers_the_far_east = {

	type = country
	
	allow = {
		tag = POR
		west_african_coast = { has_discovered =  this }
		indian_coast = { has_discovered = this }
		not = { japanese_region = { has_discovered = this } }
		not = { chinese_coast = { has_discovered = this } }
		idea = quest_for_the_new_world
		japanese_region = { range = yes }
		chinese_coast = { range = yes }
		num_of_ports = 1
	}
	abort = {
		or = {
			not = { num_of_ports = 1 }
			not = { idea = quest_for_the_new_world }
		}
	}
	success = {
		japanese_region = { has_discovered = this }
		chinese_coast = { has_discovered = this }
		or = {
			1370 = { units_in_province = this }
			1371 = { units_in_province = this }
			1372 = { units_in_province = this }
			1373 = { units_in_province = this }
			1374 = { units_in_province = this }
			1375 = { units_in_province = this }
			1386 = { units_in_province = this }
			1387 = { units_in_province = this }
			1388 = { units_in_province = this }
			1389 = { units_in_province = this }
			1390 = { units_in_province = this }
			1391 = { units_in_province = this }
		}
	}
	chance = {
		factor = 1000
		modifier = {
			factor = 2
			not = { innovative_narrowminded = 0 }
		}
		modifier = {
			factor = 2
			explorer = 1
		}
	}
	effect = {
		treasury = 100
	}
}
