##########################################################################
#
# DUNHUANG: GATEWAY TO THE SILK ROAD
#
# dunhuang.0-29		# Startup and introduction events
# dunhuang.30-39	# Kingdom of Dunhuang events
# dunhuang.40-49	# Patronize 
# dunhuang.50-99	# Patronize/Build Mogao Cave events
# dunhuang.100-129	# Working with foreign communities events
# dunhuang.130-149	# Tuyuhun Nadun events
# dunhuang.150-199	# Circuit of Guiyi narrative events
# dunhuang.200-249	# Generic flavor events
# 
##########################################################################

namespace = dunhuang

#Set up Dunhuang area provinces, flags, etc - fires on the Pope
character_event =  {
	id = dunhuang.0
	
	hide_window = yes
	is_triggered_only = yes
	
	only_playable = yes
	religion = catholic

	trigger = {
		is_save_game = no
		has_landed_title = k_papal_state # Pope's always around
		NOT = { has_alternate_start_parameter = { key = religion_names value = random } }
		NOT = { has_alternate_start_parameter = { key = culture_names value = random } }
	}
	
	immediate = {
	
		# CULTURE CHANGES
		1502 = { culture = tuyuhun } # Fuqi
		if = {
			limit = {
				NOT = { year = 1250 }
			}
			1569 = { culture = tuyuhun } # Delingha
		}
		if = {
			limit = {
				NOT = { year = 1000 }
			}
			1578 = { culture = tuyuhun } # Dulan
		}
		
		#RELIGION CHANGES
		
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		if = {
			limit = {
				NOT = { year = 1000}
			}
			1408 = {
				religion = buddhist
			}
			1448 = {
				religion = buddhist
			}
			1513 = {
				religion = buddhist
			}
			1515 = {
				religion = buddhist
			}
			1568 = {
				religion = buddhist
			}			
		}

	
		# LANDED TITLE CHANGES		
		c_dunhuang = {
			de_jure_liege = d_guiyi
		}
		c_anxi = {
			de_jure_liege = d_guiyi
		}
		c_yungguan = {
			de_jure_liege = d_guiyi
		}
		d_guiyi = {
			de_jure_liege = k_xixia
		}
		
		#Zhang family rules d_guiyi rather than d_jiuquan at 867 start
		if = {
			limit = {
				year = 800
				NOT = { year = 900 }
			}
			d_jiuquan = {
				holder_scope = {
					grant_title_no_opinion = d_guiyi
				}
			}
			d_guiyi = {
				copy_title_laws = d_jiuquan
				copy_title_history = d_jiuquan						
			}
			d_jiuquan = { destroy_landed_title = THIS }
		}
		d_guiyi = {
			copy_title_history = k_dunhuang						
		}
		
		# LONGXI LI FAMILY
		# Connect Tang Emperors to Longxi Li clan and give them their bloodline
		c_100015993 = {
			save_event_target_as = target_dunhuang_li_hu_father
		}
		c_247762 = {
			set_father = event_target:target_dunhuang_li_hu_father
		}
		
		# CAO CAO FAMILY
		# They are generated as vassals of Guiyi/Jiuquan at the Charlemagne and Old Gods start dates
		# Alternative would be to create fictional father for Cao Yujin, and give him the bloodline
		
		c_100015907 = {
			save_event_target_as = target_dunhuang_cao_yijin_father
		}		
		c_100015911 = {
			save_event_target_as = target_dunhuang_cao_yijin_mother
		}
		c_1059714 = {
			set_mother = event_target:target_dunhuang_cao_yijin_mother
			set_father = event_target:target_dunhuang_cao_yijin_father
			set_character_flag = is_special_character
			set_character_flag = VIET_is_cao_yijin
			add_trait = quick
			health = 1 #since he lived to such a long age
		}
		c_100016363 = {
			save_event_target_as = target_dunhuang_cao_guomu
		}
		c_1059716 = {
			set_mother = event_target:target_dunhuang_cao_guomu
			remove_trait = tough_soldier
			add_trait = skilled_tactician
			add_trait = shrewd
			#Religious changes - Dunhuang was very Buddhist; this is mainly to prevent him from forcibly converting other Buddhists to Taoists nonsensically
			religion = buddhist
			any_dynasty_member = {
				religion = buddhist
			}
			any_courtier = {
				limit = {
					culture_group = ROOT
					religion = taoist
				}
				random = {
					religion = buddhist
					chance = 50
				}
			}
		}
		c_1059717 = {
			set_mother = event_target:target_dunhuang_cao_guomu
		}
		c_1059715 = {
			set_mother = event_target:target_dunhuang_cao_guomu
		}
		c_1059719 = {
			set_mother = event_target:target_dunhuang_cao_guomu
		}
		c_1059718 = {
			set_mother = event_target:target_dunhuang_cao_guomu
		}		
		
	#father=1059714
	#mother=100016363
		
		if = {
			limit = {
				year = 938
			}			
			c_100016274 = {
				save_event_target_as = target_dunhuang_cao_yuanzhong_wife
			}
			c_1059722 = {
				set_mother = event_target:target_dunhuang_cao_yuanzhong_wife
			}
		}
		
		#Zhang Family corrections
		if = {
			limit = {
				year = 800
			}
			#Set Zhang Yichao's parents
			c_100016310 = {
				save_event_target_as = target_dunhuang_zhang_yichao_father
			}
			c_100016331 = {
				save_event_target_as = target_dunhuang_zhang_yichao_mother
			}
			c_206811 = {
				set_character_flag = VIET_is_zhang_yichao
				set_character_flag = is_special_character
				set_father = event_target:target_dunhuang_zhang_yichao_father
				set_mother = event_target:target_dunhuang_zhang_yichao_mother
				#Religious changes - Dunhuang was very Buddhist; this is mainly to prevent him from forcibly converting other Buddhists to Taoists nonsensically
				religion = buddhist
				any_dynasty_member = {
					religion = buddhist
				}
				any_courtier = {
					limit = {
						culture_group = ROOT
						religion = taoist
					}
					random = {
						religion = buddhist
						chance = 50
					}
				}
			}
			#Set Zhang Huaishen's parents properly
			c_100016311 = {
				save_event_target_as = target_dunhuang_zhang_huaishen_father
			}
			c_100016336 = { #Fictitious mother
				save_event_target_as = target_dunhuang_zhang_huaishen_mother
			}
			c_244004 = {
				set_father = event_target:target_dunhuang_zhang_huaishen_father
				set_mother = event_target:target_dunhuang_zhang_huaishen_mother
			}
		}
		
		#Recall some characters to China
		c_100016328 = {
			death = { death_reason = death_went_back_to_china }
		}


		#Bloodlines
		if = {
			limit = {
				has_dlc = "Holy Fury"
			}
			c_100015910 = {
				father_even_if_dead = {
					create_bloodline = {
						type = cao_cao_bloodline
					}				
				}
			}	
			c_100016005 = {
				father_even_if_dead = {
					create_bloodline = {
						type = longxi_li_bloodline
					}				
				}
			}	
			c_100016095 = {
				father_even_if_dead = {
					create_bloodline = {
						type = longxi_li_bloodline
					}				
				}
			}	
		}

		if = {
			limit = {
				year = 1000
			}
			set_global_flag = VIET_zhai_fengda_spawn_event_flag
		}

		#Generate Tuyuhun count of Fuqi and Delingha
		if = {
			limit = {
				NOT = { year = 1000 }
			}
			d_qinghai = {
				# Tanguts were strongly Buddhist
				owner = {
					character_event = { id = dunhuang.1 }
					religion = buddhist
					any_dynasty_member = {
						religion = buddhist
					}
					any_courtier = {
						limit = {
							culture_group = ROOT
							religion = taoist
						}
						random = {
							religion = buddhist
							chance = 50
						}
					}
				}
			}
		}
		
		#Assign extra Chinese rulers
		if = {
			limit = {
				year = 700
				NOT = { year = 800 }
			}
			e_tibet = {
				owner = {
					#character_event = { id = dunhuang.1 }
					character_event = { id = dunhuang.5 }
				}
			}
			#d_kumul = {
			#	owner = {
			#		character_event = { id = dunhuang.5 }
			#	}
			#}
		}
		if = {
			limit = {
				year = 800
				NOT = { year = 900 }
			}
			d_guiyi = {
				owner = {
					character_event = { id = dunhuang.2 } # As a safety measure in case relatives are elsewhere
					character_event = { id = dunhuang.3 }
				}
			}
		}
		if = {
			limit = {
				year = 900
				NOT = { year = 1000 }
			}
			d_guiyi = {
				owner = {
					character_event = { id = dunhuang.2 } # As a safety measure in case relatives are elsewhere
					character_event = { id = dunhuang.4 }
				}
			}		
			# MISCELLANEOUS STUFF
			c_100016273 = {
				add_character_modifier = {
					name = VIET_zhai_fengda_modifier
					duration = -1
				}
			}
			#c_100016204 = {
			#	save_event_target_as = target_VIET_dunhuang_zhai_fengda_wife
			#}
			#c_100016273 = {
			#	add_friend = event_target:target_VIET_dunhuang_zhai_fengda_wife
			#}
		}

		
		# COURTIER SPAWN
		#Tuyuhun
		#random_playable_ruler = {
		#	limit = {
		#		NOT = { year = 1000 }
		#		capital_scope = {
		#			OR = {
		#				duchy = { title = d_dunhuang }
		#				duchy = { title = d_guiyi }
		#				kingdom = { title = k_xixia }
		#			}
		#		}
		#	}
		#	random_list = {
		#		50 = {
		#			create_character = {
		#				random_traits = yes
		#				dynasty = actually_culture
		#				religion = buddhist
		#				culture = tuyuhun
		#				flag = ai_flag_refuse_conversion
		#			}
		#			new_character = {
		#				set_character_flag = VIET_spawned_courtier			
		#			}				
		#		}
		#		50 = {}
		#	}
		#}
		#random_playable_ruler = {
		#	limit = {
		#		NOT = { year = 1000 }
		#		capital_scope = {
		#			OR = {
		#				duchy = { title = d_dunhuang }
		#				duchy = { title = d_guiyi }
		#				kingdom = { title = k_xixia }
		#			}
		#		}
		#	}
		#	random_list = {
		#		50 = {
		#			create_character = {
		#				random_traits = yes
		#				dynasty = actually_culture
		#				religion = taoist
		#				culture = tuyuhun
		#				flag = ai_flag_refuse_conversion
		#			}
		#			new_character = {
		#				set_character_flag = VIET_spawned_courtier			
		#			}				
		#		}
		#		50 = {}
		#	}
		#}
		#random_playable_ruler = {
		#	limit = {
		#		NOT = { year = 1000 }
		#		capital_scope = {
		#			OR = {
		#				duchy = { title = d_dunhuang }
		#				duchy = { title = d_guiyi }
		#				kingdom = { title = k_xixia }
		#			}
		#		}
		#	}
		#	random_list = {
		#		50 = {
		#			create_character = {
		#				random_traits = yes
		#				dynasty = actually_culture
		#				religion = tengri_pagan
		#				culture = tuyuhun
		#				flag = ai_flag_refuse_conversion
		#			}
		#			new_character = {
		#				set_character_flag = VIET_spawned_courtier			
		#			}				
		#		}
		#		50 = {}
		#	}
		#}
		#random_playable_ruler = {
		#	limit = {
		#		NOT = { year = 1000 }
		#		capital_scope = {
		#			OR = {
		#				duchy = { title = d_dunhuang }
		#				duchy = { title = d_guiyi }
		#				kingdom = { title = k_xixia }
		#			}
		#		}
		#	}
		#	random_list = {
		#		50 = {
		#			create_character = {
		#				female = yes
		#				random_traits = yes
		#				dynasty = none
		#				religion = buddhist
		#				culture = tuyuhun
		#				flag = ai_flag_refuse_conversion
		#			}
		#			new_character = {
		#				set_character_flag = VIET_spawned_courtier			
		#			}				
		#		}
		#		50 = {}
		#	}
		#}
		#random_playable_ruler = {
		#	limit = {
		#		NOT = { year = 1000 }
		#		capital_scope = {
		#			OR = {
		#				duchy = { title = d_dunhuang }
		#				duchy = { title = d_guiyi }
		#				kingdom = { title = k_xixia }
		#			}
		#		}
		#	}
		#	random_list = {
		#		50 = {
		#			create_character = {
		#				female = yes
		#				random_traits = yes
		#				dynasty = none
		#				religion = taoist
		#				culture = tuyuhun
		#				flag = ai_flag_refuse_conversion
		#			}
		#			new_character = {
		#				set_character_flag = VIET_spawned_courtier			
		#			}				
		#		}
		#		50 = {}
		#	}
		#}
		#random_playable_ruler = {
		#	limit = {
		#		NOT = { year = 1000 }
		#		capital_scope = {
		#			OR = {
		#				duchy = { title = d_dunhuang }
		#				duchy = { title = d_guiyi }
		#				kingdom = { title = k_xixia }
		#			}
		#		}
		#	}
		#	random_list = {
		#		50 = {
		#			create_character = {
		#				female = yes
		#				random_traits = yes
		#				dynasty = none
		#				religion = tengri_pagan
		#				culture = tuyuhun
		#				flag = ai_flag_refuse_conversion
		#			}
		#			new_character = {
		#				set_character_flag = VIET_spawned_courtier			
		#			}				
		#		}
		#		50 = {}
		#	}
		#}				
	}
}





# Create fictional Tuyuhun ruler of Fuqi and Delingha
character_event = {
	id = dunhuang.1
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		create_character = {
			random_traits = yes
			dynasty = actually_culture
			religion = buddhist
			culture = tuyuhun
			female = no
		}	
		new_character = {
			#set_character_flag = VIET_dunhuang_tuyuhun_chieftain
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_fuqi = {
				grant_title_no_opinion = PREV
			}
			c_delingha = {
				grant_title_no_opinion = PREV
			}
			d_qinghai = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			create_character = { # Extra courtiers
				random_traits = yes
				dynasty = actually_culture
				religion = buddhist
				culture = tuyuhun
				female = no
				# age = 16
			}
			create_character = {
				random_traits = yes
				dynasty = actually_culture
				religion = buddhist
				culture = tuyuhun
				female = no
				# age = 18
			}
			create_character = {
				random_traits = yes
				dynasty = actually_culture
				religion = buddhist
				culture = tuyuhun
				female = no
				# age = 18
			}
			create_character = {
				random_traits = yes
				dynasty = none
				religion = buddhist
				culture = tuyuhun
				female = no
				# age = 20
			}
			create_character = {
				random_traits = yes
				dynasty = none
				religion = buddhist
				culture = tuyuhun
				female = no
				# age = 25
			}
			create_character = {
				random_traits = yes
				dynasty = actually_culture
				religion = buddhist
				culture = tuyuhun
				female = yes
				# age = 16
			}
			create_character = {
				random_traits = yes
				dynasty = none
				religion = buddhist
				culture = tuyuhun
				female = yes
				# age = 18
			}
			create_character = {
				random_traits = yes
				dynasty = none
				religion = buddhist
				culture = tuyuhun
				female = yes
				# age = 20
			}
			character_event = { id = GR.30 }
		}
	}
}



# Move family members to courts and set dynasty flag
character_event = {
	id = dunhuang.2
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				culture_group = chinese_group
			}
			set_dynasty_flag = VIET_great_dunhuang_clan
		}
		any_dynasty_member = {
			limit = {
				OR = {
					is_female = no
					is_married = no
				}
			}
			move_character = ROOT
		}
	}
}



