namespace = JD

#Written by:
#Matthew Clohessy
#Milla Isaksson

### Events for aquiring Chinese Artifacts ###
#An envoy from China appears, hidden event generates the envoy then pings
character_event = {
	id = JD.60000
	hide_window = yes
	is_triggered_only = yes

    only_capable = yes
    only_playable = yes
    has_dlc = "Jade Dragon"
    prisoner = no
    war = no
    min_age = 16

    trigger = {
        NOT = { offmap_china = { governor = { character = ROOT } } }
        is_inaccessible_trigger = no
        china_diplo_interaction_trigger = yes
        offmap_china = {
            NOR = {
                has_status = china_civil_war
                has_status = china_plague
            }
        }
    }
	
	weight_multiplier = {
		days = 1
		modifier = {
			factor = 0.1
			any_artifact = { has_artifact_flag = chinese }
		}
        modifier = {
            offmap_china = { has_status = china_unrest }
            factor = 0.6
        }
        modifier = {
            offmap_china = { has_status = china_mongol_invasion }
            factor = 0.3
        }
        modifier = {
            offmap_china = { has_status = china_jurchen_invasion }
            factor = 0.3
        }
        modifier = {
            offmap_china = { has_status = china_famine }
            factor = 0.3
        }
        modifier = {
            offmap_china = { has_status = china_golden_age }
            factor = 3
        }
        modifier = {
            offmap_china = { has_policy = china_expansionist }
            factor = 2
        }
	}
	
	immediate = {
		offmap_china = {
			governor = {
				random_list = {
					50 = {
						modifier = {
							NOT = {
								has_game_rule = {
									name = gender
									value = all
								}
							}
							factor = 0.05
						}
						create_character = {
							age = 32
							culture = PREV
							religion = PREV
							dynasty = actually_culture
							female = yes
							random_traits = yes
               				historical = yes
						}
					}
					50 = {
						create_character = {
							age = 32
							culture = PREV
							religion = PREV
							dynasty = actually_culture
							female = no
							random_traits = yes
							historical = yes
						}
					}
				}
				new_character = {
					set_character_flag = chinese_envoy_artifacts
					random = {
						chance = 10
						remove_education_effect = yes
						add_trait = brilliant_strategist
						change_martial = 5
						set_character_flag = chinese_envoy_warrior
					}
					character_event = { id = JD.60001 }
				}
			}
		}
	}
}
#Ping for picture
character_event = {
	id = JD.60001
	has_dlc = "Jade Dragon"
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		FROM = { character_event = { id = JD.60002 } }
	}
}
#An envoy from China has arrived at your court offering to trade
character_event = {
	id = JD.60002
	has_dlc = "Jade Dragon"
	desc = {
		text = EVT_DESC_JD_60002_A
		trigger = { FROM = { has_character_flag = chinese_envoy_artifacts } }
	}
	desc = { #Envoy from HL.5000
		text = EVT_DESC_JD_60002_B
		trigger = { FROM = { has_character_flag = is_chinese_envoy } }
	}
    picture = GFX_evt_chinese_bureaucrat
    border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	immediate = {
		###Find possible people to trade
		#Eunuch, same requirements as grace decision
		if = {
			limit = {
				any_courtier = {
					NOR = {
						has_character_flag = originated_from_chinese_court
						has_character_flag = eunuch_gift
						is_landed = yes
						is_female = yes
						is_betrothed = yes
						spouse = { always = yes }
						trait = incapable
						trait = inbred
						trait = imbecile
					}
					OR = {
						is_close_relative = ROOT
						diplomacy = 20
						martial = 20
						stewardship = 20
						intrigue = 20
						learning = 20
						trait = strong
						trait = genius
						trait = quick
						has_fair_trait_trigger = yes
						trait = robust
						trait = shrewd
						trait = architect
						trait = strategist
						trait = scholar
						trait = faqih
					}
					OR = {
						is_adult = yes
						AND = {
							is_close_relative = ROOT
							age = 12
						}
					}
					is_heir = no
					is_ill = no
					is_inaccessible_trigger = no
				}
			}
			random_courtier = {
				limit = {
					NOR = {
						has_character_flag = originated_from_chinese_court
						has_character_flag = eunuch_gift
						is_landed = yes
						is_female = yes
						is_betrothed = yes
						spouse = { always = yes }
						trait = incapable
						trait = inbred
						trait = imbecile
					}
					OR = {
						is_close_relative = ROOT
						diplomacy = 20
						martial = 20
						stewardship = 20
						intrigue = 20
						learning = 20
						trait = strong
						trait = genius
						trait = quick
						has_fair_trait_trigger = yes
						trait = robust
						trait = shrewd
						trait = architect
						trait = strategist
						trait = scholar
						trait = faqih
					}
					OR = {
						is_adult = yes
						AND = {
							is_close_relative = ROOT
							age = 12
						}
					}
					is_heir = no
					is_ill = no
					is_inaccessible_trigger = no
				}
				save_event_target_as = chinese_envoy_eunuch_target
			}
		}
		#Concubine, same potential as grace decision
		if = {
			limit = {
				any_courtier = {
					OR = {
						AND = {
							offmap_china = {
								offmap_ruler = {
									is_female = yes
								}
							}
							is_female = no
						}
						AND = {
							offmap_china = {
								offmap_ruler = {
									is_female = no
								}
							}
							is_female = yes
						}
					}
					is_close_relative = ROOT
					is_adult = yes
					NOT = { age = 45 }
					NOR = {
						has_character_flag = originated_from_chinese_court
						is_landed = yes
						is_betrothed = yes
						is_married = yes
						trait = incapable
						trait = inbred
						trait = imbecile
						trait = celibate
					}
					is_heir = no
					is_ill = no
					NOT = { trait = wounded }
					is_inaccessible_trigger = no
				}
			}
			random_courtier = {
				limit = {
					OR = {
						AND = {
							offmap_china = {
								offmap_ruler = {
									is_female = yes
								}
							}
							is_female = no
						}
						AND = {
							offmap_china = {
								offmap_ruler = {
									is_female = no
								}
							}
							is_female = yes
						}
					}
					is_close_relative = ROOT
					is_adult = yes
					NOT = { age = 45 }
					NOR = {
						has_character_flag = originated_from_chinese_court
						is_landed = yes
						is_betrothed = yes
						is_married = yes
						trait = incapable
						trait = inbred
						trait = imbecile
						trait = celibate
					}
					is_heir = no
					is_ill = no
					NOT = { trait = wounded }
					is_inaccessible_trigger = no
				}
				save_event_target_as = chinese_envoy_concubine_target
			}
		}
	}
	
	option = { #Send a eunuch
		name = EVT_OPTA_JD_60002
		trigger = { event_target:chinese_envoy_eunuch_target = { always = yes } }
		tooltip_info = yes
		custom_tooltip = { text = JD_60002_eunuch_tt }
		event_target:chinese_envoy_eunuch_target = {
			show_scope_change = no
			hidden_effect = {
				if = {
					limit = {
						NOT = {
							trait = eunuch
						}
					}
					add_trait = eunuch
				}
			}
			leave_court_for_china_effect = yes
		}
		if = {
			limit = {
				OR = {
					ROOT = {
						liked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
					event_target:chinese_envoy_eunuch_target = {
						liked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
				}
				NOR = {
					ROOT = {
						disliked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
					event_target:chinese_envoy_eunuch_target = {
						disliked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_likes_tt }
				}
			}
			set_character_flag = chinese_envoy_trade_like
		}
		if = {
			limit = {
				OR = {
					ROOT = {
						disliked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
					event_target:chinese_envoy_eunuch_target = {
						disliked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
				}
				NOR = {
					ROOT = {
						liked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
					event_target:chinese_envoy_eunuch_target = {
						liked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_dislikes_tt }
				}
			}
			set_character_flag = chinese_envoy_trade_dislike
		}
		if = {
			limit = {
				OR = {
					ROOT = {
						liked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
					event_target:chinese_envoy_eunuch_target = {
						liked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
				}
				OR = {
					ROOT = {
						disliked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
					event_target:chinese_envoy_eunuch_target = {
						disliked_by_offmap = {
							type = offmap_china
							context = eunuch
						}
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_likes_but_dislikes_tt }
				}
			}
		}
		character_event = { id = JD.60003 days = 1 }
	}
	option = { #Send a concubine
		name = EVT_OPTB_JD_60002
		trigger = { event_target:chinese_envoy_concubine_target = { always = yes } }
		tooltip_info = yes
		custom_tooltip = { text = JD_60002_concubine_tt }
		event_target:chinese_envoy_concubine_target = {
			show_scope_change = no
			leave_court_for_china_effect = yes
		}
		if = {
			limit = {
				OR = {
					ROOT = {
						liked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
					event_target:chinese_envoy_concubine_target = {
						liked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
				}
				NOR = {
					ROOT = {
						disliked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
					event_target:chinese_envoy_concubine_target = {
						disliked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_likes_tt }
				}
			}
			set_character_flag = chinese_envoy_trade_like
		}
		if = {
			limit = {
				OR = {
					ROOT = {
						disliked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
					event_target:chinese_envoy_concubine_target = {
						disliked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
				}
				NOR = {
					ROOT = {
						liked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
					event_target:chinese_envoy_concubine_target = {
						liked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_dislikes_tt }
				}
			}
			set_character_flag = chinese_envoy_trade_dislike
		}
		if = {
			limit = {
				OR = {
					ROOT = {
						liked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
					event_target:chinese_envoy_concubine_target = {
						liked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
				}
				OR = {
					ROOT = {
						disliked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
					event_target:chinese_envoy_concubine_target = {
						disliked_by_offmap = {
							type = offmap_china
							context = concubine
						}
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_likes_but_dislikes_tt }
				}
			}
		}
		character_event = { id = JD.60003 days = 1 }
	}
	option = { #Send gold
		name = EVT_OPTC_JD_60002
		trigger = { 
			NOR = {
				event_target:chinese_envoy_eunuch_target = { always = yes }
				event_target:chinese_envoy_concubine_target = { always = yes }
			}
		}
		scaled_wealth = { value = -2 min = -200 }
		if = {
			limit = {
				ROOT = {
					liked_by_offmap = {
						type = offmap_china
						context = wealth
					}
				}
				NOT = {
					ROOT = {
						disliked_by_offmap = {
							type = offmap_china
							context = wealth
						}
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_likes_tt }
				}
			}
			set_character_flag = chinese_envoy_trade_like
		}
		if = {
			limit = {
				ROOT = {
					disliked_by_offmap = {
						type = offmap_china
						context = wealth
					}
				}
				NOT = {
					ROOT = {
						liked_by_offmap = {
							type = offmap_china
							context = wealth
						}
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_dislikes_tt }
				}
			}
			set_character_flag = chinese_envoy_trade_dislike
		}
		if = {
			limit = {
				ROOT = {
					liked_by_offmap = {
						type = offmap_china
						context = wealth
					}
				}
				ROOT = {
					disliked_by_offmap = {
						type = offmap_china
						context = wealth
					}
				}
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_likes_but_dislikes_tt }
				}
			}
		}
		character_event = { id = JD.60003 days = 1 }
	}
	option = {
		name = EVT_OPTD_JD_60002
		prestige = -150
		if = {
			limit = {
				ROOT = { liked_by_offmap = { type = offmap_china } }
				NOT = { ROOT = { disliked_by_offmap = { type = offmap_china } } }
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_likes_tt }
				}
			}
			set_character_flag = chinese_envoy_trade_like
		}
		if = {
			limit = {
				ROOT = { disliked_by_offmap = { type = offmap_china } }
				NOT = { ROOT = { liked_by_offmap = { type = offmap_china } } }
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_dislikes_tt }
				}
			}
			set_character_flag = chinese_envoy_trade_dislike
		}
		if = {
			limit = {
				ROOT = { liked_by_offmap = { type = offmap_china } }
				ROOT = { disliked_by_offmap = { type = offmap_china } }
			}
			e_china_west_governor = {
				offmap_power = {
					show_scope_change = no
					custom_tooltip = { text = JD_60002_likes_but_dislikes_tt }
				}
			}
		}
		hidden_effect = {
			random_list = {
				8 = { set_character_flag = chinese_envoy_feast_good }
				2 = { set_character_flag = chinese_envoy_feast_bad }
			}
		}
		character_event = { id = JD.60003 days = 1 }
	}
	option = {
		name = EVT_OPTE_JD_60002
		detract_grace_trivial_effect = yes
		hidden_effect = { 
			if = { 
				limit = { 
					FROM = { has_character_flag = chinese_envoy_artifacts }
				}
				FROM = { death = { death_reason = death_went_back_to_china } }
			}
		}
	}
}
#Get an random artifact in exchange for your trade
character_event = {
	id = JD.60003
	has_dlc = "Jade Dragon"
	desc = {
		text = EVT_DESC_JD_60003_A
		trigger = { 
			NOR = {
				has_character_flag = chinese_envoy_feast_good
				has_character_flag = chinese_envoy_feast_bad
			}
		}
	}
	desc = {
		text = EVT_DESC_JD_60003_B
		trigger = { has_character_flag = chinese_envoy_feast_good }
	}
	desc = {
		text = EVT_DESC_JD_60003_C
		trigger = { has_character_flag = chinese_envoy_feast_bad }
	}
    picture = GFX_evt_china_diplomatic_success
    border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = { has_character_flag = chinese_envoy_feast_bad }
			break = yes
		}
		#Spawn artifacts in a character with the current Emperor's culture and religion so loc reffering that stays static and then transfer to intended owner.
		random_list = {
			5 = { 
				modifier = {
					factor = 0
					has_artifact = jade_dragon
				}
				modifier = {
					factor = 3
					has_character_flag = chinese_envoy_trade_like
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_dislike
				}
				add_artifact = jade_dragon
				new_artifact = {
					save_event_target_as = chinese_envoy_artifact
				}
			}
			15 = { 
				modifier = {
					factor = 0
					has_artifact = chinese_dragon_amulet
				}
				modifier = {
					factor = 3
					has_character_flag = chinese_envoy_trade_like
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_dislike
				}
				add_artifact = chinese_dragon_amulet
				new_artifact = {
					save_event_target_as = chinese_envoy_artifact
				}
			}
			40 = {
				modifier = {
					factor = 0
					has_artifact = chinese_artwork
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_like
				}
				add_artifact = chinese_artwork
				new_artifact = {
					set_name="chinese_artwork_name"
					save_event_target_as = chinese_envoy_artifact
				}
			}
			40 = { 
				modifier = {
					factor = 0
					has_artifact = chinese_calligraphy
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_like
				}
				add_artifact = chinese_calligraphy
				new_artifact = {
					set_name="chinese_calligraphy_name"
					save_event_target_as = chinese_envoy_artifact
				}
			}
			40 = { 
				modifier = {
					factor = 0
					has_artifact = chinese_sculpture
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_like
				}
				add_artifact = chinese_sculpture
				new_artifact = {
					set_name="chinese_sculpture_name"
					save_event_target_as = chinese_envoy_artifact
				}
			}
			20 = { 
				modifier = {
					factor = 0
					has_artifact = chinese_ceremonial_robes
				}
				modifier = {
					factor = 3
					has_character_flag = chinese_envoy_trade_like
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_dislike
				}
				add_artifact = chinese_ceremonial_robes
				new_artifact = {
					save_event_target_as = chinese_envoy_artifact
				}
			}
			20 = { 
				trigger = { 
					has_character_flag = chinese_envoy_trade_like
					NOT = { martial <= 10 }
					FROMFROM = { has_character_flag = chinese_envoy_warrior }
				}
				modifier = {
					factor = 0.1
					has_artifact = art_of_war
				}
				modifier = {
					factor = 2
					martial = 14
				}
				modifier = {
					factor = 2
					martial = 18
				}
				modifier = {
					factor = 2
					martial = 22
				}
				modifier = {
					factor = 2
					martial = 24
				}
				add_artifact = art_of_war
				new_artifact = {
					save_event_target_as = chinese_envoy_artifact
				}
			}
			20 = { 
				modifier = {
					factor = 0
					has_artifact = silk_shroud
				}
				modifier = {
					factor = 3
					has_character_flag = chinese_envoy_trade_like
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_dislike
				}
				add_artifact = silk_shroud
				new_artifact = {
					save_event_target_as = chinese_envoy_artifact
				}
			}
			15 = { 
				modifier = {
					factor = 0
					has_artifact = water_clock
				}
				modifier = {
					factor = 3
					has_character_flag = chinese_envoy_trade_like
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_dislike
				}
				add_artifact = water_clock
				new_artifact = {
					save_event_target_as = chinese_envoy_artifact
				}
			}
			15 = { 
				modifier = {
					factor = 0
					has_artifact = jian_sword
				}
				modifier = {
					factor = 3
					has_character_flag = chinese_envoy_trade_like
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_dislike
				}
				add_artifact = jian_sword
				new_artifact = {
					save_event_target_as = chinese_envoy_artifact
				}
			}
			10 = { 
				modifier = {
					factor = 0
					has_artifact = classic_of_poetry
				}
				modifier = {
					factor = 3
					has_character_flag = chinese_envoy_trade_like
				}
				modifier = {
					factor = 0.3
					has_character_flag = chinese_envoy_trade_dislike
				}
				add_artifact = classic_of_poetry
				new_artifact = {
					save_event_target_as = chinese_envoy_artifact
				}
			}
			1 = {
				add_artifact = chinese_prev_emperor_sculpture
				new_artifact = {
					set_name="chinese_figurine_name"
					save_event_target_as = chinese_envoy_artifact
				}
			}
		}
	}
	
	option = {
		name = EVT_OPTA_JD_60003
		trigger = { 
			NOT = { has_character_flag = chinese_envoy_feast_bad }
			event_target:chinese_envoy_artifact = { has_artifact_flag = decor }
		}
		sound_effect = china_grace_gain
		custom_tooltip = {
			text = artifact_added_tt
		}
		add_grace_trivial_effect = yes
	}
	option = {
		name = EVT_OPTB_JD_60003
		trigger = { 
			NOT = { has_character_flag = chinese_envoy_feast_bad }
			NOT = { event_target:chinese_envoy_artifact = { has_artifact_flag = decor } }
		}
		sound_effect = china_grace_gain
		custom_tooltip = {
			text = artifact_added_tt
		}
		add_grace_trivial_effect = yes
	}
	option = {
		name = EVT_OPTC_JD_60003
		trigger = { has_character_flag = chinese_envoy_feast_bad }
		detract_grace_minor_effect = yes
	}
	
	after = {
		clr_character_flag = chinese_envoy_trade_like
		clr_character_flag = chinese_envoy_trade_dislike
		clr_character_flag = chinese_envoy_feast_good
		clr_character_flag = chinese_envoy_feast_bad
		hidden_effect = { 
			if = {
				limit = {
					FROMFROM = { has_character_flag = chinese_envoy_artifacts }
				}
				FROMFROM = { death = { death_reason = death_went_back_to_china } }
			}
		}
	}
}

#Visiting councillor leaves you a gift, from JD.20000
character_event = {
	id = JD.60004
	has_dlc = "Jade Dragon"
	desc = EVT_DESC_JD_60004
	picture = GFX_evt_china_diplomatic_success
    border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	immediate = {
		#Spawn artifacts in a character with the current Emperor's culture and religion so loc reffering that stays static and then transfer to intended owner.
		offmap_china = {
			governor = {
				random_list = {
					5 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = jade_dragon }
						}
						add_artifact = jade_dragon
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					15 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = chinese_dragon_amulet }
						}
						add_artifact = chinese_dragon_amulet
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					40 = {
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = chinese_artwork }
						}
						add_artifact = chinese_artwork
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					40 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = chinese_calligraphy }
						}
						add_artifact = chinese_calligraphy
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					40 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = chinese_sculpture }
						}
						add_artifact = chinese_sculpture
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					20 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = chinese_ceremonial_robes }
						}
						add_artifact = chinese_ceremonial_robes
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					20 = { 
						trigger = { 
							event_target:chinese_guest = { has_job_title = job_marshal }
						}
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = art_of_war }
						}
						modifier = {
							factor = 2
							ROOT = { martial = 14 }
						}
						modifier = {
							factor = 2
							ROOT = { martial = 18 }
						}
						modifier = {
							factor = 2
							ROOT = { martial = 22 }
						}
						modifier = {
							factor = 2
							ROOT = { martial = 24 }
						}
						add_artifact = art_of_war
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					20 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = silk_shroud }
						}
						add_artifact = silk_shroud
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					15 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = water_clock }
						}
						add_artifact = water_clock
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					15 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = jian_sword }
						}
						add_artifact = jian_sword
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
					10 = { 
						modifier = {
							factor = 0.1
							ROOT = { has_artifact = classic_of_poetry }
						}
						add_artifact = classic_of_poetry
						new_artifact = {
							transfer_artifact = {
								from = PREV
								to = ROOT
							}
							save_event_target_as = chinese_envoy_artifact
						}
					}
				}
			}
		}
	}
	
	option = {
		name = EVT_OPTA_JD_60003
		trigger = { 
			event_target:chinese_envoy_artifact = { has_artifact_flag = decor }
		}
		sound_effect = china_grace_gain
		tooltip = { 
			event_target:chinese_envoy_artifact = { 
				show_scope_change = no
				transfer_artifact = {
					from = event_target:chinese_guest
					to = ROOT
				}
			}
		}
		add_grace_trivial_effect = yes
	}
	option = {
		name = EVT_OPTB_JD_60003
		trigger = { 
			NOT = { event_target:chinese_envoy_artifact = { has_artifact_flag = decor } }
		}
		sound_effect = china_grace_gain
		tooltip = { 
			event_target:chinese_envoy_artifact = { 
				show_scope_change = no
				transfer_artifact = {
					from = event_target:chinese_guest
					to = ROOT
				}
			}
		}
		add_grace_trivial_effect = yes
	}
}

