###############################
# Church schisms
#
# Written by Enlil
#
# HRE.1 -> HRE.7 Great Schism
# GEORGIAN.1 -> GEORGIAN.2 Georgian Schism
###############################

namespace = HRE

# To the Emperor
character_event = {
	id = HRE.1
	title = EVTNAMEHRE.1
	desc = EVTDESCHRE.1
	
	picture = GFX_evt_great_schism
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHRE.1

		if = {
			limit = { religion = arian }
			set_parent_religion = { religion = catholic parent = arian }
		}

		set_global_flag = great_schism
		give_nickname = nick_the_schismatic
		hidden_tooltip = {
			narrative_event = { id = HRE.3 }
		}
	}
}

# The Schism itself
narrative_event = {
	id = HRE.3
	title = EVTNAMEHRE.3
	desc = EVTDESCHRE.3
	picture = GFX_evt_great_schism
	
	major = yes
	# religion = nicene
	is_triggered_only = yes

	immediate = {
		d_papal_state = {
			holder_scope = {
				k_papal_state = {
					grant_title = PREV
				}
			}
		}
		d_orthodox = {
			holder_scope = {
				k_orthodox = {
					grant_title = PREV
				}
			}
		}
	}
	option = { # Orthodox
		name = EVTOPTAHRE.3
		trigger = {
			religion = nicene
		}
		ai_chance = {
			factor = 3
			modifier = {
				factor = 10
				culture_group = byzantine # Greek Orthodoxy
			}
			modifier = {
				factor = 20
				any_vassal = { controls_religion = yes }
			}
			modifier = {
				factor = 10
				culture_group = east_slavic # Kiev!!!
			}
			modifier = {
				factor = 5
				culture_group = central_semitic # Byzantine Influences
			}
			modifier = {
				factor = 10
				culture_group = altaic # Orthodoxy in the Steppes
			}
		}
		religion = orthodox
		capital_scope = {
			if = {
				limit = { religion = nicene }
			}
			religion = orthodox
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = orthodox
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = orthodox
		}
	}
	option = { # Catholic
		name = EVTOPTBHRE.3
		trigger = {
			religion = nicene
		}
		ai_chance = {
			factor = 3
			modifier = {
				factor = 10
				culture_group = west_germanic # Duh, Germans!
			}
			modifier = {
				factor = 20
				any_vassal = { controls_religion = yes }
			}
			
			modifier = {
				factor = 10
				culture_group = central_germanic # Holy Roman Empire
			}
			modifier = {
				factor = 10
				culture_group = celtic # Duh! Celts!
			}
			modifier = {
				factor = 5
				culture_group = north_germanic # Really?
			}
			modifier = {
				factor = 5
				culture_group = east_germanic # Sympathy toward Pope, hated Ecumenical patriarch
			}
			modifier = {
				factor = 10
				culture_group = latin # ROMAN Catholic church
			}
		}
		religion = catholic
		capital_scope = {
			if = {
				limit = { religion = nicene }
			}
			religion = catholic
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = catholic
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = catholic
		}
	}
	option = { # Pagan with Catholics
		name = EVTOPTCHRE.3
		
		trigger = {
			NOT = { religion = nicene }
		}
		ai_chance = {
			factor = 3
			modifier = {
				factor = 10
				culture_group = west_germanic # Duh, Germans!
			}
			modifier = {
				factor = 20
				any_vassal = { controls_religion = yes }
			}
			
			modifier = {
				factor = 10
				culture_group = central_germanic # Holy Roman Empire
			}
			modifier = {
				factor = 10
				culture_group = celtic # Duh! Celts!
			}
			modifier = {
				factor = 5
				culture_group = north_germanic # Really?
			}
			modifier = {
				factor = 5
				culture_group = east_germanic # Sympathy toward Pope, hated Ecumenical patriarch
			}
			modifier = {
				factor = 10
				culture_group = latin # ROMAN Catholic church
			}
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = catholic
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = catholic
		}
	}
	option = { # Pagan with Orthodoxians
		name = EVTOPTDHRE.3
		trigger = {
				NOT = { religion = nicene }
		}
		ai_chance = {
			factor = 3
			modifier = {
				factor = 10
				culture_group = byzantine # Greek Orthodoxy
			}
			modifier = {
				factor = 20
				any_vassal = { controls_religion = yes }
			}
			modifier = {
				factor = 10
				culture_group = east_slavic # Kiev!!!
			}
			modifier = {
				factor = 5
				culture_group = central_semitic # Byzantine Influences
			}
			modifier = {
				factor = 10
				culture_group = altaic # Orthodoxy in the Steppes
			}
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = orthodox
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = orthodox
		}
	}
}