# 867 start date - giving characters titles
character_event = {
	id = dunhuang.3
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {	
		1408 = {
			build_holding = {
				title = b_guazhou
				type = city
			}
		}	
		1448 = {
			build_holding = {
				title = b_yueyaquan
				type = city
			}
		}	
		1513 = {
			build_holding = {
				title = b_fulu
				type = castle
			}
		}
		#Cao family as counts of Jiuquan
		#Yin family as counts of Yumen
		#Li family as counts of Yangguan
		#Suo family as counts of Anxi
		#Zhai family as mayors of Suzhou - close relationship with the Cao family?
		#Fan family as mayors of Shouchang 
		#Kang family as mayors of Guazhou
		#An family as mayors of Fangpan
		#Zhu family as mayors of Yueyaquan
		c_100015907 = { # Give Jiuquan to Cao Wancheng
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_jiuquan = {
				grant_title_no_opinion = PREV
			}
			d_guiyi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}	
		c_100016243 = { # Give Anxi to Suo Xun
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_anxi = {
				grant_title_no_opinion = PREV
			}
			d_guiyi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}		
		c_100016182 = { # Give Yumen to Yin Wentong
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_yumen = {
				grant_title_no_opinion = PREV
			}
			d_guiyi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}	
		c_100016135 = { # Give Yangguan to Li Mingzhen
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_yungguan = {
				grant_title_no_opinion = PREV
			}
			d_guiyi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}	
		c_100016268 = { # Give Fulu to Zhai Farong - as baron his family has a slightly higher chance of surviving
			b_fulu = {
				grant_title_no_opinion = PREV
			}
			c_jiuquan = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}	
		c_100016386 = { # Give Suzhou to Zhang Qiu
			b_suzhou = {
				grant_title_no_opinion = PREV
			}
			c_jiuquan = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016295 = { # Give Shouchang to Fan Nan, Fan Guazhong's fictitious grandson
			b_shouchang = {
				grant_title_no_opinion = PREV
			}
			c_yungguan = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016334 = { # Give Fangpan to An Zhimu, a fictitious member of the An family
			b_dunhuang = {
				grant_title_no_opinion = PREV
			}
			c_yungguan = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016358 = { # Give Guanzhou to Kang Tongxin
			b_guazhou = {
				grant_title_no_opinion = PREV
			}
			c_anxi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016375 = { # Give Mogao to the monk Wuzhen
			b_mogao = {
				grant_title_no_opinion = PREV
			}
			c_dunhuang = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			#character_event = { id = dunhuang.2 }
		}
		c_100016374 = { # Give Shouchang to Cao Fajing, an important monk official of the Cao family
			b_kongtong = {
				grant_title_no_opinion = PREV
			}
			c_jiuquan = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			#character_event = { id = dunhuang.2 }
		}
		c_100016373 = { # Give Yueyaquan to Zhu Zaiqing, a Dunhuang nobleman and important leader of the Buddhist lay community
			b_yueyaquan = {
				grant_title_no_opinion = PREV
			}
			c_dunhuang = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			#character_event = { id = dunhuang.2 }
		}
	}
}


# 936 start date - giving characters titles
character_event = {
	id = dunhuang.4
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {	
		1408 = {
			build_holding = {
				title = b_guazhou
				type = city
			}
		}	
		1448 = {
			build_holding = {
				title = b_yueyaquan
				type = city
			}
			build_holding = {
				title = b_yumenquan
				type = castle
			}
		}	
		c_100016273 = { # Give Yangguan to Zhai Fengda
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_yungguan = {
				grant_title_no_opinion = PREV
			}
			d_guiyi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}		
		c_100016142 = { # Give Anxi to Li Ling
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_anxi = {
				grant_title_no_opinion = PREV
			}
			d_guiyi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016356 = { # Give Guazhou to Kang Qingnu
			b_guazhou = {
				grant_title_no_opinion = PREV
			}
			c_anxi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016319 = { # Give city of Dunhuang to Zhang Huaiqing
			b_dunhuang = {
				grant_title_no_opinion = PREV
			}
			c_dunhuang = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			add_pressed_claim = d_guiyi
			character_event = { id = dunhuang.2 }
		}
		c_100016205 = { # Give city of Shouchang to Yin Gonghai
			b_shouchang = {
				grant_title_no_opinion = PREV
			}
			c_yungguan = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016248 = { # Give castle of Yumenquan to Suo Ziqian (castle so there's a higher chance they'll survive given their bloodline)
			b_yumenquan = {
				grant_title_no_opinion = PREV
			}
			c_dunhuang = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016301 = { # Give town of Yueyaquan to Fan Fuzhu
			b_yueyaquan = {
				grant_title_no_opinion = PREV
			}
			c_dunhuang = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		c_100016376 = { # Give temple of Mogao to Shanyou
			b_mogao = {
				grant_title_no_opinion = PREV
			}
			c_dunhuang = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			#character_event = { id = dunhuang.2 }
		}
	}
}


# 769 start date - giving characters titles in Tibetan Empire
character_event = {
	id = dunhuang.5
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {	
		1408 = {
			build_holding = {
				title = b_guazhou
				type = city
			}
		}	
	
		#Zhang family as dukes of Guiyi/counts of Yangguan
		#Cao family as counts of Yumen under the Zhangs
		#Li family as counts of Anxi
		#Yin family as mayors of Guazhou
		#Suo family as mayors of Dunhuang
		#Zhai family as mayors of Suzhou
		#Fan family as mayors of Shouchang
		#Kang family as courtiers under Caos
		#An family as courtiers under Zhangs
		c_100016310 = { # Give Yangguan to Zhang Qianyi, Zhang Yichao's father
			#Give some starting mana like a normal Duke so they won't be completely helpless
			wealth = 50
			prestige = 30
			piety = 15
			c_yungguan = {
				grant_title_no_opinion = PREV
			}
			d_guiyi = {
				grant_title_no_opinion = PREV
			}
			e_tibet = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
			save_event_target_as = target_VIET_dunhuang_zhang_court_person
		}
		c_100015910 = { # Give Yumen to Cao Shiyuan, Cao Yijin's fictional great-great-grandfather
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_yumen = {
				grant_title_no_opinion = PREV
			}
			#d_jiuquan = {
			#	grant_title_no_opinion = PREV
			#}
			d_guiyi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
			save_event_target_as = target_VIET_dunhuang_cao_court_person
		}	
		c_100016130 = { # Give Anxi to Li Dabin
			#Give some starting mana like a normal Count so they won't be completely helpless
			wealth = 40
			prestige = 20
			piety = 10
			c_anxi = {
				grant_title_no_opinion = PREV
			}
			e_china_west_governor = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}	
		c_100016186 = { # Give Guazhou to Yin Tingjie, Li Dabin's brother-in-law/father-in-law
			b_guazhou = {
				grant_title_no_opinion = PREV
			}
			c_anxi = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}	
		c_100016235 = { # Give Dunhuang to Suo Tao
			b_dunhuang = {
				grant_title_no_opinion = PREV
			}
			e_china_west_governor = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}		
		c_100016131 = { # Give Mogao to Li Lingwu
			b_mogao = {
				grant_title_no_opinion = PREV
			}
			e_china_west_governor = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}	
		c_100016294 = { # Give Shouchang to Fan Guozhong
			b_shouchang = {
				grant_title_no_opinion = PREV
			}
			c_yungguan = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}	
		c_100016265 = { # Give Suzhou to Zhai Yangyun
			b_suzhou = {
				grant_title_no_opinion = PREV
			}
			c_jiuquan = {
				holder_scope = {
					set_defacto_vassal = PREVPREV
				}
			}
			character_event = { id = dunhuang.2 }
		}
		#Move characters
		#An Sogdians
		c_100016330 = {
			move_character = event_target:target_VIET_dunhuang_zhang_court_person
		}
		c_100016332 = {
			move_character = event_target:target_VIET_dunhuang_zhang_court_person
		}
		#Kang Sogdians
		c_100016346 = {
			move_character = event_target:target_VIET_dunhuang_cao_court_person
		}
		c_100016347 = {
			move_character = event_target:target_VIET_dunhuang_cao_court_person
		}
		#Cao Anning
		c_100016146 = {
			move_character = event_target:target_VIET_dunhuang_zhang_court_person
		}
		#Zhang Xing
		c_100016317 = {
			move_character = event_target:target_VIET_dunhuang_cao_court_person
		}
		#Misc
		c_100016238 = {
			remove_trait = bhikkhu
		}
	}
}



#Starting events if game option to not play as Dunhuang families selected
character_event = {
	id = dunhuang.6
	hide_window = yes
	
	is_triggered_only = yes
	
	ai = no
	only_playable = yes
	culture_group = chinese_group
	
	trigger = {
		has_game_rule = {
			name = monogatari_dunhuang_start_rule
			value = no
		}
		OR = {
			AND = {
				dynasty = 1055006
				year = 800
				NOT = { year = 900 }			
			}
			AND = {
				dynasty = 1055036
				year = 900
				NOT = { year = 1000 }		
			}
		}
	}
	
	immediate = {		
		# Zhang family at 867 start
		if = {
			limit = {
				dynasty = 1055006
				year = 800
				NOT = { year = 900 }
			}
			narrative_event = { id = dunhuang.16 }
		}
		# Cao family at 936 start
		if = {
			limit = {
				dynasty = 1055036
				year = 900
				NOT = { year = 1000 }
			}
			narrative_event = { id = dunhuang.17 }
		}
	}
}


# Intro if player wants to play as the Tuyuhun, or the other Dunhuang families
narrative_event =  {
	id = dunhuang.10
	#desc = dunhuang.10.desc
	title = dunhuang.10.title
	picture = GFX_evt_the_silk_road_dunhuang	
	
	desc = {
		text = dunhuang.intro.charlemagne
		trigger = {
			NOT = { year = 800 }
		}
	}	
	desc = {
		text = dunhuang.intro.oldgods
		trigger = {
			year = 800
			NOT = { year = 900 }
		}
	}	
	desc = {
		text = dunhuang.intro.ironcentury
		trigger = {
			year = 900
			NOT = { year = 1000 }
		}
	}
	
	is_triggered_only = yes
	
	ai = no
	only_playable = yes

	trigger = {
		NOT = { year = 1000 }
		is_save_game = no
		has_game_rule = {
			name = monogatari_dunhuang_start_rule
			value = yes
		}
		NOT = { has_alternate_start_parameter = { key = religion_names value = random } }
		NOT = { has_alternate_start_parameter = { key = culture_names value = random } }
		#Rulers are all either Buddhist or Taoist
		OR = {
			has_dlc = "Jade Dragon"
			has_dlc = "Rajas of India"
		}
	}

	option = { # Choose one of Chinese noble families
		name = dunhuang.10.a
		long_character_event = { id = dunhuang.11 tooltip = dunhuang.11.tooltip }	
	}	
	option = { # Choose Tuyuhun Chieftains
		name = dunhuang.10.b
		c_fuqi = {
			holder_scope = {
				save_event_target_as = target_VIET_dunhuang_tuyuhun_player
			}				
		}
		set_player_character = event_target:target_VIET_dunhuang_tuyuhun_player
		event_target:target_VIET_dunhuang_tuyuhun_player = {
			narrative_event = { id = dunhuang.15 tooltip = dunhuang.15.tooltip }		
		}
	}	
	option = { #Never mind
		name = dunhuang.10.c
		custom_tooltip = { text = VIET_dunhuang_dont_play_anyone_new }
		#If selected Zhang or Cao family from main menu normally
		hidden_tooltip = {
			# Zhang family at 867 start
			if = {
				limit = {
					dynasty = 1055006
					year = 800
					NOT = { year = 900 }
				}
				narrative_event = { id = dunhuang.16 }
			}
			# Cao family at 936 start
			if = {
				limit = {
					dynasty = 1055036
					year = 900
					NOT = { year = 1000 }
				}
				narrative_event = { id = dunhuang.17 }
			}
		}
	}
}

# If player wants to play as one of the Chinese noble families of Dunhuang
long_character_event =  {
	id = dunhuang.11
	desc = dunhuang.11.desc
	picture = GFX_evt_dunhuang_court
	
	is_triggered_only = yes
	
	################################
	#
	# Major Families other than Zhang and Cao:
	# 
	# Zhai: Powerful noble family in Dunhuang going back several centuries
	# Li: Briefly ruled Dunhuang, part of the Longxi Li clan distantly related to the Tang Emperors, descent from Later Liang Emperors
	# Suo: Cao Yijin's wife's family, also related to Zhang Yichao by marriage
	# Yin: Cao Yijin's mother's family, been in Dunhuang since Former Liang; many were officials under the Tibetan government and later the Cao regime; married Zhang Yichao's daughter; governor of Liangzhou
	#
	# Misc. families:
	# Fan: Cao Yijin's grandmother's family
	# Song: Cao Yijin's other Chinese wife's family; Zhang Yichao's wife was a Song
	# Kang: Sinicized Sogdian family
	# An: Sinicized Sogdian family
	# 
	# 769 start date: Cao and Zhang are vassals to Tibet, Li is vassal to China
	# 867 start date: Cao, Suo, Li, Yin, and Zhai are all count vassals to Zhang
	# 936 start date: only Zhai and Li are selectable, count vassals to Cao 
	# 
	# 769 Start date:
	# 
	# Zhang family as dukes of Guiyi/counts of Yangguan
	# Cao family as dukes of Jiuquan/counts of Yumen
	# Li family as counts of Anxi
	# 
	# 
	# 867 Start date:
	# Cao family as counts of Jiuquan
	# Yin family as counts of Yumen
	# Li family as counts of Yangguan
	# Suo family as counts of Anxi
	# Zhai family as mayors of Suzhou - close relationship with the Cao family?
	# Fan family as mayors of Shouchang 
	# Kang family as mayors of Guazhou
	# An family as mayors of Fangpan
	# 
	# 936 Start date:
	# Li family as counts of Anxi
	# Zhai family as counts of Yangguan - close relationship with the Cao family?
	# Suo family as mayors of Dunhuang
	# Yin family as mayors of Guazhou
	# Fan family as mayors of Suzhou
	# Zhang family as mayors of Shouchang [Anxi]
	#
	################################
	
	
	option = { # Choose Zhang family at 769 start date
		name = dunhuang.11.a
		trigger = {
			NOT = { year = 800 }
		}
		c_yungguan = {
			holder_scope = {
				save_event_target_as = target_VIET_dunhuang_zhang_player
			}				
		}
		set_player_character = event_target:target_VIET_dunhuang_zhang_player
		event_target:target_VIET_dunhuang_zhang_player = {
			narrative_event = { id = dunhuang.16 tooltip = dunhuang.16.tooltip }		
		}	
	}	
	option = { # Choose Cao family at 769 and 867 start dates
		name = dunhuang.11.b
		trigger = {
			NOT = { year = 900 }
		}
		if = {
			limit = {
				NOT = { year = 800 }
			}
			c_yumen = {
				holder_scope = {
					save_event_target_as = target_VIET_dunhuang_cao_player
				}				
			}
			set_player_character = event_target:target_VIET_dunhuang_cao_player
			event_target:target_VIET_dunhuang_cao_player = {
				narrative_event = { id = dunhuang.17 tooltip = dunhuang.17.tooltip }		
			}		
		}
		if = {
			limit = {
				year = 800
				NOT = { year = 900 }
			}
			c_jiuquan = {
				holder_scope = {
					save_event_target_as = target_VIET_dunhuang_cao_player
				}				
			}
			set_player_character = event_target:target_VIET_dunhuang_cao_player
			event_target:target_VIET_dunhuang_cao_player = {
				narrative_event = { id = dunhuang.17 tooltip = dunhuang.17.tooltip }		
			}		
		}
	}	
	option = { # Choose Suo family at 867 start date - Zhang Yichao's son-in-law was a Suo
		name = dunhuang.11.c
		trigger = {
			year = 800
			NOT = { year = 900 }
		}
		c_anxi = {
			holder_scope = {
				save_event_target_as = target_VIET_dunhuang_suo_player
			}				
		}
		set_player_character = event_target:target_VIET_dunhuang_suo_player
		event_target:target_VIET_dunhuang_suo_player = {
			narrative_event = { id = dunhuang.18 tooltip = dunhuang.18.tooltip }		
		}	
	}	
	option = { # Choose Li family at all start dates - Li Mingzhen and his sons ruled from 894-896
		name = dunhuang.11.d
		if = {
			limit = {
				NOT = { year = 800 }
			}
			c_anxi = {
				holder_scope = {
					save_event_target_as = target_VIET_dunhuang_li_player
				}				
			}
			set_player_character = event_target:target_VIET_dunhuang_li_player
			event_target:target_VIET_dunhuang_li_player = {
				narrative_event = { id = dunhuang.19 tooltip = dunhuang.19.tooltip }		
			}		
		}
		if = {
			limit = {
				year = 800
				NOT = { year = 900 }
			}
			c_yungguan = {
				holder_scope = {
					save_event_target_as = target_VIET_dunhuang_li_player
				}				
			}
			set_player_character = event_target:target_VIET_dunhuang_li_player
			event_target:target_VIET_dunhuang_li_player = {
				narrative_event = { id = dunhuang.19 tooltip = dunhuang.19.tooltip }		
			}		
		}
		if = {
			limit = {
				year = 900
			}
			c_yungguan = {
				holder_scope = {
					save_event_target_as = target_VIET_dunhuang_li_player
				}				
			}
			set_player_character = event_target:target_VIET_dunhuang_li_player
			event_target:target_VIET_dunhuang_li_player = {
				narrative_event = { id = dunhuang.19 tooltip = dunhuang.19.tooltip }		
			}		
		}
	}	
	option = { # Choose Zhai family at 936 start date
		name = dunhuang.11.e
		trigger = {
			year = 900
		}
		c_yungguan = {
			holder_scope = {
				save_event_target_as = target_VIET_dunhuang_zhai_player
			}				
		}
		set_player_character = event_target:target_VIET_dunhuang_zhai_player
		event_target:target_VIET_dunhuang_zhai_player = {
			narrative_event = { id = dunhuang.20 tooltip = dunhuang.20.tooltip }		
		}	
	}
	option = { # Choose Yin family at 867 start date - wealthy family that intermarried into the other families
		name = dunhuang.11.f
		trigger = {
			year = 800
			NOT = { year = 900 }
		}
		if = {
			limit = {
				year = 800
				NOT = { year = 900 }
			}
			c_yumen = {
				holder_scope = {
					save_event_target_as = target_VIET_dunhuang_yin_player
				}				
			}
			set_player_character = event_target:target_VIET_dunhuang_yin_player
			event_target:target_VIET_dunhuang_yin_player = {
				narrative_event = { id = dunhuang.21 tooltip = dunhuang.21.tooltip }		
			}		
		}
	}
	option = { #Never mind
		name = dunhuang.11.g
		custom_tooltip = { text = VIET_dunhuang_dont_play_anyone_new }
		#If selected Zhang or Cao family from main menu normally
		hidden_tooltip = {
			# Zhang family at 867 start
			if = {
				limit = {
					dynasty = 1055006
					year = 800
					NOT = { year = 900 }
				}
				narrative_event = { id = dunhuang.16 }
			}
			# Cao family at 936 start
			if = {
				limit = {
					dynasty = 1055036
					year = 900
					NOT = { year = 1000 }
				}
				narrative_event = { id = dunhuang.17 }
			}
		}
	}
}


# Intro if player doesn't want to play as any of the new families, and plays as existing Zhang/Cao families
#narrative_event =  {
#	id = dunhuang.12
#	#desc = dunhuang.12.desc
#	title = dunhuang.12.title
#	picture = GFX_evt_the_silk_road_dunhuang
#	
#	desc = {
#		text = dunhuang.intro.charlemagne
#		trigger = {
#			NOT = { year = 800 }
#		}
#	}	
#	desc = {
#		text = dunhuang.intro.oldgods
#		trigger = {
#			year = 800
#			NOT = { year = 900 }
#		}
#	}	
#	desc = {
#		text = dunhuang.intro.ironcentury
#		trigger = {
#			year = 900
#			NOT = { year = 1000 }
#		}
#	}
#	
#	is_triggered_only = yes
#	
#	ai = no
#	only_playable = yes
#
#	trigger = {
#		NOT = { year = 1000 }
#		is_save_game = no
#		has_game_rule = {
#			name = monogatari_dunhuang_start_rule
#			value = no
#		}			
#		NOT = { has_alternate_start_parameter = { key = religion_names value = random } }
#		NOT = { has_alternate_start_parameter = { key = culture_names value = random } }
#		capital_scope = {
#			OR = {
#				duchy = { title = d_jiuquan }
#				duchy = { title = d_guiyi }
#				duchy = { title = d_qinghai }
#				duchy = { title = d_kumul }
#			}
#		}		
#	}
#	
#	option = { # Zhang - Ok
#		name = dunhuang.12.a
#		trigger = {
#			dynasty = 1055006
#		}
#		narrative_event = { id = dunhuang.16 tooltip = dunhuang.16.tooltip }
#	}	
#	option = { # Cao - Ok
#		name = dunhuang.12.b
#		trigger = {
#			dynasty = 1055036
#		}
#		narrative_event = { id = dunhuang.17 tooltip = dunhuang.17.tooltip }
#	}	
#	option = { # Else
#		name = dunhuang.12.b
#		trigger = {
#			NOR = {
#				dynasty = 1055006
#				dynasty = 1055036
#			}
#		}
#	}
#}

# Tuyuhun intro
narrative_event = {
	id = dunhuang.15
	title = dunhuang.15.title
	desc = dunhuang.15.desc
	picture = GFX_evt_travel_dunhuang
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.15.a
	}
}

# Zhang intro
narrative_event = {
	id = dunhuang.16
	title = dunhuang.16.title
	picture = GFX_evt_china_rebel_general
	desc = {
		text = dunhuang.16.desc.a
		trigger = {
			NOT = { year = 800 }
		}
	}	
	desc = {
		text = dunhuang.16.desc.b
		trigger = {
			year = 800
			NOT = { year = 900 }
		}
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.16.a
	}
}

# Cao Cao intro - COW COW
narrative_event = {
	id = dunhuang.17
	title = dunhuang.17.title
	picture = GFX_evt_cao_cao
	desc = {
		text = dunhuang.17.desc.a
		trigger = {
			NOT = { year = 800 }
		}
	}	
	desc = {
		text = dunhuang.17.desc.b
		trigger = {
			year = 800
			NOT = { year = 900 }
		}
	}	
	desc = {
		text = dunhuang.17.desc.c
		trigger = {
			year = 900
			NOT = { year = 1000 }
		}
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.17.a
	}
}

# Suo intro
narrative_event = {
	id = dunhuang.18
	title = dunhuang.18.title
	desc = dunhuang.18.desc
	picture = GFX_evt_china_invades #GFX_evt_chinese_night_village
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.18.a
	}
}

# Li intro
narrative_event = {
	id = dunhuang.19
	title = dunhuang.19.title
	desc = dunhuang.19.desc
	picture = GFX_evt_dunhuang_manor
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.19.a
	}
}

# Zhai intro
narrative_event = {
	id = dunhuang.20
	title = dunhuang.20.title
	desc = dunhuang.20.desc
	picture = GFX_evt_chinese_night_village
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.20.a
	}
}

# Yin intro
narrative_event = {
	id = dunhuang.21
	title = dunhuang.21.title
	desc = dunhuang.21.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.21.a
	}
}


################################################
# KINGDOM OF DUNHUANG
################################################

# Kingdom of Dunhuang created
narrative_event = {
	id = dunhuang.30
	title = dunhuang.30.title
	desc = dunhuang.30.desc
	picture = GFX_evt_china_expansionist
	
	is_triggered_only = yes
	
	option = { # Kingdom of Liang
		name = dunhuang.30.a
		give_nickname = nick_the_expander_of_the_west
		wealth = -200
		prestige = 250
		primary_title = {
			save_event_target_as = current_primary_title
		}
		d_guiyi = {
			show_scope_change = no
			de_jure_liege = k_dunhuang 
		}
		d_jiuquan = {
			show_scope_change = no
			de_jure_liege = k_dunhuang
		}
		k_dunhuang = {
			show_scope_change = no
			de_jure_liege = e_tibet			
		}
		k_dunhuang = {
			show_scope_change = no
			grant_title = ROOT
			copy_title_laws = event_target:current_primary_title
		}
		k_dunhuang = {
			set_name = "KINGDOM_LIANG"
			adjective = "KINGDOM_LIANG_ADJ"
		}
		if = {
			limit = {
				OR = {
					dynasty = 1000088605
					dynasty = 1051150
				}
			}
			custom_tooltip = { text = VIET_dunhuang_founded_text_liang_li }
		}
		else = {			
			custom_tooltip = { text = VIET_dunhuang_founded_text_liang_not_li }
		}
		hidden_tooltip = {
			narrative_event = { id = dunhuang.31 }
			any_playable_ruler = {
				limit = { 
					ai = no 
					#NOT = { character = ROOT }
				}
				narrative_event = { id = dunhuang.31 }
			}
		}
	}
	
	option = { # Kingdom of Jinshan
		name = dunhuang.30.b
		give_nickname = nick_the_expander_of_the_west
		wealth = -200
		prestige = 250
		primary_title = {
			save_event_target_as = current_primary_title
		}
		d_guiyi = {
			show_scope_change = no
			de_jure_liege = k_dunhuang 
		}
		d_jiuquan = {
			show_scope_change = no
			de_jure_liege = k_dunhuang
		}
		k_dunhuang = {
			show_scope_change = no
			de_jure_liege = e_tibet			
		}
		k_dunhuang = {
			show_scope_change = no
			grant_title = ROOT
			copy_title_laws = event_target:current_primary_title
		}
		k_dunhuang = {
			set_name = "KINGDOM_JINSHAN"
			adjective = "KINGDOM_JINSHAN_ADJ"
		}
		custom_tooltip = { text = VIET_dunhuang_founded_text_jinshan }
		hidden_tooltip = {
			narrative_event = { id = dunhuang.31 }
			any_playable_ruler = {
				limit = { 
					ai = no 
					#NOT = { character = ROOT }
				}
				narrative_event = { id = dunhuang.31 }
			}
		}
	}
	
	option = { # Kingdom of Guiyi
		name = dunhuang.30.c
		give_nickname = nick_the_expander_of_the_west
		wealth = -200
		prestige = 250
		primary_title = {
			save_event_target_as = current_primary_title
		}
		d_guiyi = {
			show_scope_change = no
			de_jure_liege = k_dunhuang 
		}
		d_jiuquan = {
			show_scope_change = no
			de_jure_liege = k_dunhuang
		}
		k_dunhuang = {
			show_scope_change = no
			de_jure_liege = e_tibet			
		}
		k_dunhuang = {
			show_scope_change = no
			grant_title = ROOT
			copy_title_laws = event_target:current_primary_title
		}
		k_dunhuang = {
			set_name = "KINGDOM_GUIYI"
			adjective = "KINGDOM_GUIYI_ADJ"
		}
		custom_tooltip = { text = VIET_dunhuang_founded_text_guiyi }
		hidden_tooltip = {
			narrative_event = { id = dunhuang.31 }
			any_playable_ruler = {
				limit = { 
					ai = no 
					#NOT = { character = ROOT }
				}
				narrative_event = { id = dunhuang.31 }
			}
		}
	}
	
	option = { # Kingdom of Dunhuang
		name = dunhuang.30.d
		give_nickname = nick_the_expander_of_the_west
		wealth = -200
		prestige = 250
		primary_title = {
			save_event_target_as = current_primary_title
		}
		d_guiyi = {
			show_scope_change = no
			de_jure_liege = k_dunhuang 
		}
		d_jiuquan = {
			show_scope_change = no
			de_jure_liege = k_dunhuang
		}
		k_dunhuang = {
			show_scope_change = no
			de_jure_liege = e_tibet			
		}
		k_dunhuang = {
			show_scope_change = no
			grant_title = ROOT
			copy_title_laws = event_target:current_primary_title
		}
		k_dunhuang = {
			set_name = "k_dunhuang"
			adjective = "k_dunhuang_ADJ"
		}
		custom_tooltip = { text = VIET_dunhuang_founded_text_dunhuang }
		hidden_tooltip = {
			narrative_event = { id = dunhuang.31 }
			any_playable_ruler = {
				limit = { 
					ai = no 
					#NOT = { character = ROOT }
				}
				narrative_event = { id = dunhuang.31 }
			}
		}
	}
}


# Kingdom of Dunhuang created
narrative_event = {
	id = dunhuang.31
	title = dunhuang.31.title
	desc = dunhuang.31.desc
	picture = GFX_evt_china_expansionist
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.31.a
	}
}


################################################
# PATRONIZE MOGAO CAVE
################################################

# Event chain start - what will the cave focus on?
narrative_event = {
	id = dunhuang.50
	title = dunhuang.50.title
	desc = dunhuang.50.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	option = { # Family
		name = dunhuang.50.a
		set_character_flag = VIET_dunhuang_caves_focus_family # Prestige
		custom_tooltip = { text = VIET_dunhuang_caves_focus_family_text }
		hidden_tooltip = { character_event = { id = dunhuang.51 } }
	}	
	option = { # Buddhist stories and fables
		name = dunhuang.50.b
		set_character_flag = VIET_dunhuang_caves_focus_jataka # Piety
		custom_tooltip = { text = VIET_dunhuang_caves_focus_jataka_text }
		hidden_tooltip = { character_event = { id = dunhuang.51 } }
	}	
	option = { # Enlightened beings and deities
		name = dunhuang.50.c
		set_character_flag = VIET_dunhuang_caves_focus_deities # Prestige and piety
		custom_tooltip = { text = VIET_dunhuang_caves_focus_deities_text }
		hidden_tooltip = { character_event = { id = dunhuang.51 } }
	}
}

# Event chain start - how much extra money will we spend?
character_event = {
	id = dunhuang.51
	desc = dunhuang.51.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	option = { # A little more
		name = dunhuang.51.a
		trigger = {
			OR = {
				ai = no
				trait = ambitious
				trait = zealous
				wealth = 50
			}
		}
		wealth = -50
		set_character_flag = VIET_dunhuang_caves_extra_money
		hidden_tooltip = {
			any_dynasty_member = {
				set_character_flag = VIET_dunhuang_caves_relatives_extra_money # In case character dies
			}
			character_event = { id = dunhuang.52 days = 7 random = 21 } 
		}
	}	
	option = { # Buddhist stories and fables
		name = dunhuang.51.b
		trigger = {
			OR = {
				ai = no
				trait = ambitious
				trait = zealous
				wealth = 100
			}
		}
		wealth = -100
		set_character_flag = VIET_dunhuang_caves_extra_money_lots
		hidden_tooltip = {
			any_dynasty_member = {
				set_character_flag = VIET_dunhuang_caves_relatives_extra_money_lots # In case character dies
			}
			character_event = { id = dunhuang.52 days = 7 random = 21 } 
		}
	}	
	option = { # No more
		name = dunhuang.51.c
		hidden_tooltip = { character_event = { id = dunhuang.52 days = 7 random = 21 } }
	}
}

# Okay!
character_event = {
	id = dunhuang.52
	desc = dunhuang.52.desc
	picture = GFX_evt_mogao_caves_working
	
	is_triggered_only = yes
	
	option = { # ok
		name = dunhuang.52.a
		hidden_tooltip = { 
			character_event = { id = dunhuang.53  days = 300 random = 60 } 
			any_dynasty_member = { # In case the character building the Mogao Caves dies
				limit = {
					same_realm = ROOT
				}
				character_event = { id = dunhuang.54 days = 300 random = 60 }
			}
			#Random events
			random = { # Workman has auspicious dream
				character_event = { id = dunhuang.60 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Sandstorm strikes
				character_event = { id = dunhuang.61 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Bandits steal supplies
				character_event = { id = dunhuang.62 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Lay organization donates
				character_event = { id = dunhuang.63 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Prominent monk vistis
				character_event = { id = dunhuang.64 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Conflict with merchants
				character_event = { id = dunhuang.65 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Hidden room with treasures
				character_event = { id = dunhuang.68 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Foreign artist having troubles
				character_event = { id = dunhuang.69 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Worker is sick
				character_event = { id = dunhuang.71 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Monks come by for alms
				character_event = { id = dunhuang.72 days = 20 random = 260 } 
				chance = 20
			}
			random = { # Eating vegetarian food
				character_event = { id = dunhuang.73 days = 20 random = 260 } 
				chance = 20
			}
		}
	}
}

# Finished!
character_event = {
	id = dunhuang.53
	desc = dunhuang.53.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	immediate = {
		set_character_flag = VIET_already_built_mogao_cave
	}
	
	option = { # Family cave - prestige
		name = dunhuang.53.a
		trigger = {
			has_character_flag = VIET_dunhuang_caves_focus_family
		}
		if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money
			}
			prestige = 120
			piety = 80
			add_character_modifier = {
				name = VIET_built_mogao_cave_big
				duration = 7300
			}
		}
		else_if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money_lots
			}
			prestige = 150
			piety = 100
			add_character_modifier = {
				name = VIET_built_mogao_cave_bigger
				duration = 7300
			}
		}
		else_if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money_biggest
			}
			prestige = 180
			piety = 120
			add_character_modifier = {
				name = VIET_built_mogao_cave_biggest
				duration = 7300
			}
		}
		else = {
			prestige = 90
			piety = 60
			add_character_modifier = {
				name = VIET_built_mogao_cave_normal
				duration = 7300
			}
		}
	}	
	option = { # Jataka cave - piety
		name = dunhuang.53.a
		trigger = {
			has_character_flag = VIET_dunhuang_caves_focus_jataka
		}
		if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money
			}
			piety = 120
			prestige = 80
			add_character_modifier = {
				name = VIET_built_mogao_cave_big
				duration = 7300
			}
		}
		else_if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money_lots
			}
			piety = 150
			prestige = 100
			add_character_modifier = {
				name = VIET_built_mogao_cave_bigger
				duration = 7300
			}
		}
		else_if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money_biggest
			}
			piety = 180
			prestige = 120
			add_character_modifier = {
				name = VIET_built_mogao_cave_biggest
				duration = 7300
			}
		}
		else = {
			piety = 90
			prestige = 60
			add_character_modifier = {
				name = VIET_built_mogao_cave_normal
				duration = 7300
			}		
		}
	}	
	option = { # Deities cave - prestige and piety
		name = dunhuang.53.a
		trigger = {
			has_character_flag = VIET_dunhuang_caves_focus_deities
		}
		if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money
			}
			piety = 100
			prestige = 100
			add_character_modifier = {
				name = VIET_built_mogao_cave_big
				duration = 7300
			}
		}
		else_if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money_lots
			}
			piety = 125
			prestige = 125
			add_character_modifier = {
				name = VIET_built_mogao_cave_bigger
				duration = 7300
			}
		}
		else_if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money_biggest
			}
			prestige = 150
			piety = 150
			add_character_modifier = {
				name = VIET_built_mogao_cave_biggest
				duration = 7300
			}
		}
		else = {
			piety = 75
			prestige = 75	
			add_character_modifier = {
				name = VIET_built_mogao_cave_normal
				duration = 7300
			}	
		}
	}
}

