###########################################
# Reincarnation Events - Manichaen
###########################################

namespace = RoM

# [on_birth] Child might be a reincarnation
character_event = {
	id = RoM.10000
	hide_window = yes
	
	is_triggered_only = yes
	
	only_men = yes
	
	trigger = {
		has_dlc = "Rajas of India"
		religion = manichean 
		OR = {
			father = {
				ai = no
				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 = {
				ai = no
				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
			}
		}
	}
	
	option = {
		name = OK
		if = {
			limit = {
				father = { 
					ai = no
				}
			}
			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 = RoM.10001
					days = 3
				}
			}
		}
		if = {
			limit = {
				mother = { ai = no }
				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 = RoM.10001
					days = 3
				}
			}
		}
	}
}

# Reincarnation: Player notices the similarities
character_event = {
	id = RoM.10001
	desc = EVTDESC_RoI_10001
	picture = GFX_evt_reincarnation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_RoI_10001 # Yes, clearly
		
		hidden_tooltip = {
			FROM = {
				add_trait = reincarnation
				character_event = {
					id = RoM.10002
					days = 912
				}
			}
		}
	}
	
	option = {
		name = EVTOPTB_RoI_10001 # Nonsense!
		
		hidden_tooltip = {
			FROM = {
				set_reincarnation = 0
			}
		}
	}
}

# Reincarnation: Toddler thinks of the past life
character_event = {
	id = RoM.10002
	desc = EVTDESC_RoI_10002
	picture = GFX_evt_reincarnation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_RoI_10002
		hidden_tooltip = {
			FROM = {
				character_event = {
					id = RoM.10003
					days = 2
				}
			}
		}
	}
}

# Reincarnation: Toddler speaks of the past life
character_event = {
	id = RoM.10003
	desc = EVTDESC_RoI_10003
	picture = GFX_evt_reincarnation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_RoI_10003
		hidden_tooltip = {
			FROM = {
				set_character_flag = reincarnation_education
			}
		}
	}
	option = {
		name = EVTOPTB_RoI_10003
	}
}

# [on_yearly_childhood_pulse] Reincarnation: Youth picks up a personality trait from the previous life
character_event = {
	id = RoM.10010
	desc = EVTDESC_RoI_10010
	picture = GFX_evt_reincarnation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	trigger = {
		religion = manichean 
		has_dlc = "Rajas of India"
		has_character_flag = reincarnation_education
		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 = RoM.10011
						days = 2
					}
				}
			}
			if = {
				limit = {
					mother = {
						ai = no
					}
				}
				mother = {
					character_event = {
						id = RoM.10011
						days = 2
					}
				}
			}
			if = {
				limit = {
					guardian = {
						ai = no
					}
				}
				guardian = {
					character_event = {
						id = RoM.10011
						days = 2
					}
				}
			}
		}
	}
}

# Reincarnation: Notification of a youth picking up a personality trait from the previous life
character_event = {
	id = RoM.10011
	desc = EVTDESC_RoI_10011
	picture = GFX_evt_reincarnation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_RoI_10011
	}
}

# [on_yearly_pulse] Reincarnation: Reincarnated player remembers his murderer
character_event = {
	id = RoM.10020
	desc = EVTDESC_RoI_10020
	picture = GFX_evt_shadow
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	ai = no
	min_age = 14
	
	trigger = {
		is_reincarnated = yes
		trait = reincarnation
		has_dlc = "Rajas of India"
		reincarnation_scope = {
			OR = {
				death_reason = death_murder
				death_reason = death_murder_unknown
				death_reason = death_execution
			}
			killer = {
				always = yes
			}
		}
		NOT = { has_character_flag = reinc_remembered_killer }
	}
	
	option = {
		name = EVTOPTA_RoI_10020
		
		set_character_flag = reinc_remembered_killer
		
		if = {
			limit = {
				reincarnation_scope = {
					killer = {
						is_alive = yes
					}
				}
			}
			reincarnation_scope = {
				killer = {
					reverse_opinion = {
						who = ROOT
						years = 100
						modifier = opinion_dishonorable
					}
				}
			}
		}
	}
}

# [on_yearly_pulse] Reincarnation: Reincarnated player remembers spouse
character_event = {
	id = RoM.10021
	desc = EVTDESC_RoI_10021
	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	ai = no
	min_age = 14
	
	trigger = {
		is_reincarnated = yes
		trait = reincarnation
		has_dlc = "Rajas of India"
		reincarnation_scope = {
			spouse_even_if_dead = {
				always = yes
			} 
		}
		NOT = { has_character_flag = reinc_remembered_spouse }
	}
	
	option = {
		name = EVTOPTA_RoI_10021
		
		set_character_flag = reinc_remembered_spouse
	}
}

# [on_yearly_pulse] Reincarnation: Reincarnated player remembers birth of oldest child
character_event = {
	id = RoM.10022
	desc = EVTDESC_RoI_10022
	picture = GFX_evt_child_play
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	ai = no
	min_age = 14
	
	trigger = {
		is_reincarnated = yes
		trait = reincarnation
		has_dlc = "Rajas of India"
		reincarnation_scope = {
			num_of_children = 1
		}
		NOT = { has_character_flag = reinc_remembered_oldest_child }
	}
	
	option = {
		name = EVTOPTA_RoI_10022
		
		set_character_flag = reinc_remembered_oldest_child
	}
}


