#tgp_divine_reincarnation_decision

### Divine Reincarnation ###
tgp_divine_reincarnation_decision = {
	title = tgp_divine_reincarnation_decision
	desc = tgp_divine_reincarnation_decision_desc
	selection_tooltip = tgp_divine_reincarnation_decision_tooltip
	picture = {
		reference = "gfx/interface/illustrations/decisions/hindu_religious.dds"
	}
	sort_order = 120

	is_shown = {
		is_ai = no
		faith = { has_doctrine = tenet_reincarnation }
	}
	
	is_valid_showing_failures_only = {
		is_at_war = no
		is_adult = yes
		is_available = yes

		custom_tooltip = {
			text = tgp_divine_reincarnation_decision_valid_child_tt
			any_child = {
				is_adult = no
				faith = root.faith
				NOT = { has_trait = reincarnation }
				OR = {
					this = root.primary_heir
					has_relation_favorite_child = root
				}
				save_temporary_scope_as = child_check
				any_close_or_extended_family_member = {
					even_if_dead = yes
					is_alive = no
					sex_same_as = scope:child_check
					OR = {
						is_grandparent_of = scope:child_check
						AND = {
							is_grandparent_of = scope:child_check
							any_parent = { 
								is_alive = no
								sex_same_as = scope:child_check
							}
						}
					}
				}
			}
		}
	}
	
	cooldown = { years = 15 }
	
	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "SELECT_ACTION"
		show_from_start = yes

		item = { # Primary Heir
			value = primary_heir
			is_valid = {
				custom_tooltip = {
					text = tgp_divine_reincarnation_decision_primary_heir_tt
					any_child = {
						is_primary_heir_of = root
						is_adult = no
						faith = root.faith
						NOT = { has_trait = reincarnation }
					}
				}
			}
			localization = tgp_divine_reincarnation_decision_primary_heir_name
			icon = "gfx/interface/icons/message_feed/heir.dds"
			ai_chance = {
				value = 100
			}
		}
		item = { # Favorite Child
			value = favorite_child
			is_valid = {
				custom_tooltip = { 
					text = tgp_divine_reincarnation_decision_favorite_child_tt
					any_relation = {
						type = favorite_child
						is_adult = no
						faith = root.faith
						NOT = { has_trait = reincarnation }
						this != root.primary_heir
					}
				}
			}
			localization = tgp_divine_reincarnation_decision_favorite_child_name
			icon = "gfx/interface/icons/character_interactions/designate_favorite.dds"
			ai_chance = {
				value = 0
			}
		}
	}

	cost = {
		piety = massive_piety_value
	}

	effect = {
		trigger_event = tgp_decision_events.0200
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 48
		duchy = 48
		kingdom = 36
		empire = 36
		hegemony = 36
	}
	
	ai_potential = {
		is_at_war = no
		is_adult = yes
		is_available = yes
		any_child = { is_adult = no }
		piety >= massive_piety_value
	}
	
	ai_will_do = {
		base = 50
		ai_value_modifier = {
			ai_zeal = 0.5
		}
		modifier = {
			any_child = { has_trait = reincarnation }
			factor = 0.15
		}
	}
}
