get_an_alliance_mission = {

	type = neighbor_countries

	allow = {
		this = { NOT = { num_of_allies = 2 } }
		NOT = { num_of_allies = 2 }
		not = { is_threat = this }
		war = no
		relation = { who = THIS value = 50 }
		NOT = { alliance_with = THIS }
		NOT = { is_subject = yes }
		this = { NOT = { is_subject = yes } } 
	}
	abort = {
		OR = {
			war_with = THIS
			this = { num_of_allies = 3 }
			not = { num_of_cities = 1 }
		}
	}

	success = {
		alliance_with = THIS
	}
	
	chance = {
		factor = 1
		modifier = {
			factor = 1.5
			culture = THIS
		}
		modifier = {
			factor = 1.5
			religion = THIS
		}
		modifier = {
			factor = 1.5
			DIP = 6
		}
		modifier = {
			factor = 0.5
			NOT = { DIP = 5 }
		}
		modifier = {
			factor = 2.0
			num_of_cities = 10
		}		
	}
	effect = {
		THIS = { prestige = 0.03 }
	}	
}

improve_relations_mission = {

	type = neighbor_countries

	allow = {
		war = no
		religion_group = THIS
		NOT = { relation = { who = THIS value = 0 } }
		
	}
	abort = {
		or = {
			war_with = THIS
			not = { num_of_cities = 1 }
		}
	}

	success = {
		relation = { who = THIS value = 100 }
	}
	
	chance = {
		factor = 1
		modifier = {
			factor = 1.5
			culture = THIS
		}
		modifier = {
			factor = 1.5
			religion = THIS
		}
		modifier = {
			factor = 1.5
			DIP = 6
		}
		modifier = {
			factor = 0.5
			NOT = { DIP = 5 }
		}
	}
	effect = {
		THIS = { prestige = 0.03 }
	}	
}


generic_annex_vassal_mission = {
	
	type = neighbor_provinces

	allow = {
		this = { war = no }
		owner = {
			is_subject = yes
			vassal_of = THIS
			not = { num_of_cities = this }
			religion_group = this
		}
		not = { is_core = THIS }
	}
	abort = {
		owner = {
			or = {
				not = { religion_group = this }
				not = { num_of_cities = 1 }
				not = { vassal_of = this }
			}
		}
	}
	success = {
		owned_by = this
	}
	chance = {
		factor = 1
		modifier = {
			factor = 1.5
			DIP = 6
		}
		modifier = {
			factor = 1.5
			DIP = 8
		}
	}
	effect = {
		add_core = this
	}
}


improve_reputation_mission = {
	type = country
	allow = {
		infamy = 0.7
		ai = no
		NOT = { infamy = 0.9 }
	}
	abort = {
		infamy = 1.0
	}
	success = {
		NOT = { infamy = 0.5 }
	}
	chance = {
		factor = 1
		modifier = {
			factor = 1.5
			DIP = 6
		}
		modifier = {
			factor = 1.5
			DIP = 8
		}
	}
	effect = {
		define_advisor = { type = diplomat skill = 4 }
	}
			
}

vassalize_mission = {
	type = neighbor_countries

	allow = {
		war = no
		this = { 
			government = monarchy 
			is_subject = no 
			num_of_cities = 5
		}
		NOT = { num_of_cities = 3 }
		government = monarchy
		religion_group = THIS
		marriage_with = THIS
		is_subject = no 
		NOT = {  
			war_with = THIS
		}
		relation = { who = THIS value = 100 }
	}
	abort = {
		OR = {
			NOT = { num_of_cities = 1 }	#exists wont work, as we dont know the tag.
			war_with =  THIS
			and = {
				is_subject = yes
				not = { vassal_of = this }
			}
		}
	}

	success = {
		vassal_of = THIS
	}
	
	chance = {
		factor = 1
		modifier = {
			factor = 1.5
			culture = THIS
		}
		modifier = {
			factor = 1.5
			religion = THIS
		}
		modifier = {
			factor = 1.5
			DIP = 6
		}
		modifier = {
			factor = 1.5
			DIP = 8
		}	
		modifier = {
			factor = 1.5
			num_of_cities = 10
		}
		modifier = {
			factor = 0.5
			NOT = { DIP = 5 }
		}
	}
	
	immediate = {
		casus_belli = {
			type = cb_vassalize_mission
			months = 120
			target = THIS
		}
	}
	abort_effect = {
		remove_casus_belli = {
			type = cb_vassalize_mission
			target = THIS
		}
	}

	# The effect always has country scope (for the country that gets the mission)
	effect = {
		THIS = { infamy = -1 }
		remove_casus_belli = {
			type = cb_vassalize_mission
			target = THIS
		}
	}	
}

royal_marriage_mission = {

	type = neighbor_countries

	allow = {
		war = no

		this = { 
			government = monarchy
			is_subject = no 
		}
		government = monarchy
		religion_group = THIS
		is_subject = no 
		NOT = {  
			marriage_with = THIS 
			war_with = THIS
		}
		relation = { who = THIS value = 50 }
		
	}
	abort = {
		OR = {
			NOT = { num_of_cities = 1 }	#exists won't work, as we don't know the tag.
			war_with =  THIS
			this = {
				or = {
					not = { government = monarchy }
					is_subject = yes
				}
			}
			not = { government = monarchy }
			is_subject = yes
		}
	}

	success = {
		marriage_with = THIS
	}
	
	chance = {
		factor = 1
		modifier = {
			factor = 1.5
			culture = THIS
		}
		modifier = {
			factor = 1.5
			religion = THIS
		}
		modifier = {
			factor = 1.5
			DIP = 6
		}
		modifier = {
			factor = 0.5
			NOT = { DIP = 5 }
		}
	}

	# The effect always has country scope (for the country that gets the mission)
	effect = {
		THIS = { infamy = -1 }
	}	
}

improve_relations_with_rival = {

	type = rival_countries 

	allow = {
		war = no
		this = { infamy = 10 }
		NOT = {  relation = { who = THIS value = 0 }  }
	}
	
	abort = {
		not = { num_of_cities = 1 }
	}
	success = {
		relation = { who = THIS value = 0 }
	}
	
	chance = {
		factor = 1
		modifier = {
			factor = 1.5
			culture = THIS
		}
		modifier = {
			factor = 1.5
			religion = THIS
		}
		modifier = {
			factor = 1.5
			DIP = 6
		}
		modifier = {
			factor = 0.5
			NOT = { DIP = 5 }
		}
	}

	# The effect always has country scope (for the country that gets the mission)
	effect = {
		THIS = { infamy = -1 }
	}	
}