#Ruler can get an artifact in JD.10013 as well

### Events for converting and destroying prosthetics ###
#On startup convert modifiers into artifacts
character_event = {
	id = JD.60005

	hide_window = yes
	is_triggered_only = yes
	ai = no
	only_playable = yes

	trigger = {
		is_multiplayer_host_character = yes
		is_save_game = yes
	}

	immediate = {
		any_character = {
			limit = {
				OR = {
					has_character_modifier = golden_hand
					has_character_modifier = iron_hand
					has_character_modifier = prosthetic_leg
				}
			}
			trigger_switch = {
				on_trigger = has_character_modifier
				golden_hand = {
					remove_character_modifier = golden_hand
					add_artifact = prosthetic_hand_gold
				}
				iron_hand = {
					remove_character_modifier = iron_hand
					add_artifact = prosthetic_hand_metal
				}
				prosthetic_leg = {
					remove_character_modifier = prosthetic_leg
					add_artifact = prosthetic_leg_artifact
				}
			}
		}
	}
}
#Destroy prosthetics on death
character_event = {
	id = JD.60006
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		OR = {
			has_artifact = prosthetic_hand_gold
			has_artifact = prosthetic_hand_metal
			has_artifact = prosthetic_leg_artifact
		}
	}

	immediate = {
		if = {
			limit = { has_artifact = prosthetic_hand_gold }
			destroy_artifact = prosthetic_hand_gold
		}
		if = {
			limit = { has_artifact = prosthetic_hand_metal }
			destroy_artifact = prosthetic_hand_metal
		}
		if = {
			limit = { has_artifact = prosthetic_leg_artifact }
			destroy_artifact = prosthetic_leg_artifact
		}
	}
}
#Ruler can get an artifact in JD.10013 as well


