### Event chain for Chinese Kow Tow ###

#IDs JD.15000 - 15017
#    JD.32000 - 32299

namespace = JD

### Journey
character_event = { # I begin my journey...
	id = JD.32000
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_32000
	picture = GFX_evt_china_open
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	option = {
		name = EVTOPTA_JD_32000

		add_trait = kow_tow_travels

		character_event = { id = JD.32001 }
	}
}

character_event = { # Hidden set-up event!
	id = JD.32001

	hide_window = yes
	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		# Take distance into account for delay
		# Jiuquan on the Eastern border
		if = { # Near the far east
			limit = {
				distance = {
					where = c_jiuquan
					value < 500
				}
			}

			set_variable = {
				which = local_china_kow_tow_travel_events
				value = 1
			}
		}
		else_if = { # Still on the eastern side of the map
			limit = {
				distance = {
					where = c_jiuquan
					value < 900
				}
			}

			set_variable = {
				which = local_china_kow_tow_travel_events
				value = 2
			}
		}
		else = { # Approaching the Middle East
			# limit = {
			#	distance = {
			#		where = c_jiuquan
			#		value < 1500
			#	}
			# }

			set_variable = {
				which = local_china_kow_tow_travel_events
				value = 3
			}
		}
		# else = { # In or around the Middle East and beyond
		#	set_variable = {
		#		which = local_china_kow_tow_travel_events
		#		value = 4
		#	}
		# }

		character_event = {
			id = JD.32005 # random travel event tombola
			days = 110
			random = 30
		}
	}
}

character_event = { # Travel Tombola
	id = JD.32005

	hide_window = yes
	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		if = {
			limit = {
				check_variable = {
					which = local_china_kow_tow_travel_events
					value < 1
				}
			}

			### No more travel events - Move on to entering China
			character_event = {
				id = JD.32200
				days = 50
				random = 30
			}
		}

		else = {
			# Fire a random travel event
			random_list = {
				50 = { # Unusually heavy rain, think of late parents.
					trigger = {
						NOT = { has_character_flag = kow_tow_heavy_rain }

						OR = {
							father_even_if_dead = {
								is_alive = no
								death_in_china_trigger = no
							}

							mother_even_if_dead = {
								is_alive = no
								death_in_china_trigger = no
							}

							any_sibling_even_if_dead = {
								is_alive = no
								death_in_china_trigger = no
							}
						}
					}
					character_event = { id = JD.32100 }
				}

				50 = { # Homesick (I really miss <person>)
					trigger = {
						NOT = { has_character_flag = missed_loved_one }

						any_courtier_or_vassal = {
							OR = {
								is_lover = ROOT
								is_married = ROOT
								is_parent_of = ROOT
								is_child_of = ROOT
								is_friend = ROOT
							}
						}
					}

					character_event = { id = JD.15010 }
				}

				50 = { # Meet traveling merchant
					trigger = {
						NOR = {
							has_character_flag = met_traveling_merchant

							any_artifact = {
								count >= 15
								has_artifact_flag = chinese
							}
						}
					}

					character_event = { id = JD.15017 }
				}

				50 = { # Messenger invites you to the Lords keep, travel time > 1
					trigger = {
						NOT = { has_character_flag = kow_tow_invited_by_local_lord }

						trigger_if = {
							limit = {
								distance = {
									where = c_jiuquan
									value >= 1500
								}
							}

							check_variable = {
								which = local_china_kow_tow_travel_events
								value < 3
							}
						}
						trigger_else = {
							distance = {
								where = c_jiuquan
								value >= 900
							}

							check_variable = {
								which = local_china_kow_tow_travel_events
								value < 2
							}
						}

						any_playable_ruler = {
							ai = yes
							num_of_friends < 3
							block_general_event_trigger = no
							capital_scope = { region = custom_eastern_access }

							OR = {
								real_tier = COUNT
								real_tier = DUKE
							}
						}
					}

					character_event = { id = JD.32110 }
				}

				50 = { # Mercenary encounter (1/3)
					trigger = {
						NOT = { has_character_flag = met_mercenaries }

						any_independent_ruler = {
							ai = yes
							mercenary = yes

							OR = {
								culture = han

								trigger_if = {
									limit = {
										offmap_china = { has_status = china_jurchen_invasion }
									}
									culture = jurchen
								}
								trigger_else_if = {
									limit = {
										offmap_china = { has_status = china_mongol_invasion }
									}
									culture = mongol
								}
							}

							primary_title = {
								has_raised_standing_troops = no
							}
						}
					}

					character_event = { id = JD.15000 }
				}

				fallback = {
					### No more possible travel events - Continue to China anyway with extra delay
					character_event = {
						id = JD.32200
						months = 5
						random = 60
					}
				}
			}
		}
	}
}

