﻿
namespace = autocephaly_decision


autocephaly_decision.0020 = {
	type = character_event
	title = autocephaly_decision.0020.t
	desc = autocephaly_decision.0020.desc
	theme = realm
	
	left_portrait = {
		character = scope:scoped_emperor
		animation = personality_zealous
	}

	immediate = {
		save_scope_as = scoped_emperor
		restore_roman_patriarchate_scripted_effect = yes
		hidden_effect = {
			create_character = {
				employer = root
				faith = faith:roman_orthodox
				template = religious_leader_character
				random_traits = no
				save_scope_as = new_patriarch
				dynasty = generate
			}
		}
		scope:new_patriarch = {
			get_title = title:d_roman_patriarchate
			add_trait = education_learning_3
			add_trait = zealous
			add_trait = intellect_good_1
			random_list = {
				1 = { add_trait = lustful }
				1 = { add_trait = chaste }
				1 = { add_trait = wrathful }
				1 = { add_trait = diligent }
				1 = { add_trait = impatient }
				1 = { add_trait = arrogant }
				1 = { add_trait = humble }
				1 = { add_trait = gregarious }
			}
			random_list = {
				1 = { add_trait = honest }
				1 = { add_trait = ambitious }
				1 = { add_trait = just }
				1 = { add_trait = cynical }
				1 = { add_trait = zealous }
				1 = { add_trait = compassionate }
				1 = { add_trait = stubborn }
			}
		}
	}

	option = {
		name = autocephaly_decision.0020.a
		add_prestige = major_prestige_gain
		add_piety = major_piety_gain

		if = { # Vassalize if possible/needed.
			limit = {
				highest_held_title_tier > scope:new_patriarch.highest_held_title_tier
				NOT = { scope:new_patriarch = { any_liege_or_above = { this = root } } }
			}
			create_title_and_vassal_change = {
				type = created
				save_scope_as = change
				add_claim_on_loss = no
			}
			scope:new_patriarch = {
				change_liege = {
					liege = root
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
	}
}

autocephaly_decision.0021 = {
	type = character_event
	title = autocephaly_decision.0020.t
	desc = autocephaly_decision.0020.desc
	theme = realm

	left_portrait = {
		character = scope:scoped_emperor
		animation = personality_zealous
	}

	immediate = {
		save_scope_as = scoped_emperor
		play_music_cue = "mx_cue_faith_conversion"
	}

	option = { #Become Orthodox
		name = autocephaly_decision.0021.a
		trigger = {
			OR = {
				is_ai = no
				NOT = { has_trait = zealous } # Never!
			}
		}
		set_character_faith = faith:roman_orthodox
		every_held_title = {
			limit = { tier = tier_county }
			set_county_faith = faith:roman_orthodox
		}
		ai_chance = {
			base = 50
			modifier = { # Where the wind blows, I sail.
				add = 20
				has_trait = cynical
			}
		}
	}
	option = {
		name = autocephaly_decision.0021.b
		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_zeal = 1.0
			}
			modifier = {
				add = 80
				has_trait = zealous
			}
			modifier = {
				add = 80
				OR = {
					has_title = title:k_east_francia
					has_title = title:e_hre
					has_title = title:k_papal_state
				}
			}
		}
	}
}



autocephaly_decision.0040 = {
	type = character_event
	title = autocephaly_decision.0040.t
	desc = autocephaly_decision.0040.desc
	theme = realm
	left_portrait = {
		character = scope:scoped_emperor
		animation = personality_zealous
	}

	immediate = {
		save_scope_as = scoped_emperor
		restore_school_of_edessa_scripted_effect = yes
	}

	option = {
		name = autocephaly_decision.0040.a
	}
}