### WRITE A BOOK ### Start (fired from decision)
character_event = { 
    id = JD.10060
    title = EVTTITLE_JD_10060
    picture = GFX_evt_council
    border = GFX_event_normal_frame_religion
    is_triggered_only = yes

    trigger = {
    	age = 10
    }

    immediate = {
        if = {
        	limit = {
	        	calc_true_if = {
					amount = 4
					OR = {
	    				martial = 10
	    				has_education_martial_trigger = yes
	    			}
					OR = {
						stewardship = 10
						has_education_stewardship_trigger = yes
					}
					OR = {
						learning = 10
						is_monastic_member_trigger = yes
						has_education_learning_trigger = yes
					}
					OR = {
						diplomacy = 10
						intrigue = 10
						has_education_diplomacy_trigger = yes
						has_education_intrigue_trigger = yes
					}
				}
        	}
			set_character_flag = prepare_fallback_event
			random_list = {
				10 = {
					set_character_flag = hide_martial_this_time
				}
				10 = {
					set_character_flag = hide_relationships_this_time
				}
				10 = {
					set_character_flag = hide_administration_this_time
				}
				10 = {
					set_character_flag = hide_learning_this_time
				}
			}
        }
    }

    desc = {
        text = EVTDESC_JD_10060_A
        trigger = { trait = lunatic }
    }
    desc = {
        text = EVTDESC_JD_10060_B
        trigger = { is_smart_trigger = yes }
    }
    desc = {
        text = EVTDESC_JD_10060_C
        trigger = { is_dumb_trigger = yes }
    }
    desc = {
        text = EVTDESC_JD_10060_D
        trigger = {
        	is_smart_trigger = no
        	is_dumb_trigger = no
        	NOT = { trait = lunatic }
        }
    }

    option = { #(only available with the right education or stats)
        name = EVTOPTA_JD_10060 #I will write about battle and strategy
        custom_tooltip = { text = EVTOPTA_JD_10060_TT }

        set_character_flag = writing_about_battle

        if = {
        	limit = {
        		OR = {
	        		NOT = { martial = 5 }
	        		is_dumb_trigger = yes
	        		has_bottom_tier_education_trait_trigger = yes
        		}
        	}
			set_character_flag = decent_book_potential
        }
        if = {
        	limit = {
	        	OR = {
	        		martial = 7
					has_medium_education_trait_trigger = yes
	        	}
        	}
			set_character_flag = good_book_potential
        }
        if = {
        	limit = {
        		OR = {
        			martial = 15
        			trait = brilliant_strategist
        			is_smart_trigger = yes
        		}
        	}
			set_character_flag = great_book_potential
        }

        ai_chance = {
        	factor = 10
        	modifier = {
        		factor = 2
        		trait = brilliant_strategist
        	}
        	modifier = {
        		factor = 1.5
        		martial = 12
        	}
        }

        trigger = {
        	OR = {
        		has_education_martial_trigger = yes
        		martial = 10
        	}
        	NOT = { has_character_flag = hide_martial_this_time }
        	NOT = { has_character_flag = wrote_about_battle }
        }
    }

    option = { #(only available with the right education or stats)
        name = EVTOPTB_JD_10060 #I will write about the value and intricacies of diplomatic relationships. 
        custom_tooltip = { text = EVTOPTB_JD_10060_TT }

        set_character_flag = writing_about_relationships

        if = {
        	limit = {
        		OR = {
	        		NOT = { diplomacy = 5 }
	        		NOT = { intrigue = 5 }
	        		is_dumb_trigger = yes
	        		has_bottom_tier_education_trait_trigger = yes
        		}
        	}
			set_character_flag = decent_book_potential
        }
        if = {
        	limit = {
	        	OR = {
					diplomacy = 8
	        		intrigue = 8
					has_medium_education_trait_trigger = yes
	        	}
        	}
			set_character_flag = good_book_potential
        }
        if = {
        	limit = {
        		OR = {
        			diplomacy = 15
        			intrigue = 15
					trait = elusive_shadow
					trait = grey_eminence
        			is_smart_trigger = yes
        		}
        	}
			set_character_flag = great_book_potential
        }

        ai_chance = {
        	factor = 10
        	modifier = {
        		factor = 2
        		OR = {
        			trait = elusive_shadow
					trait = grey_eminence
        		}
        	}
        	modifier = {
        		factor = 1.5
        		OR = {
	        		diplomacy = 12
	        		intrigue = 12
        		}
        	}
        }

        trigger = {
        	OR = {
        		has_education_diplomacy_trigger = yes
        		has_education_intrigue_trigger = yes
        		diplomacy = 10
        		intrigue = 10
        	}
        	NOT = { has_character_flag = hide_relationships_this_time }
        	NOT = { has_character_flag = wrote_about_relationships }
        }
    }

    option = { #(only available with the right education or stats)
        name = EVTOPTC_JD_10060 #I will write about managing a realm...
        custom_tooltip = { text = EVTOPTC_JD_10060_TT }

        set_character_flag = writing_about_administration

        if = {
        	limit = {
        		OR = {
	        		NOT = { stewardship = 5 }
	        		is_dumb_trigger = yes
	        		has_bottom_tier_education_trait_trigger = yes
        		}
        	}
			set_character_flag = decent_book_potential
        }
        if = {
        	limit = {
	        	OR = {
	        		stewardship = 7
					has_medium_education_trait_trigger = yes
	        	}
        	}
			set_character_flag = good_book_potential
        }
        if = {
        	limit = {
        		OR = {
        			stewardship = 15
					trait = midas_touched
        			is_smart_trigger = yes
        		}
        	}
			set_character_flag = great_book_potential
        }

        ai_chance = {
        	factor = 10
        	modifier = {
        		factor = 0.5
				NOT = { trait = midas_touched } #Basically, to decrease the amount of cookbooks in the world. :D
        	}
        }

        trigger = {
        	OR = {
	        	has_education_stewardship_trigger = yes
	        	stewardship = 10
        	}
        	NOT = { has_character_flag = hide_administration_this_time }
        	NOT = { has_character_flag = wrote_about_administration }
        }
    }

    option = { #(only available with the right education or stats, OR a monastic member with not great stats or education)
        name = EVTOPTD_JD_10060 #I will write about religion...
        custom_tooltip = { text = EVTOPTD_JD_10060_TT }

		set_character_flag = writing_about_religion

		if = {
        	limit = {
        		OR = {
	        		NOT = { learning = 5 }
	        		is_dumb_trigger = yes
	        		has_bottom_tier_education_trait_trigger = yes
        		}
        	}
			set_character_flag = decent_book_potential
        }
        if = {
        	limit = {
	        	OR = {
	        		learning = 7
					has_medium_education_trait_trigger = yes
	        	}
        	}
			set_character_flag = good_book_potential
        }
        if = {
        	limit = {
        		OR = {
        			learning = 15
        			trait = mastermind_theologian
        			is_smart_trigger = yes
        		}
        	}
			set_character_flag = great_book_potential
        }
        
        ai_chance = {
        	factor = 10
        	modifier = {
        		factor = 2
				trait = mastermind_theologian
        	}
        	modifier = {
        		factor = 1.5
				is_monastic_member_trigger = yes
        	}
        	modifier = {
        		factor = 1.5
        		learning = 12
        	}
        }

        trigger = {
        	OR = {
	        	has_education_learning_trigger = yes
	        	learning = 10
        		is_monastic_member_trigger = yes
        	}
        	NOT = { has_character_flag = hide_learning_this_time }
        	NOT = { has_character_flag = wrote_about_religion }
        }
    }

    option = { #(always available)
        name = EVTOPTH_JD_10060 #I shall chronicle my family history!
        custom_tooltip = { text = EVTOPTH_JD_10060_TT }

        if = {
        	limit = {
        		OR = {
        			calc_true_if = { 
						amount = 3
		        		NOT = { diplomacy = 8 }
	        			NOT = { martial = 8 }
	        			NOT = { intrigue = 8 }
	        			NOT = { stewardship = 8 }
	        			NOT = { learning = 8 }
        			}
	        		is_dumb_trigger = yes
	        		has_bottom_tier_education_trait_trigger = yes
        		}
        	}
			set_character_flag = decent_book_potential
        }
        if = {
        	limit = {
	        	OR = {
	        		calc_true_if = { 
						amount = 3
		        		diplomacy = 12
	        			martial = 12
	        			intrigue = 12
	        			stewardship = 12
	        			learning = 12
	        		}
					has_medium_education_trait_trigger = yes
	        	}
        	}
			set_character_flag = good_book_potential
        }
        if = {
        	limit = {
        		OR = {
        			calc_true_if = { 
						amount = 3
        				diplomacy = 20
	        			martial = 20
	        			intrigue = 20
	        			stewardship = 20
	        			learning = 20
	        		}
        			is_smart_trigger = yes
					has_top_tier_education_trait_trigger = yes
        		}
        	}
			set_character_flag = great_book_potential
        }

        set_character_flag = writing_about_dynasty

        ai_chance = {
        	factor = 10
        }
        
        trigger = {
        	NOT = { has_character_flag = wrote_about_dynasty }
        }
    }

    after = {
	    if = {
	    	limit = {
	    		ai = no
	    	}
	    	add_character_modifier = {
				name = writing_a_book
				duration = -1
			}
	    }
    	hidden_effect = {
    		random_list = {
    			10 = {
    				character_event = { id = JD.10061 days = 600 random = 1095 } #invest more time/money/hire scribes 
    			}
    			10 = {
    				character_event = { id = JD.10062 days = 600 random = 1095 } #change direction/unhappy with work
    			}
    			10 = {
    				character_event = { id = JD.10063 days = 600  random = 1095 } #deal with writer's block
    			}
    			10 = {
    				character_event = { id = JD.10064 days = 600  random = 1095 } #stay up all night studying or not
    			}
				
				# testing values....
#    			10 = {
#    				character_event = { id = JD.10061 days = 5 random = 5 } #invest more time/money/hire scribes 
#    			}
#    			10 = {
#    				character_event = { id = JD.10062 days = 5 random = 5 } #change direction/unhappy with work
#    			}
#    			10 = {
#    				character_event = { id = JD.10063 days = 5  random = 5 } #deal with writer's block
#    			}
#    			10 = {
#    				character_event = { id = JD.10064 days = 5  random = 5 } #stay up all night studying or not
#    			}
    		}
    	}
    }
}


character_event = { #Progress event type 1!  #invest more time/money/hire scribes
    id = JD.10061
    picture = GFX_evt_monk
    title = EVTTITLE_JD_10061
    border = GFX_event_normal_frame_religion
    is_triggered_only = yes
    
    immediate = {
    	job_chancellor = { #For GetChancellorName
    		save_event_target_as = advisor_target
    	}
    }

    desc = {
    	text = EVTDESC_JD_10061_A
    	trigger = {
    		job_chancellor = { is_alive = yes }
    	}
    }
    desc = {
    	text = EVTDESC_JD_10061_B
    	trigger = {
    		NOT = { job_chancellor = { is_alive = yes } }
    	}
    }

    option = { # I want to invest in more into scribes and ink.
        name = EVTOPTA_JD_10061
        #custom_tooltip = { text = EVTOPTA_JD_10061_TT }
        scaled_wealth = -0.2
    }
    option = { # Maybe I can help..?
        name = EVTOPTB_JD_10061

        tooltip_info = yes

        if = { #if a learned character, things might go well, regardless!
        	limit = { NOT = { is_dumb_trigger = yes } }
	        trigger_switch = {
	        	on_trigger = trait
	        	erudite = { custom_tooltip = { text = available_because_trait_erudite_tt } }
	        	scholar = { custom_tooltip =  { text = available_because_trait_scholar_tt } }
	        	mastermind_theologian = { custom_tooltip =  { text = available_because_trait_mastermind_theologian_tt } }
	        	lunatic = { custom_tooltip =  { text = available_because_trait_lunatic_tt } }
	        }
        	custom_tooltip = { text = higher_quality_of_book_TT }
	        set_higher_quality_of_book_flags_effect = yes
        }

        if = { limit = { is_dumb_trigger = yes } #if a dumb character, you might learn something, but the work might suffer...
        	custom_tooltip = { text = available_because_is_dumb_tt }
        	random = {
				chance = 50
				change_learning = 1
			}
			custom_tooltip = { text = lower_quality_of_book_TT }
        	set_lower_quality_of_book_flags_effect = yes
        }

        trigger = {
        	OR = {
        		trait = erudite
        		trait = scholar
        		trait = mastermind_theologian
        		trait = lunatic
        		is_dumb_trigger = yes
        	}
        }
    }
    option = { # Things are going great!
        name = EVTOPTC_JD_10061
        custom_tooltip = { text = lower_quality_of_book_TT }
        set_lower_quality_of_book_flags_effect = yes
    }
    after = {
    	hidden_effect = {
    		send_final_book_outcome_event_effect = yes
    	}
    }
}

character_event = { #Progress event type 2! #Unhappy with work (gain stressed or not)
    id = JD.10062
    title = EVTTITLE_JD_10062
    desc = EVTDESC_JD_10062
    picture = GFX_evt_library
    border = GFX_event_normal_frame_religion
    is_triggered_only = yes
    
    immediate = {
    	random_courtier = { #fallbacks in case no council member... (except lunatics, who just don't care)
    		save_event_target_as = friendly_advice_target
    		if = {
    			limit = { trait = lunatic }
    			break = yes
    		}
    	}
    	random_courtier = { #better fallbacks in case no council member...
    		limit = { NOT = { trait = incapable } is_inaccessible_trigger = no }
    		save_event_target_as = friendly_advice_target
    	}
    	random_courtier = { #grown-up fallback in case no council member...
    		limit = { is_adult = yes NOT = { trait = incapable } is_inaccessible_trigger = no }
    		save_event_target_as = friendly_advice_target
    	}
    	trigger_switch = {
    		on_trigger = has_character_flag
    		writing_about_battle = {
    			if = {
    				limit = { job_marshal = { is_alive = yes } }
    				job_marshal = {
    					save_event_target_as = friendly_advice_target
    				}
    			}
    		}
    		writing_about_relationships = {
    			if = {
    				limit = { job_chancellor = { is_alive = yes } }
    				job_chancellor = {
    					save_event_target_as = friendly_advice_target
    				}
    			}
    			if = {
    				limit = { job_spymaster = { is_alive = yes } }
    				job_spymaster = {
    					save_event_target_as = friendly_advice_target
    				}
    			}
    		}
    		writing_about_administration = {
    			if = {
    				limit = { job_treasurer = { is_alive = yes } }
    				job_treasurer = {
    					save_event_target_as = friendly_advice_target
    				}
    			}
    		}
    		writing_about_religion = {
    			if = {
    				limit = { job_spiritual = { is_alive = yes } }
    				job_spiritual = {
    					save_event_target_as = friendly_advice_target
    				}
    			}
    		}
    		writing_about_dynasty = {
    			if = {
    				limit = { job_chancellor = { is_alive = yes } }
    				job_chancellor = {
    					save_event_target_as = friendly_advice_target
    				}
    			}
    			if = {
    				limit = { is_married = yes }
    				random_spouse = { save_event_target_as = friendly_advice_target }
    			}
    			if = {
    				limit = { has_lover = yes }
    				random_lover = { save_event_target_as = friendly_advice_target }
    			}
    		}
    	}
    }

    option = { # I'll ask random_target for advice!
        name = EVTOPTA_JD_10062

        trigger_switch = {
        	on_trigger = has_character_flag
        	writing_about_battle = {
        		event_target:friendly_advice_target = {
        			show_scope_change = no
        			if = {
        				limit = {
        					attribute_diff = { character = ROOT attribute = martial value = 3 }
        				}
        				ROOT = {
        					show_scope_change = no
	        				custom_tooltip = { text = higher_quality_of_book_TT }
    	    				set_higher_quality_of_book_flags_effect = yes
    	    			}
        			}
        			else = {
        				ROOT = {
        					show_scope_change = no
	        				custom_tooltip = { text = lower_quality_of_book_TT }
    	    				set_lower_quality_of_book_flags_effect = yes
    	    			}
        			}
        		}
        	}
        	writing_about_relationships = {
        		event_target:friendly_advice_target = {
        			show_scope_change = no
        			if = {
        				limit = {
        					has_job_title = job_chancellor
       						attribute_diff = { character = ROOT attribute = diplomacy value = 3 }
        				}
	        			ROOT = {
	        				show_scope_change = no
	        				custom_tooltip = { text = higher_quality_of_book_TT }
	        				set_higher_quality_of_book_flags_effect = yes
        				}
        			}
        			if = {
        				limit = {
        					has_job_title = job_spymaster
       						attribute_diff = { character = ROOT attribute = intrigue value = 3 }
        				}
        				ROOT = {
        					show_scope_change = no
	        				custom_tooltip = { text = higher_quality_of_book_TT }
	        				set_higher_quality_of_book_flags_effect = yes
	        			}
        			}
        			else = {
        				ROOT = {
        					show_scope_change = no
	        				custom_tooltip = { text = lower_quality_of_book_TT }
	        				set_lower_quality_of_book_flags_effect = yes
	        			}
        			}
        		}
        	}
        	writing_about_administration = {
        		event_target:friendly_advice_target = {
        			show_scope_change = no
        			if = {
        				limit = {
        					attribute_diff = { character = ROOT attribute = stewardship value = 3 }
        				}
        				ROOT = {
        					show_scope_change = no
	        				custom_tooltip = { text = higher_quality_of_book_TT }
    	    				set_higher_quality_of_book_flags_effect = yes
    	    			}
        			}
        			else = {
        				ROOT = {
        					show_scope_change = no
        					custom_tooltip = { text = lower_quality_of_book_TT }
        					set_lower_quality_of_book_flags_effect = yes
        				}
        			}
        		}
        	}
        	writing_about_religion = {
        		event_target:friendly_advice_target = {
        			show_scope_change = no
        			if = {
        				limit = {
        					attribute_diff = { character = ROOT attribute = learning value = 3 }
        				}
        				ROOT = {
        					show_scope_change = no
	        				custom_tooltip = { text = higher_quality_of_book_TT }
	        				set_higher_quality_of_book_flags_effect = yes
	        			}
        			}
        			else = {
        				ROOT = {
        					show_scope_change = no
        					custom_tooltip = { text = lower_quality_of_book_TT }
        					set_lower_quality_of_book_flags_effect = yes
        				}
        			}
        		}
        	}
        	writing_about_dynasty = {
        		event_target:friendly_advice_target = {
        			show_scope_change = no
        			if = {
        				limit = {
        					OR = {
        						attribute_diff = { character = ROOT attribute = diplomacy value = 4 }
								attribute_diff = { character = ROOT attribute = learning value = 4 }
        					}
        				}
        				ROOT = {
        					show_scope_change = no
        					custom_tooltip = { text = higher_quality_of_book_TT }
        					set_higher_quality_of_book_flags_effect = yes
        				}
        			}
        			else = {
        				ROOT = {
        					show_scope_change = no
	        				custom_tooltip = { text = lower_quality_of_book_TT }
	        				set_lower_quality_of_book_flags_effect = yes
        				}
        			}
        		}
        	}
        }

        #Add opinion boost with target.
        reverse_opinion = {
			who = event_target:friendly_advice_target
			modifier = opinion_grateful
			years = 10
		}
    }
    option = { # I'd rather not involve anyone else.
        name = EVTOPTB_JD_10062
        add_trait = stressed
    }
    after = {
    	hidden_effect = {
    		send_final_book_outcome_event_effect = yes
    	}
    }
}


