targeted_decisions = {
	
	# release_tributary = {
		
		# from_potential = {
			# ai = no
		# }
		# potential = {
			# is_tributary = yes
			# suzerain = { character = FROM }
		# }
		# allow = {
			# war = no
			# FROM = { war = no }
		# }
		# effect = {
			# remove_tributary = FROM
			# prestige = -200
		# }
		# ai_will_do = {
			# factor = 0
		# }
	# }

	break_non_aggression_pact = {
		ai_target_filter = self
		
		from_potential = {
			ai = no
		}
		potential = {
			is_landed = yes
			has_non_aggression_pact_with = FROM
		}
		allow = {
		FROM = { prestige = 200 }
			war = no
			FROM = { war = no }
		}
		effect = {
			opinion = {
				who = FROM
				modifier = broken_non_aggression_pact
			}
			FROM = { 
				prestige = -200
				add_character_modifier = {
					name = broken_non_aggression_pact_char_modifier
					years = 10
				}
			}
			
			FROM = {
				set_truce = {
					who = ROOT
					years = 2
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	recruit_prisoner = {
		filter = court
		ai_target_filter = court
		
		from_potential = {
			ai = no
			has_dlc = "Reapers"
		}
		
		potential = {
			prisoner = yes
			is_ruler = no
			is_adult = yes
			is_heir = no
			is_married = no
			NOT = {	trait = incapable }
			host = { character = FROM }
			liege = {
				NOT = { character = FROM }
			}
		}
		
		allow = {
			liege = {
				NOR = {
					is_lover = ROOT
					is_friend = ROOT
					is_child_of = ROOT
					is_mother = ROOT
					is_father = ROOT
				}
			}
			NOT = {
				is_rival = FROM
			}
			opinion_diff = {
				first = FROM
				second = liege
				value = -25
			}
		}
		
		effect = {
			hidden_tooltip = {
				liege = {
					character_event = { id = RIP.29700 }
				}
			}
			if = {
				limit = {
					is_consort = yes
					is_female = yes
				}
				consort = {
					remove_consort = ROOT
				}
			}
			if = {
				limit = {
					has_character_flag = originated_from_chinese_court
				}
				set_character_flag = ignore_refund
			}
			move_character = FROM
			prisoner = no
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	# The war is in FROMFROM
	interfere_in_vassal_war_attacker = {
		filter = vassal_wars
		ai_target_filter = vassal_wars
	
		from_potential = {
			ai = no
			has_dlc = "Reapers"
		}
		
		potential = {
			FROMFROM = {
				attacker = { character = ROOT }
			}
			NOR = {
				trait = peasant_leader
				has_character_flag = nationalist_rebel
				has_character_flag = heretic_revolter
				has_character_flag = religious_revolter
			}
			NOT = { owes_favor_to = FROM }
			NOT = {
				has_opinion_modifier = {
					who = FROM
					modifier = opinion_interfered_in_war
				}
			}
		}
		
		allow = {
			FROM = {
				prestige = 100
				NOT = { trait = incapable }
				prisoner = no
				in_seclusion = no
			}
		}
		
		effect = {
			FROM = { prestige = -100 }
			FROMFROM = {
				defender = {
					save_event_target_as = target_defender
				}
			}
			letter_event = { id = RIP.30000 days = 3 }
			
			hidden_tooltip = {
				opinion = {
					who = FROM
					modifier = opinion_interfered_in_war
					years = 5
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	# The war is in FROMFROM
	interfere_in_vassal_war_attacker_use_favor = {
		filter = vassal_wars
		ai_target_filter = vassal_wars
	
		from_potential = {
			ai = no
			has_dlc = "Reapers"
			has_dlc = "Conclave"
		}
		
		potential = {
			FROMFROM = {
				attacker = { character = ROOT }
			}
			owes_favor_to = FROM
		}
		
		allow = {
			FROM = {
				NOT = { trait = incapable }
				prisoner = no
				in_seclusion = no
			}
		}
		
		effect = {
			FROMFROM = {
				defender = {
					save_event_target_as = target_defender
				}
			}
			
			reverse_remove_favor = FROM
			
			letter_event = { id = RIP.30010 days = 3 }
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	# The war is in FROMFROM
	interfere_in_vassal_war_defender = {
		filter = vassal_wars
		ai_target_filter = vassal_wars
	
		from_potential = {
			ai = no
			has_dlc = "Reapers"
		}
		
		potential = {
			FROMFROM = {
				defender = { character = ROOT }
			}
			NOT = { owes_favor_to = FROM }
			NOT = {
				has_opinion_modifier = {
					who = FROM
					modifier = opinion_interfered_in_war
				}
			}
			NOR = {
				trait = pf_rebel
				trait = peasant_leader
			}
		}
		
		allow = {
			FROM = {
				prestige = 200
				NOT = { trait = incapable }
				prisoner = no
				in_seclusion = no
			}
		}
		
		effect = {
			FROM = { prestige = -200 }
			FROMFROM = {
				attacker = {
					save_event_target_as = target_attacker
				}
			}
			letter_event = { id = RIP.30020 days = 3 }
			
			hidden_tooltip = {
				opinion = {
					who = FROM
					modifier = opinion_interfered_in_war
					years = 5
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	# The war is in FROMFROM
	interfere_in_vassal_war_defender_use_favor = {
		filter = vassal_wars
		ai_target_filter = vassal_wars
	
		from_potential = {
			ai = no
			has_dlc = "Reapers"
			has_dlc = "Conclave"
		}
		
		potential = {
			FROMFROM = {
				defender = { character = ROOT }
			}
			owes_favor_to = FROM
		}
		
		allow = {
			FROM = {
				NOT = { trait = incapable }
				prisoner = no
				in_seclusion = no
			}
		}
		
		effect = {
			FROMFROM = {
				attacker = {
					save_event_target_as = target_attacker
				}
			}
			
			reverse_remove_favor = FROM
			
			letter_event = { id = RIP.30030 days = 3 }
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	demand_gavelkind = {
		filter = vassals
		ai_target_filter = vassals
		
		only_playable = yes
	
		from_potential = {
			ai = no
			has_dlc = "Reapers"
			is_feudal = yes
			is_vice_royalty = no
			prisoner = no
			NOT = { trait = incapable }
		}
		
		potential = {
			is_playable = yes
			liege = { character = FROM }
			NOT = { character = FROM }
			is_law_potential = succ_gavelkind
			NOT = { has_law = succ_gavelkind }
			NOT = { owes_favor_to = FROM }
			NOT = { has_opinion_modifier = { who = FROM name = opinion_demanded_succ_law_change } }
			is_feudal = yes
			mercenary = no
			holy_order = no
			is_vice_royalty = no
			prisoner = no
			NOT = { trait = incapable }
		}
		
		allow = {
			FROM = {
				prestige = 100
				NOT = { trait = incapable }
				prisoner = no
				in_seclusion = no
			}
		}
		
		effect = {
			prestige = -100
			letter_event = { id = RIP.30040 days = 3 }
			
			hidden_tooltip = {
				opinion = {
					who = FROM
					modifier = opinion_demanded_succ_law_change
					years = 5
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	demand_gavelkind_use_favor = {
		filter = vassals
		ai_target_filter = vassals
		
		only_playable = yes
	
		from_potential = {
			ai = no
			has_dlc = "Reapers"
			has_dlc = "Conclave"
			is_feudal = yes
			is_vice_royalty = no
			prisoner = no
			NOT = { trait = incapable }
		}
		
		potential = {
			is_playable = yes
			liege = { character = FROM }
			NOT = { character = FROM }
			is_law_potential = succ_gavelkind
			NOT = { has_law = succ_gavelkind }
			owes_favor_to = FROM
			NOT = { has_opinion_modifier = { who = FROM name = opinion_demanded_succ_law_change } }
			is_feudal = yes
			mercenary = no
			holy_order = no
			is_vice_royalty = no
			prisoner = no
			NOT = { trait = incapable }
		}
		
		allow = {
			FROM = {
				prestige = 100
				NOT = { trait = incapable }
				prisoner = no
				in_seclusion = no
			}
		}
		
		effect = {
			prestige = -100
			letter_event = { id = RIP.30050 days = 3 }
			hidden_tooltip = {
				opinion = {
					who = FROM
					modifier = opinion_demanded_succ_law_change
					years = 5
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	ask_to_leave_court = {
		filter = court
		ai_target_filter = court
		
		from_potential = {
			ai = no
			has_dlc = "Reapers"
		}
		potential = {
			liege = { character = FROM }
			can_be_asked_to_leave_court_trigger = yes
			NOT = {
				any_spouse = {
					liege = { character = FROM }
					can_be_asked_to_leave_court_trigger = no
				}
			}
		}
		allow = {
			NOT = {
				trait = incapable
			}
			prisoner = no
			NOT = {
				any_spouse = {
					liege = { character = FROM }
					OR = {
						trait = incapable
						prisoner = yes
					}
				}
			}
		}
		effect = {
			FROM = { prestige = -5 }
		
			opinion = {
				modifier = opinion_disappointed
				who = FROM
				years = 10
			}
			
			any_spouse = {
				limit = { liege = { character = FROM } }
				opinion = {
					modifier = opinion_disappointed
					who = FROM
					years = 10
				}
			}
			
			if = { # Move to a same-religion court
				limit = {
					any_playable_ruler = {
						is_within_diplo_range = ROOT
						religion = ROOT
						their_opinion = { who = ROOT value = 10 }
						NOT = { character = FROM }
					}
				}
				any_playable_ruler = {
					limit = {
						is_within_diplo_range = ROOT
						religion = ROOT
						their_opinion = { who = ROOT value = 10 }
						NOT = { character = FROM }
					}
					save_event_target_as = new_court
				}
				move_character = event_target:new_court
				any_spouse = {
					limit = {
						liege = { character = FROM }
					}
					move_character = event_target:new_court
				}
				break = yes
			}
			
			if = { # Move to any court where the character likes me
				limit = {
					any_playable_ruler = {
						is_within_diplo_range = ROOT
						their_opinion = { who = ROOT value = 10 }
						NOT = { character = FROM }
					}
				}
				any_playable_ruler = {
					limit = {
						is_within_diplo_range = ROOT
						their_opinion = { who = ROOT value = 10 }
						NOT = { character = FROM }
					}
					save_event_target_as = new_court_secondary
				}
				move_character = event_target:new_court_secondary
				any_spouse = {
					limit = {
						liege = { character = FROM }
					}
					move_character = event_target:new_court
				}
				break = yes
			}
		
			if = { # Go anywhere but here
				limit = {
					any_playable_ruler = {
						NOT = { character = FROM }
					}
				}
				any_playable_ruler = {
					limit = {
						NOT = { character = FROM }
					}
					save_event_target_as = new_court_backup
				}
				move_character = event_target:new_court_backup
				any_spouse = {
					limit = {
						liege = { character = FROM }
					}
					move_character = event_target:new_court
				}
			}
			
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	exchange_land_for_hospital = {
		filter = all
		ai_target_filter = all
		from_potential = {
			has_dlc = "Reapers"
			ai = no
			#capital has space and no hospital
			capital_scope = {
				num_of_empty_holdings = 1
				NOT = {
					hospital_level = 1
				}
			}
			NOR = {
				is_nomadic = yes
				is_tribal = yes
			}
		}
		potential = {
			is_adult = yes
			#owns holy order, this religion
			primary_title = { holy_order = yes }
			religion = FROM
			
		}
		allow = {
			FROM = {
				piety = 300
				capital_scope = {
					any_province_holding = {
						is_occupied = no
					}
				}
			}
		}
		effect = {
			#lose piety, holy order builds castle and hospital
			FROM = {
				piety = -300
				capital_scope = {
					build_holding = {
						type = castle
						holder = ROOT
					}
					build_holding = {
						type = hospital
						holder = FROM
					}
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

	commit_suicide_immortal = {
		filter = self
		ai_target_filter = self
		
		potential = {
			ai = no
			is_adult = yes
			prisoner = no
			immortal = yes

			OR = {
				trait = depressed
				age = 100
			}
		}
		

		allow = {
			immortal = yes
			OR = {
				trait = depressed
				age = 100
			}
			custom_tooltip = {
				NOT = { has_character_flag = attempting_suicide }
				text = attempting_suicide_tooltip
			}
		}

		effect = {
			if = {
				limit = { has_dlc = "Reapers" }

				set_character_flag = attempting_suicide

				if = {
					limit = { NOT = { trait = incapable } }
					character_event = { id = RIP.30200 }
				}
				if = {
					limit = { trait = incapable } 
					character_event = { id = RIP.30210 }
				}
			}
			if = {
				limit = { NOT = { has_dlc = "Reapers" } }

				prestige = -200

				add_character_modifier = {
					modifier = suicide
					duration = -1
				}
				death = { death_reason = death_suicide }
			}
		}

		ai_will_do = {
			factor = 0
		}
	}
}

decisions = {
	seek_treatment = {
		only_playable = yes
		is_high_prio = yes
		ai_check_interval = 4
		potential = {
			is_playable = yes
			OR = {
				trait = has_tuberculosis
				trait = has_typhoid_fever
				trait = has_typhus
				trait = has_bubonic_plague
				trait = has_measles
				trait = has_small_pox
				trait = has_aztec_disease
				trait = syphilitic
				trait = flu
				trait = dysentery
				trait = gout
				trait = food_poisoning
				trait = rabies
				trait = cancer
				trait = pneumonic
				num_of_symptoms = 1
			}
			has_assigned_minor_title = title_court_physician
		}
		
		allow = {
			custom_tooltip = {
				text = seek_treatment_tooltip_2
				OR = {
					NOT = { has_character_flag = being_treated }
					had_character_flag = { flag = being_treated days = 20 }
				}
				OR = {
					AND = {	#if you have a developed disease and want further treatment
						character_disease_trigger = yes
						OR = {
							NOT = { has_character_flag = recent_treatment }
							had_character_flag = { flag = recent_treatment days = 90 }
						}
					}
					AND = {	#if you have multiple symptoms and want to seek further treatment
						num_of_symptoms = 2
						OR = {
							NOT = { has_character_flag = recent_treatment }
							had_character_flag = { flag = recent_treatment days = 30 }
						}
					}
					AND = { #if your treatment failed and you want to try again
						character_disease_trigger = no
						num_of_symptoms = 1
						OR = {
							had_character_flag = { flag = disease_not_serious days = 10 } #anti-spam delay since event should handle this normally
							had_character_flag = { flag = developing_illness days = 10 }
						}
						OR = {
							NOT = { has_character_flag = recent_treatment }
							had_character_flag = { flag = recent_treatment days = 30 }
						}
						NOR = {
							has_character_modifier = successful_treatment_1
							has_character_modifier = successful_treatment_2
							has_character_modifier = successful_treatment_3
							has_character_modifier = failed_treatment_1
							has_character_modifier = failed_treatment_2
							has_character_modifier = mystic_treatment_decent
							has_character_modifier = mystic_treatment_poor
							has_character_modifier = mystic_treatment_terrible
							has_character_modifier = symptom_treatment_1
							has_character_modifier = symptom_treatment_2
							has_character_modifier = symptom_treatment_3
							has_character_modifier = symptom_treatment_4
						}
					}
				}
			}
			custom_tooltip = {
				text = seek_treatment_tooltip_1
			}
			custom_tooltip = {
				text = seek_treatment_tooltip_3
				hidden_tooltip = {
					NOR = {
						has_character_modifier = mystic_treatment_decent
						has_character_modifier = successful_treatment_1
						has_character_modifier = successful_treatment_2
						has_character_modifier = successful_treatment_3
					}
				}
			}
		}
		effect = {
			set_character_flag = recent_treatment
			hidden_tooltip = {
				remove_treatment_modifiers_effect = yes
			}
			log = "[Root.GetBestName] sought treatment"
			custom_tooltip = {
				text = seek_treatment_tooltip_4
				hidden_tooltip = {
					random_realm_character = {
						limit = {
							is_adult = yes
							has_minor_title = title_court_physician
							liege = {
								character = ROOT
							}
						}
						log = "[This.GetBestName] was identified as court physician"
						character_event = { id = RIP.11031 }
					}
				}
			}
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 2
				OR = {
					trait = craven
					trait = paranoid
				}
			}

			modifier = {
				factor = 1.4
				NOT = { health = 5 }
			}
			modifier = {
				factor = 1.4
				NOT = { health = 4 }
			}
			modifier = {
				factor = 1.4
				NOT = { health = 3 }
			}
			modifier = {
				factor = 1.4
				NOT = { health = 2 }
			}
			modifier = {
				factor = 1.4
				NOT = { health = 1 }
			}
			
			modifier = {
				factor = 0
				OR = {
					has_character_modifier = symptom_treatment_3 #characters don't want to seek treatment when they have a decent one already
					has_character_modifier = symptom_treatment_4
					AND = {
						has_character_modifier = symptom_treatment_2
						developing_epidemic_disease_trigger = no
					}
					has_character_modifier = successful_treatment_2
					has_character_modifier = successful_treatment_3
				}
			}
		}
	}

	employ_court_physician = {
		only_playable = yes
		is_high_prio = yes
		ai_check_interval = 12
		potential = {
			has_dlc = "Reapers"
			is_playable = yes
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			NOR = {
				is_tribal = yes
				is_nomadic = yes
			}
			OR = {
				mercenary = no
				ai = no
			}
			OR = {
				higher_tier_than = COUNT
				ai = no
				is_ill = yes
				num_of_symptoms > 0
			}
		}
		allow = {
			NOR = {
				has_character_modifier = in_seclusion
				has_assigned_minor_title = title_court_physician
			}
			custom_tooltip = {
				text = 3_year_physician_cooldown
				hidden_tooltip = {
					OR = {
						NOT = { has_character_flag = 3_year_physician_cooldown }
						had_character_flag = { flag = 3_year_physician_cooldown days = 1095 }
					}
				}
			}
		}
		effect = {
			custom_tooltip = {
				text = employ_court_physician_tooltip
				hidden_tooltip = {
					character_event = { id = RIP.11050 }
					clr_character_flag = 3_year_physician_cooldown
					set_character_flag = 3_year_physician_cooldown
				}
			}
		}
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0
				tier = COUNT
				NOT = {
					any_close_relative = {
						ai = no
					}
				}
			}
			modifier = {
				factor = 0.5
				NOR = {
					tier = KING
					tier = EMPEROR
				}
			}
			modifier = {
				factor = 2
				trait = paranoid
			}
			modifier = {
				factor = 10
				OR = {
					is_ill = yes
					num_of_symptoms = 1
				}
			}
		}
	}


	#Seclusion

	shut_the_gates = {
		only_rulers = yes
		is_high_prio = yes
		
		potential = {
			has_dlc = "Reapers"
			OR = {
				is_landed = yes
				is_patrician = yes
			}
			NOR = {
				is_tribal = yes
				is_nomadic = yes
				is_inaccessible_trigger = yes
			}
		}
		
		allow = {
			prisoner = no
			is_not_busy_trigger = yes
			OR = {
				trait = paranoid
				custom_tooltip = {
					text = epidemic_present_tooltip
					hidden_tooltip = {
						OR = {
							ai = no
							capital_scope = { has_epidemic = yes }
						}
						OR = {
							capital_scope = {
								OR = {
									has_epidemic = yes
									any_neighbor_province = {
										has_epidemic = yes
									}
								}
							}
							AND = {
								ai = no
								any_demesne_province = {
									has_epidemic = yes
								}
							}
							AND = {
								ai = no
								any_demesne_province = {
									any_neighbor_province = {
										has_epidemic = yes
									}
								}
							}
						}
					}
				}
			}
			NOT = { has_character_modifier = recently_opened_gates }
		}
		effect = {
			if = {
				limit = {
					has_minor_title = title_commander
				}
				remove_title = title_commander
			}
			set_character_flag = do_not_disturb
			custom_tooltip = { text = shut_the_gates_info_tooltip }
			add_character_modifier = {
				name = in_seclusion
				duration = -1
			}
			add_character_modifier = {
				name = do_not_disturb
				duration = -1
				hidden = yes
			}
			if = { # If you are a councillor, stop working and return home
				limit = {
					host = { NOT = { character = ROOT } }
					OR = {
						is_councillor = yes
						has_minor_title = title_councilmember_king
						has_minor_title = title_councilmember_emperor
					}
				}
				force_host = ROOT
			}
			hidden_tooltip = {
				if = {	# determine if there's a legitimate concern or character is just paranoid
					limit = {
						OR = {
							ai = no
							capital_scope = { has_epidemic = yes }
						}
						OR = {
							capital_scope = {
								OR = {
									has_epidemic = yes
									any_neighbor_province = {
										has_epidemic = yes
									}
								}
							}
							AND = {
								ai = no
								any_demesne_province = {
									has_epidemic = yes
								}
							}
							AND = {
								ai = no
								any_demesne_province = {
									any_neighbor_province = {
										has_epidemic = yes
									}
								}
							}
						}
					}
					set_character_flag = legitimate_isolation
				}
				character_event = { id = RIP.12000 }
				any_courtier = { # Unlanded councillors stop working in order to go into seclusion with their liege
					limit = {
						prisoner = no
						is_councillor = yes
						is_landed = no
						liege = { character = ROOT }
						NOT = { character = ROOT }
					}
					add_character_modifier = {
						name = in_seclusion
						duration = -1
					}
				}
				any_courtier = { # Unlanded non-councillors join their liege in seclusion
					limit = {
						prisoner = no
						is_councillor = no
						is_landed = no
						liege = { character = ROOT }
						NOT = { character = ROOT }
					}
					add_character_modifier = {
						name = in_seclusion
						duration = -1
					}
				}
				any_courtier = { # Landed councillors return home while you, their liege, is in seclusion
					limit = {
						prisoner = no
						OR = {
							is_councillor = yes
							has_minor_title = title_councilmember_king
							has_minor_title = title_councilmember_emperor
						}
						is_landed = yes
						liege = { character = ROOT }
						NOT = { character = ROOT }
					}
					force_host = THIS
				}
				any_courtier = { # Landed children being educated in your court are sent home, with the guardianship ending
					limit = {
						prisoner = no
						is_landed = yes
						is_adult = no
						has_guardian = yes
					}
					remove_guardian = yes
				}
				if = { #If you are getting educated elsewhere, then go home to be secluded
					limit = {
						NOT = { age = 16 }
						is_abroad = yes
					}
					remove_guardian = yes
					force_host = ROOT
				}
				any_vassal = {
					character_event = { id = RIP.12001 days = 7 random = 7 }
				}
				if = { #Notify employer that councillor is going into seclusion
					limit = { 
						is_councillor = yes 
						liege = { ai = no }
					}
					liege = { character_event = { id = RIP.12101 days = 1 } }
				}
			}
		}
		ai_will_do = {
			factor = 0.2
			
			modifier = {
				factor = 0
				NOT = {
					capital_scope = {
						OR = {
							has_epidemic = yes
							any_neighbor_province = {
								has_epidemic = yes
							}
						}
					}
				}
			}
			
			modifier = {
				factor = 0.01
				capital_scope = {
					OR = {
						disease = tuberculosis
						disease = measles
					}
				}
			}
			modifier = {
				factor = 0.5
				trait = brave
			}
			modifier = {
				factor = 2
				trait = depressed
			}
			modifier = {
				factor = 2
				trait = stressed
			}
			modifier = {
				factor = 5
				trait = craven
			}
			modifier = {
				factor = 2
				trait = paranoid
			}
			modifier = {
				factor = 50
				capital_scope = { disease = bubonic_plague }
			}
		}
	}
	
	open_the_gates = {
		only_rulers = yes
		is_high_prio = yes
		
		potential = {
			is_ruler = yes
			has_character_modifier = in_seclusion
		}

		allow = {
			has_character_modifier = in_seclusion
		}

		effect = {
			remove_do_not_disturb_effect = yes
			clr_character_flag = exposed_to_outside
			clr_character_flag = seclusion_piling_corpses
			clr_character_flag = seclusion_lazy_seduction
			clr_character_flag = seclusion_nightmares
			clr_character_flag = seclusion_gained_friend
			clr_character_flag = seclusion_child_has_lover
			clr_character_flag = seclusion_tunnel
			clr_character_flag = seclusion_food_events

			custom_tooltip = { text = open_the_gates_info_tooltip }
			remove_character_modifier = in_seclusion
			if = {
				limit = { NOT = { has_character_flag = legitimate_isolation } }
				add_character_modifier = {
					name = recently_opened_gates
					duration = 365
				}
			}
			hidden_tooltip = {
				clr_character_flag = seclusion_events_on
				character_event = { id = RIP.11557 days = 40 random = 20} #clears starvation modifiers
				any_courtier = {
					clr_character_flag = seclusion_events_on
					remove_character_modifier = in_seclusion
					character_event = { id = RIP.11557 days = 40 random = 20} #clears starvation modifiers
				}
				any_vassal = {
					limit = {
						OR = {
							is_councillor = yes
							has_minor_title = title_councilmember_king
							has_minor_title = title_councilmember_emperor
						}
						is_landed = yes
						liege = { character = ROOT }
						NOT = {
							has_character_modifier = in_seclusion
						}
						host = { NOT = { character = ROOT } }
					}
					force_host = ROOT
				}
			}
			if = { # Rejoin your liege's court if both of you are not in seclusion
				limit = {
					OR = {
						is_councillor = yes
						has_minor_title = title_councilmember_king
						has_minor_title = title_councilmember_emperor
					}
					NOT = {
						liege = {
							has_character_modifier = in_seclusion
						}
					}
				}
				liege = {
					ROOT = {
						force_host = PREV
					}
				}

				if = { #Notify employer that councillor is going into seclusion
					limit = { 
						is_councillor = yes 
						#liege = { ai = no }
					}
					liege = { character_event = { id = RIP.12100 days = 1 } }
				}
			}

			if = { limit = { has_character_modifier = secluded_revelry } remove_character_modifier = secluded_revelry }
			if = { limit = { has_character_modifier = savoring_the_end_days } remove_character_modifier = savoring_the_end_days }
		}
		ai_will_do = {
			factor = 0.1

			modifier = {
				factor = 0
				capital_scope = { has_disease = yes }
				NOT = { has_character_modifier = starving_food_shortage }
			}
			
			modifier = {
				factor = 0.5
				trait = paranoid
			}

			modifier = {
				factor = 3
				trait = brave
			}

			modifier = {
				factor = 3
				capital_scope = { has_disease = no }
			}

			modifier = {
				factor = 3
				has_character_modifier = starving_food_shortage
			}
		}
	}
	
}

title_decisions = {
	build_hospital = {
		only_playable = yes
		hide_in_decisions_list = yes		# player can build hospitals from the province view
		filter = owned
		ai_target_filter = owned
		ai_check_interval = 12
		from_potential = {					# scope: character who is building
			ai = yes
			is_playable = yes
			has_dlc = "Reapers"
			war = no
			wealth = 600
		}
		
		potential = {
			tier = COUNT
			has_hospital = no
			has_siege = no
			is_occupied = no
		}
		
		allow = {
			always = yes
		}
		
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0.1
				owner = { independent = no }
			}
			modifier = {
				factor = 0.1
				owner = { trait = greedy }
			}
			modifier = {
				factor = 0.1
				owner = { trait = arbitrary }
			}
			modifier = {
				factor = 0.1
				owner = { trait = slothful }
			}
			modifier = {
				factor = 0.1
				owner = { trait = zealous }
			}
			modifier = {
				factor = 0.1
				owner = { trait = content }
			}
			modifier = {
				factor = 5
				owner = { has_character_flag = seen_the_light_of_modern_medicine }
			}
			modifier = {
				factor = 2
				is_capital = yes
			}
			modifier = {
				factor = 2
				OR = {
					owner = { is_ill = yes }
					owner = { num_of_symptoms = 1 }
				}
			}
			modifier = {
				factor = 2
				owner = { trait = charitable }
			}
			modifier = {
				factor = 2
				owner = { trait = diligent }
			}
			modifier = {
				factor = 2
				owner = { trait = kind }
			}
			modifier = {
				factor = 2
				owner = { trait = erudite }
			}
		}
		
		effect = {
			location = {
				build_holding = {
					type = hospital
				}
			}
		}
	}
}
	
