###GRACE INTERACTION DECISIONS FOR CHINA###

#Add the decisions in a nice order which will make sense in the menu! For example, ranked by cost/reward.


#PAYING TRIBUTE DECISIONS (GAIN GRACE)
offmap_decisions = {

	chinese_grace_send_gift = {
		only_playable = yes
		button_name = offmap_gifts
		ai_check_interval = 120

		potential = {
			is_offmap_tag = offmap_china
		}

		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				scaled_wealth = { value = 4 min = 500 }
				custom_tooltip = {
					text = chinese_grace_send_gift_allow_tt 
					NOT = { has_character_modifier = chinese_grace_send_gift_timer }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			china_offmap_tribute_decisions_enabled_trigger = yes
		}
		effect = {
			FROM = {
				sound_effect = china_grace_gain
				scaled_wealth = { value = -4 min = -500 } #If this changes the ai chances should probably be adjusted
				hidden_effect = {
					add_character_modifier = {
						hidden = yes
						name = chinese_grace_send_gift_timer
						years = 15 #Change chinese_grace_send_gift_allow_tt if this number changes
					} 
				}
				tooltip = {
					if = {
						limit = {
							liked_by_offmap = {
								type = offmap_china
								context = wealth
							}
							NOT = {
								disliked_by_offmap = {
									type = offmap_china
									context = wealth
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 450
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = likes_tt }
							}
						}
					}
					if = {
						limit = {
							disliked_by_offmap = {
								type = offmap_china
								context = wealth
							}
							NOT = {
								liked_by_offmap = {
									type = offmap_china
									context = wealth
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 150
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = dislikes_tt }
							}
						}
					}
					if = {
						limit = {
							liked_by_offmap = {
								type = offmap_china
								context = wealth
							}
							disliked_by_offmap = {
								type = offmap_china
								context = wealth
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 300
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = likes_but_dislikes_tt }
							}
						}
					}
					if = {
						limit = {
							NOR = {
								liked_by_offmap = {
									type = offmap_china
									context = wealth
								}
								disliked_by_offmap = {
									type = offmap_china
									context = wealth
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 300
						}
					}
				}
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20023 } } } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.66 # slow down
			}
			modifier = {
				factor = 0.1
				FROM = { NOT = { monthly_income = 11 } } #I.e. it would take more than 4 years to collect the 500 gold
			}
		}
	}

	#Offering to become tributary
	chinese_grace_become_tributary = {
		only_independent = yes
		button_name = offmap_gifts
		ai_check_interval = 36

		potential = {
			is_offmap_tag = offmap_china
		}
	
		from_potential = {
			independent = yes
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				war = no
				OR = {
					custom_tooltip = { #Borders the Western Governate
						text = chinese_grace_become_tributary_allow_governor_neighbor_tt
						any_neighbor_independent_ruler = {
							has_landed_title = e_china_west_governor
						}
					}
					custom_tooltip = { #Borders a Chinese tributary
						text = chinese_grace_become_tributary_allow_tributary_neighbor_tt
						any_neighbor_independent_ruler = {
							suzerain = {
								has_landed_title = e_china_west_governor
							}
						}
					}
					custom_tooltip = { #Borders the eastern edge of the map
						text = chinese_grace_become_tributary_allow_chinese_influence_tt
						any_realm_province = {
							region = custom_chinese_invasion_target_region
						}
					}
					custom_tooltip = { #Within diplo range of China and has a port in India
						text = chinese_grace_become_tributary_allow_india_tt
						any_realm_province = { 
							port = yes 
							region = world_india
						}
					}
				}
				custom_tooltip = {
					text = chinese_grace_become_tributary_allow_suzerain_tt
					NAND = { #FIX (NOT)
						is_tributary = yes	suzerain = { always = yes } #FIX
					}
				}
				NOT = { tier = emperor }
				custom_tooltip = {
					text = chinese_tribute_become_tributary_cooldown_tt
					NOT = { has_character_modifier = chinese_grace_tributary_timer }
				}
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = asked_to_become_tributary }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			china_offmap_tribute_decisions_enabled_trigger = yes
		}

		effect = {
			log = "---------------------"
			log = "China Logging:"
			log = "[From.GetTitledName] has voluntarily become a tributary of the [offmap_china.GetFullname]"
			log = "---------------------"
			make_tributary = {
				who = FROM
				tributary_type = offmap
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20027 } } } }
			custom_tooltip = { text = chinese_grace_become_tributary_effect_TT }
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_gain
				tooltip = {
					if = {
						limit = {
							liked_by_offmap = {
								type = offmap_china
								context = tributary
							}
							NOT = {
								disliked_by_offmap = {
									type = offmap_china
									context = tributary
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 400
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = likes_tt }
							}
						}
					}
					if = {
						limit = {
							disliked_by_offmap = {
								type = offmap_china
								context = tributary
							}
							NOT = {
								liked_by_offmap = {
									type = offmap_china
									context = tributary
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 100
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = dislikes_tt }
							}
						}
					}
					if = {
						limit = {
							liked_by_offmap = {
								type = offmap_china
								context = tributary
							}
							disliked_by_offmap = {
								type = offmap_china
								context = tributary
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 200
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = likes_but_dislikes_tt }
							}
						}
					}
					if = {
						limit = {
							NOR = {
								liked_by_offmap = {
									type = offmap_china
									context = tributary
								}
								disliked_by_offmap = {
									type = offmap_china
									context = tributary
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 200
						}
					}
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0
			#modifier = {
			#	factor = 0.01 # slow down
			#}
			#modifier = { realm_levy_diff = { who = FROM value = 2000 } factor = 1.5 }
			#modifier = { realm_levy_diff = { who = FROM value = 5000 } factor = 3 }
		}
	}
	
	chinese_grace_supply_horses = {
		only_playable = yes
		button_name = offmap_gifts
		ai_check_interval = 36
    
		potential = {
			is_offmap_tag = offmap_china
		}
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
			is_nomadic = yes
		}
    
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				is_nomadic = yes
				custom_tooltip = {
					text = chinese_grace_supply_horses_not_already_supplying_tt
					NOT = {
						has_character_modifier = china_supply_horses
					}
				}
				custom_tooltip = {
					text = chinese_grace_supply_horses_stopped_supplying_tt
					NOT = {
						has_character_flag = stopped_supplying_horses
					}
				}
				war = no
				OR = {
					custom_tooltip = { #Borders the Western Governate
						text = chinese_grace_become_tributary_allow_governor_neighbor_tt
						any_neighbor_independent_ruler = {
							has_landed_title = e_china_west_governor
						}
					}
					custom_tooltip = { #Borders a Chinese tributary
						text = chinese_grace_become_tributary_allow_tributary_neighbor_tt
						any_neighbor_independent_ruler = {
							suzerain = {
								has_landed_title = e_china_west_governor
							}
						}
					}
					custom_tooltip = { #Borders the eastern edge of the map
						text = chinese_grace_become_tributary_allow_chinese_influence_tt
						any_realm_province = {
							region = custom_chinese_invasion_target_region
						}
					}
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			china_offmap_tribute_decisions_enabled_trigger = yes
		}
    
		effect = {
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.3040 } } } }
			FROM = {
				sound_effect = china_grace_gain
				tooltip = {
					add_character_modifier = {
						name = china_supply_horses
						duration = -1
						inherit = yes
					}
					if = {
						limit = {
							liked_by_offmap = {
								type = offmap_china
							}
							NOT = {
								disliked_by_offmap = {
									type = offmap_china
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 150
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = likes_tt }
							}
						}
					}
					if = {
						limit = {
							disliked_by_offmap = {
								type = offmap_china
							}
							NOT = {
								liked_by_offmap = {
									type = offmap_china
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 50
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = dislikes_tt }
							}
						}
					}
					if = {
						limit = {
							liked_by_offmap = {
								type = offmap_china
							}
							disliked_by_offmap = {
								type = offmap_china
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 150
						}
						e_china_west_governor = {
							show_scope_change = no
							offmap_power = {
								show_scope_change = no
								custom_tooltip = { text = likes_but_dislikes_tt }
							}
						}
					}
					if = {
						limit = {
							NOR = {
								liked_by_offmap = {
									type = offmap_china
								}
								disliked_by_offmap = {
									type = offmap_china
								}
							}
						}
						add_offmap_currency = {
							offmap = offmap_china
							value = 100
						}
					}
				}
			}
		}
    
		revoke_allowed = {
			always = no
		}
    
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				FROM = {
					NOR = {
						trait = humble
						trait = shy
						trait = craven
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = ambitious
						trait = proud
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					primary_title = {
						title = e_mongol_empire
					}
				}
			}
		}
	}
	
	chinese_grace_stop_supply_horses = {
		only_playable = yes
		button_name = offmap_gifts
		ai_check_interval = 36
    
		potential = {
			is_offmap_tag = offmap_china
		}
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
			has_character_modifier = china_supply_horses
		}
    
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				has_character_modifier = china_supply_horses
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			#china_offmap_tribute_decisions_enabled_trigger = yes
		}
    
		effect = {
			#hidden_effect = { offmap_china = { governor = { character_event = { id = JD.3040 } } } }
			FROM = {
				sound_effect = china_angered_emperor
				set_character_flag = stopped_supplying_horses
				remove_character_modifier = china_supply_horses
				if = {
					limit = {
						liked_by_offmap = {
							type = offmap_china
						}
						NOT = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = -150
					}
					e_china_west_governor = {
						show_scope_change = no
						offmap_power = {
							show_scope_change = no
							custom_tooltip = { text = likes_tt }
						}
					}
				}
				if = {
					limit = {
						disliked_by_offmap = {
							type = offmap_china
						}
						NOT = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = -50
					}
					e_china_west_governor = {
						show_scope_change = no
						offmap_power = {
							show_scope_change = no
							custom_tooltip = { text = dislikes_tt }
						}
					}
				}
				if = {
					limit = {
						liked_by_offmap = {
							type = offmap_china
						}
						disliked_by_offmap = {
							type = offmap_china
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = -150
					}
					e_china_west_governor = {
						show_scope_change = no
						offmap_power = {
							show_scope_change = no
							custom_tooltip = { text = likes_but_dislikes_tt }
						}
					}
				}
				if = {
					limit = {
						NOR = {
							liked_by_offmap = {
								type = offmap_china
							}
							disliked_by_offmap = {
								type = offmap_china
							}
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = -100
					}
				}
			}
		}
    
		revoke_allowed = {
			always = no
		}
    
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = humble
						trait = shy
						trait = craven
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					NOR = {
						trait = proud
						trait = ambitious
						trait = brave
					}
				}
			}
		}
	}

	chinese_grace_offer_eunuch = {
		only_playable = yes
		button_name = offmap_gifts
		
		third_party_filter = home_court
		ai_third_party_filter = home_court
		third_party = FROM
		ai_check_interval = 36
		show_third_party_potential = yes

		potential = {
			is_offmap_tag = offmap_china
			OR = {
				ai = no
				china_offmap_tribute_decisions_enabled_trigger = yes # Allow is checked for each valid 3rd party, so it is cheaper to check it here for the AI
			}
		}
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				custom_tooltip = {
					text = china_tribute_send_eunuch_cooldown_tt
					NOT = { has_character_modifier = chinese_grace_send_eunuch_timer }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			tooltip = { china_offmap_tribute_decisions_enabled_trigger = yes }
			hidden_tooltip = {
				OR = { 
					ai = yes
					china_offmap_tribute_decisions_enabled_trigger = yes # AI has already checked this in the potential
				}
			}
		}
		
		third_party_potential = {
			show_only_failed_conditions = yes
			FROMFROM = {
				show_scope_change = no
				custom_tooltip = {
					text = is_landless_male_tt
					NOT = { is_landed = yes }
					NOT = { is_ruler = yes }
					NOT = { is_female = yes }
					NOT = { is_patrician = yes }
				}
				custom_tooltip = {
					text = adult_or_close_relative_of_12_years_tt
					OR = {
						is_adult = yes
						AND = {
							is_close_relative = ROOT_FROM
							age = 12
						}
					}
				}
				
				NOT = { is_heir = yes }

				custom_tooltip = {
					text = not_married_or_getting_married_tt
					NOT = { is_betrothed = yes }
					NOT = { is_married = yes }
				}
				custom_tooltip = { #can't be from China
					text = is_not_from_china_tt
					NOT = {	has_character_flag = eunuch_gift }
					courtier_from_china_trigger = no
				}
				custom_tooltip = {
					text = is_not_incapable_inbred_or_imbecile_tt
					NOT = { trait = incapable }
					NOT = { trait = inbred }
					NOT = { trait = imbecile }
				}
				custom_tooltip = {
					text = is_not_maimed_or_infirm_tt
					NOT = { trait = maimed }
					NOT = { trait = infirm }
				}
				custom_tooltip = {
					text = is_not_wounded_severely_injured_tt
					NOT = { trait = wounded }
					NOT = { trait = severely_injured }
				}
				custom_tooltip = {
					text = is_not_one_eyed_handed_legged_disfigured_or_mangled_tt
					NOT = { trait = one_eyed }
					NOT = { trait = one_handed }
					NOT = { trait = one_legged }
					NOT = { trait = disfigured }
					NOT = { trait = mangled }
				}
				NOT = { prisoner = yes }

				OR = {
					custom_tooltip = {
						text = is_close_relative_tt
						is_close_relative = ROOT_FROM
					}
					custom_tooltip = {
						text = china_tribute_send_eunuch_stats_tt
						OR = {
							diplomacy = 20
							martial = 20
							stewardship = 20
							intrigue = 20
							learning = 20
						}
					}
					custom_tooltip = {
						text = china_tribute_send_eunuch_congenital_tt
						OR = {
							trait = strong
							trait = genius
							trait = quick
							trait = fair
						}
					}
					custom_tooltip = {
						text = china_tribute_send_eunuch_non_inherit_congenital_tt
						OR = {
							trait = robust
							trait = shrewd
						}
					}
					custom_tooltip = {
						text = has_the_right_eunuch_traits_tt
						OR = {
							trait = architect
							trait = administrator
							trait = strategist
							trait = scholar
							trait = faqih						
						}
					}
				}
			}
		}
		
		third_party_allow = {
			show_only_failed_conditions = yes
			FROMFROM = {
				is_ill = no
				is_inaccessible_trigger = no
			}
		}
		
		third_party_score = {
			factor = 100
			
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					diplomacy = 8					
					hidden_trigger = {
						NOT = { diplomacy = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					diplomacy = 12					
					hidden_trigger = {
						NOT = { diplomacy = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					diplomacy = 16				
					hidden_trigger = {
						NOT = { diplomacy = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					diplomacy = 20
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					martial = 8					
					hidden_trigger = {
						NOT = { martial = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					martial = 12					
					hidden_trigger = {
						NOT = { martial = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = {
					show_scope_change = no 
					martial = 16				
					hidden_trigger = {
						NOT = { martial = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					martial = 20
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					stewardship = 8					
					hidden_trigger = {
						NOT = { stewardship = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					stewardship = 12					
					hidden_trigger = {
						NOT = { stewardship = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					stewardship = 16				
					hidden_trigger = {
						NOT = { stewardship = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					stewardship = 20
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					intrigue = 8					
					hidden_trigger = {
						NOT = { intrigue = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					intrigue = 12					
					hidden_trigger = {
						NOT = { intrigue = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					intrigue = 16				
					hidden_trigger = {
						NOT = { intrigue = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					intrigue = 20
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					learning = 8					
					hidden_trigger = {
						NOT = { learning = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					learning = 12					
					hidden_trigger = {
						NOT = { learning = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					learning = 16				
					hidden_trigger = {
						NOT = { learning = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					learning = 20
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = fair
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					trait = groomed
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = genius
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = { 
					show_scope_change = no
					trait = quick
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					trait = strong
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = {
					show_scope_change = no
					trait = robust
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = {
					show_scope_change = no
					trait = shrewd
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = architect
				}
			}
			additive_modifier = {
				value = 60
				FROMFROM = { 
					show_scope_change = no
					trait = administrator
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = strategist
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = scholar
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = faqih
				}
			}
			additive_modifier = {
				value = 25
				custom_tooltip = {
					text = tribute_interaction_level3_education_tt
					FROMFROM = { 
						OR = {
							trait = intricate_webweaver
							trait = charismatic_negotiator
							trait = fortune_builder
							trait = skilled_tactician
							trait = scholarly_theologian
						}
					}
				}
			}
			additive_modifier = {
				value = 50
				custom_tooltip = {
					text = tribute_interaction_level4_education_tt
					FROMFROM = { 
						OR = {
							trait = elusive_shadow
							trait = grey_eminence
							trait = midas_touched
							trait = brilliant_strategist
							trait = mastermind_theologian
						}
					}
				}
			}
			additive_modifier = {
				value = 60
				FROMFROM = {
					show_scope_change = no
					is_adult = no
				}
			}
			modifier = {
				factor = 2.0
				OR = {
					offmap_china = {
						show_scope_change = no 
						offmap_has_like = likes_eunuchs
					}
				}
			}
			modifier = {
				factor = 2.0
				FROMFROM = {
					show_scope_change = no 
					liked_by_offmap = {
			            type = offmap_china
			        }
				}
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					show_scope_change = no 
					offmap_has_dislike = likes_eunuchs
				}
			}
			modifier = {
				factor = 0.5
				FROMFROM = {
					show_scope_change = no 
					disliked_by_offmap = {
				        type = offmap_china
				    }
				}
			}
			modifier = {
				factor = 1.5
				FROM = { 
					show_scope_change = no
					liked_by_offmap = {
						type = offmap_china
					}
				}
			}
			modifier = {
				factor = 0.66
				FROM = {
					show_scope_change = no 
					disliked_by_offmap = {
						type = offmap_china
					}
				}
			}
		}
	
		effect = {
			save_event_target_as = target_governor
			FROM = {
				sound_effect = china_grace_gain
				save_event_target_as = target_tribute_sender
			}
			FROMFROM = {
				save_event_target_as = person_sent_as_tribute
			}
			#if = {
			#	limit = {
			#		FROMFROM = { disliked_by_offmap = offmap_china }
			#	}
			#	custom_tooltip = { text = notification_china_dislike_tt }
			#}
			#if = {
			#	limit = {
			#		NOT = { FROMFROM = { disliked_by_offmap = offmap_china } }
			#		FROMFROM = { liked_by_offmap = offmap_china }
			#	}
			#	custom_tooltip = { text = notification_china_like_tt }
			#}
			FROM = {
				show_scope_change = no
				add_offmap_currency = {
					offmap = offmap_china
					value = local_third_party_score
				}
				hidden_effect = {
					if = {
						limit = {
							ai = no
						}
						set_character_flag = achievement_snipped_off_to_china
					}
				}
			}
			
			# Like/Dislike effect description
			#################################
			if = {
				limit = {
					OR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
					}
					NOR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = likes_tt }
					}
				}
			}
			
			if = {
				limit = {
					OR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
					}
					NOR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = dislikes_tt }
					}
				}
			}
			if = {
				limit = {
					OR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
					}
					OR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = eunuch
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = likes_but_dislikes_tt }
					}
				}
			}
			#################################
			
			FROMFROM = {
				show_scope_change = no
				hidden_effect = {
					if = {
						limit = {
							NOT = {
								trait = eunuch
							}
						}
						add_trait = eunuch
					}
				}
				leave_court_for_china_effect = yes
			}
			hidden_effect = {
				FROM = {
					add_character_modifier = {
						modifier = chinese_grace_send_eunuch_timer
						hidden = yes
						years = 20
					
					}
					if = {
						limit = { local_third_party_score_low_trigger = yes }
						set_character_flag = sent_bad_tribute
					}
					if = {
						limit = { local_third_party_score_medium_trigger = yes }
						set_character_flag = sent_decent_tribute
					}
					if = {
						limit = { local_third_party_score_great_trigger = yes }
						set_character_flag = sent_great_tribute
					}
					set_character_flag = sent_eunuch_tribute
					letter_event = { id = JD.10050 days = 5 random = 2 }
				}
			}
		}
	
		revoke_allowed = {
			always = no
		}
	
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.3 # slow down
			}
		}
	}
	
	chinese_grace_offer_concubine = {
		only_playable = yes
		button_name = offmap_gifts
		
		third_party_filter = home_court
		ai_third_party_filter = home_court
		third_party = FROM
		ai_check_interval = 20
		show_third_party_potential = yes

		potential = {
			is_offmap_tag = offmap_china
			OR = {
				ai = no
				china_offmap_tribute_decisions_enabled_trigger = yes # Allow is checked for each valid 3rd party, so it is cheaper to check it here for the AI
			}
		}
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				custom_tooltip = {
					text = china_tribute_send_concubine_cooldown_tt
					NOT = { has_character_modifier = chinese_grace_send_concubine_timer }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			tooltip = { china_offmap_tribute_decisions_enabled_trigger = yes }
			hidden_tooltip = {
				OR = { 
					ai = yes
					china_offmap_tribute_decisions_enabled_trigger = yes # AI has already checked this in the potential
				}
			}
		}
							
		third_party_potential = {
			show_only_failed_conditions = yes
			custom_tooltip = {
				text = china_tribute_send_concubine_preference_tt
				OR = {
					AND = {
						offmap_china = {
							offmap_ruler = {
								is_female = yes
							}
						}
						FROMFROM = {
							is_female = no
						}
					}
					AND = {
						offmap_china = {
							offmap_ruler = {
								is_female = no
							}
						}
						FROMFROM = {
							is_female = yes
						}
					}
				}
			}
			FROMFROM = {
				show_scope_change = no
				custom_tooltip = {
					text = is_close_relative_or_same_dynasty_tt
					OR = {
						is_close_relative = ROOT_FROM
						dynasty = ROOT_FROM
					}
				}
				custom_tooltip = {
					text = is_adult_under_45_tt
					is_adult = yes
					NOT = { age = 45 }
				}
				NOT = { is_landed = yes }
				NOT = { is_ruler = yes }
				NOT = { is_heir = yes }
				custom_tooltip = {
					text = not_married_or_getting_married_tt
					NOT = { is_betrothed = yes }
					NOT = { is_married = yes }
				}
				custom_tooltip = {
					text = is_not_from_china_tt
					courtier_from_china_trigger = no
				}
				custom_tooltip = {
					text = is_not_incapable_inbred_or_imbecile_tt
					NOT = { trait = incapable }
					NOT = { trait = inbred }
					NOT = { trait = imbecile }
				}
				custom_tooltip = {
					text = is_not_maimed_or_infirm_tt
					NOT = { trait = maimed }
					NOT = { trait = infirm }
				}
				custom_tooltip = {
					text = is_not_wounded_severely_injured_tt
					NOT = { trait = wounded }
					NOT = { trait = severely_injured }
				}
				custom_tooltip = {
					text = is_not_one_eyed_handed_legged_disfigured_or_mangled_tt
					NOT = { trait = one_eyed }
					NOT = { trait = one_handed }
					NOT = { trait = one_legged }
					NOT = { trait = disfigured }
					NOT = { trait = mangled }
				}
				NOT = { prisoner = yes }
				custom_tooltip = {
					text = is_not_ascetic_or_celibate_tt
					NOT = { is_ascetic_trigger = yes }
					NOT = { trait = celibate }
				}
			}
		}
		
		third_party_allow = {
			show_only_failed_conditions = yes
			FROMFROM = {
				is_ill = no
				is_inaccessible_trigger = no
			}
		}
		
		third_party_score = {
			factor = 100
			
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					diplomacy = 8					
					hidden_trigger = {
						NOT = { diplomacy = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					diplomacy = 12					
					hidden_trigger = {
						NOT = { diplomacy = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					diplomacy = 16				
					hidden_trigger = {
						NOT = { diplomacy = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					diplomacy = 20
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					martial = 8					
					hidden_trigger = {
						NOT = { martial = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					martial = 12					
					hidden_trigger = {
						NOT = { martial = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					martial = 16				
					hidden_trigger = {
						NOT = { martial = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					martial = 20
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					stewardship = 8					
					hidden_trigger = {
						NOT = { stewardship = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					stewardship = 12					
					hidden_trigger = {
						NOT = { stewardship = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					stewardship = 16				
					hidden_trigger = {
						NOT = { stewardship = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					stewardship = 20
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					intrigue = 8					
					hidden_trigger = {
						NOT = { intrigue = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					intrigue = 12					
					hidden_trigger = {
						NOT = { intrigue = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					intrigue = 16				
					hidden_trigger = {
						NOT = { intrigue = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					intrigue = 20
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					learning = 8					
					hidden_trigger = {
						NOT = { learning = 12 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					learning = 12					
					hidden_trigger = {
						NOT = { learning = 16 }
					}
				}
			}
			additive_modifier = {
				value = 75
				FROMFROM = { 
					show_scope_change = no
					learning = 16				
					hidden_trigger = {
						NOT = { learning = 20 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = { 
					show_scope_change = no
					learning = 20
				}
			}
			additive_modifier = {
				value = 80
				FROMFROM = { 
					show_scope_change = no
					trait = fair
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = groomed
				}
			}
			additive_modifier = {
				value = -80
				FROMFROM = { 
					show_scope_change = no
					trait = ugly
				}
			}
			additive_modifier = {
				value = -40
				FROMFROM = { 
					show_scope_change = no
					trait = uncouth
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = genius
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = { 
					show_scope_change = no
					trait = quick
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = strong
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = {
					show_scope_change = no
					trait = robust
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = {
					show_scope_change = no
					trait = shrewd
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = {
					show_scope_change = no
					trait = charitable
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = {
					show_scope_change = no
					trait = gregarious
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = {
					show_scope_change = no
					trait = kind
				}
			}
			additive_modifier = {
				value = -50
				FROMFROM = {
					show_scope_change = no
					trait = lunatic
				}
			}
			additive_modifier = {
				value = 25
				custom_tooltip = {
					text = tribute_interaction_level3_education_tt
					FROMFROM = { 
						OR = {
							trait = intricate_webweaver
							trait = charismatic_negotiator
							trait = fortune_builder
							trait = skilled_tactician
							trait = scholarly_theologian
						}
					}
				}
			}
			additive_modifier = {
				value = 50
				custom_tooltip = {
					text = tribute_interaction_level4_education_tt
					FROMFROM = { 
						OR = {
							trait = elusive_shadow
							trait = grey_eminence
							trait = midas_touched
							trait = brilliant_strategist
							trait = mastermind_theologian
						}
					}
				}
			}
			modifier = {
				factor = 2.0
				OR = {
					offmap_china = {
						show_scope_change = no 
						offmap_has_like = likes_concubines
					}
				}
			}
			modifier = {
				factor = 2.0
				FROMFROM = {
					show_scope_change = no 
					liked_by_offmap = {
			            type = offmap_china
			        }
				}
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					show_scope_change = no 
					offmap_has_dislike = likes_concubines
				}
			}
			modifier = {
				factor = 0.5
				FROMFROM = {
					show_scope_change = no 
					disliked_by_offmap = {
				        type = offmap_china
				    }
				}
			}
			modifier = {
				factor = 1.5
				FROM = { 
					show_scope_change = no
					liked_by_offmap = {
						type = offmap_china
					}
				}
			}
			modifier = {
				factor = 0.66
				FROM = {
					show_scope_change = no 
					disliked_by_offmap = {
						type = offmap_china
					}
				}
			}
		}
	
		effect = {
			save_event_target_as = target_governor
			FROM = {
				sound_effect = china_grace_gain
				save_event_target_as = target_tribute_sender
			}
			FROMFROM = {
				save_event_target_as = person_sent_as_tribute
			}
			#if = {
			#	limit = {
			#		FROMFROM = { disliked_by_offmap = offmap_china }
			#	}
			#	custom_tooltip = { text = notification_china_dislike_tt }
			#}
			#if = {
			#	limit = {
			#		NOT = { FROMFROM = { disliked_by_offmap = offmap_china } }
			#		FROMFROM = { liked_by_offmap = offmap_china }
			#	}
			#	custom_tooltip = { text = notification_china_like_tt }
			#}
			
			FROM = {
				show_scope_change = no
				add_offmap_currency = {
					offmap = offmap_china
					value = local_third_party_score
				}
			}
			
			# Like/Dislike effect description
			#################################
			if = {
				limit = {
					OR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
					}
					NOR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = likes_tt }
					}
				}
			}
			
			if = {
				limit = {
					OR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
					}
					NOR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = dislikes_tt }
					}
				}
			}
			if = {
				limit = {
					OR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
					}
					OR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
								context = concubine
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = likes_but_dislikes_tt }
					}
				}
			}
			#################################
			
			
			FROMFROM = {
				show_scope_change = no
				leave_court_for_china_effect = yes
			}
			hidden_effect = {
				FROM = {
					add_character_modifier = {
						modifier = chinese_grace_send_concubine_timer
						hidden = yes
						years = 20
					
					}
					if = {
						limit = { local_third_party_score_low_trigger = yes }
						set_character_flag = sent_bad_tribute
					}
					if = {
						limit = { local_third_party_score_medium_trigger = yes }
						set_character_flag = sent_decent_tribute
					}
					if = {
						limit = { local_third_party_score_great_trigger = yes }
						set_character_flag = sent_great_tribute
					}
					set_character_flag = sent_concubine_tribute
					letter_event = { id = JD.10050 days = 5 random = 2 }
				}
			}
		}
	
		revoke_allowed = {
			always = no
		}
	
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5 # slow down
			}
		}
	}
	
	chinese_grace_offer_commander = {
		only_playable = yes
		button_name = offmap_gifts
		
		third_party_filter = home_court
		ai_third_party_filter = home_court
		third_party = FROM
		ai_check_interval = 36
		show_third_party_potential = yes

		potential = {
			is_offmap_tag = offmap_china
			OR = {
				offmap_china = { has_status = china_unrest }
				offmap_china = { has_status = china_civil_war }
				offmap_china = { has_status = china_mongol_invasion }
				offmap_china = { has_status = china_jurchen_invasion }
			}
		}
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		allow = {
			show_only_failed_conditions = yes
			offmap_china = {
				OR = {
					has_status = china_unrest
					has_status = china_civil_war
					has_status = china_mongol_invasion
					has_status = china_jurchen_invasion
				}
			}
			FROM = {
				show_scope_change = no
				custom_tooltip = {
					text = china_tribute_send_commander_cooldown_tt
					NOT = { has_character_modifier = chinese_grace_send_commander_timer }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			china_offmap_tribute_decisions_enabled_trigger = yes
		}
		
		third_party_potential = {
			show_only_failed_conditions = yes
			FROMFROM = {
				show_scope_change = no

				is_adult = yes
				martial = 12
				is_heir = no
				NOT = { is_landed = yes }
				NOT = { is_ruler = yes }
				custom_tooltip = {
					text = not_married_or_getting_married_tt
					NOT = { is_betrothed = yes }
					NOT = { is_married = yes }
				}
				custom_tooltip = {
					text = is_not_from_china_tt
					courtier_from_china_trigger = no
				}
				custom_tooltip = {
					text = is_not_incapable_inbred_or_imbecile_tt
					NOT = { trait = incapable }
					NOT = { trait = inbred }
					NOT = { trait = imbecile }
				}
				custom_tooltip = {
					text = is_not_maimed_or_infirm_tt
					NOT = { trait = maimed }
					NOT = { trait = infirm }
				}

				NOT = { prisoner = yes }
				
				OR = {
					is_female = no
					has_minor_title = title_commander
					has_game_rule = {
						name = gender
						value = all
					}
				}
			}
		}

		third_party_allow = {
			show_only_failed_conditions = yes
			FROMFROM = {
				is_ill = no
				custom_tooltip = {
					text = is_not_wounded_severely_injured_tt
					NOT = { trait = wounded }
					NOT = { trait = severely_injured }
				}
				is_inaccessible_trigger = no
			}
		}
		
		third_party_score = {
			factor = 100
			
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					martial = 12					
					hidden_trigger = {
						NOT = { martial = 14 }
					}
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					martial = 14					
					hidden_trigger = {
						NOT = { martial = 16 }
					}
				}
			}
			additive_modifier = {
				value = 60
				FROMFROM = {
					show_scope_change = no 
					martial = 16				
					hidden_trigger = {
						NOT = { martial = 18 }
					}
				}
			}
			additive_modifier = {
				value = 80
				FROMFROM = {
					show_scope_change = no 
					martial = 18				
					hidden_trigger = {
						NOT = { martial = 20 }
					}
				}
			}
			additive_modifier = {
				value = 100
				FROMFROM = {
					show_scope_change = no 
					martial = 20				
					hidden_trigger = {
						NOT = { martial = 22 }
					}
				}
			}
			additive_modifier = {
				value = 120
				FROMFROM = {
					show_scope_change = no 
					martial = 22				
					hidden_trigger = {
						NOT = { martial = 24 }
					}
				}
			}
			additive_modifier = {
				value = 140
				FROMFROM = { 
					show_scope_change = no
					martial = 24
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = genius
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = { 
					show_scope_change = no
					trait = quick
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = strong
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = {
					show_scope_change = no
					trait = robust
				}
			}
			additive_modifier = {
				value = 30
				FROMFROM = {
					show_scope_change = no
					trait = shrewd
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = strategist
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = duelist
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					trait = hunter
				}
			}
			additive_modifier = {
				value = 100
				FROMFROM = { 
					show_scope_change = no
					trait = berserker
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = adventurer
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					trait = patient
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					trait = brave
				}
			}
			additive_modifier = {
				value = 20
				FROMFROM = { 
					show_scope_change = no
					trait = diligent
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = shieldmaiden
				}
			}
		
			additive_modifier = {
				value = 50
				FROMFROM = { 
					show_scope_change = no
					trait = sapper
				}
			}
			additive_modifier = {
				value = 50
				FROMFROM = { 
					show_scope_change = no
					trait = master_of_flame
				}
			}
			additive_modifier = {
				value = 50
				FROMFROM = { 
					show_scope_change = no
					trait = logistics_expert
				}
			}
			additive_modifier = {
				value = 50
				FROMFROM = { 
					show_scope_change = no
					trait = levy_coordinator
				}
			}
			
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = light_foot_leader
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = heavy_infantry_leader
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = cavalry_leader
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = inspiring_leader
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = trickster
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = organizer
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = defensive_leader
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = experimenter
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = flanker
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = aggressive_leader
				}
			}
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					trait = siege_leader
				}
			}
			
			
			additive_modifier = {
				value = 25
				custom_tooltip = {
					text = tribute_interaction_level3_education_tt
					FROMFROM = { 
						trait = skilled_tactician
					}
				}
			}
			additive_modifier = {
				value = 50
				custom_tooltip = {
					text = tribute_interaction_level4_education_tt
					FROMFROM = { 
						trait = brilliant_strategist
					}
				}
			}
			modifier = {
				factor = 2.0
				FROMFROM = { 
					show_scope_change = no
					liked_by_offmap = {
						type = offmap_china
					}
				}
			}
			modifier = {
				factor = 0.5
				FROMFROM = {
					show_scope_change = no 
					disliked_by_offmap = {
						type = offmap_china
					}
				}
			}
			modifier = {
				factor = 1.5
				FROM = { 
					show_scope_change = no
					liked_by_offmap = {
						type = offmap_china
					}
				}
			}
			modifier = {
				factor = 0.66
				FROM = {
					show_scope_change = no 
					disliked_by_offmap = {
						type = offmap_china
					}
				}
			}
		}
	
		effect = {
			save_event_target_as = target_governor
			FROM = {
				sound_effect = china_grace_gain
				save_event_target_as = target_tribute_sender
			}
			FROMFROM = {
				save_event_target_as = person_sent_as_tribute
			}
			#if = {
			#	limit = {
			#		FROMFROM = { disliked_by_offmap = offmap_china }
			#	}
			#	custom_tooltip = { text = notification_china_dislike_tt }
			#}
			#if = {
			#	limit = {
			#		NOT = { FROMFROM = { disliked_by_offmap = offmap_china } }
			#		FROMFROM = { liked_by_offmap = offmap_china }
			#	}
			#	custom_tooltip = { text = notification_china_like_tt }
			#}
			FROM = {
				show_scope_change = no
				add_offmap_currency = {
					offmap = offmap_china
					value = local_third_party_score
				}
			}
			
			# Like/Dislike effect description
			#################################
			if = {
				limit = {
					OR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
					}
					NOR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = likes_tt }
					}
				}
			}
			
			if = {
				limit = {
					OR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
					}
					NOR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = dislikes_tt }
					}
				}
			}
			if = {
				limit = {
					OR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
						FROMFROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
					}
					OR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
						FROMFROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = likes_but_dislikes_tt }
					}
				}
			}
			#################################
			
			FROMFROM = {
				show_scope_change = no
				leave_court_for_china_effect = yes
			}
			hidden_effect = {
				FROM = {
					add_character_modifier = {
						modifier = chinese_grace_send_commander_timer
						hidden = yes
						years = 20
					}
					if = {
						limit = { local_third_party_score_low_trigger = yes }
						set_character_flag = sent_bad_tribute
					}
					if = {
						limit = { local_third_party_score_medium_trigger = yes }
						set_character_flag = sent_decent_tribute
					}
					if = {
						limit = { local_third_party_score_great_trigger = yes }
						set_character_flag = sent_great_tribute
					}
					letter_event = { id = JD.10050 days = 5 random = 2 }
				}
			}
		}
	
		revoke_allowed = {
			always = no
		}
	
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.3 # slow down
			}
		}
	}
	
	chinese_grace_offer_physician = {
		only_playable = yes
		button_name = offmap_gifts
		
		third_party_filter = all
		ai_third_party_filter = home_court
		third_party = FROM
		ai_check_interval = 36
		show_third_party_potential = yes

		potential = {
			is_offmap_tag = offmap_china
			offmap_china = { has_status = china_plague }
		}
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				custom_tooltip = {
					text = china_tribute_send_physician_tt
					NOT = { has_character_flag = chinese_grace_physician_sent }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			china_offmap_tribute_decisions_enabled_trigger = yes
		}
		
		third_party_potential = {
			show_only_failed_conditions = yes
			FROMFROM = {
				hidden_tooltip = {
					liege = {
						character = ROOT_FROM
					}
				}
				show_scope_change = no
				NOT = { is_ruler = yes }
				is_adult = yes
				is_heir = no
				custom_tooltip = {
					text = not_married_or_getting_married_tt
					NOT = { is_betrothed = yes }
					NOT = { is_married = yes }
				}
				custom_tooltip = {
					text = is_not_from_china_tt
					courtier_from_china_trigger = no
				}
				custom_tooltip = {
					text = is_not_incapable_inbred_or_imbecile_tt
					NOT = { trait = incapable }
					NOT = { trait = inbred }
					NOT = { trait = imbecile }
				}
				custom_tooltip = {
					text = is_not_maimed_or_infirm_tt
					NOT = { trait = maimed }
					NOT = { trait = infirm }
				}
				OR = {
					conditional_tooltip = {
						trigger = {
							has_dlc = Reapers
						}
						has_minor_title = title_court_physician 
					}
					trait = physician
					trait = scholar
					trait = mystic
				}
			}
		}
		
		third_party_allow = {
			show_only_failed_conditions = yes
			FROMFROM = {
				is_ill = no
				custom_tooltip = {
					text = is_not_wounded_severely_injured_tt
					NOT = { trait = wounded }
					NOT = { trait = severely_injured }
				}
				is_inaccessible_trigger = no
				NOT = { is_landed = yes }
			}
		}
		
		third_party_score = {
			factor = 100
			
			additive_modifier = {
				value = -50
				FROMFROM = { 
					show_scope_change = no
					NOT = { learning = 8 }
				}
			}
			
			additive_modifier = {
				value = 40
				FROMFROM = { 
					show_scope_change = no
					learning = 8					
					hidden_trigger = {
						NOT = { learning = 12 }
					}
				}
			}
			additive_modifier = {
				value = 60
				FROMFROM = { 
					show_scope_change = no
					learning = 12					
					hidden_trigger = {
						NOT = { learning = 16 }
					}
				}
			}
			additive_modifier = {
				value = 100
				FROMFROM = { 
					show_scope_change = no
					learning = 16				
					hidden_trigger = {
						NOT = { learning = 20 }
					}
				}
			}
			additive_modifier = {
				value = 140
				FROMFROM = { 
					show_scope_change = no
					learning = 20				
					hidden_trigger = {
						NOT = { learning = 24 }
					}
				}
			}
			additive_modifier = {
				value = 180
				FROMFROM = { 
					show_scope_change = no
					learning = 24				
					hidden_trigger = {
						NOT = { learning = 28 }
					}
				}
			}
			additive_modifier = {
				value = 220
				FROMFROM = { 
					show_scope_change = no
					learning = 28				
					hidden_trigger = {
						NOT = { learning = 32 }
					}
				}
			}
			additive_modifier = {
				value = 260
				FROMFROM = { 
					show_scope_change = no
					learning = 32
				}
			}
			additive_modifier = {
				value = 100
				FROMFROM = { 
					show_scope_change = no
					trait = genius
				}
			}
			additive_modifier = {
				value = 50
				FROMFROM = { 
					show_scope_change = no
					trait = quick
				}
			}
			additive_modifier = {
				value = 50
				FROMFROM = {
					show_scope_change = no
					trait = shrewd
				}
			}
			additive_modifier = {
				value = 150
				FROMFROM = { 
					show_scope_change = no
					trait = physician
				}
			}
			additive_modifier = {
				value = 50
				FROMFROM = { 
					show_scope_change = no
					trait = mystic
				}
			}
			additive_modifier = {
				value = 50
				FROMFROM = { 
					show_scope_change = no
					trait = scholar
				}
			}
			additive_modifier = {
				value = 25
				trait = scholarly_theologian
			}
			additive_modifier = {
				value = 50
				trait = mastermind_theologian
			}
			additive_modifier = {
				value = 25
				trait = patient
			}
			additive_modifier = {
				value = 25
				trait = diligent
			}
			modifier = {
				factor = 1.5
				FROM = { 
					show_scope_change = no
					liked_by_offmap = {
						type = offmap_china
					}
				}
			}
			modifier = {
				factor = 0.66
				FROM = {
					show_scope_change = no 
					disliked_by_offmap = {
						type = offmap_china
					}
				}
			}
		}
	
		effect = {
			save_event_target_as = target_governor
			FROM = {
				sound_effect = china_grace_gain
				save_event_target_as = target_tribute_sender
			}
			FROMFROM = {
				save_event_target_as = person_sent_as_tribute
			}
			#if = {
			#	limit = {
			#		FROMFROM = { disliked_by_offmap = offmap_china }
			#	}
			#	custom_tooltip = { text = notification_china_dislike_tt }
			#}
			#if = {
			#	limit = {
			#		NOT = { FROMFROM = { disliked_by_offmap = offmap_china } }
			#		FROMFROM = { liked_by_offmap = offmap_china }
			#	}
			#	custom_tooltip = { text = notification_china_like_tt }
			#}
			FROM = {
				show_scope_change = no
				add_offmap_currency = {
					offmap = offmap_china
					value = local_third_party_score
				}
			}
			
			FROMFROM = {
				show_scope_change = no
				leave_court_for_china_effect = yes
			}
			hidden_effect = {
				FROM = {
					set_character_flag = chinese_grace_physician_sent
					if = {
						limit = { local_third_party_score_low_trigger = yes }
						set_character_flag = sent_bad_tribute
					}
					if = {
						limit = { local_third_party_score_medium_trigger = yes }
						set_character_flag = sent_decent_tribute
					}
					if = {
						limit = { local_third_party_score_great_trigger = yes }
						set_character_flag = sent_great_tribute
					}
					letter_event = { id = JD.10050 days = 5 random = 2 }
				}
			}
		}
	
		revoke_allowed = {
			always = no
		}
	
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.3 # slow down
			}
		}
	}
	
	chinese_grace_send_relief = {
		only_playable = yes
		button_name = offmap_gifts
		ai_check_interval = 60

		potential = {
			is_offmap_tag = offmap_china
			offmap_china = { has_status = china_famine }
		}

		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				is_nomadic = no
				is_tribal = no
				NOT = {
					has_character_modifier = china_send_relief
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			china_offmap_tribute_decisions_enabled_trigger = yes
		}

		effect = {
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.3010 } } } }
			FROM = {
				sound_effect = china_grace_gain
				add_character_modifier = {
					inherit = yes
					name = china_send_relief
					years = 10
				}
				if = {
					limit = {
						liked_by_offmap = {
							type = offmap_china
						}
						NOT = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = 750
					}
					e_china_west_governor = {
						show_scope_change = no
						offmap_power = {
							show_scope_change = no
							custom_tooltip = { text = likes_tt }
						}
					}
				}
				if = {
					limit = {
						disliked_by_offmap = {
							type = offmap_china
						}
						NOT = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = 250
					}
					e_china_west_governor = {
						show_scope_change = no
						offmap_power = {
							show_scope_change = no
							custom_tooltip = { text = dislikes_tt }
						}
					}
				}
				if = {
					limit = {
						liked_by_offmap = {
							type = offmap_china
						}
						disliked_by_offmap = {
							type = offmap_china
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = 500
					}
					e_china_west_governor = {
						show_scope_change = no
						offmap_power = {
							show_scope_change = no
							custom_tooltip = { text = likes_but_dislikes_tt }
						}
					}
				}
				if = {
					limit = {
						NOR = {
							liked_by_offmap = {
								type = offmap_china
							}
							disliked_by_offmap = {
								type = offmap_china
							}
						}
					}
					add_offmap_currency = {
						offmap = offmap_china
						value = 500
					}
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				FROM = {
					war = yes
				}
			}
			modifier = {
				factor = 0
				FROM = { independent = no }
			}
		}
	}
	
	chinese_grace_offer_artifact = {
		only_playable = yes
		button_name = offmap_gifts
		
		third_party_filter = artifacts
		ai_third_party_filter = artifacts
		third_party = FROM
		ai_check_interval = 60
		show_third_party_potential = yes
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			china_offmap_tribute_decisions_enabled_trigger = yes
		}
		
		third_party_potential = {
			show_only_failed_conditions = yes
			FROMFROM = {
				show_scope_change = no
				custom_tooltip = {
					text = send_artifact_potential_tt
					quality > 2
					NOR = {
						has_artifact_flag = flag_considering_donation 
						has_artifact_flag = curse
						has_artifact_flag = chinese
						AND = {
							FROM = { NOT = { has_landed_title = e_hre } }
							artifact_type = crown_hre
						}
						AND = {
							FROM = { NOT = { has_landed_title = e_byzantium } }
							artifact_type = crown_byzantine
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_norse_pagan_reformed } }
							artifact_type = crown_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_tengri_pagan_reformed } }
							artifact_type = crown_tengri_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_slavic_pagan_reformed } }
							artifact_type = crown_slavic_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_baltic_pagan_reformed } }
							artifact_type = crown_romuva_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_finnish_pagan_reformed } }
							artifact_type = crown_finnish_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_west_african_pagan_reformed } }
							artifact_type = crown_west_african_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_zun_pagan_reformed } }
							artifact_type = crown_zun_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = k_hellenic_pagan } }
							artifact_type = scepter_hellenic_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_bon_reformed } }
							artifact_type = scepter_bon_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = d_aztec_reformed } }
							artifact_type = crown_aztec_fylkir
						}
						AND = {
							FROM = { NOT = { has_landed_title = e_persia } }
							artifact_type = crown_pahlavi
						}
					}
				}
			}
		}
		
		third_party_allow = {
			
		}
		
		third_party_score = {
			factor = 500
			
			additive_modifier = {
				value = 4500
				FROMFROM = { 
					quality == 4
				}
			}
			additive_modifier = {
				value = 9500
				FROMFROM = { 
					quality == 5
				}
			}
			additive_modifier = {
				value = -200
				FROMFROM = {
					quality < 4
					has_artifact_flag = lore #Magnum Opus book
				}
			}
			additive_modifier = {
				value = -3000
				FROMFROM = {
					quality == 4
					has_artifact_flag = lore #Magnum Opus book
				}
			}
			additive_modifier = {
				value = -250
				FROMFROM = {
					quality < 4
					has_artifact_flag = created
				}
			}
			additive_modifier = {
				value = -3500
				FROMFROM = {
					quality == 4
					has_artifact_flag = created
				}
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					show_scope_change = no 
					offmap_has_like = likes_wealth
				}
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					show_scope_change = no 
					offmap_has_dislike = likes_wealth
				}
			}
			modifier = {
				factor = 1.5
				FROM = { 
					show_scope_change = no
					liked_by_offmap = {
						type = offmap_china
					}
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					show_scope_change = no 
					disliked_by_offmap = {
						type = offmap_china
					}
				}
			}
		}
	
		effect = {
			FROM = {
				show_scope_change = no
				add_offmap_currency = {
					offmap = offmap_china
					value = local_third_party_score
				}
			}

			# Like/Dislike effect description
			#################################
			if = {
				limit = {
					OR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
						offmap_china = {
							offmap_has_like = likes_wealth
						}
					}
					NOR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
						offmap_china = {
							offmap_has_dislike = likes_wealth
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = likes_tt }
					}
				}
			}
			
			if = {
				limit = {
					OR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
						offmap_china = {
							offmap_has_dislike = likes_wealth
						}
					}
					NOR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
						offmap_china = {
							offmap_has_like = likes_wealth
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = dislikes_tt }
					}
				}
			}
			if = {
				limit = {
					OR = {
						FROM = {
							liked_by_offmap = {
								type = offmap_china
							}
						}
						offmap_china = {
							offmap_has_like = likes_wealth
						}
					}
					OR = {
						FROM = {
							disliked_by_offmap = {
								type = offmap_china
							}
						}
						offmap_china = {
							offmap_has_dislike = likes_wealth
						}
					}
				}
				e_china_west_governor = {
					show_scope_change = no
					offmap_power = {
						show_scope_change = no
						custom_tooltip = { text = likes_but_dislikes_tt }
					}
				}
			}
			#################################
			hidden_tooltip = {
				if = {
					limit = {
						FROM = {
							ai = no
						}
						FROMFROM = {
							quality > 3
						}
					}
					FROM = {
						set_character_flag = achievement_a_curious_trinket
					}
				}
			}
			save_event_target_as = target_governor
			FROM = {
				sound_effect = china_grace_gain
				save_event_target_as = target_tribute_sender
			}

			hidden_effect = { #to reduce cluttered tooltip (effect already heavily implied...)
				offmap_china = {
					offmap_ruler = {
						ROOT_FROMFROM = {
							show_scope_change = no
							tooltip = {
								transfer_artifact = {
									to = PREV
									from = ROOT_FROM
								}
							}
							hidden_effect = { unsafe_destroy_artifact = yes }
						}
					}
				}
			}

			hidden_effect = {
				FROM = {
					set_character_flag = jd_gifting_artifact
				}
				hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20023 } } } }
			}
		}
	
		revoke_allowed = {
			always = no
		}
	
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				FROMFROM = {
					quality > 3
				}
			}
			modifier = {
				factor = 0.1 # slow down
			}
		}
	}
	chinese_kow_tow_pilgrimage = {
		only_playable = yes
		button_name = offmap_gifts
		ai_check_interval = 120
		
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				war = no
				NOT = {
					block_general_event_trigger = yes
					custom_tooltip = {
						text = kow_tow_tooltip_already_went
						hidden_tooltip = {
							has_character_flag = went_on_kow_tow_pilgrimage
						}
					}
				}
				custom_tooltip = {
					text = health_travel_condition
					hidden_tooltip = {
						NOR = {
							trait = pregnant
							trait = incapable
							trait = blinded
							trait = has_tuberculosis
							trait = has_typhoid_fever
							trait = has_typhus
							trait = has_bubonic_plague
							trait = has_measles
							trait = has_small_pox
							trait = has_aztec_disease
						}
					}
				}
				higher_real_tier_than = COUNT
				conditional_tooltip = {
					trigger = {
						OR = {
							real_tier = DUKE
							is_nomadic = yes
						}
					}
					prestige = 250
				}
				conditional_tooltip = {
					trigger = {
						real_tier = KING
						NOT = { is_nomadic = yes }
					}
					prestige = 500
				}
				conditional_tooltip = {
					trigger = {
						real_tier = EMPEROR
						NOT = { is_nomadic = yes }
					}
					prestige = 1000
				}
				conditional_tooltip = {
					trigger = { has_character_flag = awaiting_imperial_wedding }
					custom_tooltip = {
						text = not_awaiting_your_spouse_tt
						NOT = { has_character_flag = awaiting_imperial_wedding }
					}
				}
			}
			# china_offmap_decisions_enabled_trigger = yes #leave in please, to be used if the tooltip for china_offmap_tribute_decisions_enabled_trigger changes and we need to reference things uniquely again
			china_offmap_tribute_decisions_enabled_trigger = yes
		}
		
		effect = {
			FROM = {
				save_event_target_as = kow_tow_traveler
				set_character_flag = went_on_kow_tow_pilgrimage
				set_character_flag = do_not_disturb
				character_event = {
					id = JD.32000
				}
			}
		}
		
		ai_will_do ={
			factor = 1
			modifier = {
				factor = 0.1 #slow down
			}
		}
	}
}