character_event = { # Unusually heavy rain, think of late parents.
	id = JD.32100
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_32100
	picture = GFX_evt_carriage_default
	border = GFX_event_normal_frame_diplomacy

	hide_from = yes
	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		hidden_effect = {
			set_character_flag = kow_tow_heavy_rain

			random_list = {
				33 = {
					trigger = {
						father_even_if_dead = {
							is_alive = no
							death_in_china_trigger = no
						}
					}

					father_even_if_dead = {
						save_event_target_as = target_relative
					}
				}

				33 = {
					trigger = {
						mother_even_if_dead = {
							is_alive = no
							death_in_china_trigger = no
						}
					}

					mother_even_if_dead = {
						save_event_target_as = target_relative
					}
				}

				33 = {
					trigger = {
						any_sibling_even_if_dead = {
							is_alive = no
							death_in_china_trigger = no
						}
					}

					random_sibling_even_if_dead = {
						limit = {
							is_alive = no
							death_in_china_trigger = no
						}

						save_event_target_as = target_relative
					}
				}
			}
		}
	}

	option = {
		# <Name> was such a X person
		name = {
			text = EVTOPTA_JD_32100_young
			trigger = {
				event_target:target_relative = { is_adult = no }
			}
		}
		name = {
			text = EVTOPTA_JD_32100_pious
			trigger = {
				event_target:target_relative = { is_pious_trigger = yes }
			}
		}
		name = {
			text = EVTOPTA_JD_32100_genius
			trigger = {
				event_target:target_relative = { trait = genius }
			}
		}
		name = {
			text = EVTOPTA_JD_32100_mystic
			trigger = {
				event_target:target_relative = { trait = mystic }
			}
		}
		name = {
			text = EVTOPTA_JD_32100_brave
			trigger = {
				event_target:target_relative = {
					OR = {
						trait = brave

						trigger_if = {
							limit = {
								NOT = { trait = craven }
							}

							OR = {
								trait = holy_warrior
								trait = unyielding_leader
								trait = inspiring_leader
								trait = direct_leader
							}
						}
					}
				}
			}
		}
		name = {
			text = EVTOPTA_JD_32100_charming
			trigger = {
				event_target:target_relative = { is_attractive_trigger = yes }
			}
		}
		name = {
			text = EVTOPTA_JD_32100_just
			trigger = {
				event_target:target_relative = { trait = just }
			}
		}
		name = {
			text = EVTOPTA_JD_32100_kind
			trigger = {
				event_target:target_relative = { has_benevolent_trait_trigger = yes }
			}
		}
		name = {
			text = EVTOPTA_JD_32100_cruel
			trigger = {
				event_target:target_relative = {
					OR = {
						trait = cruel
						trait = impaler
						trait = greedy
						trait = wroth
						trait = deceitful
						trait = lunatic
						trait = possessed
					}
				}
			}
		}
		name = {
			text = EVTOPTA_JD_32100_learned
			trigger = {
				event_target:target_relative = { is_learned_trigger = yes }
			}
		}
		name = {
			text = EVTOPTA_JD_32100_good ### Fallback
			trigger = { always = yes }
		}

		show_portrait = event_target:target_relative

		custom_tooltip = { text = EVTTOOLTIPA_JD_32100 }

		add_character_modifier = {
			name = honoring_the_dead
			years = 5
		}
	}

	option = {
		name = EVTOPTB_JD_32100 # I need to focus on the journey

		add_character_modifier = {
			name = carrying_on
			years = 2
		}
	}

	after = {
		return_to_travel_tombola_effect = yes
	}
}

character_event = { # Messenger invites you to the Lords keep, travel time > 2
	id = JD.32110
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_32110
	picture = GFX_evt_courier
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:target_host

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		set_character_flag = kow_tow_invited_by_local_lord

		random_playable_ruler = {
			limit = {
				ai = yes
				num_of_friends < 3
				block_general_event_trigger = no
				capital_scope = { region = custom_eastern_access }

				OR = {
					real_tier = COUNT
					real_tier = DUKE
				}
			}

			preferred_limit = { # Bias towards rivals
				is_rival = ROOT
			}

			save_event_target_as = target_host
		}
	}

	option = { # An opportunity to get even
		name = EVTOPTA_JD_32110
		tooltip_info = master_schemer

		trigger = {
			trait = master_schemer
			is_rival = event_target:target_host
		}

		custom_tooltip = { text = EVTTOOLTIPA_JD_32110 }

		narrative_event = {
			id = JD.32113
			days = 7
			random = 4
		}
	}

	option = { # I'll accept the invitation
		name = {
			text = EVTOPTB_JD_32110
			trigger = {
				NOT = { is_rival = event_target:target_host }
			}
		}
		name = {
			text = EVTOPTB_JD_32110_RIVAL
			trigger = { is_rival = event_target:target_host }
		}

		custom_tooltip = { text = EVTTOOLTIPB_JD_32110 }

		character_event = {
			id = JD.32111
			days = 7
			random = 4
		}
	}

	option = { # My tent does fine
		name = EVTOPTC_JD_32110

		random_list = {
			25 = { add_trait_fully_content_effect = yes }
			25 = { add_trait_fully_shy_effect = yes }
			50 = { } # Nothing happens
		}

		return_to_travel_tombola_effect = yes # End of path
	}
}

