###########################################
#                                         #
# Horse Lords Silk Route events 		  #
#                                         #
# ID HL.5000-HL.5999      	              #
#                                         #
###########################################

# Written by Joel Hansson

namespace = HL

# Envoy demands tribute
character_event = {
	id = HL.5000
	desc = EVTDESC_HL_5000
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	only_playable = yes
	only_independent = yes
	only_capable = yes
	prisoner = no
	ai = no
	
	trigger = {
		has_dlc = "Horse Lords"
		conditional_tooltip = {
			trigger = { 
				has_dlc = "Jade Dragon"
			}
	        NOT = { offmap_china = { governor = { character = ROOT } } }
	        offmap_china = {
	            NOR = {
	                has_status = china_civil_war
	                has_status = china_plague
	            }
	        }
		}
		higher_tier_than = COUNT
		NOR = {
			has_character_flag = had_chinese_envoy
			trait = infirm
		}
		is_not_busy_trigger = yes
		OR = {
			AND = {
				has_dlc = "Jade Dragon"
	      	  	china_diplo_interaction_trigger = yes
	      	}
	      	AND = {
	      		NOT = { has_dlc = "Jade Dragon" }
				capital_scope = {
					OR = {
						region = world_steppe_east
						region = world_steppe_tarim
						duchy = { title = d_samarkand }
						duchy = { title = d_khiva }
						duchy = { title = d_merv }
					}
				}
			}
		}
		any_demesne_province = {
			has_trade_post = yes
			trade_route = silk_road
		#	trade_route_active = silk_road
		}
	}
	
	mean_time_to_happen = {
		years = 100
	}
	
	immediate = {
		set_character_flag = had_chinese_envoy
		random_demesne_province = {
			limit = {
				has_trade_post = yes
				trade_route = silk_road
			#	trade_route_active = silk_road
			}
			save_event_target_as = trade_province
		}
	}
	
	option = {
		name = EVTOPTA_HL_5000
		scaled_wealth = -1.5
		if = {
			limit = { has_dlc = "Jade Dragon" }
			add_grace_minor_effect = yes
		}
		hidden_tooltip = {
			character_event = {	id = HL.5001 days = 90 random = 41 }
		}
	}
	
	option = {
		name = EVTOPTB_HL_5000
		hidden_tooltip = {
			if = {
				limit = { has_dlc = "Jade Dragon" }
				offmap_china = { governor = { character_event = { id = HL.5062 days = 90 random = 41 } } }
				break = yes
			}
			letter_event = { id = HL.5048 days = 90 random = 41 }
		}
	}
}

# Envoy offers his services
character_event = {
	id = HL.5001
	desc = EVTDESC_HL_5001
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5001
		ai_chance = {
			factor = 100
		}
		create_character = {
			random_traits = no
			dynasty = actually_culture
			religion = taoist
			culture = han
			female = no
			age = 34
			attributes = {
				diplomacy = 5
				stewardship = 4
			}
			trait = administrator
			historical = yes
		}
		hidden_tooltip = {
			new_character = {
				random_list = {
					10 = {
						# semi-random traits
						add_trait = thrifty_clerk
						add_trait = proud
						add_trait = ambitious
						add_trait = cynical
					}
					10 = {
						add_trait = charismatic_negotiator
						add_trait = just
						add_trait = gregarious
						add_trait = envious
						add_trait = ambitious
					}
					10 = {
						add_trait = fortune_builder
						add_trait = greedy
						add_trait = envious
						add_trait = chaste
						add_trait = shy
					}
					10 = {
						add_trait = naive_appeaser
						add_trait = temperate
						add_trait = patient
						add_trait = slothful
						add_trait = craven
					}
				}
				set_character_flag = is_chinese_envoy
				save_event_target_as = chinese_envoy
				opinion = {
					who = ROOT
					modifier = opinion_happy
					months = 180
				}
			}
		}
		save_event_target_as = host
		event_target:trade_province = {
			add_province_modifier = {
				modifier = trade_governor
				duration = -1
			}
			hidden_tooltip = {
				province_event = { id = HL.5047 days = 30 }
			}
		}
		hidden_tooltip = {
			character_event = { id = HL.5002 days = 365 } # Determine random events
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			add_grace_trivial_effect = yes
		}
	}
	
	option = {
		name = EVTOPTB_HL_5001
		ai_chance = {
			factor = 0
		}
		hidden_tooltip = { # Angry Emperor
			if = {
				limit = { has_dlc = "Jade Dragon" }
				offmap_china = { governor = { character_event = { id = HL.5062 days = 15 random = 15 } } }
				break = yes
			}
			letter_event = { id = HL.5048 days = 15 random = 15 }
		}
		create_character = {
			random_traits = no
			dynasty = actually_culture
			religion = taoist
			culture = han
			female = no
			age = 34
			attributes = {
				diplomacy = 5
				stewardship = 4
			}
			trait = administrator
			historical = yes
		}
		hidden_tooltip = {
			new_character = {
				random_list = {
					10 = {
						# semi-random traits
						add_trait = thrifty_clerk
						add_trait = proud
						add_trait = ambitious
						add_trait = cynical
					}
					10 = {
						add_trait = charismatic_negotiator
						add_trait = just
						add_trait = gregarious
						add_trait = envious
						add_trait = ambitious
					}
					10 = {
						add_trait = fortune_builder
						add_trait = greedy
						add_trait = envious
						add_trait = chaste
						add_trait = shy
					}
					10 = {
						add_trait = naive_appeaser
						add_trait = temperate
						add_trait = patient
						add_trait = slothful
						add_trait = craven
					}
				}
				prestige = -100
				add_character_modifier = {
					modifier = dung_collector
					months = 120
				}
				opinion = {
					who = ROOT
					modifier = opinion_mocked
					months = 120
				}
			}
		}
	}
	
	option = {
		name = EVTOPTC_HL_5001
		ai_chance = {
			factor = 0
		}
	}
}