#REQUESTING BOON DECISIONS (PENDING GRACE)
offmap_decisions = {
	
	#If your grace decisions will spawn a character then give them an appropriate flag eg: is_chinese_administrator and add them to the JD.60310 trigger switch to refund grace if they die early

	#Get a peace deal
	chinese_grace_peace_deal = {
		only_playable = yes
		button_name = offmap_boons
		ai_check_interval = 12
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}

		#potential = {
			#offmap_china = { governor = { character = ROOT } }
		#}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				in_revolt = no
				independent = yes
				NOT = { pays_tribute_to = ROOT }
				has_offmap_currency = { offmap = offmap_china value = 250 }
				custom_tooltip = {
					text = chinese_grace_peace_deal_allow_tt
					NOT = { has_character_modifier = peace_deal_with_china }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			offmap_china = {
				NOT = { has_policy = china_expansionist }
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		effect = {
			FROM = {
				sound_effect = china_grace_spend
				show_scope_change = no
				add_offmap_currency = {
					offmap = offmap_china
					value = -250
				}
			}
			custom_tooltip = { text = chinese_grace_peace_deal_effect_tt }
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20025 } } } }
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1 # slow down
			}
			modifier = { realm_levy_diff = { who = FROM value = 2000 } factor = 1.5 }
			modifier = { realm_levy_diff = { who = FROM value = 5000 } factor = 3 }
			modifier = {
				FROM = {
					NOT = { has_grace_major_trigger = yes }
				}
				factor = 0.1
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						NAND = {
							any_neighbor_independent_ruler = {
								character = ROOT
							}
							capital_scope = {
								OR = {
									region = world_india_deccan
									region = world_india_bengal
									region = world_steppe_east
									region = world_himalayas
								}
							}
						}
						NOT = {
							independent = yes
						}
						offmap_china = {
							has_policy = china_isolationist
						}
					}
				}
			}
			modifier = {
				factor = 0
				FROM = {
					in_revolt = yes
				}
			}
		}
	}
	
	#Get a Chinese doctor
	chinese_grace_doctor = {
		only_playable = yes
		button_name = offmap_boons
		ai_check_interval = 12

		from_potential = {
			has_dlc = "Jade Dragon"
			has_dlc = Reapers
			mercenary = no
			holy_order = no
			is_landed = yes

		}

		potential = {
			is_offmap_tag = offmap_china
		}

		#potential = {
			#offmap_china = { governor = { character = ROOT } }
		#}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				has_offmap_currency = { offmap = offmap_china value = 250 }
				custom_tooltip = {
					text = chinese_grace_doctor_allow_tt
					NOT = { any_courtier_or_vassal = { has_minor_title = title_court_physician } }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		effect = {
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_spend
				add_offmap_currency = {
					offmap = offmap_china
					value = -250
				}
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20021 } } } }
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0
			#factor = 1
			#modifier = {
			#	factor = 0.1 # slow down
			#}
			#modifier = {
			#	FROM = { NOT = { any_courtier = { learning = 15 } } }
			#	factor = 1.5
			#}
			#modifier = {
			#	FROM = {
			#		NOT = { any_courtier = { learning = 15 } }
			#		OR = {
			#			NOT = { health = 3 }
			#			character_disease_trigger = yes
			#			has_symptom_trigger = yes
			#		}
			#	}
			#	factor = 10
			#}
			#modifier = {
			#	FROM = {
			#		NOT = { has_grace_medium_trigger = yes }
			#	}
			#	factor = 0.1
			#}
		}
	}
	
	# Chinese Artifact
	chinese_artifact = {
		only_playable = yes
		button_name = offmap_boons
		ai_check_interval = 60

		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}
	
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				has_offmap_currency = { offmap = offmap_china value = 500 }
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_boon_decisions_enabled_trigger = yes
			custom_tooltip = {
				text = chinese_artifact_has_all_tt
				hidden_tooltip = {
					FROM = {
						NAND = {
							has_artifact = chinese_artwork
							has_artifact = chinese_calligraphy
							has_artifact = chinese_sculpture
							has_artifact = chinese_ceremonial_robes
							OR = {
								has_artifact = chinese_prev_emperor_sculpture
								offmap_china = {
									offmap_prev_ruler = {
										always = no
									}
								}
							}
							has_artifact = chinese_arm_protector
							has_artifact = chinese_serpent_spear
							has_artifact = chinese_ji
							has_artifact = chinese_crossbow
							has_artifact = chinese_bronze_sculpture
							has_artifact = chinese_book_health
							has_artifact = chinese_book_law
							has_artifact = chinese_book_history
							has_artifact = chinese_book_economy
							has_artifact = chinese_painting_of_glitterhoof
							has_artifact = chinese_tapestry
							has_artifact = chinese_tapestry_grand
						}
					}
				}
			}
		}

		effect = {
			FROM = {
				show_scope_change = no
				
				sound_effect = china_grace_spend

				add_offmap_currency = {
					offmap = offmap_china
					value = -500
				}
				custom_tooltip = { text = chinese_artifact_effect_tt }
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.3030 } } } }
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0.1 # slow down
			}
			modifier = {
				factor = 0.1
				NOT = {
					trait = greedy
				}
			}
		}
	}
	
	# Siege Engineers
	chinese_siege_engineers = {
		only_playable = yes
		button_name = offmap_boons
		ai = no

		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}
	
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				has_offmap_currency = { offmap = offmap_china value = 750 }
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		effect = {
			FROM = {
				show_scope_change = no
				
				sound_effect = china_grace_spend

				add_offmap_currency = {
					offmap = offmap_china
					value = -750
				}
				custom_tooltip = { text = chinese_siege_engineers_effect_tt }
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.3000 } } } }
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0
		}
	}

	#Strategist
	chinese_strategist = {
		only_playable = yes
		button_name = offmap_boons
		ai_check_interval = 60

		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}
	
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				has_offmap_currency = { offmap = offmap_china value = 750 }
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		effect = {
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_spend
				add_offmap_currency = {
					offmap = offmap_china
					value = -750
				}
				custom_tooltip = { text = chinese_strategist_effect_tt }
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20039 } } } }
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
			hidden_effect = {
				if = {
					limit = {
						offmap_china = { has_status = china_golden_age }
					}
					set_character_flag = jd_strategist_golden_age
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1 # slow down
			}
			modifier = {
				FROM = {
					NOT = { has_grace_major_trigger = yes }
				}
				factor = 0.1
			}
			modifier = {	
				factor = 0
				FROM = {
					is_nomadic = yes
				}
			}
		}
	}
	
	#Request master engineer
	chinese_administrator = {
		only_playable = yes
		button_name = offmap_boons
		ai_check_interval = 60

		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				has_offmap_currency = { offmap = offmap_china value = 1000 }
				custom_tooltip = {
					text = chinese_administrator_allow_tt
					NOT = { any_courtier = { has_minor_title = title_administrator } }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		effect = {
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_spend
				add_offmap_currency = {
					offmap = offmap_china
					value = -1000
				}
				custom_tooltip = { text = chinese_administrator_effect_tt }
				if = {
					limit = { offmap_china = { has_status = china_golden_age } }
					tooltip = {
						add_character_modifier = {
							name = employing_jd_administrator_golden_age
							duration = -1
						}
					}
				}
				else = {
					tooltip = {
						add_character_modifier = {
							name = employing_jd_administrator
							duration = -1
						}
					}
				}
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20029 } } } }
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5 # slow down
			}
			modifier = {
				FROM = {
					NOT = { has_grace_major_trigger = yes }
				}
				factor = 0.1
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						is_tribal = yes
						is_nomadic = yes
					}
				}
			}
		}
	}

	chinese_master_engineer = {
		only_playable = yes
		button_name = offmap_boons
		ai_check_interval = 60

		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}
	
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				higher_tier_than = COUNT
				has_offmap_currency = { offmap = offmap_china value = 1000 }
				custom_tooltip = {
					text = chinese_master_engineer_allow_tt
					NOT = { any_courtier = { has_minor_title = title_master_engineer } }
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		effect = {
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_spend
				add_offmap_currency = {
					offmap = offmap_china
					value = -1000
				}
				custom_tooltip = { text = chinese_master_engineer_effect_tt }
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20031 } } } }
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1 # slow down
			}
			modifier = {
				FROM = {
					NOT = { has_grace_major_trigger = yes }
				}
				factor = 0.1
			}
			modifier = {
				factor = 0
				FROM = {	
					OR = {
						is_nomadic = yes
						is_tribal = yes
					}
				}
			}
		}
	}

	chinese_silk_road_favored_status = {
		only_playable = yes
		button_name = offmap_boons
		ai_check_interval = 36
		
		potential = {
			is_offmap_tag = offmap_china
		}

		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				has_offmap_currency = { offmap = offmap_china value = 2000 }
				NOT = { has_character_modifier = chinese_imperial_trade_contract }
				NOT = { has_character_modifier = chinese_favored_in_trade }
				custom_tooltip = {
					text = tooltip_silk_road_required
					hidden_tooltip = {
						any_realm_province = {
							trade_route = silk_road
						}
					}
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		effect = {
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_spend
				add_offmap_currency = {
					offmap = offmap_china
					value = -2000
				}
				hidden_effect = {
					add_character_modifier = {
						modifier = chinese_imperial_trade_contract
						inherit = yes
						years = 25
					}
					character_event = { id = JD.30014 }
				}
			}
			custom_tooltip = {
				text = chinese_silk_road_favored_status_modifier_tt
			}
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1 # slow down
			}
			modifier = {
				factor = 0
				FROM = {
					NOT = {
						any_demesne_province = {
							has_trade_post = yes
							trade_route = silk_road
						}
					}
				}
			}
		}
	}

	chinese_imperial_marriage = {
		only_playable = yes
		button_name = offmap_boons
		third_party_filter = realm_including_me
		ai_third_party_filter = court
		third_party = from
		ai_check_interval = 12
		show_third_party_potential = yes
		
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				conditional_tooltip = {
					trigger = { NOT = { has_character_modifier = peace_deal_with_china } }
					has_offmap_currency = { offmap = offmap_china value = 1000 }
				}
				conditional_tooltip = {
					trigger = { has_character_modifier = peace_deal_with_china }
					has_offmap_currency = { offmap = offmap_china value = 750 }
				}
				OR = {
					custom_tooltip = {
						text = can_marry_chinese_royal_tt
						AND = {
							is_adult = yes
							is_married = no
						}
					}
					custom_tooltip = {
						text = has_courtier_eligible_for_marriage_tt
						OR = {
							any_dynasty_member = {
								is_adult = yes
								is_married = no
								liege = { character = ROOT_FROM }
							}
							any_close_relative = {
								is_adult = yes
								is_married = no
								liege = { character = ROOT_FROM }
								NOT = { any_spouse = { character = ROOT_FROM } } #turns out without this, it includes your spouse
							}
						}
					}
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		third_party_potential = {
			show_only_failed_conditions = yes
			FROMFROM = {
				show_scope_change = no
				OR = {
					dynasty = ROOT_FROM
					is_close_relative = ROOT_FROM
				}
				OR = {
					character = ROOT_FROM
					AND = {
						liege = { character = ROOT_FROM }
						ai = yes
					}
				}
				NOT = { any_spouse = { character = ROOT_FROM } } 
				is_adult = yes
				is_betrothed = no
			}
		}

		third_party_allow = {
			show_only_failed_conditions = yes
			FROMFROM = {
				custom_tooltip = {
					text = can_marry_chinese_royal_tt
					can_marry = yes
					is_married = no
				}
			}
		}

		effect = {
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_spend
				if = {
					limit = { has_character_modifier = peace_deal_with_china }
					add_offmap_currency = {
						offmap = offmap_china
						value = -750
					}
				}
				else = {
					add_offmap_currency = {
						offmap = offmap_china
						value = -1000
					}
					custom_tooltip = { text = chinese_imperial_marriage_peace_deal_tt }	
				}				
			}
			if = { 
				limit = { FROMFROM = { is_female = yes } } 
				custom_tooltip = { text = chinese_imperial_marriage_prince_effect_tt }
			}
			if = { 
				limit = { FROMFROM = { is_female = no } } 
				custom_tooltip = { text = chinese_imperial_marriage_princess_effect_tt }
			}
			hidden_effect = { FROMFROM = { add_trait = cannot_marry } }
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.20045 } } } }
			hidden_effect = { FROM = { set_china_boon_cd_effect = yes } }
			FROM = {
				if = {
					limit = {
						ai = no
					}
					hidden_effect = { set_character_flag = achievement_imperial_marriage }
				}
			}
			FROMFROM = { set_character_flag = awaiting_imperial_wedding }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1 # slow down
			}
			modifier = {
				factor = 0.5
				FROM = {
					NOT = {
						higher_tier_than = DUKE
					}
				}
			}
			modifier = {
				factor = 0.75
				FROM = {
					NOT = {
						independent = yes
					}
				}
			}
		}
	}

	chinese_request_invasion = {
		only_playable = yes
		button_name = offmap_boons
		third_party_filter = independent_rulers
		ai_third_party_filter = independent_rulers
		third_party = from
		ai = no
		show_third_party_potential = yes
		
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
		}
		
		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				has_offmap_currency = { offmap = offmap_china value = 5000 }
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			offmap_china = {
				governor = {
					show_scope_change = no
					war = no
				}
				OR = {
					has_status = china_stable
					has_status = china_golden_age
				}
				NOT = { has_policy = china_expansionist }
			}
			china_offmap_boon_decisions_enabled_trigger = yes
		}

		third_party_potential = {
			show_only_failed_conditions = yes
			FROMFROM = {
				show_scope_change = no
				NOT = { character = ROOT }
				OR = {
					tier = EMPEROR
					tier = KING
				}
				num_of_count_titles_in_realm = 40
				is_within_diplo_range = ROOT
				custom_tooltip = {
					text = chinese_request_invasion_rel_head_tt
					NOT = {
						any_demesne_title = {
							higher_tier_than = DUKE
							controls_religion = yes
						}
					}
				}
				custom_tooltip = {
					text = chinese_request_invasion_defeated_china_tt
					NOT = {
						has_character_flag = defeated_china
					}
				}
			}
		}

		third_party_allow = {
			show_only_failed_conditions = yes
			FROMFROM = {
				in_revolt = no
				NOR = {
					has_non_aggression_pact_with = ROOT
					is_allied_with = ROOT
					liked_by_offmap = {
						type = offmap_china
					}
					is_tributary = { suzerain = ROOT }
					has_character_modifier = peace_deal_with_china
				}
			}
		}

		effect = {
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_spend
				add_offmap_currency = {
					offmap = offmap_china
					value = -5000
				}
				save_event_target_as = chinese_invasion_instigator
			}
			
			FROMFROM = {
				save_event_target_as = chinese_invasion_target
			}
			
			hidden_effect = {
				offmap_china = {
					governor = {
						save_event_target_as = invasion_governor
						character_event = { id = JD.3020 } 
					}
				}
			}
			
			hidden_effect = {
				offmap_china = {
					governor = {
						war = {
							target = FROMFROM
							casus_belli = destabilization_china_cb
						}
					}
				}
				#Send news of invasion to interested player parties...
				any_player = {
					limit = {
						has_offmap_news_enabled = offmap_china
						is_within_diplo_range = ROOT
					}
					narrative_event = { id = JD.3022 days = 1 }
				}
			}
			
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0
		}
	}
}

