###############################
# Church councils
#
# Written by Enlil
#
# syn.1 -> syn.13
###############################

namespace = syn

# The Three Chapters Controversy
narrative_event = {
	id = syn.1
	title = syn.1.name
	desc = syn.1.desc
	picture = GFX_evt_christian_council
	
	major = yes
	
	is_triggered_only = yes
	
	option = {
		name = syn.1.a
	}
}

# Second Council of Constantinople
character_event = {
	id = syn.2
	desc = syn.2.desc
	picture = GFX_evt_christian_council
	border = GFX_event_normal_frame_religion
	
	only_playable = yes
	has_global_flag = three_chapter_controversy
	
	trigger = {
		year = 500
		has_landed_title = e_byzantium
		NOT = { year = 600 }
		NOT = { has_global_flag = great_schism }
		NOT = { has_global_flag = second_council }
		NOT = { has_global_flag = golden_horde_arrival }
		NOT = { has_global_flag = second_council_of_constantinople }
	}
	
	mean_time_to_happen = {
		years = 10
	}
	
	immediate = {
		set_global_flag = second_council_of_constantinople
	}
	
	option = {
		name = syn.2.a
		d_orthodox = { holder_scope = { character_event = { id = syn.3 } } } # Patriarchs Decide
	}
}

# Patriarchs Decide
character_event = {
	id = syn.3
	desc = syn.3.desc
	picture = GFX_evt_christian_council
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = { # Denounce the Three Chapters
		name = syn.3.a
		ai_chance = {
			factor = 6
			modifier = {
				factor = 10
				any_character = {
					religion = monophysite
					religion_authority = 0.9
				}
			}
		}
		hidden_tooltip = {
			any_playable_ruler = {
				limit = {
					ai = no
					NOT = { character = ROOT }
				}
				narrative_event = { id = syn.4 } # The Patriarchs Agree on Condemnation
			}
		}
	}
	
	option = { # Rescind the Condemnation
		name = syn.3.b
		hidden_tooltip = {
			any_playable_ruler = {
				limit = {
					ai = no
					NOT = { character = ROOT }
				}
				narrative_event = { id = syn.5 } # The Patriarchs Agree on Rescinding the Condemnation
			}
		}
	}
}

# The Patriarchs Agree on Condemnation
narrative_event = {
	id = syn.4
	title = syn.4.name
	desc = syn.4.desc
	picture = GFX_evt_christian_council

	major = yes
	
	is_triggered_only = yes

	immediate = {
		set_parent_religion = { religion = nestorian parent = nicene }
		d_papal_state = { holder_scope = { character_event = { id = syn.6 days = 10 } } } # Pope Decides
		d_monophysite = { holder_scope = { character_event = { id = syn.8 days = 5 } } } # Monophysite Patriarch Decides
	}
	
	option = {
		name = syn.4.a
	}
}

# The Patriarchs Agree on Rescinding the Condemnation
narrative_event = {
	id = syn.5
	title = syn.4.name
	desc = syn.5.desc
	picture = GFX_evt_christian_council

	major = yes

	is_triggered_only = yes
	
	option = {
		name = syn.4.a
	}
}

# Pope Decides
character_event = {
	id = syn.6
	desc = syn.6.desc
	picture = GFX_evt_christian_council
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = { # Accept
		name = syn.6.a
		ai_chance = { factor = 3 }
		hidden_tooltip = {
			IF = {
				limit = { # b_aquileia is owned by a Nicene bishop/patriarch
					b_aquileia = {
						holder_scope = {
							religion = nicene
							is_priest = yes
						}
					}
				}
				b_aquileia = { # Milan and Aquileia reacts
					holder_scope = {
						character_event = { id = syn.12 }
					}
				}
			}
		}
	}
	
	option = { # Refuse
		name = syn.6.b
		hidden_tooltip = {
			d_orthodox = { # Ecumenial Patriarch reacts
				holder_scope = {
					character_event = { id = syn.13 }
				}
			}
		}
	}
}