# Determine random events
character_event = {
	id = HL.5002
	hide_window = yes
	is_triggered_only = yes

	
	immediate = {
		if = {
			limit = {
				OR = {
					NOT = {
						event_target:chinese_envoy = {
							OR = {
								liege = { character = ROOT }
								host = { character = ROOT }
							}
							prisoner = no
							has_character_flag = is_chinese_envoy
						}
					}
					NOT = {
						event_target:trade_province = {
							holder_scope = {
								character = ROOT
							}
						}
					}
				}
			}
			event_target:chinese_envoy = {
				clr_character_flag = is_chinese_envoy
			}
			character_event = { id = HL.5049 }
			break = yes
		}
		random_list = {
			30 = { # increase in trade
				modifier = {
					factor = 0
					event_target:trade_province = { has_province_modifier = surge_of_traders }
				}
				event_target:trade_province = { province_event = { id = HL.5005 } }
			}
			30 = { # gemstones
				modifier = {
					factor = 0
					has_character_flag = chinese_envoy_event_1
				}
				character_event = { id = HL.5006 }
			}
			30 = { # theft of goods
				modifier = {
					factor = 0
					has_character_flag = chinese_envoy_event_2
				}
				character_event = { id = HL.5007 }
			}
			30 = { # snake pet
				modifier = {
					factor = 0
					has_character_flag = chinese_envoy_event_3
				}
				event_target:chinese_envoy = { character_event = { id = HL.5018 } }
			}
			30 = { # snake pet escalation
				modifier = {
					factor = 0
					OR = {
						NOT = { has_character_flag = chinese_envoy_event_3 }
						has_character_flag = chinese_envoy_event_4
						has_character_flag = chinese_envoy_snake_ban
					}
				}
				if = {
					limit = { 
						has_character_modifier = pet_hunting_dog
					}
					character_event = { id = HL.5009 }
				}
				if = {
					limit = {
						NOT = { has_character_modifier = pet_hunting_dog }
						any_vassal = {
							NOT = { character = ROOT }
							prisoner = no
							in_command = no
							NOT = {
								trait = incapable
							}
							is_not_busy_trigger = yes
						}
					}
					random_vassal = {
						limit = {
							NOT = { character = ROOT }
							prisoner = no
							in_command = no
							NOT = {
								trait = incapable
							}
							is_not_busy_trigger = yes
						}
						character_event = { id = HL.5009 }
					}
				}
				if = {
					limit = {
						NOT = { has_character_modifier = pet_hunting_dog }
						NOT = {
							any_vassal = {
								NOT = { character = ROOT }
								prisoner = no
								in_command = no
								NOT = {
									trait = incapable
								}
								is_not_busy_trigger = yes
							}
						}
					}
					random_courtier = {
						character_event = { id = HL.5009 }
					}
				}
			}
			30 = { # request partner
				modifier = {
					factor = 0
					OR = {
						event_target:chinese_envoy = {
							is_married = yes
						}
						NOT = {
							any_courtier = {
								is_married = no
								is_female = yes
								is_adult = yes
								NOT = { age = 40 }
								NOT = { trait = incapable }
								prisoner = no
							}
						}
						has_character_flag = chinese_envoy_event_5
					}
				}
				random_courtier = {
					limit = {
						is_married = no
						is_female = yes
						is_adult = yes
						NOT = { age = 40 }
						NOT = { trait = incapable }
						prisoner = no
					}
					character_event = { id = HL.5012 }
				}
			}
			30 = { # games of chance
				modifier = {
					factor = 0
					has_character_flag = chinese_envoy_event_6
				}
				event_target:chinese_envoy = { character_event = { id = HL.5015 } }
			}
			30 = { # trade an artifact
				trigger = { 
					has_dlc = "Jade Dragon"
				}
				modifier = {
					factor = 0.1
					any_artifact = { has_artifact_flag = chinese }
				}
		        modifier = {
		            offmap_china = { has_status = china_unrest }
		            factor = 0.6
		        }
		        modifier = {
		            offmap_china = { has_status = china_mongol_invasion }
		            factor = 0.3
		        }
		        modifier = {
		            offmap_china = { has_status = china_jurchen_invasion }
		            factor = 0.3
		        }
		        modifier = {
		            offmap_china = { has_status = china_famine }
		            factor = 0.3
		        }
		        modifier = {
		            offmap_china = { has_status = china_golden_age }
		            factor = 3
		        }
		        modifier = {
		            offmap_china = { has_policy = china_expansionist }
		            factor = 2
		        }
				event_target:chinese_envoy = { character_event = { id = JD.60001 } }
			}
			10 = { # resignation
				modifier = {
					factor = 0
					NOT = { had_character_flag = { flag = is_chinese_envoy days = 500 } }
				}
				modifier = {
					factor = 0
					event_target:chinese_envoy = {
						personal_opinion = { who = ROOT value = 20 }
					}
				}
				modifier = {
					factor = 4
					NOT = {
						event_target:chinese_envoy = {
							personal_opinion = { who = ROOT value = 0 }
						}
					}
				}
				modifier = {
					factor = 4
					NOT = {
						event_target:chinese_envoy = {
							personal_opinion = { who = ROOT value = -20 }
						}
					}
				}
				modifier = {
					factor = 4
					NOT = {
						event_target:chinese_envoy = {
							personal_opinion = { who = ROOT value = -50 }
						}
					}
				}
				event_target:chinese_envoy = {
					character_event = { id = HL.5044 }
					break = yes
				}
			}
		}
		repeat_event = { id = HL.5002 days = 1095 random = 1096 }
	}
}

