namespace = succession-orthodox
######################################
####### Orthodox			   #######
######################################
character_event = {
	id = succession-orthodox.1 # sucesseur des titres papaux
	hide_window = yes
	is_triggered_only = yes	
	trigger = {
		has_landed_title = k_orthodox
		is_alive = yes
	}	
	immediate = {
		any_demesne_title = {
			add_law = {
				law = succ_papal_demesne_orthodox
				opinion_effect = no
			}
		}
	}
}

character_event = {
	id = succession-orthodox.2 # la succession Sede Vacante Orthodox (c'est la mise en place de Sede Vacante Orthodox "succession+papal.3" est lié au .2)
	hide_window = yes
	is_triggered_only = yes	
	trigger = {
		has_landed_title = k_orthodox
	}	
	immediate = {
		create_character = {
			name = "Sede Vacante Orthodox"
			culture = italian
			religion = orthodox
			dynasty = none
			random_traits = no
			female = no
			age = 16
			health = 9999
			trait = trait_Sede_Vacante_orthodox
			trait = incapable
			attributes = {
				stewardship = 1
				intrigue = 1
			}
		}
		new_character = {
			ROOT = {
				transfer_scaled_wealth = {
					to = PREV
					value = all
				}
				any_artifact = {
					transfer_artifact = {
						from = ROOT
						to = PREVPREV
					}
				}
				abdicate_to = PREV
			}
			set_name = "Sede Vacante Orthodox"
			recalc_succession = yes
			e_holy_see_orthodox = {
				elective_voting_rules = papal_elective_Orthodox
			}
			character_event = {
				id = succession-orthodox.3
				days = 30
			}
			character_event = {
				id = succession-orthodox.4
			#	days = 1 # ne pas activer le jour ou l event en question n apparait pas
			}
		}
    }
}

character_event = {
	id = succession-orthodox.3
	hide_window = yes
	only_rulers = yes
	is_triggered_only = yes	
	trigger = {
		has_landed_title = k_orthodox
		is_alive = yes
	}
	immediate = {
		e_holy_see_orthodox = {
			current_heir = {
				save_event_target_as = heritie_loi_orthodox
			}
		}
		if = {
			limit = {
				event_target:heritie_loi_orthodox = {
					trait = Eveque-Orthodox
				}
			}
			transfer_scaled_wealth = {
				to = event_target:heritie_loi_orthodox
				value = all
			}
			any_artifact = {
				transfer_artifact = {
					from = ROOT
					to = event_target:heritie_loi_orthodox
				}
			}
			event_target:heritie_loi_orthodox = {
				remove_trait = Eveque-Orthodox
			}
			event_target:heritie_loi_orthodox = {
				if = {
					limit = {
						any_courtier = {
							has_minor_title = title_archdeacon_orthodox
						}
					}
					any_courtier = {
						limit = {
							has_minor_title = title_archdeacon_orthodox
						}
						remove_title = title_archdeacon_orthodox
						save_event_target_as = deacon_orthodox
						event_target:heritie_loi_orthodox = {
							abdicate_to = event_target:deacon_orthodox
						}
					}
				}
				else = {
					abdicate = yes
				}
			}
			abdicate_to = event_target:heritie_loi_orthodox
			move_character = event_target:heritie_loi_orthodox
			e_holy_see_orthodox = {
				elective_voting_rules = papal_elective_Orthodox
			}
			recalc_succession = yes
			death = {
				death_reason = death_missing
			}
			character_event = {
				id = succession-orthodox.5
			#	days = 1 # ne pas activer le jour ou l event en question n apparait pas
			}
		}
		else = {
			character_event = {
				id = succession-orthodox.3
				days = 1
			}
		}
	}
}

character_event = {
    id = succession-orthodox.4
    desc = EVTDESC_succession-orthodox_4
	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes
	major = yes
	trigger = {
		always = yes
	}
    major_trigger = {
		ai = no
		has_landed_title = k_orthodox
	}
	option = {
		name = EVTDESC_succession-orthodox_1
	}
}

character_event = {
    id = succession-orthodox.5
    desc = EVTDESC_succession-orthodox_5
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes
	major = yes
	portrait = event_target:heritie_loi_orthodox
	trigger = {
		always = yes
	}
    major_trigger = {
		ai = no
		religion = orthodox
		NOT = {
			any_liege = {
				has_claim = k_orthodox
			}
			has_claim = k_orthodox
			any_vassal = {
				has_claim = k_orthodox
			}
		}
		NOT = {
			top_liege = {
				any_realm_character = {
					has_claim = k_orthodox
				}
			}
		}
	}
	option = {
		name = EVTDESC_succession-orthodox_2
	}
}

character_event = {
	id = succession-orthodox.6 # pour remettre sancta si il meurt
	hide_window = yes
	is_triggered_only = yes	
	trigger = {
		FROM = {
			title = e_holy_see_orthodox
		}
		NOT = {
			trait = trait_Sede_Vacante_orthodox
		}
	}
	immediate = {
		character_event = {
			id = succession-orthodox.7
			days = 1
		}
	}
}

