
# Written by Emil Tisander and Alexander Oltner

###########################################
#                                         #
# Sky Burial events 					  #
# by Emil Tisander                        #
# ID HL.8000-HL.8050      	              #
#                                         #
###########################################

namespace = HL

# Sky Burial trigger event
character_event = {
	id = HL.8001
	hide_window = yes

	is_triggered_only = yes
	
	only_playable = yes
	
	trigger = {
		has_dlc = "Horse Lords"
		death_in_china_trigger = no
		death_no_trace_trigger = no
		OR = {
			religion_group = zoroastrian_group
			religion = bon
			religion = tibetan_pagan
			AND = {
				government = nomadic_government
				OR = {
					religion = tengri_pagan
					religion = tengri_pagan_reformed
					religion_group = zoroastrian_group
					has_dharmic_religion_trigger = yes
				}
			}
		}
	}

	immediate = {
		if = {
			limit = {
				prestige = 20000
			}
			current_heir = {
				set_character_flag = sky_burial_tomb
			}
		}
		if = {
			limit = {
				current_heir = {
					is_child_of = ROOT
				}
			}
			if = {
				limit = {
					is_female = yes
				}
				current_heir = {
					set_character_flag = sky_burial_mother
				}
			}
			if = {
				limit = {
					is_female = no
				}
				current_heir = {
					set_character_flag = sky_burial_father
				}
			}
		}
		if = {
			limit = {
				current_heir = {
					sibling = ROOT
				}
			}
			if = {
				limit = {
					is_female = yes
				}
				current_heir = {
					set_character_flag = sky_burial_sister
				}
			}
			if = {
				limit = {
					is_female = no
				}
				current_heir = {
					set_character_flag = sky_burial_brother
				}
			}
		}
		current_heir = {
			set_character_flag = sky_burial
			character_event = { id = HL.8002 days = 60 }
		}
	}
}

# Clear event
character_event = {
	id = HL.8002
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		clr_character_flag = sky_burial
		clr_character_flag = sky_burial_tomb
		clr_character_flag = sky_burial_father
		clr_character_flag = sky_burial_brother
		clr_character_flag = sky_burial_mother
		clr_character_flag = sky_burial_sister
	}
}

# Decide on Burial
character_event = {
	id = HL.8005
	title = EVTNAME_HL_8005
	picture = GFX_evt_shaman
	desc = { # Father
		trigger = {
			has_character_flag = sky_burial_father
		}
		text = EVTDESC_HL_8005_father
	}
	desc = { # Mother
		trigger = {
			has_character_flag = sky_burial_mother
		}
		text = EVTDESC_HL_8005_mother
	}
	desc = { # Brother
		trigger = {
			has_character_flag = sky_burial_brother
		}
		text = EVTDESC_HL_8005_brother
	}
	desc = { # Sister
		trigger = {
			has_character_flag = sky_burial_sister
		}
		text = EVTDESC_HL_8005_sister
	}
	desc = { # Any other predecessor
		trigger = {
			NOT = { has_character_flag = sky_burial_father }
			NOT = { has_character_flag = sky_burial_brother }
			NOT = { has_character_flag = sky_burial_mother }
			NOT = { has_character_flag = sky_burial_sister }
		}
		text = EVTDESC_HL_8005_other
	}
	
	is_triggered_only = yes
	
	option = { # Sky Burial
		name = EVTOPTA_HL_8005
		custom_tooltip = { text = EVTOPTC_HL_8005_custom_tooltip_a }
		hidden_tooltip = {
			random_list = {
				25 = { character_event = { id = HL.8006 days = 10 } }
				25 = { character_event = { id = HL.8008 days = 10 } }
				50 = { character_event = { id = HL.8010 days = 10 } }
			}
		}
	}
	option = { # Raise a Golden Tomb instead
		name = EVTOPTB_HL_8005
		trigger = {
			has_character_flag = sky_burial_tomb
		}
		wealth = -250
		custom_tooltip = { text = EVTOPTC_HL_8005_custom_tooltip_b }
		hidden_tooltip = {
			character_event = { id = HL.8020 days = 10 }
		}
	}
	option = { # Lunatic option
		name = EVTOPTC_HL_8005
		trigger = {
			trait = lunatic
			OR = {
				has_landed_title = c_anxi
				any_realm_character = { has_landed_title = c_anxi }
			}
		}
		tooltip_info = lunatic
		custom_tooltip = { text = EVTOPTC_HL_8005_custom_tooltip_c }
		hidden_tooltip = {
			character_event = { id = HL.8030 days = 20 }
		}
	}
	option = { # Also for possessed
		name = EVTOPTC_HL_8005
		trigger = {
			trait = possessed
			OR = {
				has_landed_title = c_anxi
				any_realm_character = { has_landed_title = c_anxi }
			}
		}
		tooltip_info = possessed
		custom_tooltip = { text = EVTOPTC_HL_8005_custom_tooltip_c }
		hidden_tooltip = {
			character_event = { id = HL.8030 days = 20 }
		}
	}
}

