
targetted_decisions = {

	xgi-takeovermain = {

		filter = all
		ai = no
		
		is_high_prio = yes
	
		from_potential = {
			ai = no
		}
	
		potential = {
			has_character_modifier = xgi-mainbody-modifier
		}
	
		allow = { 
			has_character_modifier = xgi-mainbody-modifier
		}
		
		effect = {
			ROOT = { remove_character_modifier = xgi-stopventuring-modifier }
			ROOT = { clr_character_flag = xgi-_closed_door_cultivation }
			ROOT = { clr_character_flag = xgi-_closed_door_cultivation_player }
			ROOT = { remove_trait = travelling }
			ROOT = { clr_character_flag = xgi-_seclusion_cultivation }
			ROOT = { remove_trait = xgi-In_Seclution }
			ROOT = { clr_character_flag = xgi-mainbody-flag }
			FROM = { abdicate_to = ROOT }

		}
	
		ai_will_do = {
		  factor = 0 
		}
	}

	xgi-takeoverclone = {

		filter = all
		ai = no
		
		is_high_prio = yes
	
		from_potential = {
			ai = no
		}
	
		potential = {
			has_character_modifier = xgi-mortalclone-modifier
		}
	
		allow = { 
			FROM = { has_character_modifier = xgi-mainbody-modifier }
			has_character_modifier = xgi-mortalclone-modifier
		}
		
		effect = {
			FROM = { 
				add_character_modifier = {
					name = xgi-stopventuring-modifier
						stacking = no
						duration = -1
					hidden = no
				}
			}
			FROM = { set_character_flag = xgi-_closed_door_cultivation }
			FROM = { set_character_flag = xgi-_closed_door_cultivation_player }
			FROM = { add_trait = travelling }
			FROM = { set_character_flag = xgi-_seclusion_cultivation }
			FROM = { add_trait = xgi-In_Seclution }
			FROM = { set_character_flag = xgi-mainbody-flag }
			FROM = { abdicate_to = ROOT }

		}
	
		ai_will_do = {
		  factor = 0 
		}
	}

	xgi-mortalcloneFemale = {

		filter = self
		ai = no
		
		is_high_prio = yes
	
		from_potential = {
			OR = {
				trait = Lv_7_True_Immortal_1
				trait = Lv_7_True_Immortal_2
				trait = Lv_7_True_Immortal_3
				trait = Lv_8_Immortal_God_1
				trait = Lv_8_Immortal_God_2
				trait = Lv_8_Immortal_God_3
				trait = Lv_9_Ancestral_God_1
				trait = Lv_9_Ancestral_God_2
				trait = Lv_9_Ancestral_God_3
			}
		}
	
		potential = {
			ai = no
		}
	
		allow = { 
			NOT = { 
				has_character_modifier = xgi-mortalclone-modifier
			}

			OR = { 
				trait = Lv_7_True_Immortal_1
				trait = Lv_7_True_Immortal_2
				trait = Lv_7_True_Immortal_3
				trait = Lv_8_Immortal_God_1
				trait = Lv_8_Immortal_God_2
				trait = Lv_8_Immortal_God_3
				trait = Lv_9_Ancestral_God_1
				trait = Lv_9_Ancestral_God_2
				trait = Lv_9_Ancestral_God_3
			}
			from = { piety = 900000 }
		}
		
		effect = {
			piety = -900000
			add_character_modifier = {
				name = xgi-mainbody-modifier
					stacking = no
					duration = -1
				hidden = no
			}

			FROM = { 
				create_character = {
					female = yes
					age = 16
					random_traits = no
					dynasty = FROM
					religion = FROM
					culture = FROM
					race = FROM
					genetic_father = FROM
				}
			
				new_character = {

					set_father =  FROM
				
					prompt_name = {
						player = FROM
						type = BAPTISM
					}
					add_trait = xgi-Mortal
					add_trait = xgi-clone
					add_character_modifier = {
						name = xgi-mortalclone-modifier
							stacking = no
							duration = -1
						hidden = no
					}

				opinion = {
					modifier = opinion_power_loyal
					who = FROM
					
				}

				opinion = {
					modifier = strengthened_loyalty
					who = FROM
					
				}

				opinion = {
					modifier = opinion_loyal_servant
					who = FROM
					
				}

				opinion = {
					modifier = immortal_loyalty
					who = FROM
					
				}

				opinion = {
					modifier = opinion_friend
					who = FROM
				}

				opinion = {
					modifier = xgi-Servant
					who = FROM
					
				}
					set_character_flag = xgi-servant

				}

			}
		}
	
		ai_will_do = {
		  factor = 0 
		}
	}

	xgi-mortalcloneMale = {

		filter = self
		ai = no
		
		is_high_prio = yes
	
		from_potential = {
			OR = {
				trait = Lv_7_True_Immortal_1
				trait = Lv_7_True_Immortal_2
				trait = Lv_7_True_Immortal_3
				trait = Lv_8_Immortal_God_1
				trait = Lv_8_Immortal_God_2
				trait = Lv_8_Immortal_God_3
				trait = Lv_9_Ancestral_God_1
				trait = Lv_9_Ancestral_God_2
				trait = Lv_9_Ancestral_God_3
			}
		}
	
		potential = {
			ai = no
		}
	
		allow = { 
			NOT = { 
				has_character_modifier = xgi-mortalclone-modifier
			}

			OR = { 
				trait = Lv_7_True_Immortal_1
				trait = Lv_7_True_Immortal_2
				trait = Lv_7_True_Immortal_3
				trait = Lv_8_Immortal_God_1
				trait = Lv_8_Immortal_God_2
				trait = Lv_8_Immortal_God_3
				trait = Lv_9_Ancestral_God_1
				trait = Lv_9_Ancestral_God_2
				trait = Lv_9_Ancestral_God_3
			}
			from = { piety = 900000 }
		}
		
		effect = {
			piety = -900000
			add_character_modifier = {
				name = xgi-mainbody-modifier
					stacking = no
					duration = -1
				hidden = no
			}

			FROM = { 
				create_character = {
					female = no
					age = 16
					random_traits = no
					dynasty = FROM
					religion = FROM
					culture = FROM
					race = FROM
					genetic_father = FROM
				}
			
				new_character = {

					set_father =  FROM
				
					prompt_name = {
						player = FROM
						type = BAPTISM
					}
					add_trait = xgi-Mortal
					add_trait = xgi-clone
					add_character_modifier = {
						name = xgi-mortalclone-modifier
							stacking = no
							duration = -1
						hidden = no
					}


				opinion = {
					modifier = opinion_power_loyal
					who = FROM
					
				}

				opinion = {
					modifier = strengthened_loyalty
					who = FROM
					
				}

				opinion = {
					modifier = opinion_loyal_servant
					who = FROM
					
				}

				opinion = {
					modifier = immortal_loyalty
					who = FROM
					
				}

				opinion = {
					modifier = opinion_friend
					who = FROM
				}

				opinion = {
					modifier = xgi-Servant
					who = FROM
					
				}
					set_character_flag = xgi-servant

				}

			}
		}
	
		ai_will_do = {
		  factor = 0 
		}
	}

	xgi-capture_character = {

		filter = all
		ai_target_filter = all
		
		only_playable = yes
		ai = no
		
		is_high_prio = no
	
		from_potential = {
			OR = {
				trait = Lv_7_True_Immortal_1
				trait = Lv_7_True_Immortal_2
				trait = Lv_7_True_Immortal_3
				trait = Lv_8_Immortal_God_1
				trait = Lv_8_Immortal_God_2
				trait = Lv_8_Immortal_God_3
				trait = Lv_9_Ancestral_God_1
				trait = Lv_9_Ancestral_God_2
				trait = Lv_9_Ancestral_God_3
			}
		}
	
		potential = {
			ai = yes
		}
	
		allow = {
			NAND = {
				at_location = FROM
				prisoner = yes
			}  
			NOR = { 
				trait = Lv_7_True_Immortal_1
				trait = Lv_7_True_Immortal_2
				trait = Lv_7_True_Immortal_3
				trait = Lv_8_Immortal_God_1
				trait = Lv_8_Immortal_God_2
				trait = Lv_8_Immortal_God_3
				trait = Lv_9_Ancestral_God_1
				trait = Lv_9_Ancestral_God_2
				trait = Lv_9_Ancestral_God_3
			}
			from = { piety = 600000 }
		}
		
		effect = {
			ROOT = { liege = { opinion = { modifier = xgi-hate who = FROM } } }
			FROM = { piety = -600000 }
			imprison = ROOT
		}
	
		ai_will_do = {
		  factor = 0 
		}
	}

	xgi-restore_youthfulness = {
		only_playable = yes
		ai = no		
		filter = all_including_me
	
		
		is_high_prio = no

		from_potential = {
			OR = {
				trait = Lv_7_True_Immortal_1
				trait = Lv_7_True_Immortal_2
				trait = Lv_7_True_Immortal_3
				trait = Lv_8_Immortal_God_1
				trait = Lv_8_Immortal_God_2
				trait = Lv_8_Immortal_God_3
				trait = Lv_9_Ancestral_God_1
				trait = Lv_9_Ancestral_God_2
				trait = Lv_9_Ancestral_God_3
			}
		}

		potential = {

		}

		allow = {
			age > 27
			from = { piety = 10000 }

		}
		
		effect = {
			add_age = -10
			from = { piety = -10000 }
				opinion = {
					modifier = xgi-love
					who = FROM
				}
			hidden_tooltip = {
			ROOT = {
				cure_illness = yes
				remove_trait = wounded
				remove_trait = maimed
				remove_trait = infirm
				remove_trait = incapable
				remove_trait = inbred
				remove_trait = eunuch
				remove_trait = severely_injured
				remove_trait = lovers_pox
				remove_character_modifier = bedridden_illness
			}
			}
	 		if = { 
	 			limit = { 
					trait = xgi-unaging 
					NOT = { age = 45 } 
				}
	 			remove_trait = xgi-unaging
	 			add_trait = xgi-unaging
			}
	 		if = { 
	 			limit = { trait = immortal }
	 			remove_trait = immortal
	 			add_trait = immortal
			}
	 		if = { 
	 			limit = { trait = Lv_2_Spiritual_Seed_Nurturing_1 }
	 			remove_trait = Lv_2_Spiritual_Seed_Nurturing_1
	 			add_trait = Lv_2_Spiritual_Seed_Nurturing_1
	 		}
	 		if = { 
	 			limit = { trait = Lv_2_Spiritual_Seed_Nurturing_2 }
	 			remove_trait = Lv_2_Spiritual_Seed_Nurturing_2
	 			add_trait = Lv_2_Spiritual_Seed_Nurturing_2
	 		}
	 		if = { 
	 			limit = { trait = Lv_2_Spiritual_Seed_Nurturing_3 }
	 			remove_trait = Lv_2_Spiritual_Seed_Nurturing_3
	 			add_trait = Lv_2_Spiritual_Seed_Nurturing_3
	 		}
	 		if = { 
	 			limit = { trait = Lv_3_Soul_Germination_1 }
	 			remove_trait = Lv_3_Soul_Germination_1
	 			add_trait = Lv_3_Soul_Germination_1
	 		}
	 		if = { 
	 			limit = { trait = Lv_3_Soul_Germination_2 }
	 			remove_trait = Lv_3_Soul_Germination_2
	 			add_trait = Lv_3_Soul_Germination_2
	 		}
	 		if = { 
	 			limit = { trait = Lv_3_Soul_Germination_3 }
	 			remove_trait = Lv_3_Soul_Germination_3
	 			add_trait = Lv_3_Soul_Germination_3
	 		}
	 		if = { 
	 			limit = { trait = Lv_4_Soul_Perfection_1 }
	 			remove_trait = Lv_4_Soul_Perfection_1
	 			add_trait = Lv_4_Soul_Perfection_1
	 		}
	 		if = { 
	 			limit = { trait = Lv_4_Soul_Perfection_2 }
	 			remove_trait = Lv_4_Soul_Perfection_2
	 			add_trait = Lv_4_Soul_Perfection_2
	 		}
	 		if = { 
	 			limit = { trait = Lv_4_Soul_Perfection_3 }
	 			remove_trait = Lv_4_Soul_Perfection_3
	 			add_trait = Lv_4_Soul_Perfection_3
	 		}
	 		if = { 
	 			limit = { trait = Lv_5_Soul_Unification_1 }
	 			remove_trait = Lv_5_Soul_Unification_1
	 			add_trait = Lv_5_Soul_Unification_1
	 		}
	 		if = { 
	 			limit = { trait = Lv_5_Soul_Unification_2 }
	 			remove_trait = Lv_5_Soul_Unification_2
	 			add_trait = Lv_5_Soul_Unification_2
	 		}
	 		if = { 
	 			limit = { trait = Lv_5_Soul_Unification_3 }
	 			remove_trait = Lv_5_Soul_Unification_3
	 			add_trait = Lv_5_Soul_Unification_3
	 		}
	 		if = { 
	 			limit = { trait = Lv_6_Undying_Body_1 }
	 			remove_trait = Lv_6_Undying_Body_1
	 			add_trait = Lv_6_Undying_Body_1
	 		}
	 		if = { 
	 			limit = { trait = Lv_6_Undying_Body_2 }
	 			remove_trait = Lv_6_Undying_Body_2
	 			add_trait = Lv_6_Undying_Body_2
	 		}
	 		if = { 
	 			limit = { trait = Lv_6_Undying_Body_3 }
	 			remove_trait = Lv_6_Undying_Body_3
	 			add_trait = Lv_6_Undying_Body_3
	 		}
	 		if = { 
	 			limit = { trait = Lv_7_True_Immortal_1 }
	 			remove_trait = Lv_7_True_Immortal_1
	 			add_trait = Lv_7_True_Immortal_1
	 		}
	 		if = { 
	 			limit = { trait = Lv_7_True_Immortal_2 }
	 			remove_trait = Lv_7_True_Immortal_2
	 			add_trait = Lv_7_True_Immortal_2
	 		}
	 		if = { 
	 			limit = { trait = Lv_7_True_Immortal_3 }
	 			remove_trait = Lv_7_True_Immortal_3
	 			add_trait = Lv_7_True_Immortal_3
	 		}
	 		if = { 
	 			limit = { trait = Lv_8_Immortal_God_1 }
	 			remove_trait = Lv_8_Immortal_God_1
	 			add_trait = Lv_8_Immortal_God_1
	 		}
	 		if = { 
	 			limit = { trait = Lv_8_Immortal_God_2 }
	 			remove_trait = Lv_8_Immortal_God_2
	 			add_trait = Lv_8_Immortal_God_2
	 		}
	 		if = { 
	 			limit = { trait = Lv_8_Immortal_God_3 }
	 			remove_trait = Lv_8_Immortal_God_3
	 			add_trait = Lv_8_Immortal_God_3
	 		}
	 		if = { 
	 			limit = { trait = Lv_9_Ancestral_God_1 }
	 			remove_trait = Lv_9_Ancestral_God_1
	 			add_trait = Lv_9_Ancestral_God_1
	 		}
	 		if = { 
	 			limit = { trait = Lv_9_Ancestral_God_2 }
	 			remove_trait = Lv_9_Ancestral_God_2
	 			add_trait = Lv_9_Ancestral_God_2
	 		}
	 		if = { 
	 			limit = { trait = Lv_9_Ancestral_God_3 }
	 			remove_trait = Lv_9_Ancestral_God_3
	 			add_trait = Lv_9_Ancestral_God_3
	 		}
		}

		ai_will_do = {
		  factor = 0.1 
		}
		ai_target_filter = court
	}
}