# To the Emperor (fires for head of Nicene religion)
character_event = {
	id = HRE.4
	title = EVTNAMEHRE.4
	desc = EVTDESCHRE.4
	picture = GFX_evt_great_schism
	
	religion = nicene
	
	trigger = {
		year = 950 # Shouldn't be tied to a year
		controls_religion = yes
		has_landed_title = d_papal_state
		NOT = { has_global_flag = great_schism }
		NOT = { has_global_flag = nicene_heresy } # Nicene religion should not be a heresy
	}
	
	option = {
		name = EVTOPTAHRE.4

		set_parent_religion = { religion = arian parent = catholic }
		set_parent_religion = { religion = valentinianism parent = catholic }
		set_parent_religion = { religion = donatism parent = catholic }
		set_parent_religion = { religion = docetic parent = orthodox }
		set_parent_religion = { religion = ebionites parent = orthodox }
		set_parent_religion = { religion = marcionism parent = orthodox }
		set_parent_religion = { religion = binitarian parent = orthodox }
		set_parent_religion = { religion = melchisedechianism parent = orthodox }
		set_parent_religion = { religion = sethian parent = catholic }
		set_parent_religion = { religion = eutychian parent = orthodox } # Eutyches was a presbyter at Constantinople and the controversy was mostly in the Eastern Church
		set_parent_religion = { religion = antinomianism parent = orthodox }
		set_parent_religion = { religion = montanist parent = catholic }
		set_parent_religion = { religion = total_depravity parent = catholic }
		set_parent_religion = { religion = apollinarian parent = orthodox } #Similar to Monothelites ("Jesus is controlled by Skynet", AKA no mind of His own)
		set_parent_religion = { religion = adoptionism parent = catholic } # Spanish Adoptionism
		set_parent_religion = { religion = docetic parent = catholic }
		set_parent_religion = { religion = pneumatomachians parent = orthodox } #Founded by Macedonius, a Bishop of Constantinople
		set_parent_religion = { religion = patripassianism parent = catholic } # In the Western Church
		set_parent_religion = { religion = sabellianism parent = orthodox } # In the Eastern Church
		set_parent_religion = { religion = psilanthropism parent = orthodox }
		set_parent_religion = { religion = priscillianism parent = catholic } #Priscillian was a clergyman with extreme Gnostic influences
		
		set_global_flag = great_schism
		
		any_playable_ruler = {
			limit = {
				religion = nicene
				controls_religion = no
			}
			narrative_event = { id = HRE.5 }
		}
	}
	option = {
		name = EVTOPTBHRE.3
	}
}

# The Schism itself
narrative_event = {
	id = HRE.5
	title = EVTNAMEHRE.3
	desc = EVTDESCHRE.5
	picture = GFX_evt_great_schism
	
	is_triggered_only = yes

	immediate = {
		d_papal_state = {
			holder_scope = {
				k_papal_state = {
					grant_title = PREV
				}
			}
		}
		d_orthodox = {
			holder_scope = {
				k_orthodox = {
					grant_title = PREV
				}
			}
		}
	}
	
	option = { # Orthodox
		name = EVTOPTAHRE.3
		trigger = {
			religion = nicene
		}
		ai_chance = {
			factor = 3
			modifier = {
				factor = 10
				culture_group = byzantine # Greek Orthodoxy
			}
			modifier = {
				factor = 20
				any_vassal = { controls_religion = yes }
			}
			modifier = {
				factor = 10
				culture_group = east_slavic # Kiev!!!
			}
			modifier = {
				factor = 5
				culture_group = central_semitic # Byzantine Influences
			}
			modifier = {
				factor = 10
				culture_group = altaic # Orthodoxy in the Steppes
			}
		}
		religion = orthodox
		capital_scope = {
			if = {
				limit = { religion = nicene }
			}
			religion = orthodox
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = orthodox
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = orthodox
		}
	}
	option = { # Catholic
		name = EVTOPTBHRE.3
		trigger = {
			religion = nicene
		}
		ai_chance = {
			factor = 3
			modifier = {
				factor = 10
				culture_group = west_germanic # Duh, Germans!
			}
			modifier = {
				factor = 20
				any_vassal = { controls_religion = yes }
			}
			
			modifier = {
				factor = 10
				culture_group = central_germanic # Holy Roman Empire
			}
			modifier = {
				factor = 10
				culture_group = celtic # Duh! Celts!
			}
			modifier = {
				factor = 5
				culture_group = north_germanic # Really?
			}
			modifier = {
				factor = 5
				culture_group = east_germanic # Sympathy toward Pope, hated Ecumenical patriarch
			}
			modifier = {
				factor = 10
				culture_group = latin # ROMAN Catholic church
			}
		}
		religion = catholic
		capital_scope = {
			if = {
				limit = { religion = nicene }
			}
			religion = catholic
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = catholic
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = catholic
		}
	}
	option = { # Pagan with Catholics
		name = EVTOPTCHRE.3

		trigger = {
			NOT = { religion = nicene }
		}
		ai_chance = {
			factor = 3
			modifier = {
				factor = 10
				culture_group = west_germanic # Duh, Germans!
			}
			modifier = {
				factor = 20
				any_vassal = { controls_religion = yes }
			}
			
			modifier = {
				factor = 10
				culture_group = central_germanic # Holy Roman Empire
			}
			modifier = {
				factor = 10
				culture_group = celtic # Duh! Celts!
			}
			modifier = {
				factor = 5
				culture_group = north_germanic # Really?
			}
			modifier = {
				factor = 5
				culture_group = east_germanic # Sympathy toward Pope, hated Ecumenical patriarch
			}
			modifier = {
				factor = 10
				culture_group = latin # ROMAN Catholic church
			}
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = catholic
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = catholic
		}
	}
	option = { # Pagan with Orthodoxians
		name = EVTOPTDHRE.3
		trigger = {
			NOT = { religion = nicene }
		}
		ai_chance = {
			factor = 3
			modifier = {
				factor = 10
				culture_group = byzantine # Greek Orthodoxy
			}
			modifier = {
				factor = 20
				any_vassal = { controls_religion = yes }
			}
			modifier = {
				factor = 10
				culture_group = east_slavic # Kiev!!!
			}
			modifier = {
				factor = 5
				culture_group = central_semitic # Byzantine Influences
			}
			modifier = {
				factor = 10
				culture_group = altaic # Orthodoxy in the Steppes
			}
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = orthodox
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = orthodox
		}
	}
}

