﻿namespace = l6_christian

#Conversion of the 3000
l6_christian.1 = {
	type = country_event
	title= "l6_christian.1.t"
	desc = "l6_christian.1.desc"
	picture = crucifixion
	
	#left_portrait = current_ruler
	
	fire_only_once = yes

	goto_location = p:687
	
	trigger = {
		current_date >= 783.5.20 #30AD (should it be 33AD?) just over 40 days after passover
		current_date <= 786.6.21
		#p:687 = {
		#	owner = root
		#}
		any_owned_province = {
			any_pops_in_province = {
				OR = {
					pop_culture = hebrew
					pop_religion = judaism
				}
			}
		}
	}
	
	immediate = {
		if = {
			limit = {
				NOT = {
					has_global_variable = christianity_spreads_locally
				}
			}
			p:687 = {
				random_pops_in_province = {
					set_pop_religion = christianity
				}
				random_pops_in_province = {
					set_pop_religion = christianity
				}
				random_pops_in_province = {
					set_pop_religion = christianity
				}
			}
		}	
	}
	
	option = {
		name = "l6_christian.1.a"
		if = {
			limit = {
				NOT = {
					has_global_variable = christianity_spreads_locally
				}
			}
			p:687 = {
				random_pops_in_province = {
					set_pop_religion = christianity
				}
				random_pops_in_province = {
					set_pop_religion = christianity
				}
				random_pops_in_province = {
					set_pop_religion = christianity
				}
			}
			set_global_variable = {
				name = christianity_spreads_locally
			}
		}	
	}
}
	
#Conversion of Paul
l6_christian.2 = {
	type = country_event
	title= "l6_christian.2.t"
	desc = "l6_christian.2.desc"
	picture = crucifixion
	
	#left_portrait = current_ruler
	
	fire_only_once = yes

	goto_location = p:750
	
	#
	
	trigger = {
		current_date >= 789.5.20 #36AD 
		current_date <= 818.1.25 #65AD
		has_global_variable = christianity_spreads_locally
		#p:750 = {
		#	owner = root
		#}
		any_owned_province = {
			any_pops_in_province = {
				OR = {
					pop_culture = hebrew
					pop_religion = judaism
				}
			}
		}
	}
	
	immediate = {
		if = {
			limit = {
				NOT = {
					p:750 = {
						dominant_province_religion = christianity
					}
				}
			}
			p:750 = {
				random_pops_in_province = {
					set_pop_religion = christianity
				}
			}
		}	
	}
	
	option = {
		name = "l6_christian.2.a"
		if = {
			limit = {
				NOT = {
					has_global_variable = christianity_expands
				}
			}
			p:750 = {
				random_pops_in_province = {
					set_pop_religion = christianity
				}
			}
			set_global_variable = {
				name = christianity_expands
			}
		}	
	}
}

##########
#Christianity Spreads Locally - regions near the Holy Land
l6_christian.3 = {
	type = minor_country_event
	title= "l6_christian.3.t"
	desc = "l6_christian.3.desc"
	picture = crucifixion
	interface_lock = no
	
	left_portrait = current_ruler
	
	trigger = {
		has_global_variable = christianity_spreads_locally
		NOR = {
			religion = manichaeism
			religion = christianity
		}
		any_owned_province = {
			OR = {
				is_in_region = palestine_region
				is_in_region = syria_region
				is_in_region = lower_egypt_region
			}
			NOR = {
				has_province_modifier = early_christian_church
				has_province_modifier = early_christian_community
				has_variable = early_xian_persecution
			}
			any_pops_in_province = {
				NOR = { 
					pop_religion = christianity 
					pop_religion = judaism
				}
			}
		}
	}

	immediate = {
		random_owned_province = {
			limit = {
				OR = {
					is_in_region = palestine_region
					is_in_region = syria_region
					is_in_region = lower_egypt_region
				}
				NOR = {
					has_province_modifier = early_christian_community
					has_province_modifier = early_christian_church
					has_variable = early_xian_persecution
				}
				any_pops_in_province = {
					NOR = { 
						pop_religion = christianity 
						pop_religion = judaism
					}
				}
			}	
			save_scope_as = l6_christian_3_target
		}	
	}
	
	option = {
		name = "l6_christian.3.a"
		scope:l6_christian_3_target = {
			ordered_pops_in_province = {
				limit = {
					NOR = {
						pop_religion = christianity
						pop_religion = judaism
					}
				}
				order_by = pop_hapiness
				max = {
					value = total_population
					divide = 3
				}
				check_range_bounds = no
				set_pop_religion = christianity
			}
			if = {
				limit = {
					root = { num_of_cities > 1 }
					OR = {
						total_population > 80
						AND = {
							province_id = 687
							total_population > 20
						}
					}	
				}	
				add_permanent_province_modifier = {
					name = "early_christian_church"
				}
			}
			else = {
				add_province_modifier = {
					name = "early_christian_community"
					duration = 144000
				}
			}	
		}
	}
}