# Finished, but character who built it died
character_event = {
	id = dunhuang.54

	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				FROM = {
					is_alive = no
				}
			}
			#FROM = {
			#	save_event_target_as = target_dunhuang_relative_mogao
			#}
			character_event = { id = dunhuang.55 }
		}
	}
}

# Finished, but character who built it died
character_event = {
	id = dunhuang.55
	desc = dunhuang.55.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	option = { # ok
		name = dunhuang.55.a
		if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_relatives_extra_money
			}
			clr_character_flag = VIET_dunhuang_caves_relatives_extra_money
			piety = 30
			prestige = 30	
		}
		else_if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_relatives_extra_money_lots
			}
			clr_character_flag = VIET_dunhuang_caves_relatives_extra_money_lots
			piety = 40
			prestige = 40	
		}
		else = {
			piety = 20
			prestige = 20		
		}
	}
}

# Mogao Cave building event - workman dreams of a Bodhisattva 
character_event = {
	id = dunhuang.60
	desc = dunhuang.60.desc
	picture = GFX_evt_mogao_caves_art
	
	is_triggered_only = yes
	
	option = { # ok
		name = dunhuang.60.a
		piety = 5
	}
}

# Mogao Cave building event - small sandstorm 
character_event = {
	id = dunhuang.61
	desc = dunhuang.61.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	option = { # ok
		name = dunhuang.61.a
		wealth = -10
	}
}

# Mogao Cave building event - bandits steal building materials
character_event = {
	id = dunhuang.62
	desc = dunhuang.62.desc
	picture = GFX_evt_travel_dunhuang
	
	is_triggered_only = yes
	
	option = { # ok
		name = dunhuang.62.a
		wealth = -10
	}
}

# Mogao Cave building event - local Buddhist lay organizations request to be included in mural
character_event = {
	id = dunhuang.63
	desc = dunhuang.63.desc
	picture = GFX_evt_mogao_caves_art
	
	is_triggered_only = yes
	
	option = { # ok
		name = dunhuang.63.a
		wealth = 10
		piety = 10
		prestige = -20
	}	
	option = { # reject their donations, give them donations instead
		name = dunhuang.63.b
		wealth = -25
		piety = 20
		prestige = 10
		random_list = {
			80 = { }
			10 = { add_trait = charitable }
			10 = { add_trait = zealous }
		}
		if = {
			limit = {
				trait = greedy
			}
			random = {
				remove_trait = greedy
				chance = 20
			}
		}
	}
	option = { # don't need their help
		name = dunhuang.63.c
	}
}

# Mogao Cave building event - local monk visits the caves and approves
character_event = {
	id = dunhuang.64
	desc = dunhuang.64.desc
	picture = GFX_evt_mogao_caves_working
	
	is_triggered_only = yes
	
	option = { # ok
		name = dunhuang.64.a
		piety = 10
	}
}

# Mogao Cave building event - conflict with merchants building their own cave nearby
character_event = {
	id = dunhuang.65
	desc = dunhuang.65.desc
	picture = GFX_evt_mogao_caves_working
	
	is_triggered_only = yes
	
	option = { # back off, don't fight
		name = dunhuang.65.a
		piety = 10
		prestige = -20
		random_list = {
			80 = { }
			10 = { add_trait = humble }
			10 = { add_trait = craven }
		}
	}	
	option = { # pay the merchants to chill out
		name = dunhuang.65.b
		wealth = -15
	}
	option = { # forget the merchants!
		name = dunhuang.65.c
		piety = -10
		random_list = {
			70 = { }
			10 = { add_trait = proud }
			10 = { add_trait = stubborn }
			10 = { add_trait = greedy }
		}
	}
	option = { # combine caves
		name = dunhuang.65.d
		trigger = {
			diplomacy = 9
		}
		tooltip_info = diplomacy
		character_event = { id = dunhuang.66 tooltip = dunhuang.66.tooltip }
	}
}

# Mogao Cave building event - conflict with merchants building their own cave nearby
character_event = {
	id = dunhuang.66
	desc = dunhuang.66.desc
	picture = GFX_evt_mogao_caves_working
	
	is_triggered_only = yes
	
	option = { # yay
		name = dunhuang.66.a
		piety = 10
		prestige = 20
		random_list = {
			80 = { }
			10 = { add_trait = humble }
			10 = { add_trait = patient }
		}
		if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money
			}
			clr_character_flag = VIET_dunhuang_caves_extra_money
			set_character_flag = VIET_dunhuang_caves_extra_money_lots
		}
		else_if = {
			limit = {
				has_character_flag = VIET_dunhuang_caves_extra_money_lots
			}
			clr_character_flag = VIET_dunhuang_caves_extra_money_lots
			set_character_flag = VIET_dunhuang_caves_extra_money_biggest		
		}
		else = {
			set_character_flag = VIET_dunhuang_caves_extra_money
		}
		hidden_tooltip = {
			random = {
				character_event = { id = dunhuang.67 }
				chance = 25
			}
		}
	}
}

# Mogao Cave building event - after conflict with merchants, one of them offers to join court
character_event = {
	id = dunhuang.67
	desc = dunhuang.67.desc
	picture = GFX_evt_dunhuang_court
	
	is_triggered_only = yes
	
	option = { # yay
		name = dunhuang.67.a
		create_random_steward = {
			dynasty = actually_culture
			religion = buddhist
			culture = ROOT
			female = no
			random_traits = yes
			historical = yes
		}
		new_character = {
			#Education & other basic stuff
			#set_character_flag = ai_flag_refuse_concubinage
			#set_character_flag = ai_flag_refuse_marriage
			set_character_flag = no_court_invites
			#Guaranteed Traits
			add_trait = shrewd
			add_trait = zealous
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
			#Clutter Artifact					
			#random = {
			#	VIET_give_clutter_artifact_effect = yes
			#	chance = 10
			#}
			#Flavor
			random_list = {
				90 = { }
				9 = { add_scarred_tiered_effect = yes }
				1 = { 
					trigger = { has_dlc = Reapers }
					add_trait = one_eyed
				}
			}
			add_character_modifier = {
				name = VIET_dunhuang_mogao_cave_merchant
				duration = -1
			}	
		}
	}
}

# Mogao Cave building event - workers discover a hidden room
character_event = {
	id = dunhuang.68
	desc = dunhuang.68.desc
	picture = GFX_evt_mogao_caves_art
	
	is_triggered_only = yes
	
	option = { # Donate items
		name = dunhuang.68.a
		piety = 10
		random_list = {
			80 = { }
			10 = { add_trait = charitable }
			10 = { add_trait = zealous }
		}
	}	
	option = { # Add to cave
		name = dunhuang.68.b
		prestige = 10
		random = {
			add_trait = proud
			chance = 20
		}
	}	
	option = { # Study back home
		name = dunhuang.68.c
		random = {
			change_learning = 1
			chance = 20
		}
		random = {
			add_trait = erudite
			chance = 20
		}
	}
	option = { # Sell them
		name = dunhuang.68.d
		wealth = 25
	}
}

# Mogao Cave building event - foreign artisan has trouble communication
character_event = {
	id = dunhuang.69
	desc = dunhuang.69.desc
	picture = GFX_evt_mogao_caves_working
	
	is_triggered_only = yes
	
	option = { # Not my problem
		name = dunhuang.69.a
	}	
	option = { # Help if there are misunderstandings
		name = dunhuang.69.b
		prestige = -5
		piety = 5
		hidden_tooltip = {
			random = {
				character_event = { id = dunhuang.70 }
				chance = 25
			}
		}
	}
}