character_event = { # Follow up from accepting the invitation
	id = JD.32111
	title = EVTTITLE_JD_KOWTOW
	picture = GFX_evt_feast
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:target_host

	desc = { # Normal outcome
		text = EVTDESCA_JD_32111
		trigger = {
			NOR = {
				has_character_flag = possible_friendship
				has_character_flag = possible_murder
			}
		}
	}
	desc = { # Friendship outcome
		text = EVTDESCB_JD_32111
		trigger = { has_character_flag = possible_friendship }
	}
	desc = { # Murder attempt outcome
		text = EVTDESCC_JD_32111
		trigger = { has_character_flag = possible_murder }
	}

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		random_list = {
			50 = { # Friendship outcome
				trigger = {
					NOR = {
						is_rival = event_target:target_host
						is_friend = event_target:target_host
					}
				}

				set_character_flag = possible_friendship
			}

			25 = { # Murder attempt outcome
				trigger = { is_rival = event_target:target_host }

				mult_modifier = {
					factor = 8
					event_target:target_host = {
						trait = deceitful
					}
				}

				set_character_flag = possible_murder
			}

			50 = { } # Normal outcome
		}
	}

	option = {
		name = EVTOPTA_JD_32111 # Normal outcome

		trigger = {
			NOR = {
				has_character_flag = possible_friendship
				has_character_flag = possible_murder
			}
		}

		add_character_modifier = {
			name = good_nights_sleep
			years = 1
		}

		if = {
			limit = { is_rival = event_target:target_host }
			remove_rival = event_target:target_host
		}
	}

	option = {
		name = EVTOPTB_JD_32111 # Friendship outcome

		trigger = { has_character_flag = possible_friendship }

		add_character_modifier = {
			name = good_nights_sleep
			months = 5
		}

		add_friend = event_target:target_host
	}

	option = {
		name = EVTOPTC_JD_32111 # Friendship deny

		trigger = { has_character_flag = possible_friendship }

		add_character_modifier = {
			name = good_nights_sleep
			months = 5
		}
	}

	option = {
		name = EVTOPTD_JD_32111

		trigger = { has_character_flag = possible_murder }

		random_list = {
			50 = {
				death = {
					death_reason = death_murder_poison
					killer = event_target:target_host
				}
			}

			50 = {
				custom_tooltip = { text = EVTTOOLTIPD_JD_32111 }
				character_event = { id = JD.32112 }
			}
		}
	}

	after = {
		clr_character_flag = possible_murder
		clr_character_flag = possible_friendship
		return_to_travel_tombola_effect = yes
	}
}

character_event = { # Follow up from option D
	id = JD.32112
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_32112
	picture = GFX_evt_drunk
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:target_host

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	option = {
		name = EVTOPTA_JD_32112

		if = {
			limit = { has_dlc = "Reapers" }
			give_food_poisoning_effect = yes
			custom_tooltip = { text = EVTTOOLTIPA_JD_32112 }
		}
		else = {
			add_character_modifier = {
				name = poisoned
				months = 6
			}
		}
	}
}