# increase in trade
province_event = {
	id = HL.5005
	desc = EVTDESC_HL_5005
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5005
		add_province_modifier = {
			modifier = surge_of_traders
			months = 60
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			add_grace_trivial_effect = yes
		}
	}
}

# gemstones
character_event = {
	id = HL.5006
	desc = EVTDESC_HL_5006
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	immediate = {
		set_character_flag = chinese_envoy_event_1
	}
	
	option = {
		name = EVTOPTA_HL_5006
		if = {
			limit = {
				NOT = { yearly_income = 200 }
			}
			wealth = 40
		}
		if = {
			limit = {
				yearly_income = 200
			}
			scaled_wealth = 0.2
		}
	}
	
	option = {
		name = EVTOPTB_HL_5006
		prestige = 90
	}
	
	option = {
		name = EVTOPTC_HL_5006
		trigger = {
			spouse = { always = yes }
		}
		spouse = {
			opinion = {
				who = ROOT
				modifier = opinion_happy
				months = 60
			}
		}
	}
}

# stolen goods
character_event = {
	id = HL.5007
	desc = EVTDESC_HL_5007
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	immediate = {
		set_character_flag = chinese_envoy_event_2
	}
	
	option = {
		name = EVTOPTA_HL_5007
		scaled_wealth = -0.75
		if = {
			limit = {
				NOR = {
					trait = charitable
					trait = greedy
				}
			}
			random = {
				chance = 25
				add_trait = charitable
				hidden_tooltip = {
					character_event = { id = 38273 } # Notify charitable
				}
			}
		}
		hidden_tooltip = {
			set_character_flag = reimbursed_trader
			character_event = { id = HL.5008 days = 7 }
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			add_grace_trivial_effect = yes
		}
	}
	
	option = {
		name = EVTOPTB_HL_5007
		any_vassal = {
			limit = { is_republic = yes }
			opinion = {
				modifier = opinion_irritated
				who = ROOT
				months = 36
			}
		}
		hidden_tooltip = {
			character_event = { id = HL.5008 days = 7 }
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_trivial_effect = yes
		}
	}
}