character_event = { #Progress event type 3!  #deal with writer's block (risk doing something stupid?
    id = JD.10063
    title = EVTTITLE_JD_10063
    desc = EVTDESC_JD_10063
    picture = GFX_evt_princess_byzantine
    border = GFX_event_normal_frame_religion
    is_triggered_only = yes
    trigger = {
    
    }

    immediate = {
    	hidden_effect = {
	    	if = {
	    		limit = {
	    			any_courtier_or_vassal = { has_minor_title = title_court_physician }
	    		}
	    		random_courtier_or_vassal = {
	    			limit = { has_minor_title = title_court_physician }
	    			save_event_target_as = my_doctor
	    		}
	    	}
    	}
    }

    option = { # Go mingle with the commoners!
        name = EVTOPTA_JD_10063
        custom_tooltip = { text = EVTOPTA_JD_10063_TT }

        random_list = {
        	45 = {
        		add_trait = wounded
				hidden_tooltip = { character_event = { id = 38280 } }
        	}
        	5 = {
        		add_maimed_trait_effect = yes
        	}
        	55 = {
        		#Nothing happens!
        	}
		}
		custom_tooltip = { text = higher_quality_of_book_TT }
		set_higher_quality_of_book_flags_effect = yes
    }
    option = { # Drink something poisonous...?
        name = EVTOPTB_JD_10063
        custom_tooltip = { text = EVTOPTB_JD_10063_TT }
        random_list = {
        	99 = {
		 		add_trait = vomiting
				set_character_flag = disease_not_serious
		 		hidden_effect = { character_event = { id = HFP.14005 days = 10 random = 30 } } #remove vomiting
        	}
			1 = {
				death = { death_reason = death_drank_poison }
			}
		}

		show_portrait = event_target:my_doctor
		custom_tooltip = { text = higher_quality_of_book_TT }
		set_higher_quality_of_book_flags_effect = yes

		trigger = {
			event_target:my_doctor = { always = yes }
		}
    }
    option = { # I clearly need a break...
        name = EVTOPTC_JD_10063
        custom_tooltip = { text = lower_quality_of_book_TT }
        set_lower_quality_of_book_flags_effect = yes
    }
    after = {
    	hidden_effect = {
    		send_final_book_outcome_event_effect = yes
    	}
    }
}
##
character_event = { #Progress event type 4!  #stay up all night or not
    id = JD.10064
    title = EVTTITLE_JD_10064
    picture = GFX_evt_daughter_asking_father
    border = GFX_event_normal_frame_religion
    is_triggered_only = yes
    
    desc = {
    	text = EVTDESC_JD_10064_martial
    	trigger = { has_character_flag = writing_about_battle }
    }
    desc = {
    	text = EVTDESC_JD_10064_relationships
    	trigger = { has_character_flag = writing_about_relationships }
    }
    desc = {
    	text = EVTDESC_JD_10064_administration
    	trigger = { has_character_flag = writing_about_administration }
    }
    desc = {
    	text = EVTDESC_JD_10064_religion
    	trigger = { has_character_flag = writing_about_religion }
    }
    desc = {
    	text = EVTDESC_JD_10064_dynasty
    	trigger = { has_character_flag = writing_about_dynasty }
    }

    option = { # Stay up all night
        name = {
        	text = EVTOPTA_JD_10064
        	trigger = {
        		NOT = { has_character_flag = writing_about_dynasty }
        	}
        }
        name = {
        	text = EVTOPTA_JD_10064_dynasty
        	trigger = {
        		has_character_flag = writing_about_dynasty
        	}
        }

        trigger_switch = {
        	on_trigger = has_character_flag
        	writing_about_battle = {
        		random = {
        			chance = 80
        			if = {
        				limit = { has_dlc = Reapers }
        				custom_tooltip = {
        					text = you_get_a_cold_of_some_sort_tt
        				}
	        			hidden_effect = {
	        				random_list = {
	        					10 = {
	        						give_pneumonic_effect = yes
	        					}
	        					10 = {
	        						give_flu_effect = yes
	        					}
	        				}
	        			}
        			}
        			else = {
        				add_trait = ill
        			}
        		}
        	}
        	writing_about_relationships = {
        		random = {
        			chance = 90
        			add_trait = stressed
        			hidden_effect = {
        				character_event = { id = 38282 } #Notify Stressed
        			}
        		}
        	}
        	writing_about_administration = {
        		random = {
        			chance = 80
        			if = {
        				limit = { has_dlc = Reapers }
        				custom_tooltip = {
        					text = you_get_a_cold_of_some_sort_tt
        				}
	        			hidden_effect = {
	        				random_list = {
	        					10 = {
	        						give_pneumonic_effect = yes
	        					}
	        					10 = {
	        						give_flu_effect = yes
	        					}
	        				}
	        			}
        			}
        			else = {
        				add_trait = ill
        			}
        		}
        	}
        	writing_about_religion = {
        		random = {
        			chance = 80
        			if = {
        				limit = { has_dlc = Reapers }
        				custom_tooltip = {
        					text = you_get_a_cold_of_some_sort_tt
        				}
	        			hidden_effect = {
	        				random_list = {
	        					10 = {
	        						give_pneumonic_effect = yes
	        					}
	        					10 = {
	        						give_flu_effect = yes
	        					}
	        				}
	        			}
        			}
        			else = {
        				add_trait = ill
        			}
        		}
        	}
        	writing_about_dynasty = {
        		piety = -50
        		random = {
        			chance = 80
        			if = {
        				limit = { has_dlc = Reapers }
        				custom_tooltip = {
        					text = you_get_a_cold_of_some_sort_tt
        				}
	        			hidden_effect = {
	        				random_list = {
	        					10 = {
	        						give_pneumonic_effect = yes
	        					}
	        					10 = {
	        						give_flu_effect = yes
	        					}
	        				}
	        			}
        			}
        			else = {
        				add_trait = ill
        			}
        		}
        	}
        }
		custom_tooltip = { text = higher_quality_of_book_TT }
		set_higher_quality_of_book_flags_effect = yes
    }
    option = { # I probably just need to sleep on it.
        name = {
        	text = EVTOPTB_JD_10064
        	trigger = {
        		NOT = { has_character_flag = writing_about_dynasty }
        	}
        }
        name = {
        	text = EVTOPTB_JD_10064_dynasty
        	trigger = {
        		has_character_flag = writing_about_dynasty
        	}
        }
        #custom_tooltip = { text = lower_quality_of_book_TT }
        #set_lower_quality_of_book_flags_effect = yes
    }
    after = {
    	hidden_effect = {
    		send_final_book_outcome_event_effect = yes
    	}
    }
}