# Sky Burial - Bad weather
character_event = {
	id = HL.8006
	title = EVTNAME_HL_8006
	desc = EVTDESC_HL_8006
	picture = GFX_evt_nomad_camp
	
	is_triggered_only = yes
	
	option = { # Find shelter
		name = EVTOPTA_HL_8006
		if = {
			limit = {
				NOT = { trait = patient }
			}
			random = {
				chance = 30
				add_trait = patient
				hidden_tooltip = {
					character_event = { id = 38264 } # Notify patient
				}
			}
		}
		if = {
			limit = {
				trait = patient
			}
			prestige = 30
		}
		hidden_tooltip = {
			character_event = { id = HL.8010 days = 5 }
		}
	}
	option = { # Continue
		name = EVTOPTB_HL_8006
		if = {
			limit = {
				NOT = { trait = brave }
				NOT = { trait = craven }
			}
			random_list = {
				30 = {
					add_trait = brave
					hidden_tooltip = {
						character_event = { id = 38270 }
					}
				}
				30 = {
					if = {
						limit = {
							NOT = {
								has_dlc = "Reapers"
							}
						}
						add_trait = ill
						hidden_tooltip = {
							character_event = { id = 38290 } # Notify ill
						}
					}
					if = {
						limit = {
							has_dlc = "Reapers"
						}
						add_symptom_effect = yes
					}
				}
				40 = { }
			}
		}
		if = {
			limit = {
				trait = craven
				NOT = { trait = brave }
			}
			random_list = {
				50 = { remove_trait = craven }
				30 = {
					if = {
						limit = {
							NOT = {
								has_dlc = "Reapers"
							}
						}
						add_trait = ill
						hidden_tooltip = {
							character_event = { id = 38290 } # Notify ill
						}
					}
					if = {
						limit = {
							has_dlc = "Reapers"
						}
						add_symptom_effect = yes
					}
				}
				20 = { }
			}
		}
		if = {
			limit = {
				trait = brave
				NOT = { trait = content }
			}
			random_list = {
				30 = {
					add_trait = ambitious
					hidden_tooltip = {
						character_event = { id = 38278 }
					}
				}
				30 = {
					if = {
						limit = {
							NOT = {
								has_dlc = "Reapers"
							}
						}
						add_trait = ill
						hidden_tooltip = {
							character_event = { id = 38290 } # Notify ill
						}
					}
					if = {
						limit = {
							has_dlc = "Reapers"
						}
						add_symptom_effect = yes
					}
				}
				40 = { }
			}
		}
		hidden_tooltip = {
			character_event = { id = HL.8010 days = 5 }
		}
	}
}