character_event = {
	id = HL.5008
	desc = EVTDESC_HL_5008
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5008
		if = {
			limit = {
				has_character_flag = reimbursed_trader
			}
			random = {
				chance = 50
				add_trait = deceitful
				hidden_tooltip = {
					character_event = { id = 38255 } # notify deceitful
				}
			}
		}
		if = {
			limit = {
				NOT = { has_character_flag = reimbursed_trader }
			}
			add_trait = deceitful
		}
		scaled_wealth = 0.5
		clr_character_flag = reimbursed_trader
		if = {
			limit = { has_dlc = "Jade Dragon" }
			add_grace_trivial_effect = yes
		}
	}
	
	option = {
		name = EVTOPTB_HL_5008
		random = {
			chance = 50
			add_trait = honest
			hidden_tooltip = {
				character_event = { id = 38262 } # Notify honest
			}
		}
		clr_character_flag = reimbursed_trader
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_trivial_effect = yes
		}
	}
}

character_event = {
	id = HL.5009
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		event_target:chinese_envoy = { character_event = { id  = HL.5010 } }
	}
}

character_event = {
	id = HL.5010
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROMFROM = { character_event = { id  = HL.5011 } }
	}
}

character_event = {
	id = HL.5011
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	desc = {
		trigger = {
			FROMFROM = { character = ROOT }
		}
		text = EVTDESC_HL_5011SELF
	}
	
	desc = {
		trigger = {
			NOT = { FROMFROM = { character = ROOT } }
		}
		text = EVTDESC_HL_5011OTHER
	}
	
	immediate = {
		set_character_flag = chinese_envoy_event_4
	}
	
	option = {
		name = EVTOPTA_WOL_5011
		trigger = {
			NOT = { FROMFROM = { character = ROOT } }
		}
		FROMFROM = {
			opinion = {
				who = ROOT
				modifier = grievously_offended
				months = 60
			}
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			add_grace_trivial_effect = yes
		}
	}
	
	option = {
		name = EVTOPTB_WOL_5011
		trigger = {
			NOT = { FROMFROM = { character = ROOT } }
		}
		FROM = {
			opinion = {
				who = ROOT
				modifier = grievously_offended
				months = 60
			}
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_trivial_effect = yes
		}
	}
	
	option = { 
		name = EVTOPTC_WOL_5011_FAITHFUL
		trigger = {
			has_character_flag = dog_name_faithful
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_HUNTER
		trigger = {
			has_character_flag = dog_name_hunter
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_TRICKY
		trigger = {
			has_character_flag = dog_name_tricky
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_LUCIFER
		trigger = {
			has_character_flag = dog_name_lucifer
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_SHAYTAN
		trigger = {
			has_character_flag = dog_name_shaytan
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_FENRIR
		trigger = {
			has_character_flag = dog_name_fenrir
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_ERLIK
		trigger = {
			has_character_flag = dog_name_erlik
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_VELNIAS
		trigger = {
			has_character_flag = dog_name_velnias
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_TUONI
		trigger = {
			has_character_flag = dog_name_tuoni
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_XOLOTL
		trigger = {
			has_character_flag = dog_name_xolotl
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_VELES
		trigger = {
			has_character_flag = dog_name_veles
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_GURUHI
		trigger = {
			has_character_flag = dog_name_guruhi
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_DARKNESS
		trigger = {
			has_character_flag = dog_name_darkness
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_AHRIMAN
		trigger = {
			has_character_flag = dog_name_ahriman
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_SATAN
		trigger = {
			has_character_flag = dog_name_satan
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_VINAYAKA
		trigger = {
			has_character_flag = dog_name_vinayaka
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_MARA
		trigger = {
			has_character_flag = dog_name_mara
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	option = { 
		name = EVTOPTC_WOL_5011_PUNISHER
		trigger = {
			has_character_flag = dog_name_punisher
			FROMFROM = { character = ROOT }
		}
		set_character_flag = hunting_dog_already_killed
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		opinion = {
			who = FROM
			modifier = grievously_offended
			months = 60
		}
		random = {
			chance = 70
			add_trait = depressed
			hidden_tooltip = {
				character_event = { id = 38288 }
			}
		}
	}
	
	option = {
		name = EVTOPTD_WOL_5011
		trigger = {
			FROMFROM = { character = ROOT }
		}
		event_target:chinese_envoy = {
			death = {
				death_reason = death_execution_beheading
				killer = ROOT
			}
		}
		remove_character_modifier = pet_hunting_dog
		hidden_tooltip = { character_event = { id = WoL.5291 } }
		hidden_tooltip = {
			character_event = { id = HL.5049 } # flag-clearing
			event_target:trade_province = { province_event = { id = HL.5047 } } # clear governor modifier
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_major_effect = yes
		}
	}
}

# Requesting partner
character_event = {
	id = HL.5012
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		event_target:chinese_envoy = { character_event = { id = HL.5013 } }
	}
}

character_event = {
	id = HL.5013
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		event_target:host = { character_event = { id = HL.5014 } }
	}
}

character_event = {
	id = HL.5014
	desc = EVTDESC_HL_5014
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	immediate = {
		set_character_flag = chinese_envoy_event_5
	}
	
	option = {
		name = EVTOPTA_HL_5014
		FROMFROM = {
			event_target:chinese_envoy = {
				add_spouse = PREV
				opinion = {
					modifier = opinion_very_disappointed
					who = ROOT
					months = 60
				}
			}
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			add_grace_trivial_effect = yes
		}
	}
	
	option = {
		name = EVTOPTB_HL_5014
		event_target:chinese_envoy = {
			clr_character_flag = is_chinese_envoy
			banish = yes
		}
		event_target:trade_province = {
			remove_province_modifier = trade_governor
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_medium_effect = yes
		}
	}
}

# Games of chance
character_event = {
	id = HL.5015
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		event_target:host = {
			character_event = { id = HL.5016 }
		}
	}
}

character_event = {
	id = HL.5016
	desc = EVTDESC_HL_5016
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	immediate = {
		set_character_flag = chinese_envoy_event_6
	}
	
	option = {
		name = EVTOPTA_HL_5016
		scaled_wealth = -0.7
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_trivial_effect = yes
		}
	}
	
	option = {
		name = EVTOPTB_HL_5016
		scaled_wealth = -0.7
		event_target:chinese_envoy = {
			imprison = ROOT
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_medium_effect = yes
		}
	}
}

character_event = {
	id = HL.5017
	desc = EVTDESC_HL_5017
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	immediate = {
		set_character_flag = chinese_envoy_event_3
	}
	
	option = {
		name = EVTOPTA_HL_5017
		random = {
			chance = 5
			add_trait = wounded
			if = {
				limit = {
					NOT = {
						has_dlc = "Reapers"
					}
				}
				add_trait = ill
			}
			if = {
				limit = {
					has_dlc = "Reapers"
				}
				add_symptom_effect = yes
			}
			hidden_tooltip = {
				character_event = { id = 38290 }
			}
		}
		event_target:chinese_envoy = {
			opinion = {
				who = ROOT
				modifier = opinion_pleased
				months = 24
			}
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			add_grace_trivial_effect = yes
		}
	}
	
	option = {
		name = EVTOPTB_HL_5017
	}
	
	option = {
		name = EVTOPTC_HL_5017
		event_target:chinese_envoy = {
			opinion = {
				who = ROOT
				modifier = opinion_shocked
				months = 120
			}
		}
		set_character_flag = chinese_envoy_snake_ban
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_trivial_effect = yes
		}
	}
}

character_event = {
	id = HL.5018
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			character_event = { id = HL.5017 }
		}
	}
}

character_event = {
	id = HL.5043
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		death = {
			death_reason = death_natural
		}
	}
}

# resignation
character_event = {
	id = HL.5044
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		event_target:host = {
			character_event = { id = HL.5045 }
		}
	}
}

character_event = {
	id = HL.5045
	desc = EVTDESC_HL_5045
	picture = GFX_evt_chinese_emissary
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5045
		event_target:chinese_envoy = {
			opinion = {
				modifier = opinion_hate
				who = ROOT
				months = 1200
			}
			clr_character_flag = is_chinese_envoy
			banish = yes
			character_event = { id = HL.5043 days = 90 random = 20 }
		}
		event_target:trade_province = {
			remove_province_modifier = trade_governor
		}
		hidden_tooltip = {
			character_event = { id = HL.5049 }
		}
	}
}

# Something happened to the chinese envoy
province_event = {
	id = HL.5047
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		has_province_modifier = trade_governor
	}
	
	immediate = {
		if = {
			limit = {
				NOT = {
					holder_scope = {
						character = event_target:host
					}
					event_target:chinese_envoy = {
						OR = {
							liege = { character = event_target:host }
							host = { character = event_target:host }
						}
						prisoner = no
					}
				}
			}
			event_target:chinese_envoy = { clr_character_flag = is_chinese_envoy }
			remove_province_modifier = trade_governor
			break = yes
		}
		repeat_event = { id = HL.5047 days = 30 }
	}
}

# Emperor upset
letter_event = {
	id = HL.5048
	desc = EVTDESC_HL_5048
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5048
		event_target:trade_province = {
			add_province_modifier = {
				modifier = chinese_embargo
				months = 60
			}
		}
		if = {
			limit = { has_dlc = "Jade Dragon" }
			detract_grace_major_effect = yes
		}
	}
}

# Flag-clearing
character_event = {
	id = HL.5049
	hide_window = yes
	
	is_triggered_only = yes
	
	option = {
		clr_character_flag = chinese_envoy_event_1
		clr_character_flag = chinese_envoy_event_2
		clr_character_flag = chinese_envoy_event_3
		clr_character_flag = chinese_envoy_event_4
		clr_character_flag = chinese_envoy_event_5
		clr_character_flag = chinese_envoy_event_6
		event_target:trade_province = {
			remove_province_modifier = trade_governor
		}
		event_target:chinese_envoy = { clr_character_flag = is_chinese_envoy }
	}
}

# Ping Emperor
character_event = {
	id = HL.5062
	hide_window = yes
	is_triggered_only = yes

	immediate = { FROM = { letter_event = { id = HL.5048 } } }
}

###
# Raiders on the trade route
province_event = {
	id = HL.5050
	desc = EVTDESC_HL_5050
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	trigger = {
		has_trade_post = yes
		trade_route = silk_road
		#trade_route_active = silk_road
		holder_scope = {
			age = 16
			prisoner = no
			NOR = {
				trait = incapable
				trait = infirm
			}
			is_not_busy_trigger = yes
		}
	}
	
	mean_time_to_happen = {
		years = 130
		modifier = {
			factor = 2
			has_province_modifier = caravan_guards
		}
		modifier = {
			factor = 0.8
			holder_scope = {
				NOR = {
					stewardship = 8
					diplomacy = 8
				}
			}
		}
		modifier = {
			factor = 0.75
			holder_scope = {
				NOR = {
					stewardship = 5
					diplomacy = 5
				}
			}
		}
		modifier = {
			factor = 0.8
			holder_scope = {
				trait = greedy
			}
		}
		modifier = {
			factor = 0.85
			holder_scope = {
				trait = arbitrary
			}
		}
		modifier = {
			factor = 0.85
			holder_scope = {
				trait = cruel
			}
		}
		modifier = {
			factor = 1.15
			holder_scope = {
				trait = just
			}
		}
		modifier = {
			factor = 1.1
			holder_scope = {
				trait = kind
			}
		}
		modifier = {
			factor = 1.25
			holder_scope = {
				trait = charitable
			}
		}
	}
	
	immediate = {
		remove_province_modifier = caravan_guards
		save_event_target_as = target_province
	}
	
	option = {
		name = EVTOPTA_HL_5050
		add_province_modifier = {
			modifier = caravan_raiders
			months = 180
		}
		holder_scope = {
			add_trait = arbitrary
			scaled_wealth = 0.5
		}
	}
	
	option = {
		name = EVTOPTB_HL_5050
		trigger = {
			holder_scope = {
				job_marshal = {
					always = yes
				}
			}
		}
		add_province_modifier = {
			modifier = caravan_raiders
			months = 180
		}
		holder_scope = {
			job_marshal = {
				if = {
					limit = {
						NOT = { combat_rating = 1 }
					}
					tooltip = {
						random = {
							chance = 20
							death = {
								death_reason = death_battle
							}
						}
					}
				}
				if = {
					limit = {
						combat_rating = 1
					}
					tooltip = {
						random = {
							chance = 10
							death = {
								death_reason = death_battle
							}
						}
					}
				}
				if = {
					limit = {
						combat_rating = 3
					}
					tooltip = {
						random = {
							chance = 2
							death = {
								death_reason = death_battle
							}
						}
					}
				}
				hidden_tooltip = {
					character_event = { id = HL.5051 days = 7 }
				}
			}
		}
	}
	
	option = {
		name = EVTOPTC_HL_5050
		add_province_modifier = {
			modifier = caravan_raiders
			months = 180
		}
		hidden_tooltip = {
			holder_scope = {
				character_event = { id = HL.5056 days = 7 }
			}
		}
	}
}

character_event = {
	id = HL.5051
	desc = EVTDESC_HL_5051
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5051
		ai_chance = {
			factor = 30
		}
		random_list = {
			20 = {
				modifier = {
					factor = 0.5
					combat_rating = 1
				}
				modifier = {
					factor = 0.2
					combat_rating = 3
				}
				death = {
					death_reason = death_battle
				}
				hidden_tooltip = {
					liege = {
						character_event = { id = HL.5053 }
					}
				}
			}
			20 = {
				if = {
					limit = {
						NOT = { is_maimed_trigger = yes }
					}
					add_trait = wounded
				}
				hidden_tooltip = {
					liege = {
						character_event = { id = HL.5055 days = 7 }
					}
				}
			}
			60 = {
				prestige = 100
				tooltip = {
					event_target:target_province = {
						remove_province_modifier = caravan_raiders
					}
				}
				hidden_tooltip = {
					liege = {
						character_event = {	id = HL.5052 days = 7 }
					}
				}
			}
		}
	}
	
	option = {
		name = EVTOPTB_HL_5051
		ai_chance = {
			factor = 15
			modifier = {
				factor = 5
				trait = craven
			}
			modifier = {
				factor = 0
				trait = brave
			}
		}
		reverse_opinion = { who = FROM modifier = opinion_refused_order months = 36 }
		custom_tooltip = { text = "EVTTOOLTIP_HL_5051" }
		hidden_tooltip = {
			liege = { character_event = { id = HL.5054 days = 7 } }
		}
	}
}

character_event = {
	id = HL.5052
	desc = EVTDESC_HL_5052
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5052
		tooltip = { FROM = { prestige = 100 } }
		event_target:target_province = {
			remove_province_modifier = caravan_raiders
		}
	}
}

character_event = {
	id = HL.5053
	desc = EVTDESC_HL_5053
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5053
		tooltip = {
			FROM = {
				death = { death_reason = death_battle }
			}
		}
		prestige = -10
		if = {
			limit = {
				NOR = { trait = brave trait = berserker }
			}
			random = {
				chance = 40
				add_trait = craven
				hidden_tooltip = { character_event = { id = 38257 } } # Notify craven
			}
		}
		if = {
			limit = {
				trait = brave
			}
			remove_trait = brave
		}
	}
	
	option = {
		name = EVTOPTB_HL_5053
		tooltip = {
			FROM = {
				death = { death_reason = death_battle }
			}
		}
		character_event = { id = HL.5056 days = 7 }
	}
	
	option = {
		name = EVTOPTC_HL_5053
		tooltip = {
			FROM = {
				death = { death_reason = death_battle }
			}
		}
		scaled_wealth = -0.5
		event_target:target_province = {
			remove_province_modifier = caravan_raiders
			add_province_modifier = {
				modifier = caravan_guards
				months = 120
			}
		}
	}
}

character_event = {
	id = HL.5054
	desc = EVTDESC_HL_5054
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5054
		job_marshal = {
			imprison = ROOT
		}
	} 
	
	option = {
		name = EVTOPTB_HL_5054
		character_event = { id = HL.5056 days = 7 }
	}
	
	option = {
		name = EVTOPTC_HL_5054
		scaled_wealth = -0.5
		event_target:target_province = {
			remove_province_modifier = caravan_raiders
			add_province_modifier = {
				modifier = caravan_guards
				months = 120
			}
		}
	}
}

character_event = {
	id = HL.5055
	desc = EVTDESC_HL_5055
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5055
		
	}
}

character_event = {
	id = HL.5056
	desc = EVTDESC_HL_5056
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5056
		hidden_tooltip = {
			character_event = { id = HL.5057 }
		}
	}
	
	option = {
		name = EVTOPTB_HL_5056
		hidden_tooltip = {
			random_list = {
				50 = {
					modifier = {
						factor = 0.7
						intrigue = 7
					}
					modifier = {
						factor = 0.7
						intrigue = 10
					}
					modifier = {
						factor = 0.7
						intrigue = 13
					}
					character_event = { id = HL.5060 }
				}
				50 = {
					character_event = { id = HL.5061 }
				}
			}
		}
	}
}

