namespace = EADRE

# Patron deity
# Fired from Decision 'select_patron_deity_tribunal'
character_event = {
	id = EADRE.1
	desc = EADREDESC.1
	picture = GFX_evt_beatification_dark_elven
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	immediate = {
		remove_trait = patron_verios
		remove_trait = patron_reanna
		remove_trait = patron_al_setep
	}
	
	option = {
		name = tribunal_patron_1_a
		set_character_flag = patron_chosen
		add_trait = patron_verios
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = tribunal_patron_1_b
		set_character_flag = patron_chosen
		add_trait = patron_reanna
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = tribunal_patron_1_c
		set_character_flag = patron_chosen
		add_trait = patron_al_setep
		clr_character_flag = selecting_patron_deity
	}
}

#Remove main deity in case of religious conversion
character_event = {
	id = EADRE.2

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = {
			religion = elven_tribunal
		}
	}

	immediate = {
		remove_trait = patron_verios
		remove_trait = patron_reanna
		remove_trait = patron_al_setep
	}
}

character_event = {
	id = EADRE.3
	desc = EADREDESC.1
	picture = GFX_evt_beatification_dark_elven
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = true_tribunal_patron_1_a
		set_character_flag = patron_chosen
		add_trait = patron_aleret
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = true_tribunal_patron_1_b
		set_character_flag = patron_chosen
		add_trait = patron_mali_ra
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = true_tribunal_patron_1_c
		set_character_flag = patron_chosen
		add_trait = patron_berat_tashi
		clr_character_flag = selecting_patron_deity
	}
}

#Remove main deity in case of religious conversion
character_event = {
	id = EADRE.4

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = {
			religion = elven_tribunal_heresy
		}
	}

	immediate = {
		remove_trait = patron_aleret
		remove_trait = patron_mali_ra
		remove_trait = patron_berat_tashi
	}
}

#TRIBUNAL SAINTS 1
character_event = {
	id = EADRE.5
	desc = EADREDESC.2
	picture = GFX_evt_beatification_dark_elven
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = tribunal_saint_1_a
		set_character_flag = patron_saint_chosen
		add_character_modifier = {
			name = saint_veros
			duration = -1
		}
		clr_character_flag = selecting_patron_saint
	}
	option = {
		name = tribunal_saint_1_b
		set_character_flag = patron_saint_chosen
		add_character_modifier = {
			name = saint_navruz
			duration = -1
		}
		clr_character_flag = selecting_patron_saint
	}
	option = {
		name = tribunal_saint_1_c
		set_character_flag = patron_saint_chosen
		add_character_modifier = {
			name = saint_resin
			duration = -1
		}
		clr_character_flag = selecting_patron_saint
	}
	option = {
		name = tribunal_saint_1_d
		hidden_tooltip = { character_event = { id = EADRE.6 } }
	}
}

#TRIBUNAL SAINTS 2
character_event = {
	id = EADRE.6
	desc = EADREDESC.2
	picture = GFX_evt_beatification_dark_elven
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = tribunal_saint_1_e
		set_character_flag = patron_saint_chosen
		add_character_modifier = {
			name = saint_oros
			duration = -1
		}
		clr_character_flag = selecting_patron_saint
	}
	option = {
		name = tribunal_saint_1_f
		set_character_flag = patron_saint_chosen
		add_character_modifier = {
			name = saint_neris
			duration = -1
		}
		clr_character_flag = selecting_patron_saint
	}
	option = {
		name = tribunal_saint_1_g
		set_character_flag = patron_saint_chosen
		add_character_modifier = {
			name = saint_lloris
			duration = -1
		}
		clr_character_flag = selecting_patron_saint
	}
	option = {
		name = tribunal_saint_1_d
		hidden_tooltip = { character_event = { id = EADRE.5 } }
	}
}