narrative_event = { # Follow up from option A
	id = JD.32113
	title = EVTTITLE_JD_32113
	picture = GFX_evt_feast
	border = GFX_event_narrative_frame_intrigue
	portrait = event_target:target_host

	desc = {
		text = EVTDESCA_JD_32113
		trigger = { has_character_flag = successful_murder }
	}
	desc = {
		text = EVTDESCB_JD_32113
		trigger = { has_character_flag = successful_murder_but_caught }
	}
	desc = {
		text = EVTDESCC_JD_32113
		trigger = {
			NOR = {
				has_character_flag = successful_murder
				has_character_flag = successful_murder_but_caught
			}
		}
	}

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		random_list = {
			20 = { # Target dies while you slip away in the shadows
				mult_modifier = {
					factor = 3
					intrigue >= 18
				}
				mult_modifier = {
					factor = 2
					trait = elusive_shadow
				}

				set_character_flag = successful_murder
			}

			40 = { # Target dies, guards kill you
				set_character_flag = successful_murder_but_caught
			}

			40 = { # Target survives, guards kill you
				mult_modifier = {
					factor = 0.6
					intrigue >= 16
				}
				mult_modifier = {
					factor = 0.5
					event_target:target_host = {
						trait = trusting
					}
				}
				mult_modifier = {
					factor = 3
					event_target:target_host = {
						intrigue >= 14
					}
				}
				mult_modifier = {
					factor = 1.5
					event_target:target_host = {
						trait = paranoid
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTA_JD_32113

		trigger = { has_character_flag = successful_murder }

		event_target:target_host = {
			show_scope_change = no

			death = {
				death_reason = death_murder_poison
				killer = ROOT
			}
		}

		change_intrigue = 1
		return_to_travel_tombola_effect = yes
	}

	option = {
		name = EVTOPTB_JD_32113

		trigger = { has_character_flag = successful_murder_but_caught }

		event_target:target_host = {
			show_scope_change = no

			death = {
				death_reason = death_murder_poison
				killer = ROOT
			}
		}

		death = {
			death_reason = death_murder
			killer = event_target:target_host
		}
	}

	option = {
		name = EVTOPTC_JD_32113

		trigger = {
			NOR = {
				has_character_flag = successful_murder
				has_character_flag = successful_murder_but_caught
			}
		}

		death = {
			death_reason = death_murder
			killer = event_target:target_host
		}
	}

	after = {
		clr_character_flag = successful_murder
		clr_character_flag = successful_murder_but_caught
	}
}

character_event = { # Kow-Tow traveling event: You encounter Mercenaries (how? Depends on the status of China)
	id = JD.15000

	hide_window = yes
	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		set_character_flag = met_mercenaries

		random_independent_ruler = {
			limit = {
				ai = yes
				mercenary = yes

				OR = {
					culture = han

					trigger_if = {
						limit = {
							offmap_china = { has_status = china_jurchen_invasion }
						}

						culture = jurchen
					}
					trigger_else_if = {
						limit = {
							offmap_china = { has_status = china_mongol_invasion }
						}

						culture = mongol
					}
				}

				primary_title = {
					has_raised_standing_troops = no
				}
			}

			save_event_target_as = other_ruler
		}

		if = {
			limit = {
				offmap_china = {
					OR = {
						has_status = china_unrest
						has_status = china_civil_war
						has_status = china_mongol_invasion
						has_status = china_jurchen_invasion
					}
				}
			}

			character_event = { id = JD.15002 } # Mercenaries wants root to pay a "bridge fee"...
		}
		else_if = {
			limit = {
				offmap_china = {
					OR = {
						has_status = china_stable
						has_status = china_golden_age
						has_status = china_unrest
					}
				}
			}

			character_event = { id = JD.15003 } # Mercenaries are here to escort root...
		}
		else_if = {
			limit = {
				offmap_china = {
					OR = {
						has_status = china_famine
						has_status = china_plague
					}
				}
			}

			character_event = { id = JD.15004 } # Meet a starving mercenary band...
		}
	}
}

character_event = { # Mercenaries wants root to pay a "bridge fee"...
	id = JD.15002
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_15002
	picture = GFX_evt_china_diplomatic_success
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:other_ruler

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	option = { # Pay the fee to the bridge guards...
		name = EVTOPTA_JD_15002

		transfer_scaled_wealth = {
			to = event_target:other_ruler
			value = 0.25
			min = 50
		}

		prestige = -100

		custom_tooltip = { text = EVTOPTA_JD_15002_tt }
	}

	option = { # Kill him (IMPALER ONLY)
		name = EVTOPTC_JD_15002
		tooltip_info = impaler

		trigger = { trait = impaler }

		custom_tooltip = { text = EVTOPTC_JD_15002_tt }

		event_target:other_ruler = {
			show_scope_change = no

			death = {
				death_reason = death_murder_butchered
				killer = ROOT
			}
		}
	}

	option = {
		name = EVTOPTB_JD_15002

		random_list = {
			50 = {
				mult_modifier = {
					factor = 2
					is_strong_trigger = yes
				}
				mult_modifier = {
					factor = 2
					event_target:other_ruler = { is_weak_trigger = yes }
				}
				mult_modifier = {
					factor = 2

					combat_rating_diff = {
						who = event_target:other_ruler
						value >= 10
					}
				}
				mult_modifier = {
					factor = 2

					attribute_diff = {
						character = event_target:other_ruler
						attribute = martial
						value >= 3
					}
				}

				# You get away
				custom_tooltip = { text = you_get_away_tt }
			}
			10 = {
				mult_modifier = {
					factor = 1.5
					is_weak_trigger = yes
				}

				# You get injured
				custom_tooltip = { text = you_dont_get_away_tt }
				hidden_effect = { add_maimed_trait_effect = yes }
			}
			5 = {
				mult_modifier = {
					factor = 2
					is_weak_trigger = yes
				}

				# You are slain in personal combat!
				custom_tooltip = {
					text = you_will_be_killed_in_a_duel_tt

					death = {
						death_reason = death_duel
						killer = event_target:other_ruler
					}
				}
			}
		}
	}

	after = {
		return_to_travel_tombola_effect = yes
	}
}

character_event = { # Mercenaries: "We're here to escort you!"
	id = JD.15003
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_15003
	picture = GFX_evt_china_rebel_general
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:other_ruler

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	option = { # Er, change of plans! (Hire bodygaurds)
		name = EVTOPTA_JD_15003

		custom_tooltip = { text = EVTOPTA_JD_15003_tt }

		transfer_scaled_wealth = {
			to = event_target:other_ruler
			value = 0.5
			min = 10
		}

		add_character_modifier = {
			name = hired_body_guards
			years = 3
		}
	}

	option = { # I think you have me confused with someone else...
		name = EVTOPTB_JD_15003

		custom_tooltip = { text = EVTOPTB_JD_15003_tt }
	}

	after = {
		return_to_travel_tombola_effect = yes
	}
}

character_event = { # We see starving people...
	id = JD.15004
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_15004
	picture = GFX_evt_china_famine
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:other_ruler

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	option = { # Let's eat together, yes.
		name = EVTOPTA_JD_15004

		custom_tooltip = { text = EVTOPTA_JD_15004_tt }

		scaled_wealth = { value = -0.2 min = -25 }

		add_friend = event_target:other_ruler

		add_character_modifier = {
			name = the_kind
			years = 10
		}

		add_trait_partially_silently_charitable_effect = yes
	}

	option = {
		name = EVTOPTB_JD_15004 # Come work for me! You, in particular!

		custom_tooltip = { text = EVTOPTB_JD_15004_tt }

		scaled_wealth = { value = -0.05 min = -5 }

		hidden_effect = {
			event_target:other_ruler = {
				transfer_crown_on_abdication_effect = yes
				abdicate = yes
				move_character = ROOT

				add_character_modifier = {
					name = mercenary_traditions
					duration = -1
				}
			}
		}

		reverse_opinion = {
			name = opinion_loyal_servant
			who = event_target:other_ruler
			years = 100
		}
	}

	option = { # We can't afford to take pity on strangers...!
		name = EVTOPTC_JD_15004

		custom_tooltip = { text = EVTOPTC_JD_15004_tt }
	}

	after = {
		return_to_travel_tombola_effect = yes
	}
}

character_event = { # You feel homesick...
	id = JD.15010 # I really miss X.
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_15010
	picture = GFX_evt_carriage_default
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		set_character_flag = missed_loved_one

		any_courtier_or_vassal = { # Select someone you sort of care about at least...!
			limit = {
				OR = {
					is_lover = ROOT
					is_married = ROOT
					is_parent_of = ROOT
					is_child_of = ROOT
					is_friend = ROOT
				}
			}

			score_value = { # Prioritizes selecting an interesting courtier...
				value = 10
				interesting_courtier_selection_score = yes
			}

			save_event_target_as = person_missed

			if = {
				limit = { is_lover = ROOT }
				set_character_flag = is_lover
			}
			else_if = {
				limit = { is_married = ROOT }
				set_character_flag = is_spouse
			}
			else_if = {
				limit = { is_parent_of = ROOT }
				set_character_flag = is_parent
			}
			else_if = {
				limit = { is_child_of = ROOT }
				set_character_flag = is_child
			}
			else_if = {
				limit = { is_friend = ROOT }
				set_character_flag = is_friend
			}
		}
	}

	option = { # I will write a letter to my lover...
		name = EVTOPTA_JD_15010

		trigger = {
			event_target:person_missed = { has_character_flag = is_lover }
		}

		custom_tooltip = { text = will_receive_a_letter }
		scaled_wealth = { value = -0.1 min = -5 }

		tooltip = {
			reverse_opinion = {
				name = opinion_love_letters
				who = event_target:person_missed
				years = 15
			}
		}

	}
	option = { # I will write a letter to my friend...
		name = EVTOPTB_JD_15010

		trigger = {
			event_target:person_missed = { has_character_flag = is_friend }
		}

		custom_tooltip = { text = will_receive_a_letter }
		scaled_wealth = { value = -0.1 min = -5 }

		tooltip = {
			reverse_opinion = {
				name = opinion_pen_pal
				who = event_target:person_missed
				years = 15
			}
		}
	}

	option = { # I will write a letter to my spouse...!
		name = EVTOPTC_JD_15010

		trigger = {
			event_target:person_missed = { has_character_flag = is_spouse }
		}

		custom_tooltip = { text = will_receive_a_letter }
		scaled_wealth = { value = -0.1 min = -5 }

		tooltip = {
			reverse_opinion = {
				name = opinion_love_letters
				who = event_target:person_missed
				years = 15
			}
		}
	}

	option = { # I will write a letter to my parent...
		name = EVTOPTD_JD_15010

		trigger = {
			event_target:person_missed = { has_character_flag = is_parent }
		}

		custom_tooltip = { text = will_receive_a_letter }
		scaled_wealth = { value = -0.1 min = -5 }

		tooltip = {
			reverse_opinion = {
				name = opinion_delighted_parent
				who = event_target:person_missed
				years = 15
			}
		}
	}

	option = { # I will write a letter to my child...
		name = EVTOPTE_JD_15010

		trigger = {
			event_target:person_missed = { has_character_flag = is_child }
		}

		custom_tooltip = { text = will_receive_a_letter }
		scaled_wealth = { value = -0.1 min = -5 }

		tooltip = {
			reverse_opinion = {
				name = opinion_pen_pal
				who = event_target:person_missed
				years = 15
			}
		}
	}

	option = { # No! Time is of the essence...!
		name = EVTOPTF_JD_15010

		set_character_flag = do_nothing
	}

	after = {
		if = {
			limit = { has_character_flag = do_nothing }
			clr_character_flag = do_nothing

			hidden_effect = {
				event_target:person_missed = {
					clr_character_flag = is_lover
					clr_character_flag = is_friend
					clr_character_flag = is_spouse
					clr_character_flag = is_parent
					clr_character_flag = is_child
				}
			}
		}
		else = {
			event_target:person_missed = { character_event = { id = JD.15011 } }
		}

		return_to_travel_tombola_effect = yes
	}
}

character_event = { # Selected target receives letter from you...!
	id = JD.15011
	title = EVTTITLE_JD_KOWTOW
	picture = GFX_evt_recieve_letter
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESC_JD_15011_A
		trigger = {
			NOT = { is_child_of = FROM }
		}
	}
	desc = {
		text = EVTDESC_JD_15011_B
		trigger = { is_child_of = FROM }
	}

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	option = {
		name = {
			text = EVTOPTA_JD_15011_A
			trigger = { NOT = { is_child_of = FROM } }
		}
		name = {
			text = EVTOPTA_JD_15011_B
			trigger = { is_child_of = FROM }
		}

		if = {
			limit = {
				OR = {
					has_character_flag = is_child
					has_character_flag = is_friend
				}
			}

			clr_character_flag = is_child
			clr_character_flag = is_friend

			opinion = {
				name = opinion_pen_pal
				who = FROM
				years = 15
			}
		}
		else_if = {
			limit = {
				OR = {
					has_character_flag = is_lover
					has_character_flag = is_spouse
				}
			}

			clr_character_flag = is_lover
			clr_character_flag = is_spouse

			opinion = {
				name = opinion_love_letters
				who = FROM
				years = 15
			}
		}
		else = {
			clr_character_flag = is_parent

			opinion = {
				name = opinion_delighted_parent
				who = FROM
				years = 15
			}
		}
	}
}