character_event = {
	id = HL.5057
	desc = EVTDESC_HL_5057
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5057
		random_list = {
			30 = { #success
				modifier = {
					factor = 1.5
					combat_rating = 2
				}
				prestige = 75
				event_target:target_province = {
					remove_province_modifier = caravan_raiders
				}
			}
			20 = { #wounded
				modifier = {
					factor = 0.5
					combat_rating = 2
				}
				modifier = {
					factor = 0
					is_maimed_trigger = yes
				}
				add_trait = wounded
				hidden_tooltip = { character_event = { id = 38280 } }
			}
			10 = { #maimed
				modifier = {
					factor = 0.5
					combat_rating = 2
				}
				modifier = {
					factor = 3
					is_maimed_trigger = yes
				}
				add_maimed_trait_effect = yes
			}
		}
	}
	
	option = {
		name = EVTOPTB_HL_5057
		scaled_wealth = -1.5
		event_target:target_province = {
			remove_province_modifier = caravan_raiders
		}
	}
	
	option = {
		name = EVTOPTC_HL_5057
		hidden_tooltip = {
			character_event = { id = HL.5058 }
		}
	}
}

character_event = {
	id = HL.5058
	desc = EVTDESC_HL_5058
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5058
		character_event = { id = HL.5059 }
	}
}