#Remove saint in case of religious conversion
character_event = {
	id = EADRE.7

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOR = {
			religion = elven_tribunal_heresy
			religion = elven_tribunal
		}
	}

	immediate = {
		remove_character_modifier = saint_veros
		remove_character_modifier = saint_navruz
		remove_character_modifier = saint_neris
		remove_character_modifier = saint_oros
		remove_character_modifier = saint_resin
		remove_character_modifier = saint_lloris
	}
}

character_event = {
	id = EADRE.8
	desc = EADREDESC.8
	picture = GFX_evt_beatification_dark_elven
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = dark_dwarven_school_1_a
		set_character_flag = patron_chosen
		add_trait = school_nchar_ashdaar
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = dark_dwarven_school_1_b
		set_character_flag = patron_chosen
		add_trait = school_nchuad_ashdaar
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = dark_dwarven_school_1_c
		set_character_flag = patron_chosen
		add_trait = school_nzar_ashdaar
		clr_character_flag = selecting_patron_deity
	}
}

#Remove school in case of religious conversion
character_event = {
	id = EADRE.9

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = {
			religion = dwarven_dwemer
		}
	}

	immediate = {
		remove_trait = school_nchar_ashdaar
		remove_trait = school_nchuad_ashdaar
		remove_trait = school_nzar_ashdaar
	}
}