character_event = {
	id = succession-orthodox.7
	hide_window = yes
	is_triggered_only = yes
	immediate = {
		create_character = {
			name = "Sancta Sedes"
			culture = italian
			religion = orthodox
			dynasty = none
			random_traits = no
			female = no
			age = 16
			health = 9999
			trait = trait_Sede_Vacante_orthodox
			trait = incapable
			attributes = {
				stewardship = 1
				intrigue = 1
			}
		}
		new_character = {
			grant_title_no_opinion = e_holy_see_orthodox
		}
		e_holy_see_orthodox = {
			add_law = {
				law = succ_papal_succession_Royaume_Orthodox
				opinion_effect = no
			}
		}
		recalc_succession = yes
		death = {
			death_reason = death_missing
		}
	}
}
##################################################################
character_event = {
	id = succession-orthodox.8
	hide_window = yes
	only_rulers = yes
	mean_time_to_happen = { 
		days = 1
	}
	trigger = {
		NOT = {
			any_character = {
				has_landed_title = e_holy_see_orthodox
			}
		}
		any_character = {
			has_landed_title = k_orthodox
		}
	}
	immediate = {
		create_character = {
			name = "Sancta Sedes"
			culture = italian
			religion = orthodox
			dynasty = none
			random_traits = no
			female = no
			age = 16
			health = 9999
			trait = trait_Sede_Vacante_orthodox
			trait = incapable
			attributes = {
				stewardship = 1
				intrigue = 1
			}
		}
		new_character = {
			e_holy_see_orthodox = {
				grant_title = PREV
			}
			grant_title_no_opinion = e_holy_see_orthodox
		}
		e_holy_see_orthodox = {
			add_law = {
				law = succ_papal_succession_Royaume_Orthodox
				opinion_effect = no
			}
		}
		recalc_succession = yes
	}
}

character_event = {
	id = succession-orthodox.9 # la succession Sede Vacante Orthodox
	hide_window = yes
	is_triggered_only = yes
	trigger = {
		NOT = {
			any_character = {
				has_landed_title = e_holy_see_orthodox
			}
		}
		any_character = {
			has_landed_title = k_orthodox
		}
	}
	immediate = {
		create_character = {
			name = "Sancta Sedes"
			culture = italian
			religion = orthodox
			dynasty = none
			random_traits = no
			female = no
			age = 16
			health = 9999
			trait = trait_Sede_Vacante_orthodox
			trait = incapable
			attributes = {
				stewardship = 1
				intrigue = 1
			}
		}
		new_character = {
			e_holy_see_orthodox = {
				grant_title = PREV
			}
			grant_title_no_opinion = e_holy_see_orthodox
		}
		e_holy_see_orthodox = {
			add_law = {
				law = succ_papal_succession_Royaume_Orthodox
				opinion_effect = no
			}
		}
		recalc_succession = yes
	}
}
##################################################################
character_event = {
	id = succession-orthodox.10 # la succession holy_see
	hide_window = yes
	only_rulers = yes
	mean_time_to_happen = { 
		days = 1
	}
	trigger = {
		has_landed_title = e_holy_see_orthodox
		is_alive = yes
		OR = {
			NOT = {
				government = theocracy_government
			}
			AND = {
				independent = yes
				NOT = {
					e_holy_see_orthodox = {
						has_law = succ_papal_succession_Royaume_Orthodox
					}	
				}
			}
			NOT = {
				e_holy_see_orthodox = {
					has_law = true_cognatic_succession
				}	
			}
		}
	}	
	immediate = {
		set_government_type = theocracy_government
		e_holy_see_orthodox = {
			add_law = {
				law = succ_papal_succession_Royaume_Orthodox
				opinion_effect = no
			}
		}
		e_holy_see_orthodox = {
			add_law = {
				law = true_cognatic_succession
				opinion_effect = no
			}
		}
	}
}

character_event = {
	id = succession-orthodox.11 # la succession holy_see
	hide_window = yes
	is_triggered_only = yes	
	trigger = {
		has_landed_title = e_holy_see_orthodox
		is_alive = yes
		OR = {
			NOT = {
				government = theocracy_government
			}
			AND = {
				independent = yes
				NOT = {
					e_holy_see_orthodox = {
						has_law = succ_papal_succession_Royaume_Orthodox
					}	
				}
			}
			NOT = {
				e_holy_see_orthodox = {
					has_law = true_cognatic_succession
				}	
			}
		}
	}	
	immediate = {
		set_government_type = theocracy_government
		e_holy_see_orthodox = {
			add_law = {
				law = succ_papal_succession_Royaume_Orthodox
				opinion_effect = no
			}
		}
		e_holy_see_orthodox = {
			add_law = {
				law = true_cognatic_succession
				opinion_effect = no
			}
		}
	}
}