# Sky Burial - Hermit encountered
character_event = {
	id = HL.8008
	title = EVTNAME_HL_8008
	desc = EVTDESC_HL_8008
	picture = GFX_evt_lunatic
	
	is_triggered_only = yes
	
	option = { # Give gift
		name = EVTOPTA_HL_8008
		wealth = -10
		trigger = {
			NOT = { trait = greedy }
		}
		if = {
			limit = {
				NOT = { trait = charitable }
			}
			random = {
				chance = 50
				add_trait = charitable
				hidden_tooltip = {
					character_event = { id = 38273 }
				}
			}
		}
		if = {
			limit = {
				trait = charitable
			}
			prestige = 20
		}
		hidden_tooltip = {
			character_event = { id = HL.8010 days = 5 }
		}
	}
	option = { # Ask to join
		name = EVTOPTB_HL_8008
		ai_chance = {
			factor = 0
		}
		create_character = {
			random_traits = yes
			dynasty = NONE
			female = no
			age = 40
			religion = ROOT
			culture = ROOT
			trait = brilliant_strategist
			attributes = {
				martial = 10
			}
		}
		hidden_tooltip = {
			character_event = { id = HL.8010 days = 5 }
		}
	}
	option = { # Leave the hermit
		name = EVTOPTC_HL_8008
		hidden_tooltip = {
			character_event = { id = HL.8010 days = 5 }
		}
	}
}

# Perform Sky Burial
character_event = {
	id = HL.8010
	title = EVTNAME_HL_8010
	desc = EVTDESC_HL_8010
	picture = GFX_evt_shaman
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_8010
		prestige = 100
		hidden_tooltip = {
			random = {
				chance = 10
				character_event = { id = HL.8011 days = 10 }
			}
		}
	}
}

# Followed by a Vulture
character_event = {
	id = HL.8011
	title = EVTNAME_HL_8011
	desc = EVTDESC_HL_8011
	picture = GFX_evt_nomad_camp
	
	is_triggered_only = yes
	
	option = { # Keep the vulture
		name = EVTOPTA_HL_8011
		prestige = 10
		if = {
			limit = {
				NOT = { trait = falconer }
			}
			add_trait = falconer
		}
	}
	option = { # Send it away
		name = EVTOPTB_HL_8011
	}
}

# Begin construction on Golden Tomb
character_event = {
	id = HL.8020
	title = EVTNAME_HL_8020
	desc = EVTDESC_HL_8020
	picture = GFX_evt_fishing
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_8020
		prestige = 10
		hidden_tooltip = {
			character_event = { id = HL.8022 days = 5 }
		}
	}
}

# Golden Tomb Completed
character_event = {
	id = HL.8022
	title = EVTNAME_HL_8022
	desc = EVTDESC_HL_8022
	picture = GFX_evt_tengri_throneroom_oldgods
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_8022
		prestige = 250
	}
	option = { # Cruel option
		if = {
			limit = {
				NOT = { trait = cruel }
			}
			add_trait = cruel
			prestige = 250
		}
		if = {
			limit = {
				trait = cruel
			}
			prestige = 300
		}
		name = EVTOPTB_HL_8022
	}
}

# On the way to olgoi-khorkhoi (Mongolian death worm)
character_event = {
	id = HL.8030
	title = EVTNAME_HL_8030
	desc = EVTDESC_HL_8030
	picture = GFX_evt_sand_desert
	
	is_triggered_only = yes
	
	option = { # Continue
		name = EVTOPTA_HL_8030
		prestige = -100
		piety = 100
		random_list = {
			15 = {
				death = {
					death_reason = death_accident
				}
			}
			85 = {
				character_event = { id = HL.8032 days = 10 }
			}
		}
	}
	option = { # Go back
		name = EVTOPTB_HL_8030
		prestige = -100

		random_list = {
			5 = {
				death = {
					death_reason = death_accident
				}
			}
			95 = { custom_tooltip = { text = EVTOPTA_HL_8032_custom_tooltip } }
		}
	}
}