# Mogao Cave building event - foreign artisan decides to join your court
character_event = {
	id = dunhuang.70
	desc = dunhuang.70.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	option = { # Cool
		name = dunhuang.70.a
		prestige = 25
		random_list = {
			10 = { #Han
				modifier = {
					factor = 0
					culture = han
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = han
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = cuman }
						5 = { set_graphical_culture = sogdian }
						20 = { set_graphical_culture = bodpa }
						20 = { set_graphical_culture = mongol }
						50 = { }
					}	
				}			
			}
			10 = { # Khotanese
				modifier = {
					factor = 0
					culture = saka
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = saka
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			10 = { # Sogdian
				modifier = {
					factor = 0
					culture = sogdian
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = sogdian
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			10 = { # Bodpa
				modifier = {
					factor = 0
					culture = bodpa
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = bodpa
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						30 = { set_graphical_culture = mongol }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			10 = { # Tangut
				modifier = {
					factor = 0
					culture = tangut
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = tangut
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						30 = { set_graphical_culture = mongol }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			10 = { # Uyghur
				modifier = {
					factor = 0
					culture = uyghur
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = uyghur
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = sogdian }
						10 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			10 = { # Persian
				modifier = {
					factor = 0
					culture = persian
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = persian
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = hindustani }
						10 = { set_graphical_culture = turkish }
						15 = { set_graphical_culture = greek }
						15 = { set_graphical_culture = levantine_arabic }
						50 = { }
					}	
				}			
			}
			10 = { # Afghan
				modifier = {
					factor = 0
					culture = afghan
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = afghan
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = hindustani }
						10 = { set_graphical_culture = turkish }
						15 = { set_graphical_culture = greek }
						15 = { set_graphical_culture = levantine_arabic }
						50 = { }
					}	
				}			
			}
			10 = { # Hindustani
				modifier = {
					factor = 0
					culture = hindustani
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = hindustani
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						25 = { set_graphical_culture = tamil }
						15 = { set_graphical_culture = persian }
						60 = { }
					}	
				}			
			}
			10 = { # Panjabi
				modifier = {
					factor = 0
					culture = panjabi
				}
				create_random_steward = {
					dynasty = actually_culture
					religion = buddhist
					culture = panjabi
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					#Guaranteed Traits
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					add_character_modifier = {
						name = VIET_dunhuang_mogao_cave_artist
						duration = -1
					}
					#Randomize appearance
					random_list = {
						25 = { set_graphical_culture = tamil }
						15 = { set_graphical_culture = persian }
						60 = { }
					}	
				}			
			}
		}		
	}
}

# Mogao Cave building event - sick worker is slow
character_event = {
	id = dunhuang.71
	desc = dunhuang.71.desc
	picture = GFX_evt_mogao_caves_working
	
	is_triggered_only = yes
	
	option = { # Fire him
		name = dunhuang.71.a
		piety = -5
		prestige = 5
		if = {
			limit = {
				trait = kind
			}
			random = {
				remove_trait = kind
				chance = 50
			}
		}
		if = {
			limit = {
				trait = humble
			}
			random = {
				remove_trait = humble
				chance = 50
			}
		}
		if = {
			limit = {
				trait = patient
			}
			random = {
				remove_trait = patient
				chance = 50
			}
		}
		random_list = {
			70 = { }
			10 = { add_trait = wroth }
			10 = { add_trait = cruel }
			10 = { add_trait = cynical }
		}
	}	
	option = { # Carry on
		name = dunhuang.71.b
		prestige = -5
	}	
	option = { # Help
		name = dunhuang.71.c
		wealth = -10
		prestige = -5
		piety = 10
		if = {
			limit = {
				trait = wroth
			}
			random = {
				remove_trait = wroth
				chance = 50
			}
		}
		if = {
			limit = {
				trait = proud
			}
			random = {
				remove_trait = proud
				chance = 50
			}
		}
		random_list = {
			70 = { }
			10 = { add_trait = kind }
			10 = { add_trait = charitable }
			10 = { add_trait = content }
		}		
	}
}

# Mogao Cave building event - monks come by to pray
character_event = {
	id = dunhuang.72
	desc = dunhuang.72.desc
	picture = GFX_evt_mogao_caves_working
	
	is_triggered_only = yes
	
	option = { # Monks are greedy!
		name = dunhuang.72.a
		piety = -10		
	}	
	option = { # Give donations
		name = dunhuang.72.b
		piety = 5
		wealth = -10	
	}
	option = { # Give lots of donations
		name = dunhuang.72.c
		piety = 20
		wealth = -30
		random = {
			add_trait = zealous
			chance = 25
		}
	}
}

# Mogao Cave building event - vegetarian feast
character_event = {
	id = dunhuang.73
	desc = dunhuang.73.desc
	picture = GFX_evt_dunhuang_food
	
	is_triggered_only = yes
	
	option = { # Boo vegetarianism
		name = dunhuang.73.a
		piety = -5
		prestige = 5
		random = {
			add_trait = proud
			chance = 15
		}
	}	
	option = { # Eat what is needed
		name = dunhuang.73.b
		piety = 5
	}	
	option = { # Delicious! And great merit
		name = dunhuang.73.c
		piety = 10
		prestige = -10
	}
}


############################################################################
#
# WORKING WITH FOREIGN COMMUNITIES
#
############################################################################


# Pick one community
character_event = {
	id = dunhuang.100
	desc = dunhuang.100.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Civilized Eastern
		name = dunhuang.100.a
		add_character_modifier = {
			name = VIET_dunhuang_civilized_eastern_contacts
			duration = 3650
		}
		if = {
			limit = {
				OR = {
					culture_group = chinese_group
					culture = khitan				
				}
			}
			custom_tooltip = { text = VIET_dunhuang_reinforce_relations_civilized_eastern_chinese }
		}
		else = {
			custom_tooltip = { text = VIET_dunhuang_reinforce_relations_civilized_eastern_not_chinese }
		}
		clr_character_flag = VIET_dunhuang_community_connection_happening
		hidden_tooltip = {
			random = {
				chance = 10
				modifier = {
					factor = 1.5
					OR = {
						culture_group = chinese_group
						culture = khitan
					}
				}
				modifier = {
					factor = 1.5
					diplomacy = 15
				}
				modifier = {
					factor = 1.5
					stewardship = 15
				}
				character_event = { id = dunhuang.101 days = 30 random = 60 } # Spawn high level Chinese character
			}
		}
	}	
	option = { # Civilized Western
		name = dunhuang.100.b
		add_character_modifier = {
			name = VIET_dunhuang_civilized_western_contacts
			duration = 3650
		}
		custom_tooltip = { text = VIET_dunhuang_reinforce_relations_civilized_western }
		clr_character_flag = VIET_dunhuang_community_connection_happening
		hidden_tooltip = {
			random = {
				chance = 10
				modifier = {
					factor = 1.5
					OR = {
						culture_group = iranian
						culture_group = serindian
					}
				}
				modifier = {
					factor = 1.5
					diplomacy = 15
				}
				modifier = {
					factor = 1.5
					stewardship = 15
				}
				character_event = { id = dunhuang.102 days = 30 random = 60 } # Spawn high level Iranian character
			}
		}
	}	
	option = { # Barbarian Southern
		name = dunhuang.100.c
		add_character_modifier = {
			name = VIET_dunhuang_barbarian_southern_contacts
			duration = 3650
		}
		custom_tooltip = { text = VIET_dunhuang_reinforce_relations_barbarian_southern }
		clr_character_flag = VIET_dunhuang_community_connection_happening
		hidden_tooltip = {
			random = {
				chance = 10
				modifier = {
					factor = 1.5
					culture_group = tibetan_group
				}
				modifier = {
					factor = 1.5
					diplomacy = 15
				}
				modifier = {
					factor = 1.5
					stewardship = 15
				}
				character_event = { id = dunhuang.103 days = 30 random = 60 } # Spawn high level Tibetan character
			}
		}
	}	
	option = { # Barbarian Northern
		name = dunhuang.100.d
		add_character_modifier = {
			name = VIET_dunhuang_barbarian_northern_contacts
			duration = 3650
		}
		custom_tooltip = { text = VIET_dunhuang_reinforce_relations_barbarian_northern }
		clr_character_flag = VIET_dunhuang_community_connection_happening
		hidden_tooltip = {
			random = {
				chance = 10
				modifier = {
					factor = 1.5
					culture_group = altaic
				}
				modifier = {
					factor = 1.5
					diplomacy = 15
				}
				modifier = {
					factor = 1.5
					stewardship = 15
				}
				character_event = { id = dunhuang.104 days = 30 random = 60 } # Spawn high level Nomad character
			}
		}
	}
}

# High level Chinese courtier spawn
character_event = {
	id = dunhuang.101
	desc = dunhuang.101.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.101.a
		prestige = 10
		random_list = {
			# 75% Han
			# 25% Khitan
			75 = { # Han
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = han
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						60 = { }
						30 = { religion = taoist }
						10 = { religion = manichean }
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = cuman }
						5 = { set_graphical_culture = sogdian }
						20 = { set_graphical_culture = bodpa }
						20 = { set_graphical_culture = mongol }
						50 = { }
					}
				}			
			}
			25 = { # Khitan
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = khitan
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						80 = { }
						15 = { religion = taoist }
						5 = { religion = manichean }
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = cuman }
						5 = { set_graphical_culture = sogdian }
						20 = { set_graphical_culture = bodpa }
						20 = { set_graphical_culture = mongol }
						50 = { }
					}
				}			
			}
		}
	}
}

# High level Iranian courtier spawn
character_event = {
	id = dunhuang.102
	desc = dunhuang.102.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.102.a
		prestige = 10
		random_list = {
			# 25% Persian
			# 25% Sogdian
			# 25% Khotanese/Saka
			# 25% Tocharian
			25 = { # Persian
				create_character = {
					dynasty = actually_culture
					religion = zoroastrian
					culture = persian
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						50 = { }
						20 = { religion = manichean }
						10 = { religion = sunni }
						10 = { religion = shiite }
						5 = { religion = buddhist }
						5 = { religion = mazdaki }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = hindustani }
						10 = { set_graphical_culture = turkish }
						15 = { set_graphical_culture = greek }
						15 = { set_graphical_culture = levantine_arabic }
						50 = { }
					}	
				}			
			}
			25 = { # Sogdian
				create_character = {
					dynasty = actually_culture
					religion = khurmazta
					culture = sogdian
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						20 = { }
						20 = { religion = buddhist }
						20 = { religion = manichean }
						20 = { religion = zoroastrian }
						20 = { religion = nestorian }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = hindustani }
						20 = { set_graphical_culture = levantine_arabic }
						50 = { }
					}
				}			
			}
			25 = { # Khotanese/Saka
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = saka
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					#random_list = {
					#	20 = { }
					#	20 = { religion = buddhist }
					#	20 = { religion = manichean }
					#	20 = { religion = zoroastrian }
					#	20 = { religion = nestorian }
					#}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = han }
						50 = { }
					}
				}			
			}
			25 = { # Tocharian
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = tocharian
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					#random_list = {
					#	20 = { }
					#	20 = { religion = buddhist }
					#	20 = { religion = manichean }
					#	20 = { religion = zoroastrian }
					#	20 = { religion = nestorian }
					#}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = han }
						50 = { }
					}
				}			
			}
		}
	}
}


# High level Tibetan courtier spawn
character_event = {
	id = dunhuang.103
	desc = dunhuang.103.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.103.a
		prestige = 10
		random_list = {
			# 40% Bodpa
			# 40% Tangut
			# 20% Tuyuhun
			40 = { # Bodpa
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = bodpa
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						70 = { }
						30 = { religion = bon }
					}
					#Randomize appearance
					random_list = {
						30 = { set_graphical_culture = mongol }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			40 = { # Tangut
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = tangut
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						70 = { }
						30 = { religion = bon }
					}
					#Randomize appearance
					random_list = {
						30 = { set_graphical_culture = mongol }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			20 = { # Tuyuhun
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = tangut
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						70 = { }
						30 = { religion = bon }
					}
					#Randomize appearance
					random_list = {
						30 = { set_graphical_culture = mongol }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
		}
	}
}


# High level nomad courtier spawn
character_event = {
	id = dunhuang.104
	desc = dunhuang.104.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.104.a
		prestige = 10
		random_list = {
			# 40% uyghur
			# 20% Mongol
			# 10% Kirghiz
			# 10% Karluk
			40 = { # uyghur
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = uyghur
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						55 = { }
						35 = { religion = manichean }
						10 = {
							modifier = {
								factor = 0
								has_global_flag = tengri_reformation
							}
							religion = tengri_pagan 
						}
						10 = {
							modifier = {
								factor = 0
								NOT = { has_global_flag = tengri_reformation }
							}
							religion = tengri_pagan_reformed
						}
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = hungarian }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = han }
						10 = { set_graphical_culture = persian }
						10 = { set_graphical_culture = bodpa }
						25 = { set_graphical_culture = mongol }
						30 = { set_graphical_culture = cuman }
					}	
				}			
			}
			20 = { # mongol
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = mongol
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						40 = {
							modifier = {
								factor = 0
								has_global_flag = tengri_reformation
							}
							religion = tengri_pagan 
						}
						40 = {
							modifier = {
								factor = 0
								NOT = { has_global_flag = tengri_reformation }
							}
							religion = tengri_pagan_reformed
						}
						20 = { religion = nestorian }
						20 = { religion = buddhist }
						10 = { religion = sunni }
						10 = { religion = manichean }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = cuman }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			10 = { # kirghiz
				create_character = {
					dynasty = actually_culture
					religion = sunni
					culture = kirghiz
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						30 = { }
						40 = {
							modifier = {
								factor = 0
								has_global_flag = tengri_reformation
							}
							religion = tengri_pagan 
						}
						40 = {
							modifier = {
								factor = 0
								NOT = { has_global_flag = tengri_reformation }
							}
							religion = tengri_pagan_reformed
						}
						15 = { religion = manichean }
						15 = { religion = nestorian }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = han }
						10 = { set_graphical_culture = bodpa }
						5 = { set_graphical_culture = persian }
						5 = { set_graphical_culture = finnish }
						50 = { }
					}		
				}			
			}
			10 = { # karluk
				create_character = {
					dynasty = actually_culture
					religion = sunni
					culture = karluk
					female = no
					random_traits = yes
					historical = yes
				}
				new_character = {
					#Education & other basic stuff
					remove_trait = naive_appeaser
					remove_trait = underhanded_rogue
					remove_trait = charismatic_negotiator
					remove_trait = grey_eminence
					remove_trait = misguided_warrior
					remove_trait = tough_soldier
					remove_trait = skilled_tactician
					remove_trait = brilliant_strategist
					remove_trait = indulgent_wastrel
					remove_trait = thrifty_clerk
					remove_trait = fortune_builder
					remove_trait = midas_touched
					remove_trait = amateurish_plotter
					remove_trait = flamboyant_schemer
					remove_trait = intricate_webweaver
					remove_trait = elusive_shadow
					remove_trait = detached_priest
					remove_trait = martial_cleric
					remove_trait = scholarly_theologian
					remove_trait = mastermind_theologian
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					random_list = {
						20 = { add_trait = genius }
						30 = { add_trait = quick }
						30 = { add_trait = fair }
						20 = { add_trait = strong }
						20 = { add_trait = sturdy }
						20 = { add_trait = robust }
						30 = { add_trait = groomed }
						30 = { add_trait = shrewd }
						300 = { }
					}
					#Guaranteed Traits
					random_list = {
						25 = { add_trait = naive_appeaser }
						25 = { add_trait = underhanded_rogue }
						25 = { add_trait = misguided_warrior }
						25 = { add_trait = tough_soldier }
						25 = { add_trait = indulgent_wastrel }
						25 = { add_trait = thrifty_clerk }
						25 = { add_trait = amateurish_plotter }
						25 = { add_trait = flamboyant_schemer }
						25 = { add_trait = detached_priest }
						25 = { add_trait = martial_cleric }
						50 = { add_trait = charismatic_negotiator }
						50 = { add_trait = grey_eminence }
						50 = { add_trait = skilled_tactician }
						50 = { add_trait = brilliant_strategist }
						50 = { add_trait = fortune_builder }
						50 = { add_trait = midas_touched }
						50 = { add_trait = intricate_webweaver }
						50 = { add_trait = elusive_shadow }
						50 = { add_trait = scholarly_theologian }
						50 = { add_trait = mastermind_theologian }
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						30 = { }
						40 = {
							modifier = {
								factor = 0
								has_global_flag = tengri_reformation
							}
							religion = tengri_pagan 
						}
						40 = {
							modifier = {
								factor = 0
								NOT = { has_global_flag = tengri_reformation }
							}
							religion = tengri_pagan_reformed
						}
						15 = { religion = manichean }
						15 = { religion = nestorian }
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = hungarian }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = han }
						10 = { set_graphical_culture = persian }
						10 = { set_graphical_culture = bodpa }
						25 = { set_graphical_culture = mongol }
						30 = { }
					}		
				}			
			}
		}
	}
}


# Offerings from locals, with tombola
character_event = {
	id = dunhuang.105
	hide_window = yes
	
	is_triggered_only = yes	
	
	#min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		OR = {
			has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
			has_character_modifier = VIET_dunhuang_civilized_western_contacts
			has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
			has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
		}
	}
	
	immediate = {
		random_list = {
			# Offering of wealth
			10 = { # Gold
				modifier = {
					factor = 1.3
					has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
				}
				modifier = {
					factor = 1.6
					has_character_modifier = VIET_dunhuang_civilized_western_contacts
				}
				character_event = { id = dunhuang.106 days = 1 random = 60 }
			}
			10 = { # Modifier
				modifier = {
					factor = 1.3
					has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
				}
				modifier = {
					factor = 1.6
					has_character_modifier = VIET_dunhuang_civilized_western_contacts
				}
				character_event = { id = dunhuang.107 days = 1 random = 60 }
			}
			# Offering of prestige
			10 = { # Prestige
				modifier = {
					factor = 1.3
					has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
				}
				modifier = {
					factor = 1.6
					has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
				}
				character_event = { id = dunhuang.108 days = 1 random = 60 }
			}
			10 = { # Modifier
				modifier = {
					factor = 1.3
					has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
				}
				modifier = {
					factor = 1.6
					has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
				}
				character_event = { id = dunhuang.109 days = 1 random = 60 }
			}
			# Offering of piety
			10 = { # Piety
				modifier = {
					factor = 1.3
					has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
				}
				modifier = {
					factor = 1.6
					has_character_modifier = VIET_dunhuang_civilized_western_contacts
				}
				character_event = { id = dunhuang.110 days = 1 random = 60 }
			}
			10 = { # Modifier
				modifier = {
					factor = 1.3
					has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
				}
				modifier = {
					factor = 1.6
					has_character_modifier = VIET_dunhuang_civilized_western_contacts
				}
				character_event = { id = dunhuang.111 days = 1 random = 60 }
			}
			# Offering of male courtier (modifier first!)
			10 = {
				modifier = {
					factor = 0.1
					any_courtier = {
						has_character_flag = VIET_dunhuang_community_offering_courtier
						is_female = no
					}
				}
				character_event = { id = dunhuang.112 days = 1 random = 60 }
			}
			# Offering of female courtier (modifier first!)
			10 = {
				modifier = {
					factor = 0.1
					any_courtier = {
						has_character_flag = VIET_dunhuang_community_offering_courtier_female
						is_female = yes
					}
				}
				character_event = { id = dunhuang.113 days = 1 random = 60 }
			}
			# Offering of artifacts
			10 = {
				modifier = {
					factor = 0
					any_artifact = {
						#has_artifact_flag = VIET_clutter_flag
						has_artifact_flag = VIET_dunhuang_artifact_flag
					}
				}
				character_event = { id = dunhuang.114 days = 1 random = 60 }
			}
			# Offering of military support
			10 = { # Troops
				modifier = {
					factor = 1.3
					has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
				}
				modifier = {
					factor = 1.6
					has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
				}
				modifier = {
					factor = 0.1
					war = no
				}
				character_event = { id = dunhuang.115 days = 1 random = 60 }
			}
			10 = { # Modifier
				modifier = {
					factor = 1.3
					has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
				}
				modifier = {
					factor = 1.6
					has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
				}
				character_event = { id = dunhuang.116 days = 1 random = 60 }
			}
			# Offering of plotting assistance
			10 = { # Troops
				character_event = { id = dunhuang.117 days = 1 random = 60 }
			}
		}
	}
}


# Locals offerings - money gift
character_event = {
	id = dunhuang.106
	#title = dunhuang.106.title
	picture = GFX_evt_the_silk_road_dunhuang
	desc = {
		text = dunhuang.106.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.106.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.106.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.106.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.106.a
		if = {
			limit = {
				NOT = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
			}
			random_list = {
				40 = { wealth = 50 }				
				30 = { wealth = 100 }				
				20 = { wealth = 150 }				
				10 = { wealth = 200 }				
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_western_contacts
			}
			random_list = {
				20 = { wealth = 50 }				
				30 = { wealth = 100 }				
				30 = { wealth = 150 }				
				20 = { wealth = 200 }				
			}
		}
	}
}


# Locals offerings - agreed business deal
character_event = {
	id = dunhuang.107
	#title = dunhuang.107.title
	picture = GFX_evt_silk_road_camels
	desc = {
		text = dunhuang.107.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.107.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.107.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.107.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.107.a
		if = {
			limit = {
				NOT = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
			}
			add_character_modifier = {
				name = VIET_dunhuang_offering_wealth_basic
				duration = 1095
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_western_contacts
			}
			add_character_modifier = {
				name = VIET_dunhuang_offering_wealth_greater
				duration = 1095
			}
		}
	}
}


# Locals offerings - community leaders pay homage to you in a great feast
character_event = {
	id = dunhuang.108
	#title = dunhuang.108.title
	picture = GFX_evt_dunhuang_food
	desc = {
		text = dunhuang.108.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.108.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.108.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.108.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.108.a
		if = {
			limit = {
				NOT = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
			}
			random_list = {
				40 = { prestige = 25 }				
				30 = { prestige = 50 }				
				20 = { prestige = 75 }				
				10 = { prestige = 100 }				
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
			}
			random_list = {
				20 = { prestige = 25 }				
				30 = { prestige = 50 }				
				30 = { prestige = 75 }				
				20 = { prestige = 100 }				
			}
		}
	}
}


# Locals offerings - good rapport among community
character_event = {
	id = dunhuang.109
	#title = dunhuang.109.title
	picture = GFX_evt_eastern_celebration
	desc = {
		text = dunhuang.109.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.109.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.109.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.109.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.109.a
		if = {
			limit = {
				NOT = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
			}
			add_character_modifier = {
				name = VIET_dunhuang_offering_prestige_basic
				duration = 1095
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
			}
			add_character_modifier = {
				name = VIET_dunhuang_offering_prestige_greater
				duration = 1095
			}
		}
	}
}


# Locals offerings - community leaders give religious artifacts
character_event = {
	id = dunhuang.110
	#title = dunhuang.110.title
	picture = GFX_evt_mogao_caves_working
	desc = {
		text = dunhuang.110.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.110.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.110.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.110.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.110.a
		if = {
			limit = {
				NOT = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
			}
			random_list = {
				40 = { piety = 25 }				
				30 = { piety = 50 }				
				20 = { piety = 75 }				
				10 = { piety = 100 }				
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
			}
			random_list = {
				20 = { piety = 25 }				
				30 = { piety = 50 }				
				30 = { piety = 75 }				
				20 = { piety = 100 }				
			}
		}
	}
}


# Locals offerings - built a good relationship with religious organizations and houses of worship and study
character_event = {
	id = dunhuang.111
	#title = dunhuang.111.title
	picture = GFX_evt_mogao_caves_outside
	desc = {
		text = dunhuang.111.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.111.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.111.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.111.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.111.a
		if = {
			limit = {
				NOT = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
			}
			add_character_modifier = {
				name = VIET_dunhuang_offering_piety_basic
				duration = 1095
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
			}
			add_character_modifier = {
				name = VIET_dunhuang_offering_piety_greater
				duration = 1095
			}
		}
	}
}