# To the Pope
narrative_event = {
	id = HRE.6
	title = HRE.6.title
	desc = HRE.6.desc
	
	picture = GFX_evt_great_schism
	
	is_triggered_only = yes
	
	option = {
		name = OK
		activate_title = { title = k_orthodox status = yes }
		activate_title = { title = k_papal_state status = yes }
	}
}

#To the Ecumenical Patriarch
narrative_event = {
	id = HRE.7
	title = HRE.7.title
	desc = HRE.7.desc
	
	picture = GFX_evt_great_schism
	
	is_triggered_only = yes
	
	option = {
		name = OK
		primary_title = {
			k_orthodox = {
				grant_title = ROOT
				make_primary_title = yes
				copy_title_laws = PREV
			}
		}
	}
}

namespace = GEORGIAN

# Georgian Schism
narrative_event = {
	id = GEORGIAN.1
	title = GEORGIAN.1.title
	desc = GEORGIAN.1.desc
	picture = GFX_evt_nicene_preacher
	border = GFX_event_narrative_frame_religion
	
	only_rulers = yes
	only_independent = yes
	
	trigger = {
		year = 485
		religion = georgian_orthodox
		NOT = { has_global_flag = georgian_schism }
		NOT = { has_character_flag = georgian_schism }
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		# Prevent schism event to fire twice for same character
		set_character_flag = georgian_schism
	}
	
	option = { # Nicene
		name = GEORGIAN.1.a
		ai_chance = { factor = 70 }
		
		religion = nicene
		hidden_tooltip = {
			religion_authority = {
				modifier = ruler_converted_to
			}
		}
		capital_scope = {
			religion = nicene
		}
		hidden_tooltip = {
			any_realm_character = {
				limit = {
					religion = georgian_orthodox
					NOT = { character = ROOT }
					can_change_religion = yes
				}
				character_event = { id = GEORGIAN.2 }
			}
		}
	}
	option = { # Miaphysite
		name = GEORGIAN.1.b
		ai_chance = { factor = 25 }
		
		religion = miaphysite
		hidden_tooltip = {
			religion_authority = {
				modifier = ruler_converted_to
			}
		}
		capital_scope = {
			religion = miaphysite
		}
		hidden_tooltip = {
			any_realm_character = {
				limit = {
					religion = georgian_orthodox
					NOT = { character = ROOT }
					can_change_religion = yes
				}
				character_event = { id = GEORGIAN.2 }
			}
		}
		
	}
	option = { # Georgian
		name = GEORGIAN.1.c
		ai_chance = { factor = 5 }
	}
}

# Vassal is notified about top_liege conversion
character_event = {
	id = GEORGIAN.2
	desc = GEORGIAN.2.desc
	picture = GFX_evt_nicene_preacher
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = { # Accept the choice
		name = GEORGIAN.2.a
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0.3
				trait = zealous
				intrigue = 3
			}
			modifier = {
				factor = 0
				trait = zealous
				NOT = { intrigue = 3 }
			}
		}
		
		religion = FROM
		if = {
			limit = { trait = zealous }
			remove_trait = zealous
			piety = -50
		}
	}
	option = { # Zealous
		name = GEORGIAN.2.b
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { trait = zealous }
			}
		}
		
		piety = 100
	}
}