# Sacrifice to olgoi-khorkhoi (Mongolian death worm)
character_event = {
	id = HL.8032
	title = EVTNAME_HL_8032
	desc = EVTDESC_HL_8032
	picture = GFX_evt_sand_desert
	
	is_triggered_only = yes

	option = { # Return home
		name = EVTOPTA_HL_8032
		trigger = {
			is_weak_trigger = no
			is_ill = no
			NOT = { trait = wounded }
			NOT = { is_maimed_trigger = yes }
		}
		prestige = -100
		piety = 100
		random_list = {
			40 = {
				death = {
					death_reason = death_accident
				}
			}
			60 = {
				custom_tooltip = { text = EVTOPTA_HL_8032_custom_tooltip }
				hidden_tooltip = {
					character_event = { id = HL.8035 days = 10 }
				}
			}
		}
	}
	option = { # Rest
		name = EVTOPTB_HL_8032
		trigger = {
			OR = {
				is_weak_trigger = yes
				is_ill = yes
				trait = wounded
				is_maimed_trigger = yes
			}
		}
		death = {
			death_reason = death_accident
		}
	}
}

# You return home from the desert
character_event = {
	id = HL.8035
	title = EVTNAME_HL_8035
	desc = EVTDESC_HL_8035
	picture = GFX_evt_tengri_throneroom_oldgods
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_8035
		prestige = 150
		if = {
			limit = { is_strong_trigger = no }
		}
		add_trait = robust
	}
}

###########################################
#                                         #
# Mongol wrestling events				  #
# by Alexander Oltner                     #
# ID HL.9000-HL.9050      	              #
#                                         #
###########################################

character_event = {
	id = HL.9000
	desc =  EVTDESC_HL_9000
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_war
	
	min_age =  16
	only_men = yes
	capable_only = yes
	prisoner = no
	only_playable = yes
	only_independent = yes
	war = no
	has_dlc = "Horse Lords"

	trigger = {
		government = nomadic_government
		NOT = { has_character_modifier = manly_skill_wrestling }
		NOT = { has_character_modifier = denied_wrestling }
		any_realm_character = {
			is_female = no
			is_adult = yes
			ai = yes
			prisoner = no
			martial = 10
			NOT = {
				OR = {
					character = ROOT 
					trait = incapable
					trait = infirm
					health_traits = 1
					trait = craven
				}
			}
		}
		any_demesne_title = {
			tier = BARON
			has_building = no_wrestling_1
		}
	}
	
	mean_time_to_happen = {
		months = 360
		
		modifier = {
			factor = 0.7
			has_focus = focus_war
		}
		
		modifier = {
			factor = 0.8
			has_focus = focus_hunting
		}
		
	}
	
	option = {
		name = EVTOPTA_HL_9000
		ai_chance = { factor = 50 }
		character_event = { id = HL.9001 tooltip = EVTTOOLTIP_HL_9000A }
	}
	
	option = {
		name = EVTOPTB_HL_9000
		ai_chance = { factor = 50 }
		trigger = {
			NOT = { trait = slothful }
		}
		
		if = {
			limit = {
				NOT = { trait = diligent }
			}
			random = {
				add_trait = diligent
				chance = 35
				hidden_tooltip = { character_event = { id = 38256 } } # notify diligent
			}
		}
		add_character_modifier = {
			modifier = denied_wrestling
			years = 1
		}
	}
	
	option = {
		name = EVTOPTD_HL_9000
		ai_chance = { factor = 0 }
		trigger = {
			NOT = { trait = proud }
		}
		
		prestige = -20
	}
	
	option = {
		name = EVTOPTD_HL_9000
		ai_chance = { factor = 0 }
		trigger = {
			trait = proud
		}
		
		prestige = -20
		remove_trait = proud
	}
}