character_event = { # Encounter a merchant..!
	id = JD.15017
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_15017
	picture = GFX_evt_china_stable
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:chinese_trader

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		set_character_flag = met_traveling_merchant

		offmap_china = {
			governor = {
				create_random_intriguer = {
					age = 25
					random_traits = yes
					female = 50
					dynasty = none

					attributes = {
						intrigue = 4
					}
				}

				new_character = {
					upgrade_education_effect = yes
					save_event_target_as = chinese_trader
					add_chinese_artifact_effect = yes
				}
			}
		}
	}

	option = {
		name = EVTOPTA_JD_15017 # I'd love to take it off your hands!

		custom_tooltip = {
			text = EVTOPTA_JD_15017_TT

			event_target:chinese_trader = {
				event_target:chinese_artifact = {
					transfer_artifact = {
						from = PREV
						to = ROOT
					}
				}

				death = { death_reason = death_missing }
			}
		}

		scaled_wealth = { value = -0.4 min = -150 }
	}

	option = { # I could use a smooth-talker like you...
		name = EVTOPTB_JD_15017
		tooltip_info = kind

		trigger = { trait = kind }

		custom_tooltip = {
			text = EVTOPTB_JD_15017_TT

			event_target:chinese_trader = {
				move_character = ROOT
			}
		}
	}

	option = {
		name = EVTOPTC_JD_15017 # Guards! Cut this man/woman down.
		tooltip_info = deceitful

		trigger = { trait = deceitful }

		custom_tooltip = { text = EVTOPTC_JD_15017_TT } # You steal the artifact.

		event_target:chinese_trader = {
			show_scope_change = no

			death = {
				death_reason = death_murder
				killer = ROOT
			}
		}

		custom_tooltip = {
			text = EVTOPTA_JD_15017_TT # it's transfered to you.

			# Steal the artifact
			event_target:chinese_trader = {
				event_target:chinese_artifact = {
					transfer_artifact = {
						from = PREV
						to = ROOT
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTD_JD_15017 # I have no use of whatever that is.

		custom_tooltip = {
			text = EVTOPTD_JD_15017_TT

			event_target:chinese_trader = { # removes the trader from the game, along with their artifact (if you didn't trade)...
				any_artifact = { destroy_artifact = yes }
				death = { death_reason = death_missing }
			}
		}
	}

	after = {
		return_to_travel_tombola_effect = yes
	}
}


### Destination
character_event = { # Enter China, choose path
	id = JD.32200
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_32200
	picture = GFX_evt_china_open
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	option = { # Kow Tow before the Emperor
		name = EVTOPTA_JD_32200

		custom_tooltip = {
			text = EVTTOOLTIPA_JD_32200

			set_variable = {
				which = local_china_kow_tow_travel_events
				value = 2
			}
		}

		character_event = {
			id = JD.32210
			days = 40
			random = 25
		}
	}
}

character_event = { # Within China Tombola
	id = JD.32210

	hide_window = yes
	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		if = {
			limit = {
				check_variable = {
					which = local_china_kow_tow_travel_events
					value < 1
				}
			}

			### No more travel events - Move on to China conclusion
			character_event = {
				id = JD.32290
				days = 50
				random = 30
			}
		}
		else = {
			# Fire a random travel event
			random_list = {
				25 = { # Visit Temple
					trigger = {
						NOT = { has_character_flag = kow_tow_visited_temple }
					}

					character_event = { id = JD.32216 }
				}

				25 = { # Play GO
					trigger = {
						NOT = { has_character_flag = kow_tow_played_go }
					}

					mult_modifier = {
						factor = 2
						trait = game_master
					}

					character_event = { id = JD.32211 }
				}

				25 = { # Discuss the Writings of Master Guan
					trigger = {
						NOT = { has_character_flag = read_the_guanzi }
					}

					character_event = { id = JD.15015 }
				}

				25 = { # Visit the markets
					trigger = {
						NOT = { has_character_flag = visited_market }
					}

					character_event = { id = JD.15016 }
				}
			}
		}
	}
}

character_event = { # You spot a group of people playing GO in the park
	id = JD.32211
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_32211
	picture = GFX_evt_garden
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		set_character_flag = kow_tow_played_go
	}

	option = { # Let me show you how it's done
		name = EVTOPTA_JD_32211
		tooltip_info = game_master

		trigger = { trait = game_master }

		wealth = 50
		add_trait_fully_silently_proud_effect = yes

		custom_tooltip = {
			text = EVTTOOLTIP_JD_GOOD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 2
			}
		}
	}

	option = { # Let me try that
		name = EVTOPTB_JD_32211

		trigger = {
			NOT = { trait = game_master }
		}

		random_list = {
			65 = { wealth = 25 }
			35 = { wealth = -10 }
		}

		custom_tooltip = {
			text = EVTTOOLTIP_JD_GOOD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 2
			}
		}
	}

	option = {
		name = EVTOPTC_JD_32211 # I'll just enjoy the park instead

		random_list = {
			50 = { add_trait_fully_patient_effect = yes }
			50 = { add_trait_fully_humble_effect = yes }
		}
	}

	after = {
		return_to_china_tombola_effect = yes
	}
}