# Locals offerings - promising man wishes to join court
character_event = {
	id = dunhuang.112
	#title = dunhuang.112.title
	#picture = GFX_evt_dunhuang_manor
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
			}
			character_event = { id = dunhuang.101 }
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_western_contacts
			}
			character_event = { id = dunhuang.102 }
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
			}
			character_event = { id = dunhuang.103 }
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
			}
			character_event = { id = dunhuang.104 }
		}
	}
}


# Locals offerings - pleasing young lady offered to join court
character_event = {
	id = dunhuang.113
	#title = dunhuang.113.title
	#picture = GFX_evt_dunhuang_manor
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
			}
			character_event = { id = dunhuang.118 }
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_western_contacts
			}
			character_event = { id = dunhuang.119 }
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
			}
			character_event = { id = dunhuang.120 }
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
			}
			character_event = { id = dunhuang.121 }
		}
	}
}


# Locals offerings - locals offer valuable manuscript
character_event = {
	id = dunhuang.114
	#title = dunhuang.114.title
	picture = GFX_evt_mogao_caves_art
	desc = {
		text = dunhuang.114.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.114.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.114.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.114.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.114.a
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
			}
			random_list = {
				75 = { add_artifact = VIET_dunhuang_han_manuscript }
				25 = { add_artifact = VIET_dunhuang_khitan_manuscript }
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_western_contacts
			}
			random_list = {
				10 = { add_artifact = VIET_dunhuang_sogdian_manuscript }
				10 = { add_artifact = VIET_dunhuang_tocharian_manuscript }
				10 = { add_artifact = VIET_dunhuang_khotanese_manuscript }
				10 = { add_artifact = VIET_dunhuang_persian_manuscript }
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
			}
			random_list = {
				66 = { add_artifact = VIET_dunhuang_tibetan_manuscript }
				33 = { add_artifact = VIET_dunhuang_tangut_manuscript }
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
			}
			random_list = {
				10 = { add_artifact = VIET_dunhuang_mongol_manuscript }
				10 = { add_artifact = VIET_dunhuang_turkic_manuscript }
			}
		}
	}
}


# Locals offerings - locals offer military forces
character_event = {
	id = dunhuang.115
	#title = dunhuang.115.title
	picture = GFX_evt_china_rebel_general
	desc = {
		text = dunhuang.115.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.115.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.115.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.115.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.115.a
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_eastern_contacts
			}
			capital_scope = {
				PREV = {
					spawn_unit = {
						owner = ROOT
						province = PREV
						home = PREV
						troops = {
							archers = { 300 300 }
							pikemen = { 300 300 }
							light_infantry = { 150 150 }
							heavy_infantry = { 150 150 }
							light_cavalry = { 50 50 }
							knights = { 50 50 }
							#horse_archers = { 50 50 }
						}
						attrition = 1.0
						#disband_on_peace = yes
						maintenance_multiplier = 0.25
					}
				}
			}
			add_character_modifier = {
				name = VIET_dunhuang_community_unit_spawn_timer
				duration = 3650
				hidden = yes
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_civilized_western_contacts
			}
			capital_scope = {
				PREV = {
					spawn_unit = {
						owner = ROOT
						province = PREV
						home = PREV
						troops = {
							archers = { 100 100 }
							pikemen = { 50 50 }
							light_infantry = { 100 100 }
							heavy_infantry = { 50 50 }
							light_cavalry = { 100 100 }
							knights = { 50 50 }
							horse_archers = { 50 50 }
						}
						attrition = 1.0
						#disband_on_peace = yes
						maintenance_multiplier = 0.25
					}
				}
			}
			add_character_modifier = {
				name = VIET_dunhuang_community_unit_spawn_timer
				duration = 3650
				#hidden = yes
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_southern_contacts
			}
			capital_scope = {
				PREV = {
					spawn_unit = {
						owner = ROOT
						province = PREV
						home = PREV
						troops = {
							archers = { 50 50 }
							pikemen = { 75 75 }
							light_infantry = { 100 100 }
							heavy_infantry = { 75 75 }
							light_cavalry = { 100 100 }
							knights = { 50 50 }
							horse_archers = { 50 50 }
						}
						attrition = 1.0
						#disband_on_peace = yes
						maintenance_multiplier = 0.25
					}
				}
			}
			add_character_modifier = {
				name = VIET_dunhuang_community_unit_spawn_timer
				duration = 3650
				#hidden = yes
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
			}
			capital_scope = {
				PREV = {
					spawn_unit = {
						owner = ROOT
						province = PREV
						home = PREV
						troops = {
							archers = { 75 75 }
							#pikemen = { 50 50 }
							light_infantry = { 75 75 }
							#heavy_infantry = { 50 50 }
							light_cavalry = { 100 100 }
							knights = { 100 100 }
							horse_archers = { 100 100 }
						}
						attrition = 1.0
						#disband_on_peace = yes
						maintenance_multiplier = 0.25
					}
				}
			}
			add_character_modifier = {
				name = VIET_dunhuang_community_unit_spawn_timer
				duration = 3650
				#hidden = yes
			}
		}
	}
}


# Locals offerings - locals offer military supplies and intelligence
character_event = {
	id = dunhuang.116
	#title = dunhuang.116.title
	picture = GFX_evt_travel_dunhuang
	desc = {
		text = dunhuang.116.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.116.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.116.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.116.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.116.a
		if = {
			limit = {
				NOT = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
			}
			add_character_modifier = {
				name = VIET_dunhuang_offering_military_basic
				duration = 1095
			}
		}
		if = {
			limit = {
				has_character_modifier = VIET_dunhuang_barbarian_northern_contacts
			}
			add_character_modifier = {
				name = VIET_dunhuang_offering_military_greater
				duration = 1095
			}
		}
	}
}


# Locals offerings - locals offer intrigue and plotting assistance
character_event = {
	id = dunhuang.117
	#title = dunhuang.117.title
	picture = GFX_evt_chinese_night_village
	desc = {
		text = dunhuang.117.desc.a
		trigger = { has_character_modifier = VIET_dunhuang_civilized_eastern_contacts }
	}
	desc = {
		text = dunhuang.117.desc.b
		trigger = { has_character_modifier = VIET_dunhuang_civilized_western_contacts }
	}
	desc = {
		text = dunhuang.117.desc.c
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_southern_contacts }
	}
	desc = {
		text = dunhuang.117.desc.d
		trigger = { has_character_modifier = VIET_dunhuang_barbarian_northern_contacts }
	}
	
	is_triggered_only = yes
	
	option = {
		name = dunhuang.116.a
		add_character_modifier = {
			name = VIET_dunhuang_offering_intrigue
			duration = 1095
		}
	}
}



# Female Chinese courtier spawn
character_event = {
	id = dunhuang.118
	desc = dunhuang.118.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.101.a
		prestige = 10
		random_list = {
			# 75% Han
			# 25% Khitan
			75 = { # Han
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = han
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						9 = { add_scarred_tiered_effect = yes }
						1 = { 
							trigger = { has_dlc = Reapers }
							add_trait = one_eyed
						}
					}
					random_list = {
						60 = { }
						30 = { religion = taoist }
						10 = { religion = manichean }
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = cuman }
						5 = { set_graphical_culture = sogdian }
						20 = { set_graphical_culture = bodpa }
						20 = { set_graphical_culture = mongol }
						50 = { }
					}
				}			
			}
			25 = { # Khitan
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = khitan
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						80 = { }
						15 = { religion = taoist }
						5 = { religion = manichean }
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = cuman }
						5 = { set_graphical_culture = sogdian }
						20 = { set_graphical_culture = bodpa }
						20 = { set_graphical_culture = mongol }
						50 = { }
					}
				}			
			}
		}
	}
}

# Female Iranian courtier spawn
character_event = {
	id = dunhuang.119
	desc = dunhuang.119.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.101.a
		prestige = 10
		random_list = {
			# 25% Persian
			# 25% Sogdian
			# 25% Khotanese/Saka
			# 25% Tocharian
			25 = { # Persian
				create_character = {
					dynasty = actually_culture
					religion = zoroastrian
					culture = persian
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						50 = { }
						20 = { religion = manichean }
						10 = { religion = sunni }
						10 = { religion = shiite }
						5 = { religion = buddhist }
						5 = { religion = mazdaki }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = hindustani }
						10 = { set_graphical_culture = turkish }
						15 = { set_graphical_culture = greek }
						15 = { set_graphical_culture = levantine_arabic }
						50 = { }
					}	
				}			
			}
			25 = { # Sogdian
				create_character = {
					dynasty = actually_culture
					religion = khurmazta
					culture = sogdian
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						20 = { }
						20 = { religion = buddhist }
						20 = { religion = manichean }
						20 = { religion = zoroastrian }
						20 = { religion = nestorian }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = hindustani }
						20 = { set_graphical_culture = levantine_arabic }
						50 = { }
					}
				}			
			}
			25 = { # Khotanese/Saka
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = saka
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					#random_list = {
					#	20 = { }
					#	20 = { religion = buddhist }
					#	20 = { religion = manichean }
					#	20 = { religion = zoroastrian }
					#	20 = { religion = nestorian }
					#}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = han }
						50 = { }
					}
				}			
			}
			25 = { # Tocharian
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = tocharian
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					#random_list = {
					#	20 = { }
					#	20 = { religion = buddhist }
					#	20 = { religion = manichean }
					#	20 = { religion = zoroastrian }
					#	20 = { religion = nestorian }
					#}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = han }
						50 = { }
					}
				}			
			}
		}
	}
}




# Female Tibetan courtier spawn
character_event = {
	id = dunhuang.120
	desc = dunhuang.120.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.101.a
		prestige = 10
		random_list = {
			# 40% Bodpa
			# 40% Tangut
			# 20% Tuyuhun
			40 = { # Bodpa
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = bodpa
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						70 = { }
						30 = { religion = bon }
					}
					#Randomize appearance
					random_list = {
						30 = { set_graphical_culture = mongol }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			40 = { # Tangut
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = tangut
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						70 = { }
						30 = { religion = bon }
					}
					#Randomize appearance
					random_list = {
						30 = { set_graphical_culture = mongol }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			20 = { # Tuyuhun
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = tangut
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						70 = { }
						30 = { religion = bon }
					}
					#Randomize appearance
					random_list = {
						30 = { set_graphical_culture = mongol }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
		}
	}
}



# Female nomad courtier spawn
character_event = {
	id = dunhuang.121
	desc = dunhuang.121.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.101.a
		prestige = 10
		random_list = {
			# 40% uyghur
			# 20% Mongol
			# 10% Kirghiz
			# 10% Karluk
			40 = { # uyghur
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = uyghur
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						55 = { }
						35 = { religion = manichean }
						10 = {
							modifier = {
								factor = 0
								has_global_flag = tengri_reformation
							}
							religion = tengri_pagan 
						}
						10 = {
							modifier = {
								factor = 0
								NOT = { has_global_flag = tengri_reformation }
							}
							religion = tengri_pagan_reformed
						}
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = hungarian }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = han }
						10 = { set_graphical_culture = persian }
						10 = { set_graphical_culture = bodpa }
						25 = { set_graphical_culture = mongol }
						30 = { set_graphical_culture = cuman }
					}	
				}			
			}
			20 = { # mongol
				create_character = {
					dynasty = actually_culture
					religion = buddhist
					culture = mongol
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						40 = {
							modifier = {
								factor = 0
								has_global_flag = tengri_reformation
							}
							religion = tengri_pagan 
						}
						40 = {
							modifier = {
								factor = 0
								NOT = { has_global_flag = tengri_reformation }
							}
							religion = tengri_pagan_reformed
						}
						20 = { religion = nestorian }
						20 = { religion = buddhist }
						10 = { religion = sunni }
						10 = { religion = manichean }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = cuman }
						20 = { set_graphical_culture = han }
						50 = { }
					}	
				}			
			}
			10 = { # kirghiz
				create_character = {
					dynasty = actually_culture
					religion = sunni
					culture = kirghiz
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						30 = { }
						40 = {
							modifier = {
								factor = 0
								has_global_flag = tengri_reformation
							}
							religion = tengri_pagan 
						}
						40 = {
							modifier = {
								factor = 0
								NOT = { has_global_flag = tengri_reformation }
							}
							religion = tengri_pagan_reformed
						}
						15 = { religion = manichean }
						15 = { religion = nestorian }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = han }
						10 = { set_graphical_culture = bodpa }
						5 = { set_graphical_culture = persian }
						5 = { set_graphical_culture = finnish }
						50 = { }
					}		
				}			
			}
			10 = { # karluk
				create_character = {
					dynasty = actually_culture
					religion = sunni
					culture = karluk
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					set_character_flag = VIET_dunhuang_community_offering_courtier_female
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						55 = { add_trait = fair }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						55 = { add_trait = groomed }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Clutter Artifact					
					#random = {
					#	VIET_give_clutter_artifact_effect = yes
					#	chance = 10
					#}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						30 = { }
						40 = {
							modifier = {
								factor = 0
								has_global_flag = tengri_reformation
							}
							religion = tengri_pagan 
						}
						40 = {
							modifier = {
								factor = 0
								NOT = { has_global_flag = tengri_reformation }
							}
							religion = tengri_pagan_reformed
						}
						15 = { religion = manichean }
						15 = { religion = nestorian }
					}
					#Randomize appearance
					random_list = {
						5 = { set_graphical_culture = hungarian }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = han }
						10 = { set_graphical_culture = persian }
						10 = { set_graphical_culture = bodpa }
						25 = { set_graphical_culture = mongol }
						30 = { }
					}		
				}			
			}
		}
	}
}


##############################################################
# 
# NADUN FESTIVAL EVENTS
# 
# 130 - Initial event
# 131 - Nadun festival starts
# 132 - Nadun ends
# 133-142 - Misc flavor events
# 
##############################################################


# Nadun start
character_event = {
	id = dunhuang.130
	desc = dunhuang.130.desc
	picture = GFX_evt_chinese_night_village
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.130.a
		narrative_event = { id = dunhuang.131 tooltip = dunhuang.131.tooltip days = 10 }
	}
}


# Nadun start
narrative_event = {
	id = dunhuang.131
	title = dunhuang.131.title
	desc = dunhuang.131.desc
	picture = GFX_evt_eastern_celebration
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.131.a
		character_event = { id = dunhuang.132 tooltip = dunhuang.132.tooltip days = 30 }
		#Random flavor events
		hidden_tooltip = {
			random = {
				character_event = { id = dunhuang.133 days = 3 random = 25 }
				chance = 20
			}
			random = {
				character_event = { id = dunhuang.134 days = 3 random = 25 }
				chance = 20
			}
			random = {
				character_event = { id = dunhuang.135 days = 3 random = 25 }
				chance = 20
			}
			random = {
				character_event = { id = dunhuang.136 days = 3 random = 25 }
				chance = 20
			}
			random = {
				character_event = { id = dunhuang.137 days = 3 random = 25 }
				chance = 20
			}
			random = {
				long_character_event = { id = dunhuang.138 days = 3 random = 25 }
				chance = 20
			}
			random = {
				character_event = { id = dunhuang.139 days = 3 random = 25 }
				chance = 20
			}
			random = {
				character_event = { id = dunhuang.140 days = 3 random = 25 }
				chance = 20
			}
			random = {
				character_event = { id = dunhuang.141 days = 3 random = 25 }
				chance = 20
			}
			random = {
				character_event = { id = dunhuang.142 days = 3 random = 25 }
				chance = 20
			}
		}
	}
}

# Nadun ends
character_event = {
	id = dunhuang.132
	desc = dunhuang.132.desc
	picture = GFX_evt_chinese_night_village
	
	is_triggered_only = yes
	
	immediate = {		
		clr_character_flag = VIET_going_to_nadun_festival
		add_character_modifier = {
			name = held_nadun_festival_cooldown
			duration = 1825
			hidden = yes
		}
	}
	
	option = { # Ok
		name = dunhuang.132.a
		add_character_modifier = {
			name = VIET_recently_went_to_nadun_festival
			duration = 365
		}
	}
}

# Nadun flavor - share good news
character_event = {
	id = dunhuang.133
	desc = dunhuang.133.desc
	picture = GFX_evt_chinese_night_village
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.133.a
		prestige = 5
		random = {
			add_trait = proud
			chance = 15
		}
	}	
	option = { # Ok
		name = dunhuang.133.b
		piety = 5
		random = {
			add_trait = humble
			chance = 15
		}
	}
}

# Nadun flavor - dancing in honor of heaven
character_event = {
	id = dunhuang.134
	desc = dunhuang.134.desc
	picture = GFX_evt_eastern_celebration
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.134.a
		piety = 5
	}
}

# Nadun flavor - eating Supan cake
character_event = {
	id = dunhuang.135
	desc = dunhuang.135.desc
	picture = GFX_evt_dunhuang_food
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.135.a
	}	
	option = { # Ok
		name = dunhuang.135.b
		random = {
			add_trait = gluttonous
			chance = 15
		}
	}
	option = { # Ok
		name = dunhuang.135.c
		random = {
			add_trait = temperate
			chance = 15
		}
	}
}

# Nadun flavor - toasting the dancers
character_event = {
	id = dunhuang.136
	desc = dunhuang.136.desc
	picture = GFX_evt_eastern_celebration
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.136.a
		piety = 5
	}	
	option = { # Ok
		name = dunhuang.136.b
		random = {
			add_trait = gregarious
			chance = 15
		}
	}
}

# Nadun flavor - theatre story about farmers
character_event = {
	id = dunhuang.137
	desc = dunhuang.137.desc
	picture = GFX_evt_eastern_celebration
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.137.a
		prestige = 5
	}
}

# Nadun flavor - theatre story about the Three Kingdoms
long_character_event = {
	id = dunhuang.138
	desc = dunhuang.138.desc
	picture = GFX_evt_china_civil_war
	
	is_triggered_only = yes
	
	option = { # Liu Bei
		name = dunhuang.138.a
		piety = 5
		random_list = {
			70 = { }
			10 = { add_trait = kind }
			10 = { add_trait = just }
			10 = { add_trait = humble }
		}
	}	
	option = { # Cao Cao
		name = dunhuang.138.b
		prestige = 5
		random_list = {
			70 = { }
			10 = { add_trait = ambitious }
			10 = { add_trait = erudite }
			10 = { add_trait = lustful }
		}
	}	
	option = { # Sun Quan
		name = dunhuang.138.c
		piety = 5
		random_list = {
			70 = { }
			10 = { add_trait = proud }
			10 = { add_trait = brave }
			10 = { add_trait = stubborn }
		}
	}
	option = { # Sima Yi
		name = dunhuang.138.d
		prestige = 5
		random_list = {
			70 = { }
			10 = { add_trait = deceitful }
			10 = { add_trait = patient }
			10 = { add_trait = paranoid }
		}
	}
}


# Nadun flavor - visit friends in village?
character_event = {
	id = dunhuang.139
	desc = dunhuang.139.desc
	picture = GFX_evt_chinese_night_village
	
	is_triggered_only = yes
	
	option = { # No
		name = dunhuang.139.a
		random_list = {
			50 = { prestige = 5 }
			50 = { piety = 5 }
		}
		random = {
			add_trait = content
			chance = 20
		}
	}	
	option = { # Good idea
		name = dunhuang.139.b
		piety = 5
	}
	option = { # Make new friends
		name = dunhuang.139.c
		prestige = 5
	}
}


# Nadun flavor - food at feast
character_event = {
	id = dunhuang.140
	desc = dunhuang.140.desc
	picture = GFX_evt_dunhuang_food
	
	is_triggered_only = yes
	
	option = { # simple yes
		name = dunhuang.140.a
		prestige = -5
		piety = 5
		random = {
			add_trait = temperate
			chance = 20
		}
	}	
	option = { # ok
		name = dunhuang.140.b
	}
	option = { # boo no
		name = dunhuang.140.c
		prestige = 5
		piety = -5
		random = {
			add_trait = proud
			chance = 20
		}
	}
}


# Nadun flavor - traditional songs
character_event = {
	id = dunhuang.141
	desc = dunhuang.141.desc
	picture = GFX_evt_eastern_celebration
	
	is_triggered_only = yes
	
	option = { # simple yes
		name = dunhuang.141.a
		piety = 5
	}
}



# Nadun flavor - young love is blossoming
character_event = {
	id = dunhuang.142
	desc = dunhuang.142.desc
	picture = GFX_evt_chinese_night_village
	
	is_triggered_only = yes
	
	option = { # Young love
		name = dunhuang.142.a
		random = {
			add_trait = kind
			chance = 10
		}
	}	
	option = { # cynical
		name = dunhuang.142.b
		random = {
			add_trait = cynical
			chance = 10
		}
	}	
	option = { # none of concern
		name = dunhuang.142.c
	}
}