character_event = {
	id = HL.9001 # Wrestling Event
	desc =  EVTDESC_HL_9001
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	immediate = {
		random_realm_character = {
			limit = {
				is_female = no
				is_adult = yes
				ai = yes
				prisoner = no
				martial = 10
				NOT = {
					OR = {
						character = ROOT 
						trait = incapable
						trait = infirm
						health_traits = 1
						trait = craven
					}
				}
			}
			save_event_target_as = wrestling_opponent
		}
	}
	
	option = {
		name = EVTOPTA_HL_9001
		
		event_target:wrestling_opponent = {
			character_event = {	id = HL.9002 tooltip = EVTTOOLTIP_HL_9001A }
		}
	}
	
	option = {
		name = EVTOPTD_HL_9001
		tooltip_info = lunatic
		
		trigger = {
			trait = lunatic
		}
		
		prestige = -50
		random_list = {
				29 = {
					add_trait = wounded
					hidden_tooltip = { character_event = { id = 38280 } }
				}
				45 = {
					add_maimed_trait_effect = yes
				}
				25 = {
					death = { death_reason = death_accident }
				}
				1 = {
					custom_tooltip = { text = wrestling_win_vs_horse }
					hidden_tooltip = { 
						add_character_modifier = {
						modifier = manly_skill_wrestling
						years = 5
						}
					}
				}
			}
	}
	
	option = {
		name = EVTOPTB_HL_9001
		
		trigger = {
			NOT = { trait = arbitrary }
		}
		
		prestige = 50
		add_trait = arbitrary
		hidden_tooltip = { character_event = { id = 38266 } } # notify arbitrary
	}
	
	option = {
		name = EVTOPTB_HL_9001
		tooltip_info = arbitrary
		
		trigger = {
			trait = arbitrary
			NOT = { trait = proud }
		}
		
		prestige = 50
		add_trait = proud
		hidden_tooltip = { character_event = { id = 38261 } } # notify proud
	}
	
	option = {
		name = EVTOPTB_HL_9001
		
		trigger = {
			trait = arbitrary
			trait = proud
		}
		
		prestige = 75
	}
	
	option = {
		name = EVTOPTC_HL_9001
		
		prestige = -10
		if = {
			limit = {
				NOT = { trait = craven }
			}
			add_trait = craven
			hidden_tooltip = { character_event = { id = 38257 } } # notify craven
		}
	}

}

character_event = {
	id = HL.9002 # Wrestling Resolver

	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				OR = {
					AND = {
						FROM = { is_strong_trigger = yes }
						is_strong_trigger = no
					}
					AND = {
						FROM = { is_weak_trigger = no }
						is_weak_trigger = yes
					}
				}
			}
			random_list = {
				95 = {
					FROM = {
						long_character_event = { id = HL.9003 } # Win
					}
				}
				5 = {
					FROM = {
						long_character_event = { id = HL.9004 } # Lose
					}
				}
			}
			break = yes
		}
		if = {
			limit = {
				OR = {
					AND = {
						FROM = { is_strong_trigger = yes }
						is_strong_trigger = yes
					}
					AND = {
						FROM = { is_strong_trigger = no }
						FROM = { is_weak_trigger = no }
						NOT = { is_strong_trigger = yes }
						NOT = { is_weak_trigger = yes }
					}
				}
			}
			random_list = {
				70 = {
					FROM = {
						long_character_event = { id = HL.9003 } 
					}
				}
				30 = {
					FROM = {
						long_character_event = { id = HL.9004 } 
					}
				}
			}
			break = yes
		}	
		if = {
			limit = {
				FROM = { is_weak_trigger = yes }
				is_weak_trigger = yes
			}
			random_list = {
				50 = {
					FROM = {
						long_character_event = { id = HL.9003 } 
					}
				}
				50 = {
					FROM = {
						long_character_event = { id = HL.9004 } 
					}
				}
			}
			break = yes
		}
		if = {
			limit = {
				OR = {
					AND = {
						FROM = { is_weak_trigger = yes }
						is_weak_trigger = no
					}
					AND = {
						FROM = { is_strong_trigger = no }
						is_strong_trigger = yes
					}
				}
			}
			random_list = {
				5 = {
					FROM = {
						long_character_event = { id = HL.9003 }
					}
				}
				95 = {
					FROM = {
						long_character_event = { id = HL.9004 }
					}
				}
			}
			break = yes
		}
	}
}