character_event = {
	id = succession-orthodox.12 # vasseaux de holy_see
	hide_window = yes
	only_rulers = yes
	mean_time_to_happen = { 
		days = 1
	}
	trigger = {
		has_landed_title = e_holy_see_orthodox
		is_alive = yes
		any_vassal = {
			is_alive = yes
			OR = {
				tier = BARON
				tier = COUNT
				tier = DUKE
				tier = KING
			}
		}
	}	
	immediate = {
		any_vassal = {
			set_defacto_liege = THIS
		}
	}
}

character_event = {
	id = succession-orthodox.13 # vasseaux de holy_see
	hide_window = yes
	is_triggered_only = yes	
	trigger = {
		has_landed_title = e_holy_see_orthodox
		is_alive = yes
		any_vassal = {
			is_alive = yes
			OR = {
				tier = BARON
				tier = COUNT
				tier = DUKE
				tier = KING
			}
		}
	}	
	immediate = {
		any_vassal = {
			set_defacto_liege = THIS
		}
	}
}
##################################################################
character_event = {
	id = succession-orthodox.14 # la loi de holy_see "pour" k_orthodox
	hide_window = yes
	is_triggered_only = yes	
	trigger = {
		has_landed_title = k_orthodox
	}
	immediate = {
		recalc_succession = yes
		e_holy_see_orthodox = {
			elective_voting_rules = papal_elective_Orthodox
		}
    }
}
##################################################################
#character_event = {
#	id = succession-orthodox.15 # titres de holy_see
#	hide_window = yes
#	only_rulers = yes
#	mean_time_to_happen = { 
#		days = 1
#	}
#    trigger = {
#        has_landed_title = e_holy_see_orthodox
#        is_alive = yes
#        OR = {
#            tier = BARON
#            tier = COUNT
#            tier = DUKE
#            tier = KING
#            tier = EMPEROR
#        }
#    #    OR = { # ne pas activer sinon new character ne marche pas
#    #        num_of_emperor_titles > 1
#    #        NOT = {
#    #            primary_title = {
#    #                title = e_holy_see_orthodox
#    #            }
#    #        }
#    #    }
#    }
#    immediate = {
#        any_demesne_title = {
#            limit = { 
#                OR = {
#                    tier = DUKE
#                    tier = KING
#                    tier = EMPEROR
#                }
#                NOT = {
#                    title = e_papal_state
#                }
#            }
#            destroy_landed_title = THIS
#        }
#        e_holy_see_orthodox = {
#            make_primary_title = yes
#        }
#        create_character = {
#            name = "Roberto"
#            culture = italian
#            religion = orthodox
#            dynasty = none
#            random_traits = no
#            female = no
#            age = 16
#            health = 23
#            trait = incapable
#            attributes = {
#                stewardship = 1
#                intrigue = 1
#            }
#        }
#        any_demesne_title = {
#            limit = {
#                OR = {
#                    tier = BARON
#                    tier = COUNT
#                }
#            }
#            grant_title = new_character
#        }
#        new_character = {
#            set_defacto_liege = THIS
#            death = {
#                death_reason = death_missing
#            }
#        }
#    }
#}
#
#character_event = {
#    id = succession-orthodox.15 # titres de holy_see
#    hide_window = yes
#    is_triggered_only = yes
#    trigger = {
#        has_landed_title = e_holy_see_orthodox
#        is_alive = yes
#        OR = {
#            tier = BARON
#            tier = COUNT
#            tier = DUKE
#            tier = KING
#            tier = EMPEROR
#        }
#    #    OR = { # ne pas activer sinon new character ne marche pas
#    #        num_of_emperor_titles > 1
#    #        NOT = {
#    #            primary_title = {
#    #                title = e_holy_see_orthodox
#    #            }
#    #        }
#    #    }
#    }
#    immediate = {
#        any_demesne_title = {
#            limit = { 
#                OR = {
#                    tier = DUKE
#                    tier = KING
#                    tier = EMPEROR
#                }
#                NOT = {
#                    title = e_papal_state
#                }
#            }
#            destroy_landed_title = THIS
#        }
#        e_holy_see_orthodox = {
#            make_primary_title = yes
#        }
#        create_character = {
#            name = "Roberto"
#            culture = italian
#            religion = orthodox
#            dynasty = none
#            random_traits = no
#            female = no
#            age = 16
#            health = 23
#            trait = incapable
#            attributes = {
#                stewardship = 1
#                intrigue = 1
#            }
#        }
#        any_demesne_title = {
#            limit = {
#                OR = {
#                    tier = BARON
#                    tier = COUNT
#                }
#            }
#            grant_title = new_character
#        }
#        new_character = {
#            set_defacto_liege = THIS
#            death = {
#                death_reason = death_missing
#            }
#        }
#    }
#}
##################################################################