##############################################################
# 
# 
# 150 - Give Cao Yijin the ambitious trait
# 151 - Cao Yijin world notification
# 152 - hidden event to fire 150 after education trait is given
# 153 - Cao Yijin gets claim on Duchy of Guiyi/Jiuquan and/or Kingdom of Dunhuang
# 154 - Cao Yijin claims narrative event
# 155 - Zhai Fengda event setup
# 156 - Zhai Fengda event tombola
# 157 - Equivalent of Zhai Fengda becomes interested in calendars and astronomy
# 158 - Equivalent of Zhai Fengda narrative event
# 159 - Zhang Yichao passes away, hidden event
# 160 - Zhang Yichao passes away, narrative vent
# 161 - Zhang Yichao passes away, other families' reactions
# 162 - Zhang Yichao passes away - ping event
# 163 - Cao Yijin 
# 
# ??? - Zhangs or a Chinese character who owns Duchies of Dunhuang, Jiuquan, or Kingdom of Dunhuang gets some event troops and help in the fight against Tibet
# 
# 
# 
# 
# 
# ??? - Birth of Zhang Yichao
# ??? - Give Zhang Yichao the ambitious trait
# Dunhuang starts with primogeniture
# 
##############################################################



# Give Cao Yijin the ambitious trait when he comes of age, along with a few other goodies - this is to ensure he doesn't become a nobody
long_character_event = {
	id = dunhuang.150
	desc = dunhuang.150.desc
	picture = GFX_evt_cao_cao
	
	is_triggered_only = yes
	
	has_character_flag = VIET_is_cao_yijin
	
	option = { # Cao Yijin comes of age, shows ambition
		name = dunhuang.150.a
		add_character_modifier = {
			name = VIET_cao_yijin_modifier
			duration = -1
		}
		add_trait = ambitious
		if = {
			limit = {
				trait = naive_appeaser
			}
			remove_trait = naive_appeaser
			add_trait = grey_eminence
		}
		if = {
			limit = {
				trait = underhanded_rogue
					trait = charismatic_negotiator
			}
			remove_trait = underhanded_rogue
			add_trait = grey_eminence
		}
		if = {
			limit = {
				trait = charismatic_negotiator
			}
			remove_trait = charismatic_negotiator
			add_trait = grey_eminence
		}
		if = {
			limit = {
				trait = misguided_warrior
			}
			remove_trait = misguided_warrior
			add_trait = brilliant_strategist
		}
		if = {
			limit = {
				trait = tough_soldier
			}
			remove_trait = tough_soldier
			add_trait = brilliant_strategist
		}
		if = {
			limit = {
				trait = skilled_tactician
			}
			remove_trait = skilled_tactician
			add_trait = brilliant_strategist
		}
		if = {
			limit = {
				trait = indulgent_wastrel
			}
			remove_trait = indulgent_wastrel
			add_trait = midas_touched
		}
		if = {
			limit = {
				trait = thrifty_clerk
			}
			remove_trait = thrifty_clerk
			add_trait = midas_touched
		}
		if = {
			limit = {
				trait = fortune_builder
			}
			remove_trait = fortune_builder
			add_trait = midas_touched
		}
		if = {
			limit = {
				trait = amateurish_plotter
			}
			remove_trait = amateurish_plotter
			add_trait = elusive_shadow
		}
		if = {
			limit = {
				trait = flamboyant_schemer
			}
			remove_trait = flamboyant_schemer
			add_trait = elusive_shadow
		}
		if = {
			limit = {
				trait = intricate_webweaver
			}
			remove_trait = intricate_webweaver
			add_trait = elusive_shadow
		}
		if = {
			limit = {
				trait = detached_priest
			}
			remove_trait = detached_priest
			add_trait = mastermind_theologian
		}
		if = {
			limit = {
				trait = martial_cleric
			}
			remove_trait = martial_cleric
			add_trait = mastermind_theologian
		}
		if = {
			limit = {
				trait = scholarly_theologian
			}
			remove_trait = scholarly_theologian
			add_trait = mastermind_theologian
		}	
		hidden_tooltip = {
			narrative_event = { id = dunhuang.151 }
			any_playable_ruler = {
				limit = { 
					ai = no 
					#NOT = { character = ROOT }
					capital_scope = {
						NOT = {
							distance = {
								where = 1448 	# Dunhuang
								value = 500		# Same part of the world
							}
						}
					}
				}
				narrative_event = { id = dunhuang.151 }
			}
		}
	}
}


# Cao Yijin comes of age - narrative event
narrative_event = {
	id = dunhuang.151
	title = dunhuang.151.title
	desc = dunhuang.151.desc
	picture = GFX_evt_cao_cao
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.151.a
	}
}

# Ping
character_event = {
	id = dunhuang.152

	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		long_character_event = { id = dunhuang.150 days = 1 }
	}
}


# Cao Yjin has ambitions to rule Dunhuang
narrative_event = {
	id = dunhuang.153
	title = dunhuang.153.title
	desc = dunhuang.153.desc
	picture = GFX_evt_cao_cao
	
	is_triggered_only = yes

	has_character_flag = VIET_is_cao_yijin
	min_age = 20 # Wait a few years
	only_capable = yes
	
	trigger = {
		#Only if he's still under another Dunhuang leader
		OR = {
			capital_scope = {
				OR = {
					duchy = { title = d_jiuquan }
					duchy = { title = d_guiyi }
					duchy = { title = d_qinghai }
					duchy = { title = d_kumul }
				}
			}
			any_liege = {
				OR = {
					has_landed_title = d_jiuquan
					has_landed_title = d_guiyi
					has_landed_title = k_dunhuang
				}
			}
		}
		NAND = {
			independent = yes
			OR = {
				has_landed_title = d_jiuquan
				has_landed_title = d_guiyi
				has_landed_title = k_dunhuang				
			}
		}
	}	
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 3
			age = 20
		}
		modifier = {
			factor = 4
			age = 25
		}
		modifier = {
			factor = 5
			age = 30
		}
		modifier = {
			factor = 6
			age = 35
		}
		modifier = {
			factor = 7
			age = 40
		}
		modifier = {
			factor = 8
			age = 45
		}
		modifier = {
			factor = 9
			age = 50
		}
	}	
	
	option = { # Cao Yijin thinks about seizing power in Dunhuang
		name = dunhuang.153.a
		add_pressed_claim = d_jiuquan
		add_pressed_claim = d_guiyi
		if = {
			limit = {
				has_global_flag = VIET_kingdom_dunhuang_established
			}
			add_pressed_claim = k_dunhuang
		}
		set_character_flag = VIET_dunhuang_return_to_righteousness_army_enabled
		#custom_tooltip = { text = VIET_dunhuang_return_to_righteousness_army_enabled_info_text }
		hidden_tooltip = {
			narrative_event = { id = dunhuang.154 }
			any_playable_ruler = {
				limit = {
					ai = no 
					#NOT = { character = ROOT }
					capital_scope = {
						NOT = {
							distance = {
								where = 1448 	# Dunhuang
								value = 500		# Same part of the world
							}
						}
					}
				}
				narrative_event = { id = dunhuang.154 }
			}
		}
	}
}

# Cao Yjin has ambitions to rule Dunhuang - narrative event
narrative_event = {
	id = dunhuang.154
	title = dunhuang.154.title
	desc = dunhuang.154.desc
	picture = GFX_evt_cao_cao
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.154.a
	}
}



# Zhai Fengda equivalent becomes interested in astronomy - randomly select person from within Kingdom of Dunhuang
character_event = {
	id = dunhuang.155
	
	hide_window = yes
	
	is_triggered_only = yes
	
	only_independent = yes
	only_capable = yes
	war = no
	
	trigger = {
		# Dunhuang must be independent and a kingdom
		has_global_flag = VIET_kingdom_dunhuang_established
		has_landed_title = k_dunhuang
		#k_dunhuang = {
		#	owner = {
		#		independent = yes
		#	}
		#}
		OR = {
			culture_group = chinese_group
			culture_group = serindian
			culture = khitan
			culture = jurchen
			culture = sogdian
			culture = tocharian
			culture = tuyuhun
			culture = mongol
			culture = uyghur
		}
		#Only people with a more scholastic background
		#NOR = {
		#	trait = misguided_warrior
		#	trait = tough_soldier
		#	trait = skilled_tactician
		#	trait = brilliant_strategist
		#}
		NOT = { has_global_flag = VIET_zhai_fengda_spawn_event_flag }
		any_courtier = {
			ai = yes
			is_ruler = no
			is_lowborn = no
			NOT = { trait = incapable }
			is_adult = yes
			is_female = no
			NOT = { age = 40 }
			NOT = { is_close_relative = ROOT }
			NOR = {
				trait = misguided_warrior
				trait = tough_soldier
				trait = skilled_tactician
				trait = brilliant_strategist
			}
			OR = {
				culture_group = chinese_group
				culture = khitan
				culture = jurchen
				has_dynasty_flag = VIET_great_dunhuang_clan
			}
			learning = 8 # Don't want a dumbass
			OR = {
				learning = 12
				trait = scholar
				trait = theologian
				trait = administrator
				trait = poet
				trait = genius
				trait = quick
				trait = shrewd
				trait = erudite
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}		
		}
		any_vassal = {
			ai = yes
			is_ruler = yes
			is_lowborn = no
			NOT = { trait = incapable }
			is_adult = yes
			is_female = no
			NOT = { age = 40 }
			NOT = { is_close_relative = ROOT }
			NOR = {
				trait = misguided_warrior
				trait = tough_soldier
				trait = skilled_tactician
				trait = brilliant_strategist
			}
			OR = {
				culture_group = chinese_group
				culture = khitan
				culture = jurchen
				has_dynasty_flag = VIET_great_dunhuang_clan
			}
			learning = 8 # Don't want a dumbass
			OR = {
				learning = 12
				trait = scholar
				trait = theologian
				trait = administrator
				trait = poet
				trait = genius
				trait = quick
				trait = shrewd
				trait = erudite
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
		}
	}

	weight_multiplier = {
		days = 1
	}
	
	immediate = { # Randomly select
	
		set_global_flag = VIET_zhai_fengda_spawn_event_flag
		
		random_list = {
			#Courtier
			40 = {
				random_courtier	= {
					limit = {
						ai = yes
						is_ruler = no
						is_lowborn = no
						NOT = { trait = incapable }
						is_adult = yes
						is_female = no
						NOT = { age = 40 }
						NOT = { is_close_relative = ROOT }
						NOR = {
							trait = misguided_warrior
							trait = tough_soldier
							trait = skilled_tactician
							trait = brilliant_strategist
						}
						OR = {
							culture_group = chinese_group
							culture = khitan
							culture = jurchen
							has_dynasty_flag = VIET_great_dunhuang_clan
						}
						OR = {
							religion = buddhist
							religion = taoist
							has_dynasty_flag = VIET_great_dunhuang_clan
						}
						learning = 8 # Don't want a dumbass
						OR = {
							learning = 12
							stewardship = 12
							trait = scholar
							trait = theologian
							trait = administrator
							trait = poet
							trait = genius
							trait = quick
							trait = shrewd
							trait = erudite
							trait = detached_priest
							trait = martial_cleric
							trait = scholarly_theologian
							trait = mastermind_theologian
						}
					}
					save_event_target_as = target_VIET_zhai_fengda_tombola_courtier_candidate
					add_character_modifier = {
						name = VIET_zhai_fengda_modifier_generic
						duration = -1
					}
				}
				hidden_tooltip = {
					narrative_event = { id = dunhuang.156 }
					any_playable_ruler = {
						limit = {
							ai = no 
							#NOT = { character = ROOT }
							capital_scope = {
								NOT = {
									distance = {
										where = 1448 	# Dunhuang
										value = 600		# Same part of the world
									}
								}
							}
						}
						narrative_event = { id = dunhuang.156 }
					}
				}
			}
			#Vassal
			20 = {
				random_vassal = {
					limit = {
						ai = yes
						is_ruler = yes
						is_lowborn = no
						NOT = { trait = incapable }
						is_adult = yes
						is_female = no
						NOT = { age = 40 }
						NOT = { is_close_relative = ROOT }
						NOR = {
							trait = misguided_warrior
							trait = tough_soldier
							trait = skilled_tactician
							trait = brilliant_strategist
						}
						OR = {
							culture_group = chinese_group
							culture = khitan
							culture = jurchen
							has_dynasty_flag = VIET_great_dunhuang_clan
						}
						OR = {
							religion = buddhist
							religion = taoist
							has_dynasty_flag = VIET_great_dunhuang_clan
						}
						learning = 8 # Don't want a dumbass
						OR = {
							learning = 12
							stewardship = 12
							trait = scholar
							trait = theologian
							trait = administrator
							trait = poet
							trait = genius
							trait = quick
							trait = shrewd
							trait = erudite
							trait = detached_priest
							trait = martial_cleric
							trait = scholarly_theologian
							trait = mastermind_theologian
						}
					}
					save_event_target_as = target_VIET_zhai_fengda_tombola_courtier_candidate
					add_character_modifier = {
						name = VIET_zhai_fengda_modifier_generic
						duration = -1
					}
				}
				hidden_tooltip = {
					narrative_event = { id = dunhuang.156 }
					any_playable_ruler = {
						limit = {
							ai = no 
							#NOT = { character = ROOT }
							capital_scope = {
								NOT = {
									distance = {
										where = 1448 	# Dunhuang
										value = 600		# Same part of the world
									}
								}
							}
						}
						narrative_event = { id = dunhuang.156 }
					}
				}
			}
			#Human
			20 = {
				modifier = {
					factor = 0
					NOT = {
						any_realm_character = {
							ai = no
							NOT = { trait = incapable }
							is_adult = yes
							is_female = no
							NOT = { age = 40 }
							NOT = { is_close_relative = ROOT }
							NOR = {
								trait = misguided_warrior
								trait = tough_soldier
								trait = skilled_tactician
								trait = brilliant_strategist
							}
							OR = {
								culture_group = chinese_group
								culture = khitan
								culture = jurchen
								has_dynasty_flag = VIET_great_dunhuang_clan
							}
							OR = {
								religion = buddhist
								religion = taoist
								has_dynasty_flag = VIET_great_dunhuang_clan
							}
							learning = 8 # Don't want a dumbass
							OR = {
								learning = 12
								stewardship = 12
								trait = scholar
								trait = theologian
								trait = administrator
								trait = poet
								trait = genius
								trait = quick
								trait = shrewd
								trait = erudite
								trait = detached_priest
								trait = martial_cleric
								trait = scholarly_theologian
								trait = mastermind_theologian
							}
						}
					}
				}
				random_realm_character = {
					limit = {
						ai = no
						NOT = { trait = incapable }
						is_adult = yes
						is_female = no
						NOT = { age = 40 }
						NOT = { is_close_relative = ROOT }
						NOR = {
							trait = misguided_warrior
							trait = tough_soldier
							trait = skilled_tactician
							trait = brilliant_strategist
						}
						OR = {
							culture_group = chinese_group
							culture = khitan
							culture = jurchen
							has_dynasty_flag = VIET_great_dunhuang_clan
						}
						OR = {
							religion = buddhist
							religion = taoist
							has_dynasty_flag = VIET_great_dunhuang_clan
						}
						learning = 8 # Don't want a dumbass
						OR = {
							learning = 12
							stewardship = 12
							trait = scholar
							trait = theologian
							trait = administrator
							trait = poet
							trait = genius
							trait = quick
							trait = shrewd
							trait = erudite
							trait = detached_priest
							trait = martial_cleric
							trait = scholarly_theologian
							trait = mastermind_theologian
						}
					}
					character_event = { id = dunhuang.157 }
				}
			}
		}
		

#		random_courtier	= {
#			limit = {
#				is_ruler = no
#				is_lowborn = no
#				NOT = { trait = incapable }
#				is_adult = yes
#				is_female = no
#				NOT = { age = 40 }
#				NOT = { is_close_relative = ROOT }
#				NOR = {
#					trait = misguided_warrior
#					trait = tough_soldier
#					trait = skilled_tactician
#					trait = brilliant_strategist
#				}
#				OR = {
#					culture_group = chinese_group
#					culture = khitan
#					culture = jurchen
#					has_dynasty_flag = VIET_great_dunhuang_clan
#				}
#				learning = 8 # Don't want a dumbass
#				OR = {
#					learning = 12
#					trait = scholar
#					trait = theologian
#					trait = administrator
#					trait = poet
#					trait = genius
#					trait = quick
#					trait = shrewd
#					trait = erudite
#					trait = detached_priest
#					trait = martial_cleric
#					trait = scholarly_theologian
#					trait = mastermind_theologian
#				}
#			}
#			save_event_target_as = target_VIET_zhai_fengda_tombola_courtier_candidate
#		}
#		
#
#		random_realm_character = {
#			limit = {
#				is_ruler = yes
#				is_lowborn = no
#				NOT = { trait = incapable }
#				is_adult = yes
#				is_female = no
#				NOT = { age = 40 }
#				NOT = { is_close_relative = ROOT }
#				NOR = {
#					trait = misguided_warrior
#					trait = tough_soldier
#					trait = skilled_tactician
#					trait = brilliant_strategist
#				}
#				OR = {
#					culture_group = chinese_group
#					culture = khitan
#					culture = jurchen
#					has_dynasty_flag = VIET_great_dunhuang_clan
#				}
#				learning = 8 # Don't want a dumbass
#				OR = {
#					learning = 12
#					trait = scholar
#					trait = theologian
#					trait = administrator
#					trait = poet
#					trait = genius
#					trait = quick
#					trait = shrewd
#					trait = erudite
#					trait = detached_priest
#					trait = martial_cleric
#					trait = scholarly_theologian
#					trait = mastermind_theologian
#				}
#			}
#			save_event_target_as = target_VIET_zhai_fengda_tombola_vassal_candidate
#		}
#		
#		#If there is a human player in Dunhuang region
#		if = {
#			limit = {
#				any_realm_character = {
#					ai = no
#					NOT = { trait = incapable }
#					is_adult = yes
#					is_female = no
#					NOT = { age = 40 }
#					NOT = { is_close_relative = ROOT }
#					NOR = {
#						trait = misguided_warrior
#						trait = tough_soldier
#						trait = skilled_tactician
#						trait = brilliant_strategist
#					}
#					OR = {
#						culture_group = chinese_group
#						culture = khitan
#						culture = jurchen
#						has_dynasty_flag = VIET_great_dunhuang_clan
#					}
#					learning = 8 # Don't want a dumbass
#					OR = {
#						learning = 12
#						trait = scholar
#						trait = theologian
#						trait = administrator
#						trait = poet
#						trait = genius
#						trait = quick
#						trait = shrewd
#						trait = erudite
#						trait = detached_priest
#						trait = martial_cleric
#						trait = scholarly_theologian
#						trait = mastermind_theologian
#					}
#				}
#			}
#			random_realm_character = {
#				limit = {
#					ai = no
#					NOT = { trait = incapable }
#					is_adult = yes
#					is_female = no
#					NOT = { age = 40 }
#					NOT = { is_close_relative = ROOT }
#					NOR = {
#						trait = misguided_warrior
#						trait = tough_soldier
#						trait = skilled_tactician
#						trait = brilliant_strategist
#					}
#					OR = {
#						culture_group = chinese_group
#						culture = khitan
#						culture = jurchen
#						has_dynasty_flag = VIET_great_dunhuang_clan
#					}
#					learning = 8 # Don't want a dumbass
#					OR = {
#						learning = 12
#						trait = scholar
#						trait = theologian
#						trait = administrator
#						trait = poet
#						trait = genius
#						trait = quick
#						trait = shrewd
#						trait = erudite
#						trait = detached_priest
#						trait = martial_cleric
#						trait = scholarly_theologian
#						trait = mastermind_theologian
#					}
#				}
#				save_event_target_as = target_VIET_zhai_fengda_tombola_player_candidate
#			}
#			set_character_flag = VIET_zhai_fengda_spawn_human_player_possibility
#		}
#		
#		character_event = { id = dunhuang.156 }
	}
}


# Zhai Fengda tombola
#character_event = {
#	id = dunhuang.156
#	
#	hide_window = yes
#	
#	is_triggered_only = yes
#	
#	immediate = { # Randomly select
#
#		# Base Chances:
#		#
#		# If human player: 40% courtier in realm, 40% human player, 20% Dunhuang vassal
#		# If no human player: 66% courtier in King of Dunhuang's court, 33% Dunhuang vassal
#		#
#		# If human is quick, scholar, shrewd, or erudite their chances of becoming Zhai Fengda are increased
#		# If human has more than 16 learning or is genius, their chances of becoming Zhai Fengda is counterintuitively decreased, as he was only a mediocre student as a youth
#		#
#		# Miscellaneous factors that increase/decrease chances for all three candidates:
#		# 
#		# Administrator trait or stewardship education increases (Zhai Fengda had a background as a bureaucrat)
#		# Not being a Buddhist or Taoist decreases
#		# Being a zealous Buddhist increases
#		# 
#		
#		random_list = {
#			#Courtier in court
#			40 = {
#				modifier = {
#					factor = 1.25
#					event_target:target_VIET_zhai_fengda_tombola_courtier_candidate = {
#						OR = {
#							trait = administrator
#							trait = indulgent_wastrel
#							trait = thrifty_clerk
#							trait = fortune_builder
#							trait = midas_touched
#						}					
#					}
#				}
#				modifier = {
#					factor = 1.25
#					event_target:target_VIET_zhai_fengda_tombola_courtier_candidate = {
#						religion = buddhist
#						trait = zealous
#					}
#				}
#				modifier = {
#					factor = 0.75
#					event_target:target_VIET_zhai_fengda_tombola_courtier_candidate = {
#						OR = {
#							religion = buddhist
#							religion = taoist
#						}	
#					}
#				}
#				event_target:target_VIET_zhai_fengda_tombola_courtier_candidate = {
#					character_event = { id = dunhuang.157 }
#				}
#			}
#			#Vassal
#			20 = {
#				modifier = {
#					factor = 1.25
#					event_target:target_VIET_zhai_fengda_tombola_vassal_candidate = {
#						OR = {
#							trait = administrator
#							trait = indulgent_wastrel
#							trait = thrifty_clerk
#							trait = fortune_builder
#							trait = midas_touched
#						}					
#					}
#				}
#				modifier = {
#					factor = 1.25
#					event_target:target_VIET_zhai_fengda_tombola_vassal_candidate = {
#						religion = buddhist
#						trait = zealous
#					}
#				}
#				modifier = {
#					factor = 0.75
#					event_target:target_VIET_zhai_fengda_tombola_vassal_candidate = {
#						OR = {
#							religion = buddhist
#							religion = taoist
#						}	
#					}
#				}
#				event_target:target_VIET_zhai_fengda_tombola_vassal_candidate = {
#					character_event = { id = dunhuang.157 }
#				}	
#			}
#			#Human
#			20 = {
#				modifier = {
#					factor = 0
#					NOT = { has_character_flag = VIET_zhai_fengda_spawn_human_player_possibility }
#				}
#				modifier = {
#					factor = 1.25
#					event_target:target_VIET_zhai_fengda_tombola_player_candidate = {
#						OR = {
#							trait = administrator
#							trait = indulgent_wastrel
#							trait = thrifty_clerk
#							trait = fortune_builder
#							trait = midas_touched
#						}					
#					}
#				}
#				modifier = {
#					factor = 1.25
#					event_target:target_VIET_zhai_fengda_tombola_player_candidate = {
#						religion = buddhist
#						trait = zealous
#					}
#				}
#				modifier = {
#					factor = 0.75
#					event_target:target_VIET_zhai_fengda_tombola_player_candidate = {
#						OR = {
#							religion = buddhist
#							religion = taoist
#						}	
#					}
#				}
#				modifier = {
#					factor = 2
#					event_target:target_VIET_zhai_fengda_tombola_player_candidate = {
#						OR = {
#							trait = quick
#							trait = erudite
#							trait = shrewd
#							trait = scholar
#						}					
#					}
#				}
#				modifier = {
#					factor = 0.5
#					event_target:target_VIET_zhai_fengda_tombola_player_candidate = {
#						OR = {
#							trait = genius
#							learning = 16
#						}					
#					}
#				}
#				event_target:target_VIET_zhai_fengda_tombola_player_candidate = {
#					character_event = { id = dunhuang.157 }
#				}
#			}
#		}
#	}
#}


# Zhai Fengda notification - not player
narrative_event = {
	id = dunhuang.156
	title = dunhuang.156.title
	desc = dunhuang.156.desc
	picture = GFX_evt_comet
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.156.a
		event_target:target_VIET_zhai_fengda_tombola_courtier_candidate = {
			show_portrait = yes
		}
	}
}