# The Aquileian Schism
character_event = {
	id = syn.7
	title = syn.7.name
	desc = syn.7.desc
	picture = GFX_evt_christian_council

	is_triggered_only = yes

	immediate = {
		set_global_flag = aquileian_schism
		b_aquileia = {
			holder_scope = {
				d_aquileia_church = {
					grant_title = PREV
				}
			}
		}
	}
	
	option = { # Aquileian
		name = syn.7.a
		trigger = {
			religion = nicene
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2
				culture = roman # Milan, Aquileia
			}
			modifier = {
				factor = 20
				any_vassal = { has_landed_title = d_aquileia_church }
			}
			modifier = {
				factor = 50
				has_landed_title = d_aquileia_church
			}
			modifier = {
				factor = 10
				any_vassal = { has_landed_title = b_monza }
			}
			modifier = {
				factor = 0.01
				culture_group = byzantine # Agreed with Second Council
			}
		}
		religion = aquileian
		capital_scope = {
			if = {
				limit = {
					religion = nicene
				}
				religion = aquileian
			}
		}
		any_realm_province = {
			limit = {
				religion = nicene
			}
			religion = aquileian
		}
		any_realm_character = {
			limit = { religion = nicene }
			religion = aquileian
		}
	}
	option = { # Stay
		name = syn.7.b
		ai_chance = { factor = 6 }
		trigger = {
			religion = nicene
		}
	}
	option = { # Non-Nicene
		name = syn.7.c
		trigger = {
			NOT = { religion = nicene }
		}
	}
}

# Monophysite Patriarch Decides
character_event = {
	id = syn.8
	desc = syn.8.desc
	picture = GFX_evt_christian_council
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = { # Accept
		name = syn.8.a
		hidden_tooltip = {
			any_playable_ruler = {
				narrative_event = { id = syn.9 }
			}
		}
	}
	option = { # Refuse
		name = syn.8.b
		ai_chance = { factor = 5 }
	}
}

# The Monophysites Rejoin
narrative_event = {
	id = syn.9
	title = syn.9.name
	desc = syn.9.desc
	picture = GFX_evt_christian_council
	
	is_triggered_only = yes

	immediate = {
		set_parent_religion = { religion = monophysite parent = 0 }
		activate_title = {
			title = d_monophysite
			status = no
		}
	}
	
	option = {
		name = syn.9.a
		trigger = {
			religion = monophysite
		}
		religion = nicene
		capital_scope = {
			if = {
				limit = {
					religion = monophysite
				}
				religion = nicene
			}
		}
		any_realm_province = {
			limit = {
				religion = monophysite
			}
			religion = nicene
		}
		any_realm_character = {
			limit = { religion = monophysite }
			religion = nicene
		}
	}
	option = { # Stay
		name = syn.9.b
		trigger = {
			NOT = { religion = monophysite }
		}
	}
}

# The Council of Aquileia
narrative_event = {
	id = syn.10
	title = syn.10.name
	desc = syn.10.desc
	picture = GFX_evt_christian_council
	
	major = yes
	
	is_triggered_only = yes
	
	option = {
		name = syn.10.a
		set_global_flag = the_aquileian_capture
	}
}

# End of Aquileian Schism
narrative_event = {
	id = syn.11
	title = syn.11.name
	desc = syn.11.desc
	picture = GFX_evt_christian_council

	major = yes
	
	is_triggered_only = yes
	
	option = {
		name = syn.11.a
		trigger = {
			religion = aquileian
		}
		religion = nicene
		capital_scope = {
			if = {
				limit = {
					religion = aquileian
				}
				religion = nicene
			}
		}
		any_realm_province = {
			limit = {
				religion = aquileian
			}
			religion = nicene
		}
		any_realm_character = {
			limit = { religion = aquileian }
			religion = nicene
		}
	}
	option = { # Okay
		name = syn.11.b
		trigger = {
			NOT = { religion = aquileian }
		}
		capital_scope = {
			if = {
				limit = {
					religion = aquileian
				}
				religion = nicene
			}
		}
		any_realm_province = {
			limit = {
				religion = aquileian
			}
			religion = nicene
		}
		any_realm_character = {
			limit = { religion = aquileian }
			religion = nicene
		}
	}
}

# Milan and Aquileia reacts
character_event = {
	id = syn.12
	desc = syn.12.desc
	picture = GFX_evt_christian_council
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = { # Accept
		name = syn.12.a
		# Nothing more happens
	}
	
	option = { # Refuse
		name = syn.12.b
		ai_chance = { factor = 3 }
		hidden_tooltip = {
			any_playable_ruler = {
				limit = {
					NOT = { character = ROOT }
					NOT = { has_landed_title = d_papal_state }
				}
				character_event = { id = syn.7 } # The Aquileian Schism
			}
		}
	}
}

# Ecumenial Patriarch reacts
character_event = {
	id = syn.13
	desc = syn.13.desc
	picture = GFX_evt_christian_council
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = { # Excommunicate Pope
		name = syn.13.a
		d_papal_state = {
			holder_scope = {
				character_event = { id = HRE.4 } # The Great Schism
			}
		}
	}
	
	option = { # Reverse judgement
		name = syn.13.b
		ai_chance = { factor = 3 }
		# Changes undone
		set_parent_religion = { religion = nestorian parent = 0 }
	}
}