#HOSTILE DECISIONS (ATTACKING CHINA)
offmap_decisions = {
	
	china_raid = {
		only_playable = yes
		button_name = offmap_hostility
		ai_check_interval = 36
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
			NOT = {
				has_character_modifier = china_raid_active
			}
		}

		potential = {
			is_offmap_tag = offmap_china
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				independent = yes
				is_allowed_to_loot = yes
				NOT = {
					is_tributary = {
						type = offmap
						suzerain = ROOT
					}
				}
				NOT = { has_character_modifier = peace_deal_with_china }
				custom_tooltip = {
					text = chinese_grace_supply_horses_not_already_supplying_tt
					NOT = {
						has_character_modifier = china_supply_horses
					}
				}
				custom_tooltip = { #Borders the eastern edge of the map
					text = chinese_grace_become_tributary_allow_chinese_influence_tt
					any_realm_province = {
						region = custom_chinese_invasion_target_region
					}
				}
				custom_tooltip = {
					text = china_offmap_boon_decisions_enabled_trigger_raiding_tt
					NOT = {
						has_character_modifier = china_raid_grace_cd
					}
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_hostile_decisions_enabled_trigger = yes
		}

		effect = {
			save_event_target_as = target_governor
			FROM = {
				show_scope_change = no
				sound_effect = china_angered_emperor
				add_offmap_currency = {
					offmap = offmap_china
					value = -500
				}
				hidden_effect = {
					add_character_modifier = {
						inherit = yes
						name = china_raid_active
						duration = -1
					}
				}
			}
			hidden_effect = { offmap_china = { governor = { character_event = { id = JD.3050 } } } }
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0.1
			modifier = {
				factor = 0
				FROM = {
					has_grace_medium_trigger = yes
				}
			}
			modifier = {
				factor = 0
				FROM = {
					OR = {
						trait = shy
						trait = content
						trait = craven
					}
				}
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { dynasty = FROM } }
			}
		}
	}
	
	china_stop_raid = {
		only_playable = yes
		button_name = offmap_hostility
		ai_check_interval = 36
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
			has_character_modifier = china_raid_active
		}

		potential = {
			is_offmap_tag = offmap_china
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				has_character_modifier = china_raid_active
			}
		}

		effect = {
			save_event_target_as = target_governor
			FROM = {
				show_scope_change = no
				sound_effect = china_grace_gain
				remove_character_modifier = china_raid_active
				hidden_effect = {
					add_character_modifier = {
						name = china_raid_grace_cd
						hidden = yes
						years = 5
					}
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0.1
			modifier = {
				factor = 10
				offmap_china = { offmap_ruler = { dynasty = FROM } }
			}
			modifier = {
				factor = 0
				AND = {
					FROM = {
						NOR = {
							trait = shy
							trait = content
							trait = craven
						}
					}
					NOT = {
						offmap_china = { offmap_ruler = { dynasty = FROM } }
					}
				}
			}
		}
	}

	china_force_to_open = {
		only_playable = yes
		button_name = offmap_hostility
		ai = no
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
			#offmap_china = { has_policy = china_isolationist }
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				independent = yes
				NOT = {
					is_tributary = {
						type = offmap
						suzerain = ROOT
					}
				}
				custom_tooltip = {
					text = force_china_open_cooldown_tt
					NOT = { has_character_modifier = china_force_open_cooldown }
				}
				OR = {
					custom_tooltip = { #Borders the Western Governate
						text = chinese_grace_become_tributary_allow_governor_neighbor_tt
						any_neighbor_independent_ruler = {
							has_landed_title = e_china_west_governor
						}
					}
					custom_tooltip = { #Borders a Chinese tributary
						text = chinese_grace_become_tributary_allow_tributary_neighbor_tt
						any_neighbor_independent_ruler = {
							suzerain = {
								has_landed_title = e_china_west_governor
							}
						}
					}
					custom_tooltip = { #Borders the eastern edge of the map
						text = chinese_grace_become_tributary_allow_chinese_influence_tt
						any_realm_province = {
							region = custom_chinese_invasion_target_region
						}
					}
					custom_tooltip = { #Within diplo range of China and has a port in India
						text = chinese_grace_become_tributary_allow_india_tt
						any_realm_province = { 
							port = yes 
							region = world_india
						}
					}
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			offmap_china = {
				has_policy = china_isolationist
			}
			offmap_china = {
				custom_tooltip = {
					text = already_at_war_tt
					hidden_tooltip = {
						governor = {
							NOT = {
								any_war = {
									using_cb = force_open_china_cb
								}
							}
						}
					}
				}
			}
			china_offmap_hostile_decisions_enabled_trigger = yes
		}

		effect = {
			save_event_target_as = target_governor
			hidden_effect = { offmap_china = { set_offmap_tmp_flag = china_force_open_in_progress } }
			FROM = { 
				sound_effect = china_angered_emperor
				hidden_effect = { 
					add_character_modifier = { 
						name = china_force_open_cooldown
						years = 15
						hidden = yes
					}
				}
				ROOT = {
					show_scope_change = no
					character_event = { id = JD.60300 tooltip = force_open_china_start_tt }
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0
		}
	}

	china_tributary_break_free = {
		only_playable = yes
		button_name = offmap_hostility
		ai = no
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
			is_landed = yes
		}

		potential = {
			is_offmap_tag = offmap_china
			FROM = {
				is_tributary = {
					type = offmap
					suzerain = ROOT
				}
			}
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = yes
				is_tributary = {
					type = offmap
					suzerain = ROOT
				}
				can_use_cb = {
					target = ROOT
					casus_belli = free_tributary_cb
				}
				NOT = { is_decision_allowed = tributary_independence_china }
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_hostile_decisions_enabled_trigger = yes
		}

		effect = {
			FROM = {
				show_scope_change = no
				sound_effect = china_angered_emperor
				war = {
					target = ROOT
					casus_belli = free_tributary_cb
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0
		}
	}

	china_invade_dragon_throne = {
		only_playable = yes
		button_name = offmap_hostility
		
		third_party_filter = home_court
		ai_third_party_filter = home_court
		third_party = FROM
		show_third_party_potential = yes
		ai = no
	
		from_potential = {
			has_dlc = "Jade Dragon"
			mercenary = no
			holy_order = no
		}

		potential = {
			is_offmap_tag = offmap_china
			NOT = { offmap_ruler = { dynasty = FROM } }
		}

		allow = {
			show_only_failed_conditions = yes
			FROM = {
				show_scope_change = no
				independent = yes
				in_revolt = no
				NOT = {
					is_tributary = {
						type = offmap
						suzerain = ROOT
					}
				}
				OR = {
					custom_tooltip = { #Borders the Western Governate
						text = chinese_grace_become_tributary_allow_governor_neighbor_tt
						any_neighbor_independent_ruler = {
							has_landed_title = e_china_west_governor
						}
					}
					custom_tooltip = { #Borders the eastern edge of the map
						text = china_invade_dragon_throne_eastern_edge_tt
						any_realm_province = {
							region = custom_eastern_edge_of_map
						}
					}
				}
				custom_tooltip = {
					text = china_invade_dragon_throne_failed_tt
					NOT = { has_character_modifier = failed_invasion_of_china }
				}
				can_use_cb = {
					target = ROOT
					casus_belli = invasion_of_china_cb
					only_check_triggers = yes
				}
				NOT = { has_raised_levies = THIS }
				custom_tooltip = {
					text = china_invade_dragon_throne_levies_tt
					NOT = { any_vassal = { ROOT_FROM = { has_raised_levies = PREV } } }
				}
				NOT = { has_truce = ROOT }
				tier = EMPEROR
				conditional_tooltip = {
					trigger = { is_nomadic = no }
					realm_size = 300
				}
				conditional_tooltip = {
					trigger = { is_nomadic = yes }
					num_of_count_titles_in_realm = 50
				}
				prisoner = no
				NOT = { trait = incapable }
				is_inaccessible_trigger = no
			}
			china_offmap_hostile_decisions_enabled_trigger = yes
			offmap_china = {
				OR = {
					has_status = china_stable
					has_status = china_golden_age
				}
				ROOT = {
					show_scope_change = no
					custom_tooltip = {
						text = china_invade_dragon_throne_war_tt
						NOT = { any_war = { using_cb = invasion_of_china_cb } }
					}
				}
			}
		}

		third_party_potential = {
			show_only_failed_conditions = yes
			FROMFROM = {
				show_scope_change = no
				dynasty = ROOT_FROM
				is_adult = yes
				NOR = {
					courtier_from_china_trigger = yes
					is_landed = yes
					is_incapable = yes
					trait = inbred
					trait = imbecile
					trait = celibate
					is_ascetic_trigger = yes
					prisoner = yes
				}
				is_primary_heir = no
			}
		}
		
		third_party_allow = {
			show_only_failed_conditions = yes		
			FROMFROM = {
				is_ill = no
				is_inaccessible_trigger = no
			}
		}

		effect = {
			hidden_effect = {
				FROMFROM = { #Stop them from moving, marrying or being diplomatically dealt with
					set_character_flag = invasion_china_claimant
					set_character_flag = no_court_invites
					add_trait = cannot_marry
					diplomatic_immunity = yes
					save_global_event_target_as = invasion_of_china_claimant
				}
				ROOT = { #Set amount of troops
					set_offmap_tmp_flag = china_war_variables_set
					set_variable = {
						which = china_war_troop_quantity
						value = 15
						# 15 regiments of ~500 units
					}
					set_variable = {
						which = china_war_target_match_mult
						value = 2
					}
					set_variable = {
						which = china_war_troop_quality
						value = 6
						# Value between 1-7
					}
					set_variable = {
						which = china_war_minimum_commander_martial
						value = 16
					}
					set_variable = { #Minimum 80k
						which = china_war_troop_quantity_override
						value = 160
					}
					save_event_target_as = invasion_of_china_govenor
				}
			}
			FROM = {
				show_scope_change = no
				sound_effect = china_angered_emperor
				save_event_target_as = invasion_of_china_attacker
				custom_tooltip = {
					text = china_invade_dragon_throne_modifiers_tt
					hidden_effect = {
						set_offmap_currency = { offmap = offmap_china value = 0 }
						remove_character_modifier = peace_deal_with_china
						remove_character_modifier = chinese_grace_send_gift_timer
						remove_character_modifier = chinese_grace_send_eunuch_timer
						remove_character_modifier = chinese_grace_send_concubine_timer
						remove_character_modifier = chinese_grace_tributary_timer
						remove_character_modifier = jd_china_boon_cd
						remove_character_modifier = china_force_open_cooldown
						remove_character_modifier = angered_china_modifier
						remove_character_modifier = chinese_imperial_trade_contract
					}
				}
				hidden_effect = {
					add_character_modifier = {
						name = war_with_china_modifier
						inherit = yes
						duration = -1
					}
					war = {
						target = ROOT
						casus_belli = invasion_of_china_cb
					}
				}
			}
			hidden_effect = {
				any_player = {
					limit = {
						has_offmap_news_enabled = offmap_china
						is_within_diplo_range = ROOT
					}
					narrative_event = { id = JD.60400 }
				}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 0
		}
	}
}