# Zhai Fengda equivalent gets modifier - NO EVENT POPUP WHEN COURTIER??? VASSALS NOT GETTING IT?
character_event = {
	id = dunhuang.157
	#title = dunhuang.157.title
	desc = dunhuang.157.desc
	picture = GFX_evt_comet
	
	is_triggered_only = yes
	
	option = { # Get the modifier, become a calendarist and astronomer
		name = dunhuang.157.a
		add_character_modifier = {
			name = VIET_zhai_fengda_modifier_generic
			duration = -1
		}
		hidden_tooltip = {
			narrative_event = { id = dunhuang.158 }
			any_playable_ruler = {
				limit = {
					ai = no 
					#NOT = { character = ROOT }
					capital_scope = {
						NOT = {
							distance = {
								where = 1448 	# Dunhuang
								value = 600		# Same part of the world
							}
						}
					}
				}
				narrative_event = { id = dunhuang.158 }
			}
		}
	}
}

# Zhai Fengda notification
narrative_event = {
	id = dunhuang.158
	title = dunhuang.158.title
	desc = dunhuang.158.desc
	picture = GFX_evt_comet
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.158.a
	}
}

# Zhang Yichao passes away - hidden event
narrative_event = {
	id = dunhuang.159
	
	hide_window = yes
	
	is_triggered_only = yes
	
	has_character_flag = VIET_is_zhang_yichao
	
	trigger = {
		#Won't fire if he isn't a big leader in Dunhuang
		OR = {
			AND = {
				has_global_flag = VIET_kingdom_dunhuang_established
				has_landed_title = k_dunhuang			
			}
			AND = {
				OR = {
					has_landed_title = d_jiuquan
					has_landed_title = d_guiyi
				}
				independent = yes
			}
			AND = {
				has_landed_title = d_jiuquan
				has_landed_title = d_guiyi			
			}
		}
	}
	
	immediate = {
		if = {
			limit = {
				has_landed_title = k_dunhuang
			}
			set_global_flag = VIET_zhang_yichao_death_owned_k_dunhuang
		}
		if = {
			limit = {
				has_landed_title = d_jiuquan
			}
			set_global_flag = VIET_zhang_yichao_death_owned_d_jiuquan
		}
		if = {
			limit = {
				has_landed_title = d_guiyi
			}
			set_global_flag = VIET_zhang_yichao_death_owned_d_guiyi
		}
		any_playable_ruler = {
			limit = {
				OR = {
					capital_scope = {
						NOT = {
							distance = {
								where = 1448 	# Dunhuang
								value = 1000	# Same part of the world
							}
						}
					}
					same_realm = ROOT
				}
			}
			narrative_event = { id = dunhuang.160 } # Narrative event
		}
		any_realm_character = {
			limit = {
				is_landed = yes
				is_theocracy = no
				is_republic = no
				OR = {
					culture_group = chinese_group
					#culture_group = serindian
					culture = khitan
					culture = jurchen
					#culture = sogdian
					#culture = tocharian
					#culture = tuyuhun
					#culture = mongol
					#culture = uyghur
					has_dynasty_flag = VIET_great_dunhuang_clan
				}
				#If Zhang Yichao has somehow conquered a crapload, don't want random mofos from halfway across the world bothering with Dunhuang
				OR = {
					capital_scope = {
						NOT = {
							distance = {
								where = 1448 	# Dunhuang
								value = 1000	# Same part of the world
							}
						}
					}
					has_dynasty_flag = VIET_great_dunhuang_clan #Unless if they're one of the original great clans of Dunhuang
				}
			}
			#narrative_event = { id = dunhuang.160 } # Narrative event
			character_event = { id = dunhuang.162 } # Ping to event that actually gives claims and stuff
		}
	}
}

# Zhang Yichao passes away - narrative event
narrative_event = {
	id = dunhuang.160
	title = dunhuang.160.title
	desc = dunhuang.160.desc
	picture = GFX_evt_china_unrest
	
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.160.a
	}
}

# Zhang Yichao passes away - give weak claims to vassals and other powerful nobles of the realm of Dunhuang, to ensure chaos for approximately a generation
narrative_event = {
	id = dunhuang.161
	title = dunhuang.161.title
	picture = GFX_evt_china_invades
	
	desc = { #Zhang
		text = dunhuang.161.desc.a
		trigger = { dynasty = 1055006 }
	}	
	desc = { #Cao
		text = dunhuang.161.desc.b
		trigger = { dynasty = 1055036 }
	}		
	desc = { #Li
		text = dunhuang.161.desc.c
		trigger = { dynasty = 1000088605 }
	}			
	desc = { #Yin
		text = dunhuang.161.desc.d
		trigger = { dynasty = 1000088600 }
	}				
	desc = { #Suo
		text = dunhuang.161.desc.e
		trigger = { dynasty = 1000088601 }
	}				
	desc = { #Other clans
		text = dunhuang.161.desc.f
		trigger = { 
			NOR = {
				dynasty = 1055006
				dynasty = 1055036
				dynasty = 1000088605
				dynasty = 1000088600
				dynasty = 1000088601
			}
		}
	}	
		
	is_triggered_only = yes
	
	option = { # Ok
		name = dunhuang.161.a
		if = {
			limit = {
				has_global_flag = VIET_zhang_yichao_death_owned_k_dunhuang
				NOR = {
					has_landed_title = k_dunhuang
					has_strong_claim = k_dunhuang
					has_strong_pressed_claim = k_dunhuang
					has_weak_claim = k_dunhuang
					has_weak_pressed_claim = k_dunhuang
				}
			}
			add_weak_claim = k_dunhuang
		}
		if = {
			limit = {
				has_global_flag = VIET_zhang_yichao_death_owned_d_jiuquan
				NOR = {
					has_landed_title = d_jiuquan
					has_strong_claim = d_jiuquan
					has_strong_pressed_claim = d_jiuquan
					has_weak_claim = d_jiuquan
					has_weak_pressed_claim = d_jiuquan
				}
			}
			add_weak_claim = d_jiuquan
		}
		if = {
			limit = {
				has_global_flag = VIET_zhang_yichao_death_owned_d_guiyi
				NOR = {
					has_landed_title = d_guiyi
					has_strong_claim = d_guiyi
					has_strong_pressed_claim = d_guiyi
					has_weak_claim = d_guiyi
					has_weak_pressed_claim = d_guiyi
				}
			}
			add_weak_claim = d_guiyi
		}
	}
}



# Zhang Yichao passes away - ping event
character_event = {
	id = dunhuang.162
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		narrative_event = { id = dunhuang.161 days = 2 } # Ping to event that actually gives claims and stuff
	}
}



###################################################################
# 
# Dunhuang Flavor Events
# 
# dunhuang.200-dunhuang.249
# 
###################################################################


# Visiting Mogao Caves with noble family depicted
character_event = {
	id = dunhuang.200
	desc = dunhuang.200.desc
	picture = GFX_evt_mogao_caves_art
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = brave
		}
		modifier = {
			factor = 0.8
			trait = craven
		}	
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}
	}
	
	option = { # Life back then
		name = dunhuang.200.a
		prestige = 5
	}	
	option = { # Normal people
		name = dunhuang.200.b
		random_list = {
			10 = { piety = 5 }
			10 = { prestige = 5 }
		}
	}	
	option = { # Faded memories
		name = dunhuang.200.c
		piety = 5
	}
}



# Visiting Mogao Caves - see attractive person
character_event = {
	id = dunhuang.201
	desc = dunhuang.201.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = lustful
		}
		modifier = {
			factor = 0.8
			trait = chaste
		}	
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}
	}
	
	option = { # Ignore
		name = dunhuang.201.a
		piety = 5
		if = {
			limit = {
				trait = lustful
			}
			random = {
				remove_trait = lustful
				chance = 25
			}
		}
		else = {
			random = {
				add_trait = chaste
				chance = 25
			}			
		}
	}
	
	option = { # Approach
		name = dunhuang.201.b
		piety = -5
		if = {
			limit = {
				trait = chaste
			}
			random = {
				remove_trait = chaste
				chance = 25
			}
		}
		else = {
			random = {
				add_trait = lustful
				chance = 25
			}			
		}
	}
}


# Pass by a section of the Great War
character_event = {
	id = dunhuang.202
	desc = dunhuang.202.desc
	picture = GFX_evt_sand_desert
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = lustful
		}
		modifier = {
			factor = 0.8
			trait = chaste
		}	
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}
	}
	
	option = { # Sad
		name = dunhuang.202.a
		piety = 5
	}
	
	option = { # Glory
		name = dunhuang.202.b
		prestige = 5
	}
}


# Singing sand dunes
character_event = {
	id = dunhuang.203
	desc = dunhuang.203.desc
	picture = GFX_evt_sand_desert
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = lustful
		}
		modifier = {
			factor = 0.8
			trait = chaste
		}	
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}
	}
	
	option = { # ok
		name = dunhuang.203.a
		prestige = 5
	}
}



# Foreign artists in Dunhuang give presents
character_event = {
	id = dunhuang.204
	desc = dunhuang.204.desc
	picture = GFX_evt_dunhuang_court
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = lustful
		}
		modifier = {
			factor = 0.8
			trait = chaste
		}	
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}
	}
	
	option = { # ok
		name = dunhuang.204.a
		prestige = 10
		add_character_modifier = {
			name = VIET_dunhuang_gift_foreign_art
			duration = 365
		}
	}
}



# Buddhist nun acquaintance passes away and leaves you some stuff in her will but her family disputes this
character_event = {
	id = dunhuang.205
	desc = dunhuang.205.desc
	picture = GFX_evt_dunhuang_court
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		OR = {
			religion_group = indian_group
			trait = sympathy_indian
			is_dunhuang_sinosphere_trigger = yes
		}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = kind
		}
		modifier = {
			factor = 0.8
			trait = cruel
		}	
		modifier = {
			factor = 1.2
			trait = humble
		}
		modifier = {
			factor = 0.8
			trait = patient
		}
	}
	
	option = { # mine!
		name = dunhuang.205.a
		wealth = 20
		prestige = -5
		piety = -5
		random_list = {
			70 = { }
			10 = { add_trait = wroth }
			10 = { add_trait = proud }
			10 = { add_trait = stubborn }
		}
	}
	
	option = { # No need
		name = dunhuang.205.b
		piety = 10
		random_list = {
			70 = { }
			10 = { add_trait = humble }
			10 = { add_trait = charitable }
			10 = { add_trait = content }
		}
	}
	
	option = { # Settle honorably in courts
		name = dunhuang.205.c
		wealth = 20
	}
	
	option = { # heathens!
		name = dunhuang.205.d
		trigger = {
			NOT = { religion = buddhist }
			NOT = { trait = sympathy_indian }
		}
		piety = 5
		random = {
			add_trait = zealous
			chance = 25
		}
	}
}



# Elderly monk passes away and relatives fight over inheritance
long_character_event = {
	id = dunhuang.206
	desc = dunhuang.206.desc
	picture = GFX_evt_dunhuang_court
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#OR = {
		#	religion_group = indian_group
		#	culture_group = chinese_group
		#	culture_group = serindian
		#	culture = khitan
		#	culture = jurchen
		#	culture = sogdian
		#	culture = tocharian
		#	culture = tuyuhun
		#	culture = mongol
		#	culture = uyghur
		#	trait = sympathy_indian
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = just
		}
		modifier = {
			factor = 0.8
			trait = arbitrary
		}	
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}
	}
	
	option = { # nephew
		name = dunhuang.206.a
		prestige = 5
		piety = -5
	}
	
	option = { # niece
		name = dunhuang.206.b
		piety = 5
		prestige = -5
	}
	
	option = { # belongs to the state
		name = dunhuang.206.c
		prestige = -25
		piety = -25
		wealth = 20
		if = {
			limit = {
				trait = charitable
			}
			remove_trait = charitable
		}
		else = {
			random = {
				add_trait = greedy
				chance = 40
			}
		}
	}
	
	option = { # don't intervene
		name = dunhuang.206.d
	}
}


# Fake monks and nuns
character_event = {
	id = dunhuang.207
	desc = dunhuang.207.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	religion_group = indian_group
	
	trigger = {
		#in_command = no
		#OR = {
		#	#has_landed_title = k_dunhuang
		#	#has_landed_title = d_guiyi
		#	#has_landed_title = d_jiuquan
		#	has_landed_title = c_jiuquan
		#	has_landed_title = c_dunhuang
		#	has_landed_title = c_anxi
		#	has_landed_title = c_yungguan
		#	has_landed_title = c_yumen
		#}
		capital_scope = {
			OR = {
				province_id = 1408
				province_id = 1448
				province_id = 1513
				province_id = 1515
				province_id = 1568
			}
		}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = zealous
		}
		modifier = {
			factor = 0.8
			trait = cynical
		}	
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}
	}
	
	option = { # enforce law
		name = dunhuang.207.a
		random = {
			add_trait = just
			chance = 20
		}
	}	
	option = { # not a biggie
		name = dunhuang.207.b
		random_list = {
			70 = { }
			10 = { add_trait = slothful }
			10 = { add_trait = content }
			10 = { add_trait = trusting }
		}
	}
}


# Gift of juicy Dunhuang melons
character_event = {
	id = dunhuang.208
	desc = dunhuang.208.desc
	picture = GFX_evt_dunhuang_food
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = gluttonous
		}
		modifier = {
			factor = 0.8
			trait = temperate
		}	
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}
	}
	
	option = { # ok
		name = dunhuang.208.a
		prestige = 5
	}
}





# Ancient hidden, sealed Mogao cave discovered
character_event = {
	id = dunhuang.209
	desc = dunhuang.209.desc
	picture = GFX_evt_mogao_caves_art
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = zealous
		}
		modifier = {
			factor = 0.8
			trait = cynical
		}	
		modifier = {
			factor = 1.2
			trait = patient
		}
		modifier = {
			factor = 0.8
			trait = wroth
		}
	}
	
	option = { # ok
		name = dunhuang.209.a
		trigger = {
			OR = {
				wealth = 25
				ai = no
			}
		}
		wealth = -25
		prestige = 20
		piety = 20
	}	
	option = { # ok
		name = dunhuang.209.b
	}
}



# Visiting Crescent Lake
character_event = {
	id = dunhuang.210
	desc = dunhuang.210.desc
	picture = GFX_evt_sand_desert
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = slothful
		}
		modifier = {
			factor = 0.8
			trait = diligent
		}	
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}
	}
	
	option = { # ok
		name = dunhuang.210.a
		piety = 5
	}
}


# Dispute between Khotanese monk and Sogdian merchant
character_event = {
	id = dunhuang.211
	desc = dunhuang.211.desc
	picture = GFX_evt_china_stable
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = just
		}
		modifier = {
			factor = 0.8
			trait = arbitrary
		}	
		modifier = {
			factor = 1.2
			trait = patient
		}
		modifier = {
			factor = 0.8
			trait = wroth
		}
	}
	
	option = { # support Sogdian merchant
		name = dunhuang.211.a
		prestige = 5
	}
	
	option = { # support Khotanese monk
		name = dunhuang.211.b
		piety = 5
	}
	
	option = { # who cares
		name = dunhuang.211.c
		random = {
			add_trait = slothful
			chance = 30
		}
	}
	
	option = { # ACKSHUALLY
		name = dunhuang.211.d
		trigger = {
			diplomacy = 9
		}
		tooltip_info = diplomacy
		prestige = 5
		piety = 5
		random = {
			add_trait = just
			chance = 15
		}
	}
}


# Taking Rhubarb for health reasons
character_event = {
	id = dunhuang.212
	desc = dunhuang.212.desc
	picture = GFX_evt_dunhuang_manor
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
		NOT = {
			has_character_modifier = VIET_dunhuang_rhubarb_person
		}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}	
		modifier = {
			factor = 1.2
			trait = erudite
		}
		modifier = {
			factor = 0.8
			trait = stubborn
		}
	}
	
	option = { # ok
		name = dunhuang.212.a
		add_character_modifier = {
			name = VIET_dunhuang_rhubarb_person
			duration = 730
		}
	}
}


# Inspecting a new Mogao cave made by community effort
character_event = {
	id = dunhuang.213
	desc = dunhuang.213.desc
	picture = GFX_evt_mogao_caves_working
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}	
		modifier = {
			factor = 1.2
			trait = zealous
		}
		modifier = {
			factor = 0.8
			trait = cynical
		}
	}
	
	option = { # ok
		name = dunhuang.213.a
		random = {
			chance = 25
			add_trait = proud
		}
		prestige = 5
	}	
	option = { # ok
		name = dunhuang.213.b
		piety = 5
	}	
	option = { # ok
		name = dunhuang.213.c
		random = {
			chance = 25
			add_trait = humble
		}
		prestige = 5
	}
}



