﻿### Return Rome ###
return_rome_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	desc = return_rome_decision_desc
	selection_tooltip = return_rome_decision_tooltip

	is_shown = {
		top_liege = this
		faith = faith:catholic
		exists = faith.religious_head
		faith.religious_head = {
			OR = {
				top_liege = this
				NOT = {
					any_liege_or_above = {
						this = root
					}
				}
			}
		}
		any_sub_realm_county = {
			this = title:c_vaticano
		}
		NAND = {
			is_ai = no
			NOT = {
				any_sub_realm_county = {
					NOT = {
						this = title:c_vaticano
					}
				}
			}
		}
		root != root.faith.religious_head
	}

	effect = {
		create_title_and_vassal_change = {
			type = returned
			save_scope_as = change
			add_claim_on_loss = no
		}
		title:c_vaticano = {
			change_title_holder = {
				holder = root.faith.religious_head
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change

		add_piety = major_piety_value
		if = {
			limit = {
				faith.religious_head ?= {
					this != root
				}
			}
			faith.religious_head = {
				add_opinion = {
					target = root
					modifier = grateful_opinion
					opinion = 20
				}
			}
		}

		stress_impact = {
			cynical = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 12
		duchy = 12
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	ai_potential = {
		is_at_war = no
		top_liege = this
		faith = faith:catholic
		ai_zeal > very_high_negative_ai_value
		title:c_vaticano = {
			holder = {
				is_ai = yes
			}
		}
	}

	ai_will_do = {
		base = 100

		modifier = { # If you fought the pope to get rome, don't immediately hand it back
			factor = 0
			faith.religious_head = {
				has_opinion_modifier = {
					target = root
					modifier = declared_war
				}
			}
		}
	}
}
restore_pope_in_rome_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}
	desc = restore_pope_in_rome_decision_desc
	selection_tooltip = restore_pope_in_rome_decision_tooltip
	decision_group_type = major

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		is_ruler = yes
		is_playable_character = yes
		faith = faith:catholic
		NOR = {
			has_title = title:k_papal_state
			is_roman_emperor_excluding_byzantium_trigger = yes
		}
		NOT = { title:c_vaticano.holder = { has_title = title:k_papal_state } }
		NOT = { capital_county = { this = title:c_vaticano } }
		title:k_papal_state.holder ?= {
			NOT = { 	
				has_opinion_modifier = { #Not accepting it if you conquered it yourself.
					target = root
					modifier = declared_war
				}
			}
			NOT = { 	
				has_opinion_modifier = { #Not accepting it if you conquered it yourself.
					target = root
					modifier = revoked_title
				}
			}
		}
		NOT = { has_character_flag = flag_already_given_rome_once }
	}

	is_valid_showing_failures_only = {
		is_landed = yes
		is_capable_adult = yes
		is_imprisoned = no
		top_liege = this
		highest_held_title_tier > 3 #Only Kings and Emperors
		custom_tooltip = {
			text = hof_exists_tt
			faith = { exists = religious_head }
		}
		custom_tooltip = {
			text = rome_held_by_you_or_vassal_tt
			OR = {
				title:c_vaticano.holder = { 	
					any_liege_or_above = { this = root }
				}
				title:c_vaticano.holder = { this = root }
			}
		}
	}

	effect = {
		add_piety = 1000
		add_character_flag = flag_already_given_rome_once
		create_title_and_vassal_change = {
			type = returned
			save_scope_as = change
			add_claim_on_loss = no
		}
		title:c_vaticano = {
			change_title_holder = {
				holder = title:k_papal_state.holder
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change

		title:k_papal_state.holder = {
			set_realm_capital = title:c_vaticano
			add_opinion = {
				target = prev
				modifier = restored_papacy_opinion
			}
		}
	}
	
	ai_potential = {
		faith = faith:catholic
		highest_held_title_tier > 3 #Only Kings and Emperors
	}

	ai_will_do = { #Do it always, for coherence.
		base = 100
		modifier = {
			factor = 0
			title:c_vaticano.holder = {
				OR = {
					is_ai = no
					any_liege_or_above = { is_ai = no }  # AI will never take Rome province away from a player.
				}
			}
		}
		modifier = {
			factor = 0
			has_trait = cynical
		}
		modifier = {
			factor = 0
			has_title = title:e_italy
		}
	}
}