decisions = {
	
	establish_kingdom_of_dunhuang = {
		only_playable = yes
		#is_high_prio = yes
		ai_check_interval = 60
		
		potential = {
			is_playable = yes
			NOT = { has_global_flag = VIET_kingdom_dunhuang_established }
			OR = {
				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
			}
			OR = {
				culture_group = chinese_group
				culture = khitan
			}
			lower_tier_than = king
			k_dunhuang = {
				has_holder = no
			}
			is_alternate_start = no
			#NOR = {
			#	has_alternate_start_setting = {
			#		setting = dejure
			#		value = random
			#	}
			#	has_alternate_start_setting = {
			#		setting = title_names
			#		value = random
			#	}
			#	has_alternate_start_setting = {
			#		setting = title_names
			#		value = random_including_duchies
			#	}
			#}
		}
		allow = {
			independent = yes
			wealth = 200
			prestige = 1000
			OR = {
				has_landed_title = d_guiyi
				has_landed_title = d_jiuquan
			}
			OR = {
				has_landed_title = c_jiuquan
				any_realm_character = { has_landed_title = c_jiuquan }
			}
			OR = {
				has_landed_title = c_dunhuang
				any_realm_character = { has_landed_title = c_dunhuang }
			}
			OR = {
				has_landed_title = c_anxi
				any_realm_character = { has_landed_title = c_anxi }
			}
			OR = {
				has_landed_title = c_yungguan
				any_realm_character = { has_landed_title = c_yungguan }
			}
			OR = {
				has_landed_title = c_yumen
				any_realm_character = { has_landed_title = c_yumen }
			}
		}
		effect = {
			hidden_tooltip = {
				set_global_flag = VIET_kingdom_dunhuang_established
				narrative_event = { id = dunhuang.30 }
			}
			#set_preferred_capital
		}
		ai_will_do = {
			factor = 1			
			#modifier = {
			#	factor = 0
			#	NOT = {
			#		year = 850
			#	}
			#}		
		}
	}
	
	patronize_mogao_cave = {
		only_playable = yes
		ai_check_interval = 36
		potential = {
			is_playable = yes
			age = 16
			prisoner = no
			is_dunhuang_sinosphere_trigger = yes
			is_dunhuang_owner_trigger = yes
			NOT = {	has_character_flag = VIET_building_mogao_cave }
			NOT = {	has_character_flag = VIET_already_built_mogao_cave }
			NOT = {
				has_alternate_start_parameter = { key = religion_names value = random }
			}
			NOT = {
				has_alternate_start_parameter = { key = culture_names value = random }
			}
		}
		allow = {
			OR = {
				religion = buddhist
				religion = taoist
				#AND = {
				#	culture_group = chinese_group
				#	NOT = { trait = zealous }
				#}
			}
			wealth = 100
			prisoner = no
		}
		effect = {
			wealth = -100
			set_character_flag = VIET_building_mogao_cave
			hidden_tooltip = { 
				narrative_event = { id = dunhuang.50 }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { wealth = 300 }
			}
			modifier = {
				factor = 0
				trait = cynical
			}	
			modifier = {
				factor = 2
				religion = buddhist
				trait = zealous
			}			
			modifier = {
				factor = 1.2
				trait = ambitious
			}			
			modifier = {
				factor = 1.2
				trait = proud
			}				
			modifier = {
				factor = 0.8
				trait = greedy
			}				
			modifier = {
				factor = 0.8
				trait = slothful
			}			
		}
	}	
	
	dunhuang_reinforce_relations = {
		only_playable = yes
		ai_check_interval = 12
		potential = {
			is_playable = yes
			age = 16
			prisoner = no
			is_dunhuang_owner_trigger = yes
			NOT = {	has_character_flag = VIET_dunhuang_community_connection_happening }
			NOT = {
				has_alternate_start_parameter = { key = religion_names value = random }
			}
			NOT = {
				has_alternate_start_parameter = { key = culture_names value = random }
			}
		}
		allow = {
			is_dunhuang_owner_trigger = yes
			wealth = 50
			prestige = 50
			prisoner = no
			custom_tooltip = { 
				text = VIET_no_current_dunhuang_focus 
				hidden_tooltip = {
					NOR = {
						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
					}
				}
			}
		}
		effect = {
			wealth = -25
			set_character_flag = VIET_dunhuang_community_connection_happening
			hidden_tooltip = { 
				character_event = { id = dunhuang.100 }
			}
		}
		ai_will_do = {
			factor = 0.5		
			modifier = {
				factor = 1.2
				trait = ambitious
			}			
			modifier = {
				factor = 1.2
				trait = diligent
			}				
			modifier = {
				factor = 0.8
				trait = stubborn
			}				
			modifier = {
				factor = 0.8
				trait = slothful
			}			
		}
	}	

	attend_nadun_festival = {
		only_playable = yes
		ai_check_interval = 100
		potential = {
			is_playable = yes
			is_adult = yes
			prisoner = no
			NOT = {	has_character_flag = flag_holding_great_tribal_festival }
			OR = {
				culture = tuyuhun
				any_demesne_province = {
					culture = tuyuhun
				}
			}
		}
		allow = {
			war = no
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			custom_tooltip = {
				text = is_not_busy_trigger_tooltip
				hidden_tooltip = { NOT = { has_character_flag = do_not_disturb } }
			}
			NOT = { has_character_flag = VIET_going_to_nadun_festival }
			wealth = 25
			month = 7
			NOT = { month = 11 }
			custom_tooltip = {
				text = VIET_nadun_recent_text
				NOT = { has_character_modifier = held_nadun_festival_cooldown }
			}
		}
		effect = {
			wealth = -25
			set_character_flag = VIET_going_to_nadun_festival
			set_character_flag = do_not_disturb
			hidden_tooltip = {
				character_event = { id = dunhuang.130 }
			}
		}
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0.01
				NOT = {
					wealth = 100
				}
			}
			modifier = {
				factor = 0.5
				trait = shy
			}
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = zealous
			}
		}
	}
	
}