character_event = {
	id = HL.5059
	desc = EVTDESC_HL_5059
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5059
		scaled_wealth = -1
		prestige = -75
	}
	
	option = {
		name = EVTOPTB_HL_5059
		prestige = -100
		add_character_modifier = {
			modifier = publicly_humiliated
			months = 36
		}
	}
}

character_event = {
	id = HL.5060
	desc = EVTDESC_HL_5060
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5060
		ai_chance = {
			factor = 1
		}
		character_event = { id = HL.5059 }
	}
	
	option = {
		name = EVTOPTB_HL_5060
		ai_chance = {
			factor = 0
		}
		trigger = {
			trait = duelist
		}
		tooltip_info = duelist
		random_list = {
			80 = {
				death = { death_reason = death_battle }
			}
			20 = {
				modifier = {
					factor = 2
					combat_rating = 3
				}
				modifier = {
					factor = 2
					combat_rating = 5
				}
				modifier = {
					factor = 2
					combat_rating = 7
				}
				modifier = {
					factor = 0.1
					NOT = { combat_rating = -1 }
				}
				modifier = {
					factor = 0.1
					NOT = { combat_rating = -4 }
				}
				prestige = 75
				event_target:target_province = {
					remove_province_modifier = caravan_raiders
				}
			}
		}
	}
	
	option = {
		name = EVTOPTB_HL_5060
		ai_chance = {
			factor = 0
		}
		trigger = {
			trait = lunatic
		}
		tooltip_info = lunatic
		random_list = {
			80 = {
				death = { death_reason = death_battle }
			}
			20 = {
				modifier = {
					factor = 2
					combat_rating = 3
				}
				modifier = {
					factor = 2
					combat_rating = 5
				}
				modifier = {
					factor = 2
					combat_rating = 7
				}
				modifier = {
					factor = 0.1
					NOT = { combat_rating = -1 }
				}
				modifier = {
					factor = 0.1
					NOT = { combat_rating = -4 }
				}
				prestige = 75
				event_target:target_province = {
					remove_province_modifier = caravan_raiders
				}
			}
		}
	}
}

character_event = {
	id = HL.5061
	desc = EVTDESC_HL_5061
	picture = GFX_evt_steppe_mercenaries
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_HL_5061
		ai_chance = {
			factor = 1
		}
		event_target:target_province = {
			remove_province_modifier = caravan_raiders
		}
	}
	
	option = {
		name = EVTOPTB_HL_5061
		ai_chance = {
			factor = 0
		}
		random_list = {
			80 = {
				death = { death_reason = death_battle }
			}
			20 = {
				modifier = {
					factor = 2
					combat_rating = 3
				}
				modifier = {
					factor = 2
					combat_rating = 5
				}
				modifier = {
					factor = 2
					combat_rating = 7
				}
				modifier = {
					factor = 0.1
					NOT = { combat_rating = -1 }
				}
				modifier = {
					factor = 0.1
					NOT = { combat_rating = -4 }
				}
			}
		}
		add_trait = cruel
		event_target:target_province = {
			remove_province_modifier = caravan_raiders
		}
	}
}