# Come across a big Buddha in the Mogao cave
character_event = {
	id = dunhuang.214
	desc = dunhuang.214.desc
	picture = GFX_evt_mogao_caves_art
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = humble
		}
		modifier = {
			factor = 0.8
			trait = proud
		}		
		modifier = {
			factor = 1.2
			trait = zealous
		}
		modifier = {
			factor = 0.8
			trait = cynical
		}
	}
	
	option = { # ok
		name = dunhuang.214.a
		piety = 5
	}
}



# Come across a nobleman's cave in Dunhuang
character_event = {
	id = dunhuang.215
	desc = dunhuang.215.desc
	picture = GFX_evt_mogao_caves_art
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = ambitious
		}
		modifier = {
			factor = 0.8
			trait = content
		}	
		modifier = {
			factor = 1.2
			trait = greedy
		}
		modifier = {
			factor = 0.8
			trait = temperate
		}
	}
	
	option = { # ok
		name = dunhuang.215.a
		piety = 5
	}	
	option = { # ok
		name = dunhuang.215.b
		prestige = 5
	}
	option = { # ok
		name = dunhuang.215.c
		random_list = {
			50 = { piety = 5 }
			50 = { prestige = 5 }
		}
		random = {
			add_trait = cynical
			chance = 10
		}
	}
}



# Buy foreign art decor?
character_event = {
	id = dunhuang.216
	desc = dunhuang.216.desc
	picture = GFX_evt_mogao_caves_art
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
		NOT = { has_character_modifier = VIET_dunhuang_foreign_art_decor }
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = proud
		}
		modifier = {
			factor = 0.8
			trait = humble
		}	
		modifier = {
			factor = 1.2
			trait = gluttonous
		}
		modifier = {
			factor = 0.8
			trait = temperate
		}
	}
	
	option = { # ok
		name = dunhuang.216.a
		trigger = {
			OR = {
				wealth = 20
				ai = no
			}
		}
		wealth = -20
		add_character_modifier = {
			name = VIET_dunhuang_foreign_art_decor
			duration = 1095
		}
	}	
	option = { # ok
		name = dunhuang.216.b
	}
}




# Family pays fine in silk
character_event = {
	id = dunhuang.217
	desc = dunhuang.217.desc
	picture = GFX_evt_dunhuang_court
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = just
		}
		modifier = {
			factor = 0.8
			trait = arbitrary
		}	
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}
	}
	
	option = { # ok
		name = dunhuang.217.a
		wealth = 10
	}
}



# Acquaintance needs to sell a slave girl
character_event = {
	id = dunhuang.218
	desc = dunhuang.218.desc
	picture = GFX_evt_china_stable
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
		NOT = { has_character_flag = VIET_dunhuang_bankrupt_friend_event }
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}	
		modifier = {
			factor = 1.2
			trait = honest
		}
		modifier = {
			factor = 0.8
			trait = deceitful
		}
	}
	
	immediate = {
		set_character_flag = VIET_dunhuang_bankrupt_friend_event
	}
	
	option = { # sell her!
		name = dunhuang.218.a
	}	
	option = { # lend him some money
		name = dunhuang.218.b
		trigger = {
			OR = {
				wealth = 30
				ai = no
			}
		}
		wealth = -30
		add_trait = charitable
	}	
	option = { # buy the girl
		name = dunhuang.218.c
		trigger = {
			OR = {
				wealth = 50
				ai = no
			}
		}
		wealth = -50
		random = {
			add_trait = lustful
			chance = 25
		}
		add_character_modifier = {
			name = VIET_dunhuang_pretty_new_iranian_serving_girl
			duration = 730
		}
		random_list = {
			# 40% Persian
			# 60% Sogdian
			# 40% Khotanese/Saka
			# 60% Tocharian
			40 = { # Persian
				create_character = {
					dynasty = actually_culture
					religion = ROOT
					culture = persian
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					add_trait = fair
					culture = ROOT
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = hindustani }
						10 = { set_graphical_culture = turkish }
						15 = { set_graphical_culture = greek }
						15 = { set_graphical_culture = levantine_arabic }
						50 = { }
					}	
				}			
			}
			60 = { # Sogdian
				create_character = {
					dynasty = actually_culture
					religion = ROOT
					culture = sogdian
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					add_trait = fair
					culture = ROOT
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					random_list = {
						20 = { }
						20 = { religion = buddhist }
						20 = { religion = manichean }
						20 = { religion = zoroastrian }
						20 = { religion = nestorian }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = hindustani }
						20 = { set_graphical_culture = levantine_arabic }
						50 = { }
					}
				}			
			}
			40 = { # Khotanese/Saka
				create_character = {
					dynasty = actually_culture
					religion = ROOT
					culture = saka
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					add_trait = fair
					culture = ROOT
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = han }
						50 = { }
					}
				}			
			}
			60 = { # Tocharian
				create_character = {
					dynasty = actually_culture
					religion = ROOT
					culture = tocharian
					female = yes
					random_traits = yes
					historical = yes
				}
				new_character = {
					#set_character_flag = ai_flag_refuse_concubinage
					#set_character_flag = ai_flag_refuse_marriage
					set_character_flag = no_court_invites
					add_trait = fair
					culture = ROOT
					random_list = {
						20 = { add_trait = genius }
						20 = { add_trait = quick }
						10 = { add_trait = strong }
						10 = { add_trait = sturdy }
						10 = { add_trait = robust }
						20 = { add_trait = shrewd }
						300 = { }
					}
					opinion = {
						modifier = opinion_loyal_servant
						who = ROOT
						years = 100
					}
					#Flavor
					random_list = {
						90 = { }
						10 = { add_scarred_tiered_effect = yes }
					}
					#Randomize appearance
					random_list = {
						10 = { set_graphical_culture = cuman }
						10 = { set_graphical_culture = turkish }
						10 = { set_graphical_culture = mongol }
						10 = { set_graphical_culture = bodpa }
						10 = { set_graphical_culture = han }
						50 = { }
					}
				}			
			}
		}
	}
}



# Irrigation experts arrive from China
character_event = {
	id = dunhuang.219
	desc = dunhuang.219.desc
	picture = GFX_evt_eastern_celebration
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
		NOT = {
			any_demesne_province = {
				has_province_modifier = VIET_dunhuang_irrigation_experts
			}
		}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = trusting
		}
		modifier = {
			factor = 0.8
			trait = paranoid
		}	
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}
	}
	
	option = { # ok
		name = dunhuang.219.a
		if = {
			limit = {
				has_landed_title = c_jiuquan
			}
			1513 = {
				add_province_modifier = {
					name = VIET_dunhuang_irrigation_experts
					duration = 1825
				}		
			}
		}
		if = {
			limit = {
				has_landed_title = c_dunhuang
			}
			1448 = {
				add_province_modifier = {
					name = VIET_dunhuang_irrigation_experts
					duration = 1825
				}		
			}
		}
		if = {
			limit = {
				has_landed_title = c_anxi
			}
			1408 = {
				add_province_modifier = {
					name = VIET_dunhuang_irrigation_experts
					duration = 1825
				}		
			}
		}
		if = {
			limit = {
				has_landed_title = c_yumen
			}
			1568 = {
				add_province_modifier = {
					name = VIET_dunhuang_irrigation_experts
					duration = 1825
				}		
			}
		}
		if = {
			limit = {
				has_landed_title = c_yungguan
			}
			1515 = {
				add_province_modifier = {
					name = VIET_dunhuang_irrigation_experts
					duration = 1825
				}		
			}
		}
	}
}

# Sogdian buddy concludes business deal
character_event = {
	id = dunhuang.220
	desc = dunhuang.220.desc
	picture = GFX_evt_iranian_settlement_nowruz
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = trusting
		}
		modifier = {
			factor = 0.8
			trait = paranoid
		}	
		modifier = {
			factor = 1.2
			stewardship = 11
		}
		modifier = {
			factor = 0.8
			NOT = { stewardship = 8 }
		}
	}
	
	option = { # ok
		name = dunhuang.220.a
		add_character_modifier = {
			name = VIET_dunhuang_recent_sogdian_friend_deals
			duration = 730
		}
	}
}



# Monk friend dedicates poetry
character_event = {
	id = dunhuang.221
	desc = dunhuang.221.desc
	picture = GFX_evt_mogao_caves_outside
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = erudite
		}
		modifier = {
			factor = 0.8
			trait = stubborn
		}	
		modifier = {
			factor = 1.2
			trait = humble
		}
		modifier = {
			factor = 0.8
			trait = proud
		}
	}
	
	option = { # ok
		name = dunhuang.221.a
		prestige = 5
	}
}


# Horny courtier gets a Sogdian/Tocharian slave girl
character_event = {
	id = dunhuang.222
	desc = dunhuang.222.desc
	picture = GFX_evt_dunhuang_manor
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
		any_courtier = {
			ai = yes
			is_ruler = no
			NOT = { trait = incapable }
			is_adult = yes
			is_female = no
			is_married = no
			NOT = { is_close_relative = ROOT }
			NOR = {
				trait = celibate
				trait = chaste
				trait = eunuch
				trait = homosexual
			}
			OR = {
				culture_group = chinese_group
				culture = khitan
				culture = jurchen
				has_dynasty_flag = VIET_great_dunhuang_clan
			}
			OR = {
				trait = lustful
				trait = hedonist
				trait = gregarious
				trait = content
				trait = slothful
				trait = seducer
				trait = seductress
				trait = socializer
			}				
		}
	}
	
	weight_multiplier = {
		days = 1		
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}	
		modifier = {
			factor = 1.2
			trait = humble
		}
		modifier = {
			factor = 0.8
			trait = proud
		}
	}
	
	immediate = {
		random_courtier = {
			limit = {
				ai = yes
				is_ruler = no
				NOT = { trait = incapable }
				is_adult = yes
				is_female = no
				is_married = no
				NOT = { is_close_relative = ROOT }
				NOR = {
					trait = celibate
					trait = chaste
					trait = eunuch
					trait = homosexual
				}
				OR = {
					culture_group = chinese_group
					culture = khitan
					culture = jurchen
					has_dynasty_flag = VIET_great_dunhuang_clan
				}
				OR = {
					trait = lustful
					trait = hedonist
					trait = gregarious
					trait = content
					trait = slothful
					trait = seducer
					trait = seductress
					trait = socializer
				}				
			}
			save_event_target_as = target_dunhuang_horny_character
		}	
	}
	
	option = { # ok
		name = dunhuang.222.a
		event_target:target_dunhuang_horny_character = {
			random = {
				chance = 50
				add_trait = lustful
			}
			add_character_modifier = {
				name = VIET_dunhuang_pretty_new_iranian_serving_girl
				duration = 730
			}
		}
		random_list = {
			# 33% Tocharian
			# 33% Sogdian
			# 33% Saka/Khotanese
			10 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = event_target:target_dunhuang_horny_character
					culture = tocharian
					female = yes
				}
				new_character = {
					culture = event_target:target_dunhuang_horny_character
					# Her traits aren't that random
					random_list = {
						70 = { add_trait = groomed }
						30 = { add_trait = fair }
					}
					random = {
						chance = 5
						add_trait = quick
					}
					random = {
						chance = 5
						add_trait = genius
					}
					remove_trait = ugly
					remove_trait = incapable
					remove_trait = inbred
					remove_trait = hunchback
					add_spouse = event_target:target_dunhuang_horny_character
				}			
			}
			10 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = event_target:target_dunhuang_horny_character
					culture = sogdian
					female = yes
				}
				new_character = {
					culture = event_target:target_dunhuang_horny_character
					# Her traits aren't that random
					random_list = {
						70 = { add_trait = groomed }
						30 = { add_trait = fair }
					}
					random = {
						chance = 5
						add_trait = quick
					}
					random = {
						chance = 5
						add_trait = genius
					}
					remove_trait = ugly
					remove_trait = incapable
					remove_trait = inbred
					remove_trait = hunchback
					add_spouse = event_target:target_dunhuang_horny_character
				}			
			}
			10 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = event_target:target_dunhuang_horny_character
					culture = saka
					female = yes
				}
				new_character = {
					culture = event_target:target_dunhuang_horny_character
					# Her traits aren't that random
					random_list = {
						70 = { add_trait = groomed }
						30 = { add_trait = fair }
					}
					random = {
						chance = 5
						add_trait = quick
					}
					random = {
						chance = 5
						add_trait = genius
					}
					remove_trait = ugly
					remove_trait = incapable
					remove_trait = inbred
					remove_trait = hunchback
					add_spouse = event_target:target_dunhuang_horny_character
				}			
			}
		}
	}
}


# Cao Cao's descendant has self-doubts
character_event = {
	id = dunhuang.223
	desc = dunhuang.223.desc
	picture = GFX_evt_cao_cao
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		#OR = {
		#	#has_landed_title = k_dunhuang
		#	#has_landed_title = d_guiyi
		#	#has_landed_title = d_jiuquan
		#	has_landed_title = c_jiuquan
		#	has_landed_title = c_dunhuang
		#	has_landed_title = c_anxi
		#	has_landed_title = c_yungguan
		#	has_landed_title = c_yumen
		#}
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
		dynasty = 1055036
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 0.1
			NOR = {
				culture_group = chinese_group
				culture = khitan
				culture = jurchen
				religion = buddhist
				religion = taoist
			}
		}
		modifier = {
			factor = 1.2
			trait = paranoid
		}
		modifier = {
			factor = 0.8
			trait = trusting
		}	
		modifier = {
			factor = 1.2
			trait = shy
		}
		modifier = {
			factor = 0.8
			trait = proud
		}
	}
	
	option = { # ok
		name = dunhuang.223.a
		add_character_modifier = {
			name = VIET_dunhuang_inspired_by_cao_cao
			duration = 730
		}
	}
}




# Cao Cao's descendant thinks of stories about Cao Cao
character_event = {
	id = dunhuang.224
	desc = dunhuang.224.desc
	picture = GFX_evt_cao_cao
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		#OR = {
		#	#has_landed_title = k_dunhuang
		#	#has_landed_title = d_guiyi
		#	#has_landed_title = d_jiuquan
		#	has_landed_title = c_jiuquan
		#	has_landed_title = c_dunhuang
		#	has_landed_title = c_anxi
		#	has_landed_title = c_yungguan
		#	has_landed_title = c_yumen
		#}
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
		dynasty = 1055036
		NOT = { has_character_flag = VIET_dunhuang_cao_cao_reflections }
	}
	
	weight_multiplier = {
		days = 1	
		modifier = {
			factor = 0.1
			NOR = {
				culture_group = chinese_group
				culture = khitan
				culture = jurchen
				religion = buddhist
				religion = taoist
			}
		}	
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}	
		modifier = {
			factor = 1.2
			trait = ambitious
		}
		modifier = {
			factor = 0.8
			trait = content
		}
	}
	
	immediate = {
		set_character_flag = VIET_dunhuang_cao_cao_reflections
	}
	
	option = { # betrayal quote
		name = dunhuang.224.a
		change_intrigue = 1
		custom_tooltip = { text = VIET_dunhuang_cao_cao_thoughts_betrayal_quote }
	}
	
	option = { # great poetry
		name = dunhuang.224.b
		change_learning = 1
		custom_tooltip = { text = VIET_dunhuang_cao_cao_thoughts_great_poetry }
	}
	
	option = { # Red Cliffs
		name = dunhuang.224.c
		change_martial = 1
		custom_tooltip = { text = VIET_dunhuang_cao_cao_thoughts_red_cliffs }
	}
	
	option = { # MILF Fetish
		name = dunhuang.224.d
		change_diplomacy = 1
		custom_tooltip = { text = VIET_dunhuang_cao_cao_thoughts_MILF_fetish }
	}
}

# Li family member scoffs at those who deny their lineage
character_event = {
	id = dunhuang.225
	desc = dunhuang.225.desc
	picture = GFX_evt_china_expansionist
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		#OR = {
		#	#has_landed_title = k_dunhuang
		#	#has_landed_title = d_guiyi
		#	#has_landed_title = d_jiuquan
		#	has_landed_title = c_jiuquan
		#	has_landed_title = c_dunhuang
		#	has_landed_title = c_anxi
		#	has_landed_title = c_yungguan
		#	has_landed_title = c_yumen
		#}
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
		dynasty = 1000088605
	}
	
	weight_multiplier = {
		days = 1	
		modifier = {
			factor = 0.1
			NOR = {
				culture_group = chinese_group
				culture = khitan
				culture = jurchen
				religion = buddhist
				religion = taoist
			}
		}	
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}	
		modifier = {
			factor = 1.2
			trait = ambitious
		}
		modifier = {
			factor = 0.8
			trait = content
		}
	}
	
	option = { # ok
		name = dunhuang.225.a
		add_character_modifier = {
			name = VIET_dunhuang_li_family_pride
			duration = 365
		}
	}
}



# Sogdian merchant passes through Dunhuang
character_event = {
	id = dunhuang.226
	desc = dunhuang.226.desc
	picture = GFX_evt_silk_road_camels
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		#in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}	
		modifier = {
			factor = 1.2
			trait = just
		}
		modifier = {
			factor = 0.8
			trait = arbitrary
		}
	}
	
	option = { # ok
		name = dunhuang.226.a
		add_province_modifier = {
			name = VIET_dunhuang_sogdian_merchant_visits
			duration = 730
		}
	}
}


# Visiting White Horse Pagoda
character_event = {
	id = dunhuang.227
	desc = dunhuang.227.desc
	picture = GFX_evt_the_silk_road_dunhuang
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}	
		modifier = {
			factor = 1.2
			trait = content
		}
		modifier = {
			factor = 0.8
			trait = ambitious
		}
	}
	
	option = { # ok
		name = dunhuang.227.a
		piety = 5
	}	
	option = { # ok
		name = dunhuang.227.b
		trigger = {
			NOR = {
				religion = buddhist
				religion = taoist
			}
		}
		prestige = 5
	}	
	option = { # ok
		name = dunhuang.227.c
		random = {
			add_trait = cynical
			chance = 30
		}
	}
}

# Encounter caravan praying at Mogao Cave
character_event = {
	id = dunhuang.228
	desc = dunhuang.228.desc
	picture = GFX_evt_travel_dunhuang
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}	
		modifier = {
			factor = 1.2
			trait = brave
		}
		modifier = {
			factor = 0.8
			trait = craven
		}
	}
	
	option = { # ok
		name = dunhuang.228.a
		piety = 5
	}	
	option = { # ok
		name = dunhuang.228.b
		random_list = {
			80 = { }
			10 = { add_trait = cynical }
			5 = { add_trait = brave }
			5 = { add_trait = diligent }
		}
	}
}


# Acrobats from China
character_event = {
	id = dunhuang.229
	desc = dunhuang.229.desc
	picture = GFX_evt_eastern_celebration
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}	
		modifier = {
			factor = 1.2
			trait = slothful
		}
		modifier = {
			factor = 0.8
			trait = diligent
		}
	}
	
	option = { # ok
		name = dunhuang.229.a
		prestige = 5
	}
}

# Performers from Tarim Basin at night
character_event = {
	id = dunhuang.230
	desc = dunhuang.230.desc
	picture = GFX_evt_chinese_night_village
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.2
			trait = gregarious
		}
		modifier = {
			factor = 0.8
			trait = shy
		}	
		modifier = {
			factor = 1.2
			trait = slothful
		}
		modifier = {
			factor = 0.8
			trait = diligent
		}
	}
	
	option = { # ok
		name = dunhuang.230.a
		prestige = 5
	}
}

# Important delegation passes through
character_event = {
	id = dunhuang.231
	desc = dunhuang.231.desc
	picture = GFX_evt_silk_road_camels
	
	is_triggered_only = yes
	
	min_age = 16
	only_rulers = yes
	capable_only = yes
	prisoner = no
	#war = no
	#religion_group = indian_group
	
	trigger = {
		in_command = no
		is_dunhuang_owner_trigger = yes
		#capital_scope = {
		#	OR = {
		#		province_id = 1408
		#		province_id = 1448
		#		province_id = 1513
		#		province_id = 1515
		#		province_id = 1568
		#	}
		#}
	}
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.2
			trait = diligent
		}
		modifier = {
			factor = 0.8
			trait = slothful
		}	
		modifier = {
			factor = 1.2
			trait = just
		}
		modifier = {
			factor = 0.8
			trait = arbitrary
		}
	}
	
	option = { # ok
		name = dunhuang.231.a
		trigger = {
			OR = {
				wealth = 30
				ai = no
			}
		}
		prestige = 40
		wealth = -30
	}	
	option = { # ok
		name = dunhuang.231.b
		prestige = -15
	}
}