long_character_event = {
	id = HL.9003 # Win Wrestling
	desc =  EVTDESC_HL_9003
	picture = GFX_evt_tengri_throneroom_oldgods
	border = GFX_event_long_frame_war
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_9003
		tooltip_info = proud
		
		trigger = {
			trait = proud
		}
		
		prestige = 100
		if = {
			limit = {
				NOT = { is_rival = FROM }
			}
			add_rival = FROM
		}
		add_character_modifier = {
			modifier = manly_skill_wrestling
			years = 5
		}
	}
	
	option = {
		name = EVTOPTB_HL_9003
		
		prestige = 50
		add_character_modifier = {
			modifier = manly_skill_wrestling
			years = 5
		}
	}
	
	option = {
		name = EVTOPTC_HL_9003
		tooltip_info = kind
		
		trigger = {
			trait = kind
			NOT = { is_friend = FROM }
		}
		
		prestige = 25
		add_friend = FROM
		add_character_modifier = {
			modifier = manly_skill_wrestling
			years = 5
		}
	}
	
	option = {
		name = EVTOPTC_HL_9003
		tooltip_info = gregarious
		
		trigger = {
			trait = gregarious
			NOT = { trait = kind }
			NOT = { is_friend = FROM }
		}
		
		prestige = 25
		add_friend = FROM
		add_character_modifier = {
			modifier = manly_skill_wrestling
			years = 5
		}
	}
	
	option = {
		name = EVTOPTD_HL_9003
		tooltip_info = homosexual
		
		trigger = {
			trait = homosexual
			FROM = { trait = homosexual }
			FROM = { NOT = { is_close_relative = ROOT } }
			NOT = { is_lover = FROM }
			NOT = { is_former_lover = FROM }
		}
		
		prestige = 50
		add_lover = FROM
		add_character_modifier = {
			modifier = manly_skill_wrestling
			years = 5
		}
	}
}

long_character_event = {
	id = HL.9004 # Lose Wrestling
	desc =  EVTDESC_HL_9004
	picture = GFX_evt_mongols
	border = GFX_event_long_frame_war
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTB_HL_9004
		tooltip_info = gregarious
		
		trigger = {
			trait = gregarious
		}
		
		FROM = { prestige = 25 }
		prestige = -25
		if = {
			limit = {
				NOT = { is_friend = FROM }
			}
			add_friend = FROM
		}
	}
	
	option = {
		name = EVTOPTA_HL_9004
		
		FROM = { prestige = 50 }
		prestige = -50
	}
	
	option = {
		name = EVTOPTC_HL_9004
		tooltip_info = wroth
		
		trigger = {
			trait = wroth
			FROM = { NOT = { health_traits = 1 } }
		}
		
		FROM = { prestige = 75 }
		prestige = -75
		FROM = { 
			random_list = {
					90 = {
						add_trait = wounded
					}
					10 = {
						add_maimed_trait_effect = yes
					}
				} 
			}
		if = {
			limit = {
				NOT = { is_rival = FROM }
			}
			add_rival = FROM
		}
		if = {
			limit = {
				NOT = { trait = cruel }
			}
			add_trait = cruel
			hidden_tooltip = { character_event = { id = 38259 } } # notify cruel
		}
	}
	
	option = {
		name = EVTOPTD_HL_9004
		tooltip_info = homosexual
		
		trigger = {
			trait = homosexual
			FROM = { trait = homosexual }
			FROM = { NOT = { is_close_relative = ROOT } }
			NOT = { is_lover = FROM }
			NOT = { is_former_lover = FROM }
		}
		
		FROM = { prestige = 50 }
		prestige = -50
		add_lover = FROM
	}
}