############################################################################
# Bloodthirsty Gods/Aztecs, but aapted for fantasy rulers
# Sacrifying prisoners increases burned_hearts_points variable, unlocking tiered traits. It's like Viking traits, but for psychos.
# Hidden on death event for the sacrifical victims.
character_event = {
	id = EADRE.23430
	hide_window = yes
	trigger = { 
		has_dlc = "Holy Fury"
		death_sacrificed_trigger = yes
		killer = { 
			is_playable = yes
			is_landed = yes
			NOT = { trait = incapable }
			is_evil_otherworlden_religion = yes
		}
	}
	
	is_triggered_only = yes

	immediate = { 
		killer = { 
			#Bonus points first.
			if = { #The gods appreciate your sacrifice.
				limit = {
					is_adult = no
					ROOT = { is_child_of = PREV } 
				}
				change_variable = { which = burned_hearts_points value = 1 }
			}
			if = { #And a divine child is even better.
				limit = {
					is_adult = no
					ROOT = { religion = PREV } 
					OR = { 
						has_religion_feature = religion_holy_family 
						has_religion_feature = religion_feature_zun
					} 
				}
				change_variable = { which = burned_hearts_points value = 1 }
			}
			if = { #A foreign religious head is also quite good.
				limit = {
					NOT = { religion = ROOT } 
					controls_religion = yes
				}
				change_variable = { which = burned_hearts_points value = 2 }
			}
			if = { #A foreign emperor is also well accepted.
				limit = {
					NOT = { religion = ROOT } 
					higher_tier_than = KING
				}
				change_variable = { which = burned_hearts_points value = 2 }
			}
			#Finally, a third point is added regardless in the following scripted effect, which will also trigger the events below, when the proper score is reached.
			bloodthirsty_fantasy_tiered_traits_effect = yes 
		}
	}
}
#Gained the Haemophiliac trait.
character_event = {
	id = EADRE.23431
	desc = EVTDESCAHF23431
	picture = { 
		trigger = { 
			ROOT = { 
				is_evil_otherworlden_religion = yes
			} 
		} 
		picture = GFX_evt_pagan_blood_sacrifice
	}
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	trigger = {
		NOT = { trait = bloodthirsty_gods_1 }
		is_evil_otherworlden_religion = yes
	}

	immediate = { 
		add_blood_splatter_effect = yes
		add_trait = bloodthirsty_gods_1
	}

	option = { 
		name = EVTOPTAHF23431
		add_trait = bloodthirsty_gods_1
		if = { 
			limit = { NOR = { trait = kind trait = cruel } } 
			random = { 
				chance = 25 
				add_trait = cruel 
				hidden_tooltip = { character_event = { id = 38259 } }
			} 
		} 
		if = { 
			limit = { trait = kind } 
			random = { 
				chance = 25 
				remove_trait = kind 
				hidden_tooltip = { character_event = { id = 38307 } }
			} 
		} 
		if = { 
			limit = { trait = cynical } 
			random = { chance = 25 remove_trait = cynical } 
		}
	}
}
#Gained the Haemophant trait.
character_event = {
	id = EADRE.23432
	desc = EVTDESCAHF23432
	picture = { 
		trigger = { 
			ROOT = { 
				is_evil_otherworlden_religion = yes
			} 
		} 
		picture = GFX_evt_pagan_blood_sacrifice
	}
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	trigger = {
		OR = { 
			has_religion_feature = religion_ritual_sacrifice
			religion = aztec
			religion = aztec_reformed
		}
		NOR = { 
			trait = bloodthirsty_gods_2 
			trait = bloodthirsty_gods_3
		}
	}
	
	immediate = { 
		add_blood_splatter_effect = yes
		add_trait = bloodthirsty_gods_2
	}

	option = { 
		name = EVTOPTAHF23432
		if = { 
			limit = { trait = bloodthirsty_gods_1 } 
			remove_trait = bloodthirsty_gods_1
		} 
		add_trait = bloodthirsty_gods_2
		if = { 
			limit = { NOR = { trait = kind trait = cruel } } 
			random = { 
				chance = 50 
				add_trait = cruel 
				hidden_tooltip = { character_event = { id = 38259 } }
			} 
		} 
		if = { 
			limit = { trait = kind } 
			random = { 
				chance = 50 
				remove_trait = kind 
				hidden_tooltip = { character_event = { id = 38307 } }
			} 
		}
		if = { 
			limit = { trait = cynical } 
			random = { 
				chance = 50 
				remove_trait = cynical 
			} 
		}
	}
}
#Gained the Haemoarch trait.
character_event = {
	id = EADRE.23433
	desc = EVTDESCAHF23433
	picture = { 
		trigger = { 
			ROOT = { 
				is_evil_otherworlden_religion = yes
			} 
		} 
		picture = GFX_evt_pagan_blood_sacrifice
	}
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	trigger = {
		OR = { 
			has_religion_feature = religion_ritual_sacrifice
			religion = aztec
			religion = aztec_reformed
		}
		NOT = { 
			trait = bloodthirsty_gods_3
		}
	}
	immediate = { 
		add_blood_splatter_effect = yes
		add_trait = bloodthirsty_gods_3
	}

	option = { 
		name = EVTOPTAHF23433
		if = { 
			limit = { trait = bloodthirsty_gods_1 } 
			remove_trait = bloodthirsty_gods_1
		} 
		if = { 
			limit = { trait = bloodthirsty_gods_2 } 
			remove_trait = bloodthirsty_gods_2
		} 
		add_trait = bloodthirsty_gods_3
		if = { 
			limit = { NOR = { trait = kind trait = cruel } } 
			random = { 
				chance = 75 
				add_trait = cruel 
				hidden_tooltip = { character_event = { id = 38259 } }
			} 
		}
		if = { 
			limit = { trait = kind } 
			remove_trait = kind
		}
		if = { 
			limit = { trait = cynical } 
			remove_trait = cynical
		}
	}
}
#Gained the Bloodthirsty Bloodline.
narrative_event = {
	id = EADRE.23434
	title = EVTTITLE23434
	desc = EVTDESCAHF23434
	picture = { 
		trigger = { 
			ROOT = { 
				is_evil_otherworlden_religion = yes
			} 
		} 
		picture = GFX_evt_pagan_blood_sacrifice
	}
	border = GFX_event_narrative_frame_religion
	sound = bloodline_added
	
	is_triggered_only = yes

	trigger = {
		is_evil_otherworlden_religion = yes
		NOT = { 
			any_owned_bloodline = { # Not already has a Bloodthirsty bloodline.
				has_bloodline_flag = bloodline_created_bloodthirsty
			}
		}
	}

	immediate = { 
		add_blood_splatter_effect = yes
		if = {
			limit = {
				ai = no
			}
			set_character_flag = achievement_bloody_line
		}
	}

	option = {
		name = EVTOPTAHF23434
		hidden_tooltip = { 
			if = { 
				limit = { this_has_super_cool_nickname_trigger = no }
				random_list = { 
					20 = { 
						give_nickname = nick_the_red_storm 
					} 
					20 = { 
						give_nickname = nick_the_scarlet_hands 
					} 
					20 = { 
						give_nickname = nick_the_blood_monger 
					} 
					20 = { 
						give_nickname = nick_the_black_skull 
					} 
					20 = { 
						give_nickname = nick_the_heart_eater 
					} 
					20 = { 
						give_nickname = nick_the_slaughterer 
					} 
					20 = { 
						give_nickname = nick_the_soul_flayer
					} 
					20 = { 
						give_nickname = nick_the_spirit_stalker 
					} 
					10 = { 
						give_nickname = nick_the_crimson_reaper 
					} 
					10 = { 
						give_nickname = nick_the_dreaded
					} 
					5 = { 
						give_nickname = nick_the_chest_buster 
					} 
				}
			}
		}
		if = { 
			limit = { is_female = no }
			create_bloodline = {
				type = bloodthirsty_male_bloodline
			}
			new_bloodline = {
				set_description = "bloodline_desc_bloodthirsty_gods_bloodline"
				random_list = { 
					20 = { set_name = bloodline_bloodthirsty_name_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = bloodline_bloodthirsty_name_random_b }
					20 = { set_name = bloodline_bloodthirsty_name_random_c }
					20 = { set_name = bloodline_bloodthirsty_name_random_d } 
					20 = { set_name = bloodline_bloodthirsty_name_random_e } 
					20 = { set_name = bloodline_bloodthirsty_name_random_f } 
				}
			}
		}
		if = { 
			limit = { is_female = yes }
			create_bloodline = {
				type = bloodthirsty_female_bloodline
			}
			new_bloodline = {
				set_description = "bloodline_desc_bloodthirsty_gods_bloodline"
				random_list = { 
					20 = { set_name = bloodline_bloodthirsty_name_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = bloodline_bloodthirsty_name_random_b }
					20 = { set_name = bloodline_bloodthirsty_name_random_c }
					20 = { set_name = bloodline_bloodthirsty_name_random_d } 
					20 = { set_name = bloodline_bloodthirsty_name_random_e } 
					20 = { set_name = bloodline_bloodthirsty_name_random_f } 
				}
			}		
		}
		hidden_tooltip = { 
			any_player = { 
				limit = { 
					NOT = { character = ROOT }
					is_within_diplo_range = ROOT
				}
				narrative_event = { id = EADRE.23435 }
			}
		}
	}
}

#Inform players.
narrative_event = {
	id = EADRE.23435
	title = EVTTITLE23435
	desc = {
		trigger = {
			OR = {
				religion = FROM
				is_evil_otherworlden_religion = yes
			}
		}
		text = EVTDESCAHF23435
	}
	desc = {
		trigger = {
			NOR = {
				religion = FROM
				is_evil_otherworlden_religion = yes
			}
		}
		text = EVTDESCBHF23435
	}
	picture = { 
		trigger = { 
			FROM = { 
				is_evil_otherworlden_religion = yes
			} 
		} 
		picture = GFX_evt_pagan_blood_sacrifice
	}
	border = GFX_event_narrative_frame_religion
	
	is_triggered_only = yes

	option = { 
		name = EVTOPTAHF23435
		trigger = { 
			OR = {
				religion = FROM
				is_evil_otherworlden_religion = yes
			}
		}
	}
	option = { 
		name = EVTOPTBHF23435
		trigger = { 
			NOR = {
				religion = FROM
				is_evil_otherworlden_religion = yes
			}
		}
	}
}