#Jews Convert To Christianity - any region
l6_christian.4 = {
	type = minor_country_event
	title= "l6_christian.4.t"
	desc = "l6_christian.4.desc"
	picture = crucifixion
	interface_lock = no
	
	left_portrait = current_ruler
	
	trigger = {
		has_global_variable = christianity_spreads_locally
		OR = {
			has_global_variable = jewish_diaspora
			NOR = {
				has_global_variable = jewish_diaspora
				religion_pops_in_country = {
					target = christianity
					value >= rare_deity_svalue
				}
			}		 
		}
		NOR = {
			religion = manichaeism
			religion = christianity
		}
		current_date >= 885.7.30
		any_owned_province = {
			any_pops_in_province = {
				pop_religion = judaism
			}
			NOT = {
				dominant_province_religion = christianity
			}
		}
	}
	
	option = {
		name = "l6_christian.4.a"
		random_owned_province = {
			limit = {
				NOT = {
					province_id = 687
				}
				any_pops_in_province = {
					count > 6
				}
				any_pops_in_province = {
					pop_religion = judaism
				}
			}
			ordered_pops_in_province = {
				limit = {
					pop_religion = judaism
				}
				order_by = pop_hapiness
				max = {
					value = total_population
					divide = 6
				}
				check_range_bounds = no
				set_pop_religion = christianity
			}
		}
	}
}

#Gentiles Convert - provinces next to/with Christians
l6_christian.5 = {
	type = minor_country_event
	title= "l6_christian.5.t"
	desc = "l6_christian.5.desc"
	picture = crucifixion
	interface_lock = no
	
	left_portrait = current_ruler
	
	trigger = {
		current_date > 853.12.31
		has_global_variable = christianity_expands
		NOR = {
			religion = manichaeism
			religion = christianity
			has_variable = medium_xian_kerygma_target
			has_variable = small_xian_kerygma_target
			has_variable = tiny_xian_kerygma_target
		}
		NAND = {
			is_ai = yes
			current_date < 953.12.31
			NOT = {
				religion = roman_pantheon
			}	
			capital_scope = {
				dominant_province_religion = christianity
			}
			religion_pops_in_country = {
				target = christianity
				value >= 25
			}
		}
		any_owned_province = {
			NOR = {
				is_in_region = scandinavia_region
				is_in_region = venedia_region
				is_in_region = germania_region
				is_in_region = germania_superior_region
				is_in_region = bohemia_area
				is_in_region = vistulia_region
				is_in_region = borysthenia_region
				is_in_region = tibet_region
				###Invictus v1.6###########
				is_in_region = burma_region
				is_in_region = central_asian_steppes_region
				####Invictus v1.8########
				is_in_region = hyperborea_region
				#################################
				dominant_province_religion = christianity
			}
			OR = {
				any_neighbor_province = {
					any_pops_in_province = {
						pop_religion = christianity
					}
				}
				any_pops_in_province = {
					pop_religion = christianity
				}
			}
			any_pops_in_province = {
				count > 4
			}	
		}
	}
	
	immediate = {
		random_owned_province = {
			limit = {
				NOR = {
					is_in_region = scandinavia_region
					is_in_region = venedia_region
					is_in_region = germania_region
					is_in_region = germania_superior_region
					is_in_region = bohemia_area
					is_in_region = vistulia_region
					is_in_region = borysthenia_region
					is_in_region = tibet_region
					###Invictus v1.6###########
					is_in_region = burma_region
					is_in_region = central_asian_steppes_region
					####Invictus v1.8###############
					is_in_region = hyperborea_region
					################################
					dominant_province_religion = christianity
				}
				OR = {
					any_neighbor_province = {
						any_pops_in_province = {
							pop_religion = christianity
						}
					}
					any_pops_in_province = {
						pop_religion = christianity
					}
				}
				any_pops_in_province = {
					count > 4
				}	
			}
			save_scope_as = l6_christian_5_target
		}	
	}

	option = {
		name = "l6_christian.5.a"
		scope:l6_christian_5_target = {
			ordered_pops_in_province = {
				limit = {
					NOT = { 
						pop_religion = judaism
					}	
				}
				order_by = pop_hapiness
				max = {
					value = total_population
					divide = 4
				}
				check_range_bounds = no
				set_pop_religion = christianity
			}
		}
	}

	after = {
		if = {
			limit = {
				AND = {
					num_of_cities <= 100
					num_of_cities >= 25
				}
			}
			set_variable = {
				name = medium_xian_kerygma_target
				days = 726 
			}	
		}
		else_if = {
			limit = {
				num_of_cities < 25
				num_of_cities >= 5
			}
			set_variable = {
				name = small_xian_kerygma_target
				days = 1452
			}
		}
		else_if = {
			limit = {
				num_of_cities < 5
			}
			set_variable = {
				name = tiny_xian_kerygma_target
				days = 2904
			}
		}		
	}
}

#Ruler conversion option
##Only if ruler is in civil war (like Constantine) or pops are X% converted
