#######################################
#
# ANCIENT RELIGIONS
# - Celtic Reincarnation
#
# Event ID  celtic.270 - celtic.279 reserved
#
#######################################

namespace = celtic

# [on_birth] Child might be a reincarnation
# Duplicate event RoI.10000 for the religion check and to have Celtic specific text on chained event
character_event = {
	id = celtic.270
	hide_window = yes
	
	is_triggered_only = yes
	
	only_men = yes
	has_dlc = "Rajas of India"
	
	trigger = {
		religion_openly_in_celtic_subgroup_trigger = yes
		OR = {
			father = {
				supernatural_events_trigger = yes
				is_reincarnated = no
				father_even_if_dead = {
					OR = {
						is_alive = no
						father_even_if_dead = {
							is_alive = no
						}
					}
				}
				NOT = {
					any_sibling = {
						is_reincarnated = yes
					}
				}
			}
			mother = {
				supernatural_events_trigger = yes
				is_reincarnated = no
				father_even_if_dead = {
					OR = {
						is_alive = no
						father_even_if_dead = {
							is_alive = no
						}
					}
				}
				NOT = {
					any_sibling = {
						is_reincarnated = yes
					}
				}
			}
		}
		NOT = {
			any_sibling = {
				is_reincarnated = yes
			}
		}
	}
	
	immediate = {
		if = {
			limit = {
				father = { 
					supernatural_events_trigger = yes
				}
			}
			if = {
				limit = {
					father = {
						father_even_if_dead = {
							father_even_if_dead = {
								is_alive = no
							}
						}
					}
				}
				father = {
					father_even_if_dead = {
						father_even_if_dead = {
							ROOT = {
								set_reincarnation = THIS
							}
						}
					}
				}
			}
			if = {
				limit = {
					is_reincarnated = no
				}
				father = {
					father_even_if_dead = {
						ROOT = {
							set_reincarnation = THIS
						}
					}
				}
			}
			
			father = {
				character_event = {
					id = celtic.271
					days = 3
				}
			}
		}
		if = {
			limit = {
				mother = {
					supernatural_events_trigger = yes
				}
				is_reincarnated = no
			}
			if = {
				limit = {
					mother = {
						father_even_if_dead = {
							father_even_if_dead = {
								is_alive = no
							}
						}
					}
				}
				mother = {
					father_even_if_dead = {
						father_even_if_dead = {
							ROOT = {
								set_reincarnation = THIS
							}
						}
					}
				}
			}
			if = {
				limit = {
					is_reincarnated = no
				}
				mother = {
					father_even_if_dead = {
						ROOT = {
							set_reincarnation = THIS
						}
					}
				}
			}
			
			mother = {
				character_event = {
					id = celtic.271
					days = 3
				}
			}
		}
	}
}

# Reincarnation: Player notices the similarities
character_event = {
	id = celtic.271
	desc = celtic.271.desc
	picture = GFX_evt_reincarnation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {# Yes, clearly
		name = celtic.271.a 
		
		hidden_tooltip = {
			FROM = {
				add_trait = reincarnation
				character_event = {
					id = RoI.10002 # Back to RoI event chain, which is not Indian specific.
					days = 912
				}
			}
		}
	}
	
	option = {# Nonsense!
		name = celtic.271.b
		
		hidden_tooltip = {
			FROM = {
				set_reincarnation = 0
			}
		}
	}
}

# [on_yearly_childhood_pulse] Reincarnation: Youth picks up a personality trait from the previous life
# Duplicate event RoI.10010 for the religion check
character_event = {
	id = celtic.272
	desc = EVTDESC_RoI_10010
	picture = GFX_evt_reincarnation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	has_dlc = "Rajas of India"
	has_character_flag = reincarnation_education
	
	trigger = {
		religion_openly_in_celtic_subgroup_trigger = yes
		NOT = { personality_traits = 5 }
		reincarnation_scope = {
			ROOT = {
				can_copy_personality_trait_from = PREV
			}
		}
	}
	
	option = {
		name = EVTOPTA_RoI_10010
		reincarnation_scope = {
			ROOT = {
				copy_random_personality_trait = PREV
			}
		}
		hidden_tooltip = {
			if = {
				limit = {
					father = {
						ai = no
					}
				}
				father = {
					character_event = {
						id = RoI.10011
						days = 2
					}
				}
			}
			if = {
				limit = {
					mother = {
						ai = no
					}
				}
				mother = {
					character_event = {
						id = RoI.10011
						days = 2
					}
				}
			}
			if = {
				limit = {
					guardian = {
						ai = no
					}
				}
				guardian = {
					character_event = {
						id = RoI.10011
						days = 2
					}
				}
			}
		}
	}
}