character_event = { #Outcome: Book is finished! It went Great/Good/Decent!
    id = JD.10070    
    title = EVTTITLE_JD_10070
    desc = EVTDESC_JD_10070_A
    picture = GFX_evt_library
    border = GFX_event_normal_frame_religion
    is_triggered_only = yes

    hide_from = yes

    trigger = {
    	is_landed = yes
    }

    immediate = {
    	hidden_effect = {
    		#Fallback in case flags have cleared somehow...
			if = {
				limit = {
					NOR = {
						has_character_flag = decent_book_potential
		        		has_character_flag = good_book_potential
		        		has_character_flag = great_book_potential
					}
				}
				set_character_flag = decent_book_potential
			}

	    	#Evaluates how it's gone, from stats, traits, and choices. The flags unlock quality-level of book (or eliminates a level). Relevant event_targets (spouse/lover?) are saved, for loc (custom book names and descs) and opinion bonuses.
	    	trigger_switch = {
	    		on_trigger = has_character_flag
	    		writing_about_battle = {
	    			random_list = {
	    				10 = { #quality level 1
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = decent_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								has_lifestyle_martial_trigger = no
							}
							additive_modifier = {
								value = 10
								has_education_martial_trigger = no
							}
							additive_modifier = {
								value = 10
								OR = {
									is_the_worst_duelist_trigger = yes
									is_terrible_duelist_trigger = yes
								}
							}
							additive_modifier = {
								value = 10
								NOT = { martial = 5 }
							}
							additive_modifier = {
								value = 10
								NOT = { martial = 10 }
							}
	    					random_list = {
			    				10 = {
			    					add_artifact = how_to_hold_a_sword
			    					random = {
			    						chance = 50
		    							new_artifact = {
		    								set_name = how_to_carry_a_bow
		    								set_description = how_to_carry_a_bow_desc
		    							}
			    					}
			    					trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = how_to_hold_a_sword
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
				    				random_rival = { save_event_target_as = dedication_target }
			    					add_artifact = lessons_taught_to_me_by_rival_1
			    					new_artifact = {
			    						set_description = lessons_taught_to_me_by_rival_1_desc_rename
			    					}

			    					additive_modifier = {
										value = 10
										any_rival = { is_adult = yes }
									}
									trigger = { 
										any_rival = { is_adult = yes }
										NOT = {
											any_artifact = {
												artifact_type = lessons_taught_to_me_by_rival_1
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    				10 = { #quality level 2
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = good_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								duelist_skill_is_medium_group_trigger = yes
							}
							additive_modifier = {
								value = 10
								OR = {
									trait = misguided_warrior
									trait = tough_soldier
								}
							}
							additive_modifier = {
								value = 10
								OR = {
									has_focus = focus_war
									has_focus = focus_hunting							
								}
							}
	    					random_list = {
			    				10 = {
			    					add_artifact = a_history_of_armor
			    					additive_modifier = {
										value = 10
										trait = administrator
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = a_history_of_armor
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_life_of_root
			    					new_artifact = {
			    						set_description = the_life_of_root_desc_rename
			    					}
			    					additive_modifier = {
										value = 10
										trait = strategist
									}
									additive_modifier = {
										value = 10
										trait = proud
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = the_life_of_root
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = a_soldiers_life
			    					additive_modifier = {
										value = 10
										trait = poet
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = a_soldiers_life
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					random_rival = { save_event_target_as = dedication_target }
			    					add_artifact = lessons_taught_to_me_by_rival_2
			    					new_artifact = {
			    						set_description = lessons_taught_to_me_by_rival_2_desc_rename
			    						random_list = {
			    							50 = {
			    								set_name = lessons_taught_to_me_by_rival_2_rename_1
			    							}
			    							50 = {
			    								set_name = lessons_taught_to_me_by_rival_2_rename_2
			    							}
			    						}
			    					}
			    					additive_modifier = {
										value = 10
										any_rival = { is_adult = yes }
									}
									trigger = { 
										any_rival = { is_adult = yes }
										NOT = {
											any_artifact = {
												artifact_type = lessons_taught_to_me_by_rival_2
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_wisdom_of_the_heavens
			    					additive_modifier = {
										value = 10
										trait = hunter
									}
									additive_modifier = {
										value = 10
										trait = falconer
									}
									additive_modifier = {
										value = 10
										has_focus = focus_hunting
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = the_wisdom_of_the_heavens
												original_owner = { character = ROOT }
											}
										}
										trait = falconer
									}
			    				}
	    					}
	    				}
	    				10 = { #quality level 3 (or 4)
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = great_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								has_lifestyle_martial_trigger = yes
							}
							additive_modifier = {
								value = 10
								has_education_martial_trigger = yes
								NOT = { trait = misguided_warrior }
							}
							additive_modifier = {
								value = 10
								duelist_skill_is_high_group_trigger = yes
							}
							additive_modifier = {
								value = 10
								is_the_best_duelist_trigger = yes
							}
							additive_modifier = {
								value = 10
								NOT = { can_have_more_leadership_traits = yes }
							}
							additive_modifier = {
								value = 10
								OR = {
									has_focus = focus_war
									has_focus = focus_hunting					
								}
							}
							additive_modifier = {
								value = 10
								martial = 10
							}
							additive_modifier = {
								value = 10
								martial = 15
							}
							additive_modifier = {
								value = 10
								martial = 20
							}
	    					random_list = {
			    				10 = {
			    					add_artifact = military_strategy_guide
			    					additive_modifier = {
										value = 10
										trait = strategist
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = military_strategy_guide
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = my_fechtbuch
			    					new_artifact = {
			    						set_name = my_fechtbuch_rename
			    					}

			    					additive_modifier = {
										value = 5
										trait = duelist
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = my_fechtbuch
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = codex_dynasty_name
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = codex_dynasty_name
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_sword_and_buckler
			    					additive_modifier = {
										value = 10
										trait = duelist
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = the_sword_and_buckler
												original_owner = { character = ROOT }
											}
										}
										OR = {
											trait = duelist
											trait = hunter
											trait = strategist
											has_education_martial_trigger = yes
										}
									}
			    				}
			    				10 = {
			    					random_rival = {
			    						limit = { root_attraction_trigger = yes is_adult = yes } #if ROOT can be attracted to them...
			    						save_event_target_as = dedication_target
			    					}
			    					add_artifact = lessons_taught_to_me_by_rival_3
			    					new_artifact = {
			    						set_description = lessons_taught_to_me_by_rival_3_desc_rename
			    					}
			    					additive_modifier = {
										value = 10
										any_rival = { always = yes }
									}
									additive_modifier = {
										value = 10
										OR = {
											trait = lustful
											trait = hedonist									
										}
									}
									trigger = { 
										any_rival = {
											root_attraction_trigger = yes
											is_adult = yes
											OR = {
												ROOT = { has_religion_feature = religion_feature_zun }
												ROOT = { has_religion_feature = religion_holy_family }
												ROOT = { religion = messalian }
												ROOT = { religion = zoroastrian }
												NOT = { is_close_relative = ROOT }
											}
										}
										NOT = {
											any_artifact = {
												artifact_type = lessons_taught_to_me_by_rival_3
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = ordinary_beasts
			    					additive_modifier = {
										value = 10
										has_focus = focus_intrigue
									}
									additive_modifier = {
										value = 10
										trait = arbitrary
									}
									additive_modifier = {
										value = 10
										trait = cruel
									}
									additive_modifier = {
										value = 10
										has_lifestyle_intrigue_trigger = yes
									}
									additive_modifier = {
										value = 10
										is_weak_trigger = yes
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = ordinary_beasts
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_white_animal
			    					new_artifact = {
			    						set_name = the_white_animal_rename
			    						set_description = the_white_animal_desc_rename
			    					}
			    					additive_modifier = {
										value = 10
										trait = hunter
									}
									additive_modifier = {
										value = 10
										trait = falconer
									}
									additive_modifier = {
										value = 10
										has_focus = focus_hunting
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = the_white_animal
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_bestiary
			    					additive_modifier = {
										value = 10
										trait = hunter
									}
									additive_modifier = {
										value = 10
										trait = falconer
									}
									additive_modifier = {
										value = 10
										has_focus = focus_hunting
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = the_bestiary
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_book_of_shadows
			    					additive_modifier = {
										value = 10
										trait = duelist
									}
									additive_modifier = {
										value = 10
										has_education_intrigue_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_focus = focus_intrigue
									}
									additive_modifier = {
										value = 10
										has_lifestyle_intrigue_trigger = yes
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = the_book_of_shadows
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = on_government_type_warfare
			    					new_artifact = {
			    						set_name = on_government_type_warfare_rename
			    						set_description = on_government_type_warfare_desc_rename
			    					}
			    					additive_modifier = {
										value = 10
										trait = strategist
									}
									additive_modifier = {
										value = 10
										has_education_martial_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_focus = focus_war
									}
									additive_modifier = {
										value = 10
										OR = {
											trait = diligent
											trait = organizer
											trait = inspiring_leader
											trait = defensive_leader
										}
									}
									trigger = {
				    					NOT = {
											any_artifact = {
												artifact_type = on_government_type_warfare
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    			}
	    			set_character_flag = wrote_about_battle
	    		}
	    		writing_about_relationships = {
	    			random_list = {
	    				10 = { #quality level 1
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = decent_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								has_bottom_tier_education_trait_trigger = yes
							}
							additive_modifier = {
								value = 10
								OR = {
									NOT = { diplomacy = 1 }
									NOT = { intrigue = 1 }
								}
							}
							additive_modifier = {
								value = 10
								OR = {
									NOT = { diplomacy = 5 }
									NOT = { intrigue = 5 }
								}
							}
							additive_modifier = {
								value = 10
								OR = {
									NOT = { diplomacy = 10 }
									NOT = { intrigue = 10 }
								}
							}
	    					random_list = {
			    				10 = {
			    					add_artifact = to_my_descendants
			    					additive_modifier = {
										value = 10
										trait = stubborn
									}
									additive_modifier = {
										value = 10
										trait = cynical
									}
									additive_modifier = {
										value = 10
										trait = diligent
									}
									additive_modifier = {
										value = 10
										trait = paranoid
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = to_my_descendants
												original_owner = { dynasty = ROOT }
											}
										}
									}
			    				}
			    				10 = {
									random_lover = { save_event_target_as = dedication_target }
			    					add_artifact = in_honor_of_roots_beloved_1
			    					new_artifact = {
			    						set_name = in_honor_of_roots_beloved_1_rename
			    						set_description = in_honor_of_roots_beloved_1_desc_rename_lover
			    					}
			    					additive_modifier = {
										value = 10
										trait = kind
									}
									additive_modifier = {
										value = 10
										trait = shy
									}
									additive_modifier = {
										value = 10
										trait = lustful
									}
			    					trigger = {
			    						has_lover = yes
			    						NOT = {
											any_artifact = {
												artifact_type = in_honor_of_roots_beloved_1
												original_owner = { character = ROOT }
											}
										}
			    					}
			    				}
			    				10 = {
			    					random_spouse = { save_event_target_as = dedication_target }
			    					add_artifact = in_honor_of_roots_beloved_1
			    					new_artifact = {
			    						set_name = in_honor_of_roots_beloved_1_rename
			    						set_description = in_honor_of_roots_beloved_1_desc_rename_spouse
			    					}
			    					additive_modifier = {
										value = 10
										trait = kind
									}
									additive_modifier = {
										value = 10
										trait = shy
									}
			    					trigger = { is_married = yes }
			    				}
			    				10 = {
			    					add_artifact = court_etiquette_1 #only if have no other volumes in the series
			    					trigger = {
			    						NOT = {
			    							any_artifact = {
			    								OR = {
			    									artifact_type = court_etiquette_2
			    									artifact_type = court_etiquette_3    								
			    								}
			    							}
			    						}
			    					}
			    				}
	    					}
	    				}
	    				10 = { #quality level 2
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = good_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								OR = {
									has_focus = focus_intrigue
									has_focus = focus_family
								}
							}
							additive_modifier = {
								value = 10
								NOT = { diplomacy = 10 }
							}
							additive_modifier = {
								value = 10
								NOT = { intrigue = 10 }
							}
	    					random_list = {
	    						10 = {
			    					random_spouse = { save_event_target_as = dedication_target }
			    					add_artifact = in_honor_of_roots_beloved_2
			    					new_artifact = {
			    						set_name = in_honor_of_roots_beloved_2_rename
			    						set_description = in_honor_of_roots_beloved_2_desc_rename_spouse
			    					}
			    					additive_modifier = {
										value = 10
										any_spouse = {
											possibly_romantically_interested_in_ROOT_trigger = yes
										}
									}
									additive_modifier = {
										value = 5
										has_focus = focus_family
									}
									additive_modifier = {
										value = 10
										trait = poet
									}
			    					trigger = {
			    						is_married = yes
			    						NOT = {
											any_artifact = {
												artifact_type = in_honor_of_roots_beloved_2
												original_owner = { character = ROOT }
											}
										}
			    					}
			    				}
			    				10 = {
									random_lover = { save_event_target_as = dedication_target }
			    					add_artifact = in_honor_of_roots_beloved_2
			    					new_artifact = {
			    						set_name = in_honor_of_roots_beloved_2_rename
			    						set_description = in_honor_of_roots_beloved_2_desc_rename_lover
			    					}
			    					additive_modifier = {
										value = 10
										trait = cynical
									}
									additive_modifier = {
										value = 10
										trait = lustful
									}
									additive_modifier = {
										value = 10
										trait = cruel
									}
									additive_modifier = {
										value = 5
										trait = poet
									}
			    					trigger = {
			    						has_lover = yes
			    						NOT = {
			    							any_lover = {
			    								spouse = { character = ROOT }
			    							}
			    						}
			    						NOT = {
											any_artifact = {
												artifact_type = in_honor_of_roots_beloved_2
												original_owner = { character = ROOT }
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = notes_from_a_kitchen
			    					additive_modifier = {
										value = 10
										trait = poet
									}
									additive_modifier = {
										value = 5
										trait = gluttonous
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = notes_from_a_kitchen
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				20 = {
			    					random_artifact = {
			    						limit = {
			    							artifact_type = court_etiquette_1
			    						}
			    						original_artifact_owner = {
			    							save_event_target_as = other_author
			    						}
			    					}
			    					add_artifact = court_etiquette_2 #if you have volume I already!
			    					new_artifact = {
			    						set_description = court_etiquette_2_desc_rename #sets the name of the other author
			    					}

			    					trigger = {
			    						any_artifact = {
			    							artifact_type = court_etiquette_1
			    						}
			    						NOT = {
			    							any_artifact = {
			    								OR = {
			    									artifact_type = court_etiquette_2
			    									artifact_type = court_etiquette_3    								
			    								}
			    							}
			    						}
			    					}
			    				}
			    				10 = {
			    					add_artifact = how_to_write_a_letter
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = how_to_write_a_letter
												original_owner = { character = ROOT }
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = fifty_shades_of_root
			    					new_artifact = {
			    						set_description = fifty_shades_of_root_desc_rename
			    					}
			    					additive_modifier = {
										value = -5
										is_learned_trigger = yes
									}
									additive_modifier = {
										value = 5
										trait = lustful
									}
									additive_modifier = {
										value = 5
										trait = cruel
									}
									additive_modifier = {
										value = 5
										trait = impaler
									}
									additive_modifier = {
										value = 5
										trait = arbitrary
									}
									additive_modifier = {
										value = 5
										is_evil_trigger = yes
									}
			    					trigger = {
			    						OR = {
			    							trait = lustful
			    							trait = hedonist
			    							trait = seducer
			    							trait = seductress
			    						}
			    						NOT = {
											any_artifact = {
												artifact_type = fifty_shades_of_root
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = how_to_make_allies
			    					additive_modifier = {
										value = 10
										trait = shy
									}
									additive_modifier = {
										value = 10
										trait = paranoid
									}
									additive_modifier = {
										value = 10
										trait = ambitious
									}
									additive_modifier = {
										value = 10
										trait = cynical
									}
									additive_modifier = {
										value = 5
										OR = {
											has_education_stewardship_trigger = yes
											has_education_intrigue_trigger = yes									
										}
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = how_to_make_allies
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    				10 = { #quality level 3 (or 4)
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = great_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								OR = {
									has_lifestyle_diplomacy_trigger = yes
									has_lifestyle_intrigue_trigger = yes
								}
							}
							additive_modifier = {
								value = 10
								OR = {
									has_education_diplomacy_trigger = yes
									has_education_intrigue_trigger = yes
								}
							}
							additive_modifier = {
								value = 10
								OR = {
									has_focus = focus_intrigue
									has_focus = focus_family
								}
							}
							additive_modifier = {
								value = 10
								OR = {
									diplomacy = 10
									intrigue = 10
								}
							}
							additive_modifier = {
								value = 10
								OR = {
									diplomacy = 15
									intrigue = 15
								}
							}
							additive_modifier = {
								value = 10
								OR = {
									diplomacy = 20
									intrigue = 20
								}
							}
	    					random_list = {
			    				10 = {
			    					random_spouse = { save_event_target_as = dedication_target }
			    					random_lover = { save_event_target_as = dedication_target }
			    					add_artifact = in_honor_of_roots_beloved_3
			    					new_artifact = { set_name = in_honor_of_roots_beloved_3_rename }
			    					additive_modifier = {
										value = 10
										trait = lustful
									}
									additive_modifier = {
										value = 10
										trait = poet
									}
			    					trigger = {
			    						OR = {
				    						has_lover = yes
				    						is_married = yes
			    						}
			    						NOT = {
											any_artifact = {
												artifact_type = in_honor_of_roots_beloved_3
												original_owner = { character = ROOT }
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = court_etiquette_3 #if you have volume II already!
			    					trigger = {
			    						any_artifact = {
		    								artifact_type = court_etiquette_2
			    						}
			    						NOT = {
			    							any_artifact = {
		    									artifact_type = court_etiquette_3    								
			    							}
			    						}
			    					}
			    				}
			    				10 = {
			    					add_artifact = kama_sutra
			    					trigger = {
			    						OR = {
			    							AND = {
				    							trait = lustful
				    							trait = hedonist		    							
			    							}
			    							trait = seducer
			    							trait = seductress
			    						}
			    						culture_group = indo_aryan_group
			    						NOT = {
											any_artifact = {
												artifact_type = kama_sutra
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = the_art_of_love
			    					if = {
			    						limit = {
			    							culture_group = latin
			    						}
			    						new_artifact = { set_name = the_art_of_love_rename_1 }
			    					}
			    					else = {
			    						new_artifact = { set_name = the_art_of_love_rename_2 }	
			    					}
			    					additive_modifier = {
										value = 10
										trait = lustful
									}
									additive_modifier = {
										value = 10
										trait = poet
									}
									additive_modifier = {
										value = 10
										trait = hedonist
									}
									additive_modifier = {
										value = 10
										has_lifestyle_diplomacy_trigger = yes
									}
									additive_modifier = {
										value = -5
										is_pious_trigger = yes
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_art_of_love
												original_owner = { character = ROOT }
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = the_hunchback_of_capital
			    					new_artifact = {
			    						set_name = the_hunchback_of_capital_rename
			    						set_description = the_hunchback_of_capital_desc_rename
			    					}		    					
									additive_modifier = {
										value = 10
										has_lifestyle_diplomacy_trigger = yes
									}
									additive_modifier = {
										value = 10
										NOT = { trait = shy }
									}
									additive_modifier = {
										value = 10
										has_pleasant_trait_trigger = yes
									}
									additive_modifier = {
										value = 10
										trait = honest
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_hunchback_of_capital
												original_owner = { character = ROOT }
											}
										}
										trait = hunchback
			    					}
			    				}
			    				10 = {
			    					add_artifact = the_illiad
			    					new_artifact = {
			    						set_description = the_illiad_desc_rename
			    					}
									additive_modifier = {
										value = 10
										has_lifestyle_martial_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_education_martial_trigger = yes
									}
									additive_modifier = {
										value = 10
										trait = poet
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_illiad
											}
										}
			    					}
			    				}
			    				10 = {
			    					random_artifact = {
			    						limit = {
			    							artifact_type = the_illiad
			    						}
			    						original_artifact_owner = {
			    							save_event_target_as = other_author
			    						}
			    					}
			    					add_artifact = the_odyssey
			    					new_artifact = {
			    						set_description = the_odyssey_desc_rename
			    					}
									additive_modifier = {
										value = 10
										has_lifestyle_martial_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_education_martial_trigger = yes
									}
									additive_modifier = {
										value = 10
										trait = poet
									}
									additive_modifier = {
										value = 20
										OR = {
											trait = viking
											trait = pirate
											trait = ravager
											trait = seaking
											trait = sea_queen
										}
									}
			    					trigger = {
			    						any_artifact = {
											artifact_type = the_illiad
										}
			    						NOT = {
											any_artifact = {
												artifact_type = the_odyssey
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = contracts_of_the_romans	    					
									additive_modifier = {
										value = 10
										has_education_stewardship_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_lifestyle_stewardship_trigger = yes
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = contracts_of_the_romans
												original_owner = { character = ROOT }
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = speculum_regale	    					
									additive_modifier = {
										value = 10
										is_smart_trigger = yes
									}
									additive_modifier = {
										value = 10
										age = 50
									}
									additive_modifier = {
										value = 10
										age = 70
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = speculum_regale
												original_owner = { character = ROOT }
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = religious_head_culture_courtesy
			    					new_artifact = {
			    						set_name = religious_head_culture_courtesy_rename
			    						set_description = religious_head_culture_courtesy_desc_rename
			    					}
									additive_modifier = {
										value = 10
										is_pious_trigger = yes
									}
									additive_modifier = {
										value = 10
										trait = stubborn
									}
									trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = religious_head_culture_courtesy
												original_owner = { character = ROOT }
											}
										}
										OR = {
											religion = catholic							
											religion = orthodox
											religion = nestorian
											religion = sunni
											religion = shiite
										}
										rightful_religious_head_scope = { always = yes }
			    					}
			    				}
			    				10 = {
			    					add_artifact = keeping_government_court
			    					new_artifact = {
			    						set_name = keeping_government_court_rename
			    						set_description = keeping_government_court_desc_rename
			    					}
									additive_modifier = {
										value = 10
										is_pious_trigger = yes
									}
									additive_modifier = {
										value = 10
										trait = stubborn
									}
									trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = keeping_government_court
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    			}
	    			set_character_flag = wrote_about_relationships
	    		}
	    		writing_about_administration = {
	    			random_list = {
	    				10 = { #quality level 1
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = decent_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								has_bottom_tier_education_trait_trigger = yes
							}
							additive_modifier = {
								value = 10
								NOT = { stewardship = 1 }
							}
							additive_modifier = {
								value = 10
								NOT = { stewardship = 5 }
							}
							additive_modifier = {
								value = 10
								NOT = { stewardship = 10 }
							}
		    				random_list = {
			    				10 = {
			    					add_artifact = culinary_diary
			    					additive_modifier = {
										value = 10
										trait = stubborn
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = culinary_diary
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = yes_I_ate_that
			    					new_artifact = {
							        	set_description = yes_I_ate_that_desc_rename
							        }
							        additive_modifier = {
										value = 10
										trait = arbitrary
									}
									additive_modifier = {
										value = 10
										trait = gluttonous
									}
									additive_modifier = {
										value = 10
										trait = adventurer
									}
									additive_modifier = {
										value = -5
										trait = proud
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = yes_I_ate_that
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_well_dressed_chef
			    					additive_modifier = {
										value = 10
										trait = proud
									}
									additive_modifier = {
										value = 10
										has_fair_trait_trigger = yes
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = the_well_dressed_chef
												original_owner = { character = ROOT }
											}
										}							
									}
			    				}
			    				10 = {
			    					add_artifact = big_book_of_meat
			    					additive_modifier = {
										value = 10
										trait = arbitrary
									}
									additive_modifier = {
										value = 10
										trait = gluttonous
									}
									additive_modifier = {
										value = 10
										trait = hunter
									}
									additive_modifier = {
										value = -5
										trait = proud
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = big_book_of_meat
												original_owner = { character = ROOT }
											}
										}
										NOT = { religion = jain }
									}
			    				}
			    				10 = {
			    					add_artifact = a_book_of_vegetables
			    					additive_modifier = {
										value = 10
										trait = arbitrary
									}
									additive_modifier = {
										value = 10
										trait = gluttonous
									}
									additive_modifier = {
										value = 10
										trait = hunter
									}
									additive_modifier = {
										value = -5
										trait = proud
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = a_book_of_vegetables
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = fruits_the_book
			    					new_artifact = {
							        	set_description = fruits_the_book_desc_rename
							        }
							        additive_modifier = {
										value = -5
										trait = cannibal_trait
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = fruits_the_book
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = shoddy_recipes
			    					additive_modifier = {
										value = -5
										trait = administrator
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = shoddy_recipes
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = bad_fishing_book
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = bad_fishing_book
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
		    				}
	    				}
	    				10 = { #quality level 2
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = good_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								NOT = { stewardship = 15 }
							}
							additive_modifier = {
								value = 10
								OR = {
									has_focus = focus_business
									has_focus = focus_rulership
								}
							}
	    					random_list = {
			    				10 = {
			    					add_artifact = decent_cookbook
			    					trigger = {
										NOT = {
											any_artifact = {
												artifact_type = decent_cookbook
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = honest_recipes
			    					trigger = {
										NOT = {
											any_artifact = {
												artifact_type = honest_recipes
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = gastronomic_tonics #if intrigue/deceitful? (plot power!)
			    					trigger = {
			    						OR = {
			    							has_education_intrigue_trigger = yes
			    							has_lifestyle_intrigue_trigger = yes
			    							intrigue = 10
			    						}
			    						NOT = {
											any_artifact = {
												artifact_type = gastronomic_tonics
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = the_omnivore #if cannibal
			    					trigger = {
			    						trait = cannibal_trait
										NOT = {
											any_artifact = {
												artifact_type = the_omnivore
											}
										}
			    					}
			    				}
			    			}
	    				}
	    				10 = { #quality level 3 (or 4)
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = great_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								has_lifestyle_stewardship_trigger = yes
							}
							additive_modifier = {
								value = 10
								has_education_stewardship_trigger = yes
							}
							additive_modifier = {
								value = 10
								OR = {
									has_focus = focus_business
									has_focus = focus_rulership
								}
							}
							additive_modifier = {
								value = 10
								stewardship = 10
							}
							additive_modifier = {
								value = 10
								stewardship = 15
							}
							additive_modifier = {
								value = 10
								stewardship = 20
							}
	    					random_list = {
			    				10 = {
			    					add_artifact = the_dynasty_cookbook
			    					additive_modifier = {
										value = 10
										has_focus = focus_family
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = the_dynasty_cookbook
												original_owner = { dynasty = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = modest_measures
			    					new_artifact = {
			    						set_description = modest_measures_desc_rename
			    					}
			    					additive_modifier = {
										value = 10
										trait = temperate
									}
									additive_modifier = {
										value = 10
										trait = humble
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = modest_measures
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = good_cookbook
			    				}
			    				10 = {
			    					add_artifact = cookbook_3_roman
			    					new_artifact = {
			    						set_description = cookbook_3_roman_desc_rename
			    					}
			    					trigger = {
			    						culture_group = latin
			    						NOT = {
				    						any_artifact = {
												artifact_type = cookbook_3_roman
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = cookbook_3_arabic
			    					trigger = {
			    						culture_group = arabic
			    						NOT = {
				    						any_artifact = {
												artifact_type = cookbook_3_arabic
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = cookbook_3_chinese_group
			    					trigger = {
			    						culture_group = chinese_group
			    						NOT = {
				    						any_artifact = {
												artifact_type = cookbook_3_chinese_group
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = cookbook_3_central_german
			    					new_artifact = {
			    						set_description = cookbook_3_central_german_desc_rename
			    					}
			    					trigger = {
			    						culture_group = central_germanic
			    						NOT = {
				    						any_artifact = {
												artifact_type = cookbook_3_central_german
											}
										}
			    					}
			    				}
			    				10 = {
			    					add_artifact = on_culture_architecture
			    					additive_modifier = {
										value = 10
										trait = architect
									}
									additive_modifier = {
										value = 10
										trait = organizer
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = on_culture_architecture
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = how_to_build_a_well
			    					additive_modifier = {
										value = 10
										trait = architect
									}
									additive_modifier = {
										value = 10
										trait = stubborn
									}
									additive_modifier = {
										value = 10
										is_smart_trigger = yes
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = how_to_build_a_well
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = gardens_of_planet
			    					new_artifact = {
			    						set_name = gardens_of_planet_rename
			    					}
									additive_modifier = {
										value = -5
										NOT = { society_member_of = hermetics }
									}
									additive_modifier = {
										value = 10
										trait = gardener
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = gardens_of_planet
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = treatise_on_fishing
			    					additive_modifier = {
										value = 10
										trait = hunter
									}
									additive_modifier = {
										value = 10
										trait = falconer
									}
									additive_modifier = {
										value = 10
										trait = gardener
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = treatise_on_fishing
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    			}
	    			set_character_flag = wrote_about_administration
	    		}
	    		writing_about_religion = {
	    			random_list = {
	    				10 = { #quality level 1
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = decent_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								NOT = { learning = 1 }
							}
							additive_modifier = {
								value = 10
								NOT = { learning = 5 }
							}
							additive_modifier = {
								value = 10
								NOT = { learning = 10 }
							}
							additive_modifier = {
								value = 10
								has_bottom_tier_education_trait_trigger = yes
							}
	    					random_list = {
			    				10 = {
			    					add_artifact = in_honor_of_highgod
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = in_honor_of_highgod
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = faith_eternal
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = faith_eternal
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = what_do_monks_wear
			    					trigger = {
			    						OR = {
			    							is_monastic_member_trigger = yes
			    							religion_group = christian
			    							religion_group = indian_group
			    						}
			    						NOT = {
											any_artifact = {
												artifact_type = what_do_monks_wear
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = learning_languages_1
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = learning_languages_1
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = choice_passages
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = choice_passages
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    				10 = { #quality level 2
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = good_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								NOT = { learning = 15 }
							}
							additive_modifier = {
								value = 10
								OR = {
									has_focus = focus_theology
									has_focus = focus_scholarship
								}
							}
							
	    					random_list = {
			    				10 = {
			    					add_artifact = hymns_to_highgod
			    					additive_modifier = {
										value = 10
										trait = poet
									}
									trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = hymns_to_highgod
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = learning_languages_2
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = learning_languages_2
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = unnatural_history
			    					additive_modifier = {
										value = 10
										trait = hedonist
									}
									additive_modifier = {
										value = 10
										trait = drunkard
									}
									additive_modifier = {
										value = 10
										trait = depressed
									}
									additive_modifier = {
										value = 10
										is_impious_trigger = yes
									}
									additive_modifier = {
										value = 10
										is_devil_worshiper_trigger = yes
									}
									additive_modifier = {
										value = 10
										age = 60
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = unnatural_history
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = human_anatomy
									additive_modifier = {
										value = 20
										trait = cannibal_trait
									}
									additive_modifier = {
										value = 20
										trait = physician
									}
									additive_modifier = {
										value = 10
										trait = impaler
									}
									additive_modifier = {
										value = 10
										trait = erudite
									}
									additive_modifier = {
										value = 10
										has_lifestyle_learning_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_lifestyle_intrigue_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_education_intrigue_trigger = yes
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = human_anatomy
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = maladies_and_remedies
									additive_modifier = {
										value = 10
										trait = physician
									}
									additive_modifier = {
										value = 10
										trait = erudite
									}
									additive_modifier = {
										value = 10
										has_lifestyle_learning_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_lifestyle_intrigue_trigger = yes
									}
									additive_modifier = {
										value = 10
										has_education_intrigue_trigger = yes
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = maladies_and_remedies
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					random_courtier = {
			    						limit = { culture = horse }
			    						save_event_target_as = dedication_target
			    					}
			    					add_artifact = equine_maxims
			    					new_artifact = {
			    						set_name = equine_maxims_rename
			    					}
									additive_modifier = {
										value = 10
										culture = horse
									}
									additive_modifier = {
										value = 30
			    						any_courtier = {
			    							culture = horse
			    						}
									}
									additive_modifier = {
										value = 10
			    						any_courtier = {
			    							count = 2
			    							culture = horse
			    						}
									}
			    					trigger = {
			    						any_courtier = {
			    							culture = horse
			    						}
			    						NOT = {
											any_artifact = {
												artifact_type = equine_maxims
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    				10 = { #quality level 3 (or 4)
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = great_book_potential
	    					}
	    					additive_modifier = {
								value = 10
								has_lifestyle_learning_trigger = yes
							}
							additive_modifier = {
								value = 10
								has_education_learning_trigger = yes
							}
							additive_modifier = {
								value = 10
								is_monastic_member_trigger = yes
							}
							additive_modifier = {
								value = 10
								OR = {
									has_focus = focus_theology
									has_focus = focus_scholarship
								}
							}
							additive_modifier = {
								value = 10
								learning = 10
							}
							additive_modifier = {
								value = 10
								learning = 15
							}
							additive_modifier = {
								value = 10
								learning = 20
							}
	    					random_list = {
			    				10 = {
			    					add_artifact = a_history_of_churches
			    					additive_modifier = {
										value = 10
										trait = architect
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = a_history_of_churches
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = how_to_worship
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = how_to_worship
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_not_actual_holy_book #lunatic only
			    					additive_modifier = {
										value = 10
										trait = lunatic
									}
									additive_modifier = {
										value = 10
										trait = possessed
									}
			    					trigger = {
			    						trait = lunatic
			    						NOT = { any_artifact = { artifact_type = the_not_actual_holy_book } }
			    					}
			    				}
			    				10 = {
			    					add_artifact = the_spirits
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_spirits
												original_owner = { character = ROOT }
											}
										}
										religion_group = pagan_group
									}
			    				}
			    				10 = {
			    					add_artifact = learning_languages_3
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = learning_languages_3
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = learning_languages_4
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = learning_languages_4
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_republic
			    					new_artifact = {
			    						set_name = the_republic_rename
			    					}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_republic
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_confessions_of_root
									additive_modifier = {
										value = -3
										trait = drunkard
									}
									additive_modifier = {
										value = -3
										trait = depressed
									}
									additive_modifier = {
										value = 10
										is_pious_trigger = yes
									}
									additive_modifier = {
										value = 10
										is_monastic_member_trigger = yes
									}
									additive_modifier = {
										value = 10
										age = 40
									}
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_confessions_of_root
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
								10 = {
			    					add_artifact = the_book_of_healing
									additive_modifier = {
										value = -5
										is_learned_trigger = yes
									}
									additive_modifier = {
										value = 10
										is_pious_trigger = yes
									}
									additive_modifier = {
										value = 10
										OR = {
											is_monastic_member_trigger = yes
											society_member_of = hermetics
										}
									}
									additive_modifier = {
										value = 10
										age = 40
									}
									additive_modifier = {
										value = 5
										has_lifestyle_learning_trigger = yes
									}
									additive_modifier = {
										value = 5
										has_education_learning_trigger = yes
									}
			    					trigger = {
			    						culture_group = arabic
			    						NOT = {
											any_artifact = {
												artifact_type = the_book_of_healing
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = comforting_poetry
									additive_modifier = {
										value = 20
										trait = poet
									}
									additive_modifier = {
										value = 10
										trait = stressed
									}
									additive_modifier = {
										value = 20
										trait = depressed
									}
			    					trigger = {
			    						OR = {
			    							trait = stressed
			    							trait = depressed
			    						}
			    						NOT = {
											any_artifact = {
												artifact_type = comforting_poetry
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = equine_sequins
									additive_modifier = {
										value = 20
										has_education_stewardship_trigger = yes
									}
									additive_modifier = {
										value = 10
										trait = stressed
									}
									additive_modifier = {
										value = 10
										culture = horse
									}
									additive_modifier = {
										value = 10
										any_courtier = {
			    							culture = horse
			    						}
									}
			    					trigger = {
			    						any_courtier = {
			    							culture = horse
			    						}
			    						NOT = {
											any_artifact = {
												artifact_type = comforting_poetry
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    			}
	    			set_character_flag = wrote_about_religion
	    		}
	    		writing_about_dynasty = {
	    			random_list = {
	    				10 = { #quality level 1
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = decent_book_potential
	    					}
	    					random_list = {
			    				10 = {
			    					add_artifact = to_my_descendants
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = to_my_descendants
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
								10 = {
			    					add_artifact = the_legend_of_roots_ancestors_1
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_legend_of_roots_ancestors_1
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    				10 = { #quality level 2
	    					trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = good_book_potential
	    					}
	    					random_list = {
			    				10 = {
			    					add_artifact = records_of_roots_dynasty
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = records_of_roots_dynasty
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_legend_of_roots_ancestors_2
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_legend_of_roots_ancestors_2
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    				10 = { #quality level 3 (or 4)
	    				    trigger = { #trigger for the following randomlist (certain quality needed)...
	    						has_character_flag = great_book_potential
	    					}
	    					random_list = {
			    				
			    				10 = {
			    					add_artifact = the_legend_of_roots_ancestors_3
			    					trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_legend_of_roots_ancestors_3
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = a_story_about_my_aunt
									additive_modifier = {
										value = 10
				    					any_dynasty_member = {
				    						trait = adventurer
				    					}
									}
									additive_modifier = {
										value = 5
				    					trait = poet
									}
									additive_modifier = { #If you actually have an aunt...
										value = 10
				    					any_dynasty_member = {
				    						is_female = yes
											parent_sibling_of_root_trigger = yes
											NOT = { any_spouse = { character = ROOT } }
				    					}
									}
									trigger = { NOT = { any_artifact = { artifact_type = a_story_about_my_aunt } } }
			    				}
			    				10 = {
			    					add_artifact = the_dynasty_cookbook
			    					additive_modifier = {
										value = 10
										trait = gluttonous
									}	
									additive_modifier = {
										value = 10
										trait = hedonist
									}
									additive_modifier = {
										value = 10
										trait = drunkard
									}
									trigger = {
										NOT = {
											any_artifact = {
												artifact_type = the_dynasty_cookbook
												original_owner = { dynasty = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_annals_of_roots_dynasty
			    					additive_modifier = {
										value = 10
										trait = proud
									}
									trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_annals_of_roots_dynasty
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_legendary_dynasty_warrior #about you!
			    					new_artifact = {
			    						set_name = the_legendary_dynasty_warrior_root
			    					}
			    					additive_modifier = {
										value = 10
										trait = brave
									}
									additive_modifier = {
										value = 10
										is_member_of_any_warrior_lodge_trigger = yes
									}
									additive_modifier = {
										value = 10
										prestige = 500
									}
									trigger = {
										any_owned_bloodline = {
											has_bloodline_flag = legendary_warrior_lodge_bloodline
											founder = { character = ROOT }
										}
			    						NOT = {
											any_artifact = {
												artifact_type = the_legendary_dynasty_warrior
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					random_owned_bloodline = {
			    						limit = { has_bloodline_flag = legendary_warrior_lodge_bloodline }
				    					founder = { save_event_target_as = warrior_relative }
				    				}
			    					add_artifact = the_legendary_dynasty_warrior #about a relative
			    					new_artifact = {
			    						set_name = the_legendary_dynasty_warrior_not_root
			    						set_description = the_legendary_dynasty_warrior_desc_not_root
			    					}
			    					additive_modifier = {
										value = 10
										trait = brave
									}
									additive_modifier = {
										value = 10
										is_member_of_any_warrior_lodge_trigger = yes
									}
									additive_modifier = {
										value = 10
										prestige = 500
									}
									trigger = {
										any_owned_bloodline = {
											has_bloodline_flag = legendary_warrior_lodge_bloodline
											founder = { NOT = { character = ROOT } }
										}
			    						NOT = {
											any_artifact = {
												artifact_type = the_legendary_dynasty_warrior
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					random_owned_bloodline = {
			    						limit = { has_bloodline_flag = saintly_bloodline }
				    					founder = { save_event_target_as = saintly_relative }
				    				}
			    					add_artifact = the_saintly_relative
			    					new_artifact = {
			    						set_name = the_saintly_relative_1 #contains event-target, so need to be "set"
			    						set_description = the_saintly_relative_desc
			    					}

			    					additive_modifier = {
										value = 10
										trait = zealous
									}
									additive_modifier = {
										value = 10
										is_christian_monastic_member_trigger = yes
									}
									additive_modifier = {
										value = 10
										trait = celibate
									}
									trigger = {
										any_owned_bloodline = {
											has_bloodline_flag = saintly_bloodline
											founder = { religion = ROOT }
										}
			    						NOT = {
											any_artifact = {
												artifact_type = the_saintly_relative
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
			    				10 = {
			    					add_artifact = the_secret_history_of_culture
			    					additive_modifier = {
										value = 10
										trait = proud
									}
									additive_modifier = {
										value = 10
										culture = mongol
									}
									trigger = {
			    						NOT = {
											any_artifact = {
												artifact_type = the_secret_history_of_culture
												original_owner = { character = ROOT }
											}
										}
									}
			    				}
	    					}
	    				}
	    			}
	    			set_character_flag = wrote_about_dynasty
	    		}
	    	}
	    	new_artifact = {
	    		save_event_target_as = new_book #for effects and localization purposes!
	    	}
	    }
    }

    option = {  #How swell!
        name = {
        	text = EVTOPTA_JD_10070_A #I suppose we got a little sidetracked...
        	trigger = {
        		event_target:new_book = {
    				quality = 1
    				NOT = { quality = 2 }
    			}
    			NOT = { trait = lunatic }
        	}
        }
        name = {
        	text = EVTOPTA_JD_10070_B #I felt inspired...!
        	trigger = {
        		event_target:new_book = {
    				quality = 2
    				NOT = { quality = 3 }
    			}
    			NOT = { trait = lunatic }
        	}
        }
        name = {
        	text = EVTOPTA_JD_10070_C #It was all worth the hard work.
        	trigger = {
        		event_target:new_book = {
    				OR = {
    					quality = 3
    					quality = 4
    				}
    			}
    			NOT = { trait = lunatic }
    			NOT = { trait = poet }
        	}
        }
        name = {
        	text = EVTOPTA_JD_10070_lunatic #Should've dedicated it to demons in my head...
        	trigger = {
    			trait = lunatic
        	}
        }
        name = {
        	text = EVTOPTA_JD_10070_dying #At least we finished it before I died!
        	trigger = {
        		OR = {
        			age = 75
        			AND = {
        				NOT = { has_character_flag = disease_not_serious }
        				has_disease_trigger = yes
        			}
        		}
        		NOT = { trait = lunatic }
        	}
        }
        name = {
        	text = EVTOPTA_JD_10070_great_poet #Perhaps I have found my calling?
        	trigger = {
        		event_target:new_book = {
    				OR = {
    					quality = 3
    					quality = 4
    				}
    			}
    			NOT = { trait = lunatic }
    			trait = poet
        	}
        }

        custom_tooltip = {
        	text = new_book_added_tt
        }

    	if = { #Add some prestige...
    		limit = {
    			event_target:new_book = {
    				quality = 1
    				NOT = { quality = 2 }
    			}
    		}
    		prestige = 20
    	}
    	if = {
    		limit = {
    			event_target:new_book = {
    				quality = 2
    				NOT = { quality = 3 }
    			}
    		}
    		prestige = 50
    	}
    	if = {
    		limit = {
    			event_target:new_book = {
    				OR = {
    					quality = 3
    					quality = 4
    				}
    			}
    		}
    		prestige = 100
    	}

    	if = { #add opinion bonus with the correct targets...
    		limit = { event_target:dedication_target = { always = yes } }

    		if = {
    			limit = {
    				event_target:dedication_target = {
    					OR = {
    						is_lover = ROOT
    						any_spouse = { character = ROOT }
    					}
    				}
				}
				reverse_opinion = {
					who = event_target:dedication_target
					modifier = opinion_flattered
					years = 20
				}
    		}
    		if = {
    			limit = {
    				event_target:dedication_target = {
    					is_rival = ROOT
    					NOT = { is_lover = ROOT }
    					NOT = { any_spouse = { character = ROOT } }
    				}
    			}
    			reverse_opinion = {
					who = event_target:dedication_target
					modifier = opinion_strangely_flattered
					years = 20
				}
    		}

		}
    }

    after = { #Clear and set all relevant flags...
    	if = {
    		limit = {
    			has_character_flag = wrote_about_battle
    			has_character_flag = wrote_about_relationships
    			has_character_flag = wrote_about_administration
    			has_character_flag = wrote_about_religion
    			has_character_flag = wrote_about_dynasty
    		}
    		set_character_flag = has_explored_all_topics
    	}

    	clr_character_flag = writing_about_battle
		clr_character_flag = writing_about_relationships
		clr_character_flag = writing_about_administration
		clr_character_flag = writing_about_religion
		clr_character_flag = writing_poetry
		clr_character_flag = writing_about_dynasty
		clr_character_flag = decent_book_potential
		clr_character_flag = good_book_potential
		clr_character_flag = great_book_potential
		clr_character_flag = hide_martial_this_time
		clr_character_flag = hide_relationships_this_time
		clr_character_flag = hide_administration_this_time
		clr_character_flag = hide_learning_this_time
		clr_character_flag = currently_working_on_a_book
		
		add_character_modifier = {
			name = uninspired
			duration = 7300
		}

		hidden_effect = {
			remove_character_modifier = writing_a_book
		}
    }
}

### Protect your Horse ###
character_event = {
	id = JD.60007
	hide_window = yes

	is_triggered_only = yes
	has_dlc = "Jade Dragon"

	option = {
		FROM = { character_event = { id = JD.60008 } }
	}
}
character_event = {
	id = JD.60008
	border = GFX_event_normal_frame_economy
	picture = GFX_evt_courier
	only_playable = yes
	desc = {
		trigger = {
			has_dlc = "Horse Lords"
			is_nomadic = yes
		}
		text = EVT_DESC_JD_60008
		picture = GFX_evt_horse_friend
	}
	desc = {
		trigger = {
			NAND = {
				has_dlc = "Horse Lords"
				is_nomadic = yes
			}
		}
		text = EVT_DESC_JD_60008
		picture = GFX_evt_courier
	}
	
	is_triggered_only = yes
	
	trigger = {
		trait = lunatic
		FROM = {
			NOR = {
				has_artifact = horse_armor_tier_3_golden_stallion
				has_artifact = horse_armor_tier_3_gilded_mare
				has_artifact = horse_armor_tier_3_ornate_steed
				has_artifact = horse_armor_tier_2
				has_artifact = horse_armor_tier_1
			}
		}
	}

	option = {
		name = EVT_OPTA_JD_60008
        scaled_wealth = { value = -2 min = -200 max = -400 }
        prestige = 300
		FROM = {
			random_list = {
				10 = { 
					trigger = { is_female = no }
					add_artifact = horse_armor_tier_3_golden_stallion
				}
				10 = { 
					trigger = { is_female = yes }
					add_artifact = horse_armor_tier_3_gilded_mare
				}
				10 = { 
					add_artifact = horse_armor_tier_3_ornate_steed
				}
			}
		}
	}
	option = {
		name = EVT_OPTB_JD_60008
        scaled_wealth = { value = -1 min = -100 max = -200 }
        prestige = 200
		FROM = {
			add_artifact = horse_armor_tier_2
		}
	}
	option = {
		name = EVT_OPTC_JD_60008
        scaled_wealth = { value = -0.5 min = -50 max = -100 }
        prestige = 100
		FROM = {
			add_artifact = horse_armor_tier_1
		}
	}
	option = {
		name = EVT_OPTD_JD_60008
	}
}


### A Chinese Prince/Princess has died - Sends event to spouse or child ### (fired from on_death)
character_event = { #
    id = JD.10080
    is_triggered_only = yes
    hide_window = yes
    has_dlc = "Jade Dragon"

    trigger = {
        NOT = {
	        offmap_china = {
	        	has_policy = china_isolationist
	        }
		}
    	NAND = {
	    	killer = { character = liege }
			OR = { #make sure China doesn't know they were actually murdered by you
				death_murder_known_trigger = yes
				death_execution_trigger = yes
				death_sacrificed_trigger = yes
				death_reason = death_duel
				death_reason = death_dungeon
			}
    	}
    	OR = {
    		has_character_modifier = jd_prince
    		has_character_modifier = jd_princess
    	}
    	OR = { #Must have either a spouse or a landed child still around
    		any_spouse = {
    			ai = no
    			is_alive = yes
    			is_landed = yes
    			NOT = { is_rival = ROOT }
    			opinion = { who = ROOT value = 30 } #Spouse must have liked the prince/princess at least A LITTLE
    			root_has_terrible_opinion_modifier_of_this_trigger = no
    		}
			any_child = {
				ai = no
				is_landed = yes
				is_alive = yes
				age = 10
				NOT = { is_rival = ROOT }
				root_has_terrible_opinion_modifier_of_this_trigger = no
			}
    	}
    	had_character_flag = { flag = originated_from_chinese_court days = 1825 } #If less, the regular "grace refund" event will fire instead
    }

    immediate = {
		offmap_china = {
			governor = {
				save_event_target_as = the_protector_general
			}    			
		}
    	random_list = {
    		40 = { #China sends their condolences...
    			random_spouse = {
    				limit = {
    					ai = no
    					is_landed = yes
    					NOT = { is_rival = ROOT }
    					NOT = { war_with = event_target:the_protector_general }
    					root_has_terrible_opinion_modifier_of_this_trigger = no
    				}
    				set_character_flag = scenario_1
    				set_character_flag = mourner_is_spouse
    				character_event = { id = JD.10079 days = 35 }
    			}
    			any_child = {
    				if = {
	    				limit = {
	    					ai = no
		    				age = 15
		    				is_landed = yes
		    				NOT = { is_rival = ROOT }
		    				NOT = { war_with = event_target:the_protector_general }
		    				root_has_terrible_opinion_modifier_of_this_trigger = no
	    				}
	    				set_character_flag = scenario_1
	    				set_character_flag = mourner_is_grown_child
	    				character_event = { id = JD.10079 days = 35 }
    				}
    			}
    			any_child = {
    				if = {
	    				limit = {
	    					ai = no
	    					age = 10
		    				NOT = { age = 15 }
		    				is_landed = yes
		    				NOT = { is_rival = ROOT }
		    				NOT = { war_with = event_target:the_protector_general }
		    				root_has_terrible_opinion_modifier_of_this_trigger = no
	    				}
	    				set_character_flag = scenario_1
    					set_character_flag = mourner_is_small_child
    					character_event = { id = JD.10079 days = 35 }
    				}
    			}
    			trigger = {
    				offmap_china = {
    					offmap_ruler = {
    						dynasty = ROOT
    					}
    				}
    				OR = {
    					any_child = {
    						ai = no
    						is_landed = yes
    						age = 10
    						NOT = { is_rival = ROOT }
    						NOT = { war_with = event_target:the_protector_general }
    						root_has_terrible_opinion_modifier_of_this_trigger = no
    					}
    					any_spouse = {
    						ai = no
    						is_landed = yes
    						NOT = { is_rival = ROOT }
    						NOT = { war_with = event_target:the_protector_general }
    						root_has_terrible_opinion_modifier_of_this_trigger = no
    					}
    				}
    			}
    		}
    		30 = { #China sends you an artifact
				add_chinese_artifact_effect = yes

				while = { #runs until it finds an appropriate artifact...
					limit = {
						event_target:chinese_artifact = {
							NOR = {
								has_artifact_flag = decor
								has_artifact_flag = statue
								has_artifact_flag = art
								has_artifact_flag = clothing
								has_artifact_flag = textile
							}
						}
					}
					event_target:chinese_artifact = {
						destroy_artifact = yes
					}
					add_chinese_artifact_effect = yes
				}
				
				event_target:chinese_artifact = {
					set_name = the_chinese_royals_favorite
					set_description = the_chinese_royals_favorite_desc
					set_artifact_flag = royal_inheritance_gift@ROOT
					transfer_artifact = {
						from = PREV
						to = event_target:the_protector_general
					}
				}

				random_spouse = {
    				limit = {
    					ai = no
    					is_landed = yes
    					NOT = { is_rival = ROOT }
    					NOT = { war_with = event_target:the_protector_general }
    					root_has_terrible_opinion_modifier_of_this_trigger = no
    				}
    				set_character_flag = scenario_2
    				set_character_flag = mourner_is_spouse
    				character_event = { id = JD.10079 days = 35 }
    			}
    			any_child = {
    				if = {
	    				limit = {
	    					ai = no
		    				age = 15
		    				is_landed = yes
		    				NOT = { is_rival = ROOT }
		    				NOT = { war_with = event_target:the_protector_general }
		    				root_has_terrible_opinion_modifier_of_this_trigger = no
	    				}
	    				set_character_flag = scenario_2
	    				set_character_flag = mourner_is_grown_child
	    				character_event = { id = JD.10079 days = 35 }
    				}
    			}
    			any_child = {
    				if = {
	    				limit = {
	    					ai = no
		    				NOT = { age = 15 }
		    				age = 10
		    				is_landed = yes
		    				NOT = { is_rival = ROOT }
		    				NOT = { war_with = event_target:the_protector_general }
		    				root_has_terrible_opinion_modifier_of_this_trigger = no
	    				}
	    				set_character_flag = scenario_2
	    				set_character_flag = mourner_is_small_child
    					character_event = { id = JD.10079 days = 35 }
    				}
    			}
    			trigger = {
					offmap_china = {
						offmap_ruler = {
							dynasty = ROOT
						}
					}
    				OR = {
    					any_child = {
    						ai = no
    						is_landed = yes
    						age = 10
    						NOT = { is_rival = ROOT }
    						NOT = { war_with = event_target:the_protector_general }
    						root_has_terrible_opinion_modifier_of_this_trigger = no
    					}
    					any_spouse = {
    						ai = no
    						is_landed = yes
    						NOT = { is_rival = ROOT }
    						NOT = { war_with = event_target:the_protector_general }
    						root_has_terrible_opinion_modifier_of_this_trigger = no
    					}
    				}
    			}
    		}
    		15 = { #You find a personal diary...
				add_artifact = chinese_journal

				new_artifact = {
					save_event_target_as = chinese_artifact
				}
				event_target:chinese_artifact = {
					set_name = the_chinese_royals_personal_note_book
					set_description = the_chinese_royals_personal_note_book_desc
					set_artifact_flag = royal_inheritance_gift@ROOT
					transfer_artifact = {
						from = PREV
						to = event_target:the_protector_general
					}
				}

				random_spouse = {
    				limit = {
    					ai = no
    					is_landed = yes
    					NOT = { is_rival = ROOT }
    					root_has_terrible_opinion_modifier_of_this_trigger = no
    				}
    				set_character_flag = scenario_3
    				set_character_flag = mourner_is_spouse
    				character_event = { id = JD.10079 days = 35 }
    			}
    			any_child = {
    				if = {
	    				limit = {
	    					ai = no
		    				is_landed = yes
		    				age = 14
		    				NOT = { is_rival = ROOT }
		    				root_has_terrible_opinion_modifier_of_this_trigger = no
	    				}
	    				set_character_flag = scenario_3
	    				set_character_flag = mourner_is_grown_child
	    				character_event = { id = JD.10079 days = 35 }
    				}
    			}
    			any_child = {
    				if = {
	    				limit = {
	    					ai = no
		    				is_landed = yes
		    				NOT = { age = 14 }
		    				NOT = { is_rival = ROOT }
		    				root_has_terrible_opinion_modifier_of_this_trigger = no
	    				}
	    				set_character_flag = scenario_3
	    				set_character_flag = mourner_is_small_child
    					character_event = { id = JD.10079 days = 35 }
    				}
    			}
    			modifier = {
		            factor = 0.5 #less likely if an alive spouse does NOT have family focus (since the prince/princess will write about their family in their journal)
		            any_spouse = {
		            	is_alive = yes
		            	is_landed = yes
		            	NOT = { has_focus = focus_family }
		            }
		        }
		        modifier = {
		            factor = 1.1 #more likely if there was love between the prince/princess and their spouse
		            any_spouse = {
		            	is_alive = yes
		            	is_landed = yes
		            	has_opinion_modifier = { who = ROOT modifier = opinion_lover }
		            }
		        }
    		}
    		15 = {
    			#Nothing happens (more likely if China is busy with other stuff)
    			set_character_flag = nothing_happened
    			modifier = {
		            factor = 5
		            china_is_suffering_trigger = yes
		        }
    		}
    	}
    	if = { limit = { NOT = { has_character_flag = nothing_happened } }
    		set_character_flag = ignore_refund #(blocks the other letter of condolences-event from China)
    	}
    }
}

### Delayed gating event to make sure the Protector General is still alive, and still has the artifact
# Sent on target character, from JD.10080
character_event = {
    id = JD.10079
    hide_window = yes
    is_triggered_only = yes
    has_dlc = "Jade Dragon"
    
    immediate = {
    	if = {  #for loc + artifact purposes
    		limit = { event_target:the_protector_general = { is_alive = no } }
    		offmap_china = { governor = { save_event_target_as = the_protector_general } }
    	}

    	if = { ### (1) If you are to receive a letter...
    		limit = { has_character_flag = scenario_1 }
			character_event = { id = JD.10081 }
    	}

    	if = { ### (2) If you are to be gifted a Chinese artifact...
    		limit = { has_character_flag = scenario_2 }
			if = { #if the artifact still exists in the treasury of the WP... (even if the Protector General might've died, but HOPEFULLY they inherited the thing?)
				limit = {
					event_target:the_protector_general = {
						any_artifact = { has_artifact_flag = royal_inheritance_gift@FROM }
					}
				}
				character_event = { id = JD.10082 } #Continue and send scenario 2...!
			}
			else = {
				character_event = { id = JD.10081 } # else, send scenario 1 instead...
			}
    	}

    	if = { ### (3) If you are to find a personal journal...
    		limit = { has_character_flag = scenario_3 }
    		if = { #if the artifact still exists in the treasury of the WP... (even if the Protector General might've died, but HOPEFULLY they inherited the thing?)
				limit = {
					event_target:the_protector_general = {
						any_artifact = { has_artifact_flag = royal_inheritance_gift@FROM }
					}
				}
				character_event = { id = JD.10083 }  #Continue and send scenario 3...!
			}
			else = {
    			character_event = { id = JD.10081 } # else, send scenario 1 instead...
    		}
    	}


    	### Fall-back clearing of flags (if at war with WP already)...
    	if = {
    		limit = { war_with = event_target:the_protector_general }
			if = {
				limit = { has_character_flag = scenario_2 }
				#to make sure the WP doesn't end up with a ton of Chinese artifacts (named things like "Shan Li's Favorite Tapestry") when the follow-up (JD.10082) doesn't trigger...
			    hidden_effect = { event_target:chinese_artifact = { destroy_artifact = yes } }
			}
			if = {
				limit = { NOT = { has_character_flag = scenario_3 } } #The only event that doesn't require peace with WP...
		    	clr_character_flag = mourner_is_spouse
				clr_character_flag = mourner_is_grown_child
				clr_character_flag = mourner_is_small_child
				clr_character_flag = scenario_1
				clr_character_flag = scenario_2
		    	clr_character_flag = scenario_3
			}
    	}
    }
}

### For a spouse or child ###
character_event = { #China sends their condolences, in the form of a LETTER...
    id = JD.10081
    desc = EVTDESC_JD_10081
    picture = GFX_evt_chinese_bureaucrat
    border = GFX_event_normal_frame_diplomacy
    is_triggered_only = yes

    has_dlc = "Jade Dragon"

    portrait = FROMFROM

    trigger = {
    	NOT = { war_with = event_target:the_protector_general }
    }

    immediate = {
    	offmap_china = {
			governor = {
				save_event_target_as = the_protector_general
			}    			
		}
    }

    #Basically, if you are Depressed, you get to choose between a shot at losing Depressed
    # or some Grace. If you are NOT Depressed, there is a risk you will gain the trait instead, if you choose to read the letter.
    option = {
        name = EVTOPTA_JD_10081
        custom_tooltip = { text = EVTOPTA_JD_10081_TT }

        if = {
        	limit = { NOT = { trait = depressed } }
	        random = {
	        	chance = 50
	        	add_trait_depressed_effect = yes #only happens if you are NOT depressed
	        }
        }
        add_grace_minor_effect = yes
    }
    option = {
        name = {
        	text = EVTOPTB_JD_10081_depressed
        	trigger = { trait = depressed }
        }
        name = {
        	text = EVTOPTB_JD_10081_regular
        	trigger = { NOT = { trait = depressed } }
        }
        if = {
        	limit = { trait = depressed }
        	custom_tooltip = { text = EVTOPTB_JD_10081_TT }
        }

        if = {
        	limit = { trait = depressed }
		    random = {
		    	chance = 50
				remove_trait_depressed_effect = yes
		    }
        }
    }

    after = {
    	clr_character_flag = mourner_is_spouse
    	clr_character_flag = mourner_is_grown_child
    	clr_character_flag = mourner_is_small_child
    	clr_character_flag = scenario_1
    	clr_character_flag = scenario_2
    	clr_character_flag = scenario_3
    }
}

### For a spouse or child ###
character_event = { #China sends their condolences, in the form of a GIFT...
    id = JD.10082
    desc = EVTDESC_JD_10082
    picture = GFX_evt_chinese_bureaucrat
    border = GFX_event_normal_frame_diplomacy
    is_triggered_only = yes

    has_dlc = "Jade Dragon"

    portrait = FROMFROM

    trigger = {
    	NOT = { war_with = event_target:the_protector_general }
    }

    #Basically, if you are Depressed, you get to choose between a shot at losing Depressed
    # or an artifact. If you are NOT Depressed, there is a risk you will gain the trait instead, if you choose to accept the gift.
    option = {
        name = EVTOPTA_JD_10082
        custom_tooltip = { text = EVTOPTA_JD_10082_TT }

        hidden_effect = {
	        event_target:chinese_artifact = {
				transfer_artifact = {
					from = event_target:the_protector_general
					to = ROOT
				}
			}
        }

        if = { limit = { NOT = { trait = depressed } }
	        random = {
	        	chance = 50
	        	add_trait_depressed_effect = yes #only happens if you are NOT depressed
	        }
        }
    }
    option = {
        name = EVTOPTB_JD_10082
        custom_tooltip = { text = EVTOPTB_JD_10082_TT }

        if = {
        	limit = { trait = depressed } 
		    random = {
		    	chance = 50
		    	remove_trait_depressed_effect = yes  #only happens if you ARE depressed
		    }
        }
        hidden_effect = {
        	event_target:chinese_artifact = {
        		destroy_artifact = yes
        	}
        }
    }

    after = {
    	clr_character_flag = mourner_is_spouse
    	clr_character_flag = mourner_is_grown_child
    	clr_character_flag = mourner_is_small_child
    	clr_character_flag = scenario_1
    	clr_character_flag = scenario_2
    	clr_character_flag = scenario_3
    }
}


### For a spouse or child ###
character_event = { #You find their journal...
    id = JD.10083
    desc = EVTDESC_JD_10083
    picture = GFX_evt_library
    border = GFX_event_normal_frame_diplomacy
    is_triggered_only = yes

	has_dlc = "Jade Dragon"

    portrait = FROMFROM

    option = {
        name = EVTOPTA_JD_10083
        custom_tooltip = { text = EVTOPTA_JD_10083_TT }

        hidden_effect = {
	        event_target:chinese_artifact = {
				transfer_artifact = {
					from = event_target:the_protector_general
					to = ROOT
				}
			}
        }
    }
    option = {
        name = EVTOPTB_JD_10083
        custom_tooltip = { text = EVTOPTB_JD_10083_TT }
        
        if = {
			limit = {
				NOT = { trait = cynical }
			}
			add_trait = cynical
		}

        hidden_effect = {
        	event_target:chinese_artifact = {
        		destroy_artifact = yes
        	}
        }
    }

    after = {
    	clr_character_flag = mourner_is_spouse
    	clr_character_flag = mourner_is_grown_child
    	clr_character_flag = mourner_is_small_child
    	clr_character_flag = scenario_1
    	clr_character_flag = scenario_2
    	clr_character_flag = scenario_3
    }
}