character_event = { # You visit a local temple
	id = JD.32216
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_32216
	picture = GFX_evt_china_diplomatic_incident
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		set_character_flag = kow_tow_visited_temple
	}

	option = { # Study their rituals
		name = EVTOPTA_JD_32216

		trigger = {
			NOR = {
				trait = zealous
				religion_group = indian_group # Eastern religion group
			}
		}

		add_trait = sympathy_indian # Sympathy for eastern religions
	}

	option = { # Join in the ceremony
		name = EVTOPTB_JD_32216

		if = {
			limit = {
				trait = zealous
				NOT = { religion_group = indian_group } # Eastern religion group
			}

			remove_trait = zealous
		}

		random = {
			chance = 30
			add_trait_fully_content_effect = yes
		}

		custom_tooltip = {
			text = EVTTOOLTIP_JD_GOOD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 3
			}
		}
	}

	option = { # Loudly criticize their heathen ways
		name = EVTOPTC_JD_32216

		trigger = {
			trait = zealous
			NOT = { religion_group = indian_group } # Eastern religion group
		}

		piety = 30
		custom_tooltip = {
			text = EVTTOOLTIP_JD_BAD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = -5
			}
		}
	}

	option = { # Study the symbolism used in their texts.
		name = EVTOPTD_JD_32216

		random = {
			chance = 15
			change_learning = 1
		}
	}

	after = {
		return_to_china_tombola_effect = yes
	}
}

character_event = { # Learn about political philosophy or attempt to impress pretty [man/woman]
	id = JD.15015
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_15015
	picture = GFX_evt_chinese_bureaucrat
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		set_character_flag = read_the_guanzi
	}

	option = { # I would love to hear more about political philosophy!
		name = EVTOPTA_JD_15015

		custom_tooltip = { text = EVTOPTA_JD_15015_TT } # They like your enthusiasm!

		custom_tooltip = {
			text = EVTTOOLTIP_JD_GOOD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 3
			}
		}
	}

	option = { # Actually, I'm already well familiar with 'the Guanzi', my lords (poet)
		name = EVTOPTB_JD_15015
		tooltip_info = poet

		trigger = {
			trait = poet
			NOT = { trait = scholar }
		}

		custom_tooltip = { text = EVTOPTB_JD_15015_TT } # They are impressed...!

		prestige = 50

		custom_tooltip = {
			text = EVTTOOLTIP_JD_GOOD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 3
			}
		}
	}

	option = { # Actually, I'm already well familiar with 'the Guanzi', my lords. (scholar)
		name = EVTOPTB_JD_15015
		tooltip_info = scholar

		trigger = { trait = scholar }

		custom_tooltip = { text = EVTOPTB_JD_15015_TT } # They are impressed..!

		prestige = 100

		custom_tooltip = {
			text = EVTTOOLTIP_JD_GOOD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 3
			}
		}
	}

	option = { # I'd rather see the palace...
		name = EVTOPTC_JD_15015

		custom_tooltip = { text = EVTOPTC_JD_15015_TT } # They make sure you are accompanied...

		random = {
			chance = 30
			change_stewardship = 1
		}

		custom_tooltip = {
			text = EVTTOOLTIP_JD_BAD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = -5
			}
		}
	}

	after = {
		return_to_china_tombola_effect = yes
	}
}

character_event = { # Visit the market
	id = JD.15016
	title = EVTTITLE_JD_KOWTOW
	desc = EVTDESC_JD_15016
	picture = GFX_evt_china_stable
	border = GFX_event_normal_frame_diplomacy
	portrait = event_target:chinese_trader

	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		set_character_flag = visited_market

		hidden_effect = {
			offmap_china = {
				governor = {
					create_random_steward = {
						age = 45
						random_traits = yes
						female = 50
						dynasty = none
						health = 10

						attributes = {
							stewardship = 3
						}
					}

					new_character = {
						save_event_target_as = chinese_trader
						give_nickname = nick_the_trader
						add_chinese_artifact_effect = yes
					}
				}
			}
		}
	}

	option = { # What is that scent...? Mmhm!
		name = EVTOPTA_JD_15016

		custom_tooltip = { text = EVTOPTA_JD_15016_TT } # you partake in the local cuisine!

		random = {
			chance = 50
			add_trait_gluttonous_effect = yes
		}

		custom_tooltip = {
			text = EVTTOOLTIP_JD_GOOD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 3
			}
		}
	}

	option = { # You there, let's trade!
		name = EVTOPTB_JD_15016

		trigger = { # only if you don't already have a ton of chinese artifacts
			NOT = {
				any_artifact = {
					count >= 13
					has_artifact_flag = chinese
				}
			}
		}

		custom_tooltip = { text = EVTOPTB_JD_15016_TT }

		scaled_wealth = { value = -0.6 min = -200 }

		hidden_effect = {
			event_target:chinese_trader = {
				event_target:chinese_artifact = {
					transfer_artifact = {
						from = PREV
						to = ROOT
					}
				}
			}
		}

		custom_tooltip = {
			text = EVTTOOLTIP_JD_GOOD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 3
			}
		}
	}

	option = { # Steal a Chinese artifact in the market!
		name = EVTOPTC_JD_15016
		tooltip_info = intrigue

		trigger = {
			OR = {
				trait = elusive_shadow
				intrigue >= 15
			}
		}

		custom_tooltip = { text = EVTOPTC_JD_15016_TT }

		hidden_effect = {
			event_target:chinese_trader = {
				event_target:chinese_artifact = {
					transfer_artifact = {
						from = PREV
						to = ROOT
					}
				}
			}
		}

		custom_tooltip = {
			text = EVTTOOLTIP_JD_BAD_INFLUENCE_ON_EMPEROR_EVALUATION

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = -3
			}
		}
	}

	option = { # I just wanna go home.
		name = EVTOPTD_JD_15016
	}

	after = {
		return_to_china_tombola_effect = yes

		hidden_effect = {
			event_target:chinese_trader = { # removes the trader from the game, along with their artifact (if you didn't trade)...
				any_artifact = { destroy_artifact = yes }
				death = { death_reason = death_missing }
			}
		}
	}
}


### Outcome
character_event = { # audience w/ the Emperor
	id = JD.32290
	title = EVTTITLE_JD_KOWTOW
	picture = GFX_evt_china_golden_age
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCA_JD_32290 # Bad outcome
		picture = GFX_evt_chinese_bureaucrat
		trigger = { has_character_flag = kow_tow_bad_outcome }
	}
	desc = {
		text = EVTDESCB_JD_32290 # Okay outcome
		picture = GFX_evt_china_golden_age
		trigger = { has_character_flag = kow_tow_okay_outcome }
	}
	desc = {
		text = EVTDESCC_JD_32290 # Great outcome
		picture = GFX_evt_china_golden_age
		trigger = { has_character_flag = kow_tow_great_outcome }
	}


	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	trigger = { trait = kow_tow_travels }

	immediate = {
		export_to_variable = {
			which = local_kow_tow_temp_calc
			value = diplomacy
		}

		divide_variable = {
			which = local_kow_tow_temp_calc
			value = 2
		}

		change_variable = {
			which = local_kow_tow_emperor_impression_evaluation
			which = local_kow_tow_temp_calc
		}

		if = {
			limit = { real_tier = KING }

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 7
			}
		}
		else_if = {
			limit = { real_tier = EMPEROR }

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 14
			}
		}

		if = {
			limit = {
				disliked_by_offmap = {
					type = offmap_china
				}
			}

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = -5
			}
		}
		else_if = {
			limit = {
				liked_by_offmap = {
					type = offmap_china
				}
			}

			change_variable = {
				which = local_kow_tow_emperor_impression_evaluation
				value = 5
			}
		}

		random_list = {
			45 = { # Bad outcome
				trigger = {
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value < 23
					}
				}

				mult_modifier = {
					factor = 0.85
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 12
					}
				}
				mult_modifier = {
					factor = 0.85
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 13
					}
				}
				mult_modifier = {
					factor = 0.85
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 14
					}
				}
				mult_modifier = {
					factor = 0.85
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 15
					}
				}
				mult_modifier = {
					factor = 0.85
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 17
					}
				}
				mult_modifier = {
					factor = 0.85
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 19
					}
				}
				mult_modifier = {
					factor = 0.85
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 21
					}
				}

				set_character_flag = kow_tow_bad_outcome
			}

			45 = { # Okay outcome
				set_character_flag = kow_tow_okay_outcome
			}

			10 = { # Great outcome
				trigger = {
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 10
					}
				}

				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 11
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 12
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 13
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 14
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 15
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 17
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 19
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 21
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 23
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 25
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 27
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 29
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 31
					}
				}
				mult_modifier = {
					factor = 1.1
					check_variable = {
						which = local_kow_tow_emperor_impression_evaluation
						value >= 33
					}
				}

				set_character_flag = kow_tow_great_outcome
			}
		}
	}

	option = {
		name = EVTOPTA_JD_32290 # Perform kow-tow before the Emperor

		trigger = { has_character_flag = kow_tow_bad_outcome }

		add_trait = kow_tow_completed_tier_1

		add_offmap_currency = {
			offmap = offmap_china
			value = 100
		}

		if = {
			limit = { is_nomadic = yes }
			prestige = -250
		}
		else = {
			trigger_switch = {
				on_trigger = real_tier

				DUKE    = { prestige =  -250 }
				KING    = { prestige =  -500 }
				EMPEROR = { prestige = -1000 }
			}
		}
	}

	option = {
		name = EVTOPTB_JD_32290 # Refuse the humiliation
		trigger = { has_character_flag = kow_tow_bad_outcome }
	}

	option = {
		name = EVTOPTC_JD_32290 # Perform kow-tow before the Emperor
		trigger = { has_character_flag = kow_tow_okay_outcome }

		add_trait = kow_tow_completed_tier_2

		add_offmap_currency = {
			offmap = offmap_china
			value = 100
		}

		if = {
			limit = { is_nomadic = yes }
			prestige = -250
		}
		else = {
			trigger_switch = {
				on_trigger = real_tier

				DUKE    = { prestige =  -250 }
				KING    = { prestige =  -500 }
				EMPEROR = { prestige = -1000 }
			}
		}
	}

	option = {
		name = EVTOPTD_JD_32290 # Perform kow-tow before the Emperor
		trigger = { has_character_flag = kow_tow_great_outcome }

		add_trait = kow_tow_completed_tier_3

		add_offmap_currency = {
			offmap = offmap_china
			value = 100
		}

		if = {
			limit = { is_nomadic = yes }
			prestige = -250
		}
		else = {
			trigger_switch = {
				on_trigger = real_tier

				DUKE    = { prestige =  -250 }
				KING    = { prestige =  -500 }
				EMPEROR = { prestige = -1000 }
			}
		}
	}

	after = {
		clr_character_flag = kow_tow_bad_outcome
		clr_character_flag = kow_tow_okay_outcome
		clr_character_flag = kow_tow_great_outcome
		clean_up_after_kow_tow_effect = yes
	}
}

### Cancel Kowtows if China becomes isolationist
character_event = {
	id = JD.32298

	hide_window = yes
	is_triggered_only = yes # on_offmap_policy_changed

	has_dlc = "Jade Dragon"

	trigger = {
		FROM = { has_policy = china_isolationist }
	}

	immediate = {
		any_playable_ruler = {
			limit = { trait = kow_tow_travels }
			set_character_flag = kow_tow_abort_isolationist
			character_event = { id = JD.32299 }
		}
	}
}

### Kowtow was aborted for some reason
character_event = {
	id = JD.32299
	title = EVTTITLE_JD_KOWTOW
	picture = GFX_evt_china_isolationist
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = EVTDESCA_JD_32299
		trigger = { has_character_flag = kow_tow_abort_war }
	}
	desc = {
		text = EVTDESCB_JD_32299
		trigger = { has_character_flag = kow_tow_abort_isolationist }
	}
	desc = {
		text = EVTDESCC_JD_32299
		trigger = {
			NOR = {
				has_character_flag = kow_tow_abort_war
				has_character_flag = kow_tow_abort_isolationist
			}
		}
	}

	hide_from = yes
	is_triggered_only = yes

	has_dlc = "Jade Dragon"

	immediate = {
		clean_up_after_kow_tow_effect = yes
	}

	option = {
		name = EVTOPTA_JD_32299

		clr_character_flag = kow_tow_abort_war
		clr_character_flag = kow_tow_abort_isolationist

		tooltip = {
			remove_trait = kow_tow_travels
		}
	}
}