﻿##########################################
# Hire for a specific Court Position
# These used to be separate decisions, but are now combined into one
# by Chad Uhl
###########################################
recruit_court_position_decision = {
	ai_check_interval = 60
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_recruitment.dds"
	}
	sort_order = 10
	decision_group_type = courtier

	is_shown = {
		is_landed_or_landless_administrative = yes
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
	}

	# TODO_CD_EP3: Fix cooldowns on options after code support is finished TIT-49117
	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "CHOOSE_CHARACTER_ROLE_DECISION_NEXT_STEP_BUTTON"
		show_from_start = yes

		item = { # Court Physician
			value = hire_physician_decision
			is_shown = {
				is_ruler = yes
				is_landless_adventurer = no
			}
			is_valid = {
				NOR = {
					employs_court_position = court_physician_court_position
					custom_tooltip = {
						text = recruit_court_physician_cooldown_tt
						has_character_flag = recruit_court_physician_cooldown
					}
				}
			}
			current_description = hire_physician_decision_desc
			localization = hire_physician_decision
			icon = "gfx/interface/icons/court_position_types/court_physician_court_position.dds"
			ai_chance = { value = 100 }
		} 
		item = { #Caraven Master
			value = hire_travel_leader_decision
			is_shown = {
				exists = primary_title 
				primary_title.tier >= tier_county
				is_landless_adventurer = no
			}
			is_valid = {
				NOR = {
					employs_court_position = travel_leader_court_position
					custom_tooltip = {
						text = recruit_travel_leader_cooldown_tt
						has_character_flag = recruit_travel_leader_cooldown
					}
				}
			}
			current_description = hire_travel_leader_decision_desc
			localization = hire_travel_leader_decision
			icon = "gfx/interface/icons/court_position_types/travel_leader_court_position.dds"
			ai_chance = {
				value = 100
				if = {
					limit = {
						NOR = {
							highest_held_title_tier > tier_barony
							is_landed_or_landless_administrative = yes
							gold > low_skill_court_physician_cost
							is_at_war = no
						}
					}
					multiply = 0
				}
			}
		}
		item = { # Wet Nurse 
			value = find_wet_nurse_decision
			is_shown = {
				is_landed_or_landless_administrative = yes
				has_bp2_dlc_trigger = yes
			}
			is_valid = {
				NOR = {
					employs_court_position = wet_nurse_court_position
					custom_tooltip = {
						text = recruit_wet_nurse_cooldown_tt
						has_character_flag = recruit_wet_nurse_cooldown
					}
				}
				custom_tooltip = {
					text = find_wet_nurse_decision.tt
					OR = {
						any_child = {
							is_adult = no
						}
						is_adult = no
						any_warden_hostage = {
							is_adult = no
						}
					}
				}
			}
			current_description = find_wet_nurse_decision_desc
			localization = find_wet_nurse_decision
			icon = "gfx/interface/icons/court_position_types/wet_nurse_court_position.dds"
			ai_chance = {
				value = 10
				if = {
					limit = {
						any_child = { #more willing if mother of your children is dead, too old or not healthy
							exists = mother
							mother = {
								OR = {
									is_alive = no
									age > 45
									health < 3
								}
							}
						}
					}
					add = 100
				}
				if = {
					limit = {
						NOR = {
							highest_held_title_tier > tier_barony
							NOT = {
								employs_court_position = wet_nurse_court_position
							}
							any_child = {
								age < 5
							}
						}
					}
					multiply = 0
				}
			}
		}
		item = { # Charioteer
			value = hire_charioteer_decision
			is_shown = {
				has_ep3_dlc_trigger = yes
				is_landless_adventurer = no
				culture = {
					has_cultural_parameter = hosts_chariot_races
				}
			}
			is_valid = {
				NOR = {
					employs_court_position = charioteer_court_position
					custom_tooltip = {
						text = recruit_charioteer_cooldown_tt
						has_character_flag = recruit_charioteer_cooldown
					}
				}
			}
			current_description = hire_charioteer_decision_desc
			localization = hire_charioteer_decision
			icon = "gfx/interface/icons/court_position_types/charioteer_court_position.dds"
			ai_chance = { value = 100 }
		}
		item = { # Bookmaker
			value = hire_bookmaker_decision
			is_shown = {
				has_ep3_dlc_trigger = yes
				is_landless_adventurer = no
				culture = {
					has_cultural_parameter = hosts_chariot_races
				}
			}
			is_valid = {
				NOR = {
					employs_court_position = bookmaker_court_position
					custom_tooltip = {
						text = recruit_bookmaker_cooldown_tt
						has_character_flag = recruit_bookmaker_cooldown
					}
				}
			}
			current_description = hire_bookmaker_decision_desc
			localization = hire_bookmaker_decision
			icon = "gfx/interface/icons/court_position_types/bookmaker_court_position.dds"
			ai_chance = { value = 100 }
		}
		item = { # Eunuch
			value = hire_eunuch_decision
			is_shown = {
				has_ep3_dlc_trigger = yes
				is_landless_adventurer = no
				culture = {
					has_cultural_parameter = can_appoint_chief_eunuch
				}
			}
			is_valid = {
				NOR = {
					employs_court_position = chief_eunuch_court_position
					custom_tooltip = {
						text = recruit_chief_eunuch_cooldown_tt
						has_character_flag = recruit_eunuch_cooldown
					}
				}
			}
			current_description = hire_eunuch_decision_desc
			localization = hire_eunuch_decision
			icon = "gfx/interface/icons/court_position_types/chief_eunuch_court_position.dds"
			ai_chance = { value = 100 }
		}
		item = { # Gardener
			value = recruit_gardener_decision
			is_shown = {
				culture = {
					has_cultural_parameter = can_recruit_gardeners
				}
				is_landless_adventurer = no
			}
			is_valid = {
				NOR = {
					employs_court_position = court_gardener_court_position
					custom_tooltip = {
						text = recruit_court_gardener_cooldown_tt
						has_character_flag = recruit_court_gardener_cooldown
					}
				}
			}
			current_description = recruit_gardener_decision_desc
			localization = recruit_gardener_decision
			icon = "gfx/interface/icons/court_position_types/court_gardener_court_position.dds"
			ai_chance = { value = 100 }
		}
		item = { # Linguist (Self)
			value = invite_a_linguist_self
			is_shown = {
				# Standard filter checks.
				is_playable_character = yes
				has_royal_court = yes
				has_dlc_feature = royal_court
				# Language checks.
				NOT = { has_court_language_of_culture = root.culture } # No need for linguist
				any_culture_global = { # Need somewhere to recruit linguist from
					exists = culture_head
					root.liege = { has_court_language_of_culture = prev }
				}
			}
			is_valid = {
				age >= 6
				is_alive = yes
				NOT = { exists = involved_activity }
				is_imprisoned = no
				NOT = { knows_court_language_of = root }
				custom_tooltip = {
					text = scheming_already
					NOT = { # Is not currently learning a language and doesn't know court language
						any_scheme = { scheme_type = learn_language }	
					}
				}
				custom_tooltip = {
					text = linguist_already_present
					NOT = {
						any_courtier = { # You don't already have a linguist at court
							has_character_flag = court_linguist_flag
							knows_court_language_of = root
						}
					}
				}
				NOT = {
					custom_tooltip = {
						text = recruit_linguist_self_cooldown_tt
						has_character_flag = recruit_linguist_self_cooldown
					}
				}
			}
			current_description = invite_a_linguist_desc
			localization = invite_a_linguist_self
			icon = "gfx/interface/icons/scheme_types/icon_scheme_learn_language.dds"
			ai_chance = { value = 100 }
		}
		item = { # Linguist (Liege)
			value = invite_a_linguist_liege
			is_shown = {
				# Standard filter checks.
				is_landed_or_landless_administrative = yes
				# Liege checks.
				is_independent_ruler = no
				liege = { has_royal_court = yes has_dlc_feature = royal_court }
				# Language checks.
				trigger_if = {
					limit = { has_royal_court = yes }
					NOT = { has_same_court_language = liege } # Can use other decision in this case
				}
				NOR = {
					liege = { has_court_language_of_culture = root.culture } # No need to learn your own culture's language
					AND = {
						knows_language_of_culture = root.liege.culture 
						trigger_if = {
							limit = {
								any_child = {
									count > 0
								}
							}
							any_child = {
								count > 0
								knows_language_of_culture = root.liege.culture 
							}
						}
					}
				}
				any_culture_global = { # Need somewhere to recruit linguist from
					exists = culture_head
					root.liege = { has_court_language_of_culture = prev }
				}
			}
			is_valid = {
				age >= 6
				is_alive = yes
				NOT = { exists = involved_activity }
				is_imprisoned = no
				custom_tooltip = {
					text = scheming_already
					NOT = { # Is not currently learning a language and doesn't know court language
						any_scheme = { scheme_type = learn_language }
					}
				}
				custom_tooltip = {
					text = linguist_already_present
					NOT = {
						any_courtier = { # You don't already have a linguist at court
							has_character_flag = court_linguist_flag
							knows_court_language_of = root.liege
						}
					}
				}
				NOT = {
					custom_tooltip = {
						text = recruit_linguist_liege_cooldown_tt
						has_character_flag = recruit_linguist_liege_cooldown
					}
				}
			}
			current_description = invite_a_linguist_desc
			localization = invite_a_linguist_liege
			icon = "gfx/interface/icons/scheme_types/icon_scheme_learn_language.dds"
			ai_chance = { value = 100 }
		}
		item = { #Stargazer
			value = invite_a_stargazer_decision
			is_shown = {
				government_has_flag = government_is_nomadic
				exists = primary_title 
				primary_title.tier >= tier_county
				is_landless_adventurer = no
			}
			is_valid = {
				NOR = {
					employs_court_position = court_astrologer_court_position
					custom_tooltip = {
						text = recruit_court_astrologer_cooldown_tt
						has_character_flag = recruit_court_astrologer_cooldown
					}
				}
				exists = capital_province
			}
			current_description = invite_a_stargazer_decision_desc
			localization = invite_a_stargazer_decision
			icon = "gfx/interface/icons/court_position_types/court_astrologer_court_position.dds"
			ai_chance = {
				value = 100
				if = {
					limit = {
						NOR = {
							highest_held_title_tier > tier_barony
							gold > low_skill_court_physician_cost
							is_at_war = no
						}
					}
					multiply = 0
				}
			}
		}
		item = { # Siege Engineer
			value = invite_a_siege_engineer_decision
			is_shown = {
				government_has_flag = government_is_nomadic
				exists = primary_title 
				primary_title.tier >= tier_county
				is_landless_adventurer = no
			}
			is_valid = {
				NOR = {
					employs_court_position = siege_engineer_court_position
					custom_tooltip = {
						text = recruit_siege_engineer_cooldown_tt
						has_character_flag = recruit_siege_engineer_cooldown
					}
				}
				exists = capital_province
			}
			current_description = invite_a_siege_engineer_decision_desc
			localization = invite_a_siege_engineer_decision
			icon = "gfx/interface/icons/court_position_types/siege_engineer_court_position.dds"
			ai_chance = {
				value = 100
				if = {
					limit = {
						NOR = {
							highest_held_title_tier > tier_barony
							gold > low_skill_court_physician_cost
							is_at_war = no
						}
					}
					multiply = 0
				}
			}
		}
		item = { # Foreign Emissary
			value = invite_a_foreign_emissary_decision
			is_shown = {
				government_has_flag = government_is_nomadic
				exists = primary_title 
				primary_title.tier >= tier_county
				is_landless_adventurer = no
			}
			is_valid = {
				NOR = {
					employs_court_position = foreign_emissary_court_position
					custom_tooltip = {
						text = recruit_foreign_emissary_cooldown_tt
						has_character_flag = recruit_foreign_emissary_cooldown
					}
				}
				exists = capital_province
			}
			current_description = invite_a_foreign_emissary_decision_desc
			localization = invite_a_foreign_emissary_decision
			icon = "gfx/interface/icons/court_position_types/foreign_emissary_court_position.dds"
			ai_chance = {
				value = 100
				if = {
					limit = {
						NOR = {
							highest_held_title_tier > tier_barony
							gold > low_skill_court_physician_cost
							is_at_war = no
						}
					}
					multiply = 0
				}
			}
		}
		item = { # Keeper of the Menagerie
			value = find_keeper_of_menagerie_decision
			is_shown = {
				is_landless_adventurer = no
			}
			is_valid = {
				NOR = {
					employs_court_position = keeper_of_menagerie_court_position
					custom_tooltip = {
						text = find_keeper_of_menagerie_cooldown_tt
						has_character_flag = find_keeper_of_menagerie_cooldown
					}
				}
			}
			current_description = find_keeper_of_menagerie_decision_desc
			localization = find_keeper_of_menagerie_decision
			icon = "gfx/interface/icons/court_position_types/keeper_of_menagerie_court_position.dds"
			ai_chance = { value = 100 }
		}
	}

	effect = {
		custom_tooltip = recruit_court_position_decision_tt
		hidden_effect = {
			custom_tooltip = recruit_court_position_decision_tooltip
			if = { # Court Physician
				limit = { scope:hire_physician_decision = yes }
				hidden_effect = {
					add_character_flag = {
						flag = health_3001_hire_physician_decision_text
						days = 20
					}
				}
				set_variable = {
					name = recruit_court_physician_cooldown
					years = 1
				}
				trigger_event = {
					id = health.3001
					days = { 7 14 }
				}
			}
			else_if = { # Travel Leader
				limit = { scope:hire_travel_leader_decision = yes }
				add_character_flag = {
					flag = recruit_travel_leader_cooldown
					years = 1
				}
				trigger_event = {
					id = travel_events.1010
					days = { 7 14 }
				}
			}
			else_if = { # Wet Nurse
				limit = { scope:find_wet_nurse_decision = yes }
				add_character_flag = {
					flag = recruit_wet_nurse_cooldown
					years = 1
				}
				trigger_event = {
					id = bp2_decision.0001
					days = { 7 14 }
				}
			}
			else_if = { # Charioteer
				limit = { scope:hire_charioteer_decision = yes }
				add_character_flag = {
					flag = recruit_charioteer_cooldown
					years = 1
				}
				trigger_event = {
					id = ep3_decisions_event.1000
					days = { 7 14 }
				}
			}
			else_if = {
				limit = { scope:hire_bookmaker_decision = yes }
				add_character_flag = {
					flag = recruit_bookmaker_cooldown
					years = 1
				}
				trigger_event = {
					id = ep3_decisions_event.1010
				}
			}
			else_if = { # Eunuch
				limit = { scope:hire_eunuch_decision = yes }
				add_character_flag = {
					flag = recruit_eunuch_cooldown
					years = 1
				}
				trigger_event = {
					id = ep3_decisions_event.5010
					days = { 7 14 }
				}
			}
			else_if = { # Court Gardener 
				limit = { scope:recruit_gardener_decision = yes }
				hidden_effect = {
					if = {
						limit = {
							exists = root.capital_province
							any_pool_character = {
								province = root.capital_province
								stewardship >= medium_skill_rating
								culture = root.culture
								opinion = { # Just to make sure you don't pull in rivals or similar
									value >= -30
									target = root
								}
							}
						}
						random_pool_character = {
							province = root.capital_province
							limit = {
								stewardship >= medium_skill_rating
								culture = root.culture
								opinion = { # Just to make sure you don't pull in rivals or similar
									value >= -30
									target = root
								}
							}
							if = {
								limit = {
									NOT = {
										has_trait = lifestyle_gardener
									}
								}
								add_trait = lifestyle_gardener
							}
							save_scope_as = new_commander # Ignore the name, it's to save on localisation
						}
					}
					else = {
						create_character = {
							employer = root
							template = pool_repopulate_stewardship
							faith = root.faith
							culture = root.culture
							save_scope_as = new_commander
						}
					}
					if = {
						limit = {
							exists = scope:new_commander
						}
						scope:new_commander = {
							force_character_skill_recalculation = yes
							add_character_flag = {
								flag = blocked_from_leaving
								years = 25
							}
							if = {
								limit = {
									NOT = {
										has_trait = lifestyle_gardener
									}
								}
								add_trait = lifestyle_gardener
							}
						}
						if = {
							limit = {
								scope:new_commander = {
									NOT = {
										is_courtier_of = root
									}
								}
							}
							add_courtier = scope:new_commander
						}
						send_interface_toast = {
							type = event_toast_effect_neutral
							title = gardener_recruited.t
							left_icon = scope:new_commander
							custom_tooltip = commander_recruited.desc
						}
					}
				}
				add_character_flag = {
					flag = recruit_court_gardener_cooldown
					years = 1
				}
			}
			else_if = {
				limit = { scope:invite_a_linguist_self = yes }
				save_scope_as = target_court_language
				custom_tooltip = {
					text = invite_a_linguist_tt_self
					trigger_event = ep1_decision.0201
				}
				if = {
					limit = {
						NOT = { knows_court_language_of = root.liege }
						any_scheme = { is_hostile = no }
					}
					custom_description_no_bullet = { text = learn_language_will_cancel_ongoing_schemes_tt }
				}
				add_character_flag = {
					flag = recruit_linguist_self_cooldown
					years = 1
				}
			}
			else_if = {
				limit = { scope:invite_a_linguist_liege = yes }
				liege = { save_scope_as = target_court_language }
				save_scope_value_as = { name = language_scheme_type value = flag:liege }
				custom_tooltip = {
					text = invite_a_linguist_tt_liege
					trigger_event = ep1_decision.0201
				}
				if = {
					limit = {
						NOT = { knows_court_language_of = root.liege }
						any_scheme = { is_hostile = no }
					}
					custom_description_no_bullet = { text = learn_language_will_cancel_ongoing_schemes_tt }
				}
				add_character_flag = {
					flag = recruit_linguist_liege_cooldown
					years = 1
				}
			}
			else_if = { # Stargazer
				limit = { scope:invite_a_stargazer_decision = yes }
				add_character_flag = {
					flag = recruit_court_astrologer_cooldown
					years = 1
				}
				trigger_event = {
					id = mpo_decisions_events.0070
					days = { 7 14 }
				}
			}
			else_if = { # Siege Engineer
				limit = { scope:invite_a_siege_engineer_decision = yes }
				add_character_flag = {
					flag = recruit_siege_engineer_cooldown
					years = 1
				}
				trigger_event = {
					id = mpo_decisions_events.0080
					days = { 7 14 }
				}
			}
			else_if = { # Foreign Emissary
				limit = { scope:invite_a_foreign_emissary_decision = yes }
				add_character_flag = {
					flag = recruit_foreign_emissary_cooldown
					years = 1
				}
				trigger_event = {
					id = mpo_decisions_events.0090
					days = { 7 14 }
				}
			}
			else_if = { # Keeper of the Menagerie
				limit = { scope:find_keeper_of_menagerie_decision = yes }
				add_character_flag = {
					flag = find_keeper_of_menagerie_cooldown
					years = 1
				}
				trigger_event = {
					id = pets_expanded_keeper_of_menagerie.1001
					days = { 7 14 }
				}
			}
		}
	}
	
	ai_potential = {
	# TODO_CD_EP3: TIT-55684 make AI use this
		always = no # Only players can do this. AI vassals go through the normal court events/hold court activity.
	}
}

gain_weight_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = gain_weight_decision_desc
	selection_tooltip = gain_weight_decision_tooltip

	ai_check_interval = 0

	is_shown = {
		OR = {
			has_character_modifier = malnourished_modifier
			current_weight < -50
		}
		NOT = { has_character_modifier = gaining_weight_modifier }
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
		NOT = { has_trait = incapable }
	}

	effect = {
		add_character_modifier = {
			modifier = gaining_weight_modifier
		}

		trigger_event = { #To give faster, and steadier, results
			id = health.5004
			days = 90
		}
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

stop_gain_weight_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_activity.dds"
	}
	desc = stop_gain_weight_decision_desc
	selection_tooltip = stop_gain_weight_decision_tooltip

	ai_check_interval = 0

	is_shown = {
		has_character_modifier = gaining_weight_modifier
	}

	effect = {
		remove_character_modifier = gaining_weight_modifier
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

lose_weight_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_activity.dds"
	}
	desc = lose_weight_decision_desc
	selection_tooltip = lose_weight_decision_tooltip

	ai_check_interval = 0

	is_shown = {
		OR = {
			has_character_modifier = obese_modifier
			current_weight > 50
		}
		NOT = { has_character_modifier = losing_weight_modifier }
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
		NOT = { has_trait = incapable }
	}

	effect = {
		stress_impact = {
			gluttonous = medium_stress_impact_gain
		}
		add_character_modifier = {
			modifier = losing_weight_modifier
		}

		trigger_event = { #To give faster results
			id = health.5005
			days = 180
		}
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

stop_lose_weight_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stop_lose_weight_decision_desc
	selection_tooltip = stop_lose_weight_decision_tooltip

	ai_check_interval = 0

	is_shown = {
		has_character_modifier = losing_weight_modifier
	}

	effect = {
		remove_character_modifier = losing_weight_modifier
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

commit_suicide_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { has_variable = mourning_parent }
				desc = commit_suicide_decision_desc_parent
			}
			triggered_desc = {
				trigger = { has_variable = mourning_soulmate }
				desc = commit_suicide_decision_desc_soulmate
			}
			triggered_desc = {
				trigger = { has_trait = lunatic }
				desc = commit_suicide_decision_desc_lunatic
			}
			triggered_desc = {
				trigger = { has_trait = depressed }
				desc = commit_suicide_decision_desc_depressed
			}
			triggered_desc = {
				trigger = { has_trait = cancer }
				desc = commit_suicide_decision_desc_cancer
			}
			triggered_desc = {
				trigger = { has_trait = leper }
				desc = commit_suicide_decision_desc_leper
			}
			triggered_desc = {
				trigger = { has_variable = messy_divorce }
				desc = commit_suicide_decision_desc_divorce
			}
			triggered_desc = {
				trigger = { has_variable = rank_demoted }
				desc = commit_suicide_decision_desc_demoted
			}
			triggered_desc = {
				trigger = { has_variable = mourning_friend }
				desc = commit_suicide_decision_desc_friend
			}
			triggered_desc = {
				trigger = { has_trait = great_pox }
				desc = commit_suicide_decision_desc_great_pox
			}
			triggered_desc = {
				trigger = { has_trait = incapable }
				desc = commit_suicide_decision_desc_incapable
			}
			triggered_desc = {
				trigger = { stress >= extremely_high_stress }
				desc = commit_suicide_decision_desc_stressed
			}
			triggered_desc = {
				trigger = { 
					has_trait = witch 
					faith = { has_doctrine_parameter = witchcraft_illegal }
				}
				desc = commit_suicide_decision_desc_witch
			}
			triggered_desc = {
				trigger = { 
					has_trait = cannibal
					NOT = { 
						faith = { has_doctrine_parameter = cannibalism_legal }
					}
				}
				desc = commit_suicide_decision_desc_cannibal
			}
			triggered_desc = {
				trigger = { 
					has_trait = sodomite
					faith = { has_doctrine_parameter = homosexuality_illegal }
				}
				desc = commit_suicide_decision_desc_sodomite
			}
			triggered_desc = {
				trigger = { 
					has_trait = deviant
					faith = { has_doctrine_parameter = deviancy_illegal }
				}
				desc = commit_suicide_decision_desc_deviant
			}
			triggered_desc = {
				trigger = { 
					OR = {
						has_trait = adulterer
						has_trait = fornicator
					}
					OR = {
						AND = {
							faith = { has_doctrine_parameter = adultery_female_crime }
							is_female = yes
						}
						AND = {
							faith = { has_doctrine_parameter = adultery_male_crime }
							is_male = yes
						}
					}
				}
				desc = commit_suicide_decision_desc_criminal
			}
		}
	}
	selection_tooltip = commit_suicide_decision_tooltip
	

	ai_check_interval = 500

	cooldown = { days = 1825 }

	is_shown = {
		is_adult = yes
		NOT = { can_execute_decision = initiate_consolamentum_decision }
		OR = {
			has_trait = depressed
			has_trait = incapable
			has_trait = cancer
			has_trait = leper
			has_trait = great_pox
			has_trait = lunatic
			has_character_flag = make_suicide_available
			stress >= extremely_high_stress
			AND = { #You have a criminal trait and you are stressed
				stress >= very_high_stress
				OR = {
					AND = {
						has_trait = witch
						faith = { has_doctrine_parameter = witchcraft_illegal }
					}
					AND = {
						has_trait = cannibal
						NOT = {
							faith = { has_doctrine_parameter = cannibalism_legal }
						}
					}
					AND = {
						has_trait = sodomite
						faith = { has_doctrine_parameter = homosexuality_illegal }
					}
					AND = {
						has_trait = deviant
						faith = { has_doctrine_parameter = deviancy_illegal }
					}
					AND = {
						OR = {
							has_trait = adulterer
							has_trait = fornicator
						}
						OR = {
							AND = {
								faith = { has_doctrine_parameter = adultery_female_crime }
								is_female = yes
							}
							AND = {
								faith = { has_doctrine_parameter = adultery_male_crime }
								is_male = yes
							}
						}
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		not = { exists = involved_activity }
		is_imprisoned = no
		is_commanding_army = no
	}

	effect = {
		show_as_tooltip = {
			committed_suicide_effect = yes
		}
		
		custom_tooltip = commit_suicide_decision_effect_tooltip
		trigger_event = {
			on_action = commit_suicide
		}
	}
	
	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0
		modifier = {
			add = 30
			has_trait = depressed
		}
		modifier = {
			add = 25
			has_trait = incapable
		}
		modifier = {
			add = 10
			has_trait = cancer
		}
		modifier = {
			add = 10
			has_trait = leper
		}
		modifier = {
			add = 10
			has_trait = great_pox
		}
		modifier = {
			add = 10
			has_trait = lunatic
		}
		modifier = {
			add = 20
			has_character_flag = make_suicide_available
		}
	}
}

secede_from_empire_decision = { #by Sean Hughes
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = secede_from_empire_decision_desc
	selection_tooltip = secede_from_empire_decision_tooltip
	decision_group_type = major

	ai_check_interval = 12

	is_shown = {
		liege ?= {
			highest_held_title_tier = tier_empire
			NOT = { this = root }
		}
		OR = {
			liege ?= { debt_level >= 7 } # Over 25 years in debt
			liege ?= {
				any_character_war = {
					primary_attacker = prev
					war_days >= 9125 # Offensive war lasting over 25 years.
				}
			}	
		}
		is_landed = yes
	}

	is_valid = {
		OR = {
			custom_description = {
				liege = { debt_level >= 7 } # Over 25 years in debt
				subject = liege
				object = root
				text = secede_from_empire_decision_trigger_debt
			}
			custom_description = {		
				liege = {
					any_character_war = {
						primary_attacker = prev
						war_days >= 9125 # Offensive war lasting over 25 years.
					}
				}
				subject = liege
				object = root
				text = secede_from_empire_decision_trigger_war
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		# Liege loses debt proportionally to how much realm_size they will lose when you go independent.
		custom_tooltip = secede_from_empire_decision_effect_tooltip
		hidden_effect = {
			liege = {
				save_scope_as = liege
				save_scope_value_as = {
					name = debt_cleared
					value = {
						value = gold 						# Example: I am 1000 gold in debt, so we start with -1000
						multiply = root.sub_realm_size 		# The seceeding vassal has a realm size of 25...
						divide = scope:liege.realm_size 			# ...while the top liege has a realm size of 100, scaling the value to -250
						multiply = -1.1 	
					}
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = secede_from_empire_decision_notification
					left_icon = root

					custom_tooltip = secede_from_empire_decision_notification_tt
					add_gold = scope:debt_cleared
				}
			}
		}

		# Go independent
		create_title_and_vassal_change = {
			type = independency 
			save_scope_as = change
		}
		becomes_independent = {
			change = scope:change
		}
		resolve_title_and_vassal_change = scope:change
		
		debug_log = "Empire Vassal Secession:"
		debug_log_scopes = no
		scope:liege = { debug_log_scopes = no }
		scope:debt_cleared = { debug_log_scopes = no }
	}
	
	ai_potential = {
		liege = { debt_level >= 5 } # More than 5 years in debt
		trigger_if = {
			limit = {
				liege = { is_rightful_liege_of = root }
			}
			is_powerful_vassal = yes # The strongest vassals go first
			highest_held_title_tier >= tier_county # Counts should never break away from their rightful liege, though.
		}
		trigger_else = {
			liege = { is_ai = yes }

			# Slightly different from the rightful liege check, this looks to see if I hold any land at all that De Jure belongs to my liege's empire(s).
			NOT = {	
				any_held_title = {
					tier = tier_county
					exists = empire.holder
					empire.holder = root.liege
				}
			}
		}
	}

	ai_will_do = {
		base = -40

		# Realm Modifiers
		compare_modifier = {
			value = sub_realm_size
			multiplier = 1
		}

		modifier = {
			add = 50
			NOT = {
				liege = { is_rightful_liege_of = root }
			}
		}

		modifier = {
			# Kings are more likely to seceede
			add = 25
			highest_held_title_tier = tier_kingdom
		}

		modifier = {
			add = -35
			# Electors in the HRE are far less likely to seceede.
			liege.primary_title = title:e_hre
			title:e_hre = {
				has_title_law = princely_elective_succession_law
				any_elector = {
					this = root
				}
			}
		}

		modifier = {
			add = -60 
			# Satraps of the Mongol Empire should (almost) never seceede.
			liege.primary_title = title:e_mongolia  
		}

		# 'Soft' Modifiers, e.g., Opinion and Personality
		ai_value_modifier = {
			ai_greed = 0.35
			ai_boldness = 0.35
		}

		opinion_modifier = {
			opinion_target = liege
			who = root
			multiplier = -0.15
		}

		# Faith and Culture Factors
		modifier = {
			factor = 1.2
			NOT = { culture = { has_same_culture_heritage = root.liege.culture }}
		}

		modifier = {
			factor = 1.1
			faith = {		
				faith_hostility_level = {
					target = root.liege.faith
					value = faith_astray_level
				}
			}
		}

		modifier = {
			factor = 1.3
			faith = {		
				faith_hostility_level = {
					target = root.liege.faith
					value = faith_hostile_level
				}
			}
		}

		modifier = {
			factor = 1.5
			faith = {		
				faith_hostility_level = {
					target = root.liege.faith
					value = faith_evil_level
				}
			}
		}
	}	
}

#pet_dog_decision = { #by Linnéa Thimrén
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_pet_dog.dds"
#	}
#	desc = pet_dog_decision_desc
#	selection_tooltip = pet_dog_decision_tooltip
#
#	ai_check_interval = 120
#
#	cooldown = { days = 1825 }
#
#	is_shown = {
#		any_owned_story = {
#			story_type = story_cycle_pet_dog
#			exists = story_owner.var:story_cycle_dog_name
#		}
#	}
#
#	is_valid_showing_failures_only = {
#		is_available = yes
#	}
#
#	effect = {
#		custom_tooltip = pet_decision_effect_tooltip
#
#		trigger_event = {
#			on_action = story_cycle_dog_pet_decision_on_actions
#		}
#	}

#	ai_potential = {
#		always = yes
#	}
#
#	ai_will_do = {
#		base = 0
#
#		modifier = {
#			add = 100
#			stress > 10
#		}
#	}
#}
#
#pet_cat_decision = { #by Linnéa Thimrén
#	picture = {
#		reference = "gfx/interface/illustrations/decisions/decision_pet_dog.dds"
#	}
#	desc = pet_cat_decision_desc
#	selection_tooltip = pet_cat_decision_tooltip
#
#	ai_check_interval = 120
#
#	cooldown = { days = 1825 }
#
#	is_shown = {
#		any_owned_story = {
#			story_type = story_cycle_pet_cat
#			exists = story_owner.var:story_cycle_cat_name
#		}
#	}
#
#	is_valid_showing_failures_only = {
#		is_available = yes
#	}
#
#	effect = {
#		custom_tooltip = pet_decision_effect_tooltip
#
#		trigger_event = {
#			on_action = story_cycle_cat_pet_decision_on_actions
#		}
#	}

#	ai_potential = {
#		always = yes
#	}
#
#	ai_will_do = {
#		base = 0
#
#		modifier = {
#			add = 100
#			stress > 10
#		}
#	}
#}

#DECISIONS TO "USE" YOUR STRESS COPING TRAITS TO LOSE STRESS

stress_loss_drunkard_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stress_loss_drunkard_decision_desc
	selection_tooltip = stress_loss_drunkard_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = drunkard
	}

	is_valid_showing_failures_only = {
		is_available = yes
		NOT = { has_character_modifier = court_no_wine_modifier }
	}

	effect = {
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip
		show_as_tooltip = { add_prestige = medium_prestige_loss } # The effect is actually applied in the event itself

		trigger_event = { on_action = stress_loss_drunkard }
	}
	
	ai_potential = { has_trait = drunkard }
	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_hashishiyah_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stress_loss_hashishiyah_decision_desc
	selection_tooltip = stress_loss_hashishiyah_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = hashishiyah
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			add_character_modifier = {
				modifier = stress_hashish_stupor
				years = 2
			}
		}

		trigger_event = {
			on_action = stress_loss_hashishiyah
		}
	}
	
	ai_potential = {
		has_trait = hashishiyah
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_rakish_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_recruitment.dds"
	}
	desc = {
		desc = stress_loss_rakish_decision_desc
		desc = {
			first_valid = {
				triggered_desc = {
					trigger = {
						is_female = yes
					}
					desc = stress_loss_rakish_decision_desc_woman_ending
				}
				desc = stress_loss_rakish_decision_desc_man_ending
			}
		}
	}
	selection_tooltip = stress_loss_rakish_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = rakish
	}

	is_valid_showing_failures_only = {
		is_available = yes
		short_term_gold >= minor_gold_value
		is_eunuch_trigger = no
		NOT = { has_trait = celibate }
	}

	effect = {
		show_as_tooltip = {
			remove_short_term_gold = minor_gold_value
		}
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip
		custom_tooltip = stress_threshold.1011.rakish.tt


		#So that stress_trait_coping_decisions.2002 can trigger in yearly events too
		save_scope_value_as = {
			name = from_stress_loss_decision
			value = yes
		}

		trigger_event = {
			on_action = stress_loss_rakish
		}

		# Only men have a chance of bastards this way, as real_father cannot be anonymous
		if = {
			limit = { is_male = yes }
			hidden_effect = {
				save_scope_value_as = {
					name = brothel_bastard_chance
					value = {
						# 1% chance with a fertility of 0.1
						value = fertility
						multiply = 10
						# Men dont 'need' to be fertile (there is always a chance they are not the father)
						add = 5
						if = { # Recklessness
							limit = { ai_boldness != 0 }
							add = {
								value = ai_boldness
								divide = 100
							}
						}
						if = { # Shrewdness
							limit = { ai_rationality != 0 }
							add = {
								value = ai_rationality
								divide = 100
								multiply = -1
							}
						}
					}
				}
				random = {
					# 1% chance with a fertility of 0.1
					chance = scope:brothel_bastard_chance
					trigger_event = stress_trait_coping_decisions.2003
				}
			}
		}
	}
	
	ai_potential = {
		has_trait = rakish
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_reclusive_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	desc = stress_loss_reclusive_decision_desc
	selection_tooltip = stress_loss_reclusive_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = reclusive
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			add_prestige = medium_prestige_loss
		}

		trigger_event = {
			on_action = stress_loss_reclusive
		}
	}
	
	ai_potential = {
		has_trait = reclusive
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_irritable_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	desc = stress_loss_irritable_decision_desc
	selection_tooltip = stress_loss_irritable_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = irritable
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			random_list = {
				50 = {
					trigger = {
						any_vassal = { count >= 1 }
					}
					custom_tooltip = stress_loss_irritable_decision_effect_tooltip
				}
				50 = {
					trigger = {
						any_vassal = { count < 1 }
						any_courtier_or_guest = { 
							count >= 1
							OR = { 
								NOT = { this = root }
								this = { is_adult = no }
							}
						}
					}
					custom_tooltip = stress_loss_irritable_decision_effect_courtier_tooltip
				}
				50 = {
					trigger = {
						any_vassal = { count < 1 }
					}
					add_character_modifier = {
						modifier = irritating_everyone_courtier_modifier
						years = 1
					}
				}
			}
		}

		trigger_event = {
			on_action = stress_loss_irritable
		}
	}
	
	ai_potential = {
		has_trait = irritable
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_flagellant_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	}
	desc = stress_loss_flagellant_decision_desc
	selection_tooltip = stress_loss_flagellant_decision_tooltip

	ai_check_interval = 120

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = flagellant
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		
		custom_tooltip = stress_loss_flaggelant_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			increase_wounds_effect = { REASON = whipping }
		}

		trigger_event = {
			on_action = stress_loss_flagellant
		}
	}
	
	ai_potential = {
		has_trait = flagellant
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_profligate_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_spend_money.dds"
	}
	desc = stress_loss_profligate_decision_desc
	selection_tooltip = stress_loss_profligate_decision_tooltip

	ai_check_interval = 120

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = profligate
	}

	is_valid_showing_failures_only = {
		is_available = yes
		short_term_gold >= medium_gold_value
	}

	effect = {
		
		show_as_tooltip = { #The effect is actually applied in the event itself
			remove_short_term_gold = medium_gold_value
		}
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip


		trigger_event = {
			on_action = stress_loss_profligate
		}
	}
	
	ai_potential = {
		has_trait = profligate
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_improvident_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stress_loss_improvident_decision_desc
	selection_tooltip = stress_loss_improvident_decision_tooltip

	ai_check_interval = 120

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = improvident
	}

	is_valid_showing_failures_only = {
		is_available = yes
		short_term_gold >= medium_gold_value
	}

	effect = {
		
		show_as_tooltip = { #The effect is actually applied in the event itself
			remove_short_term_gold = medium_gold_value
		}
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip


		trigger_event = {
			on_action = stress_loss_improvident
		}
	}
	
	ai_potential = {
		has_trait = improvident
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_contrite_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stress_loss_contrite_decision_desc
	selection_tooltip = stress_loss_contrite_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = contrite
	}

	is_valid_showing_failures_only = {
		is_available = yes
		NOT = { has_character_modifier = stress_disturbing_confession }
	}

	effect = {
		
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			if = {
				limit = {
					any_secret = {
						can_be_exposed_by = root
					}
				}
				custom_tooltip = stress_loss_contrite_decision_expose_random_secret
			}
			else = {
				add_character_modifier = {
					modifier = stress_disturbing_confession
					years = 2
				}
			}
		}

		trigger_event = {
			on_action = stress_loss_contrite
		}
	}
	
	ai_potential = {
		has_trait = contrite
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_comfort_eater_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stress_loss_comfort_eater_decision_desc
	selection_tooltip = stress_loss_comfort_eater_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = comfort_eater
	}

	is_valid_showing_failures_only = {
		is_available = yes
		short_term_gold >= medium_gold_value
		custom_description = {
			text = "lackluster_diet_hindrance_desc"
			NOT = { has_character_modifier = fp3_lackluster_diet_modifier }
		}
	}

	effect = {
		
		show_as_tooltip = { #The effect is actually applied in the event itself
			remove_short_term_gold = medium_gold_value
		}
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip


		trigger_event = {
			on_action = stress_loss_comfort_eater
		}
	}
	
	ai_potential = {
		has_trait = comfort_eater
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_inappetetic_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stress_loss_inappetetic_decision_desc
	selection_tooltip = stress_loss_inappetetic_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = inappetetic
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			inappetetic_advance_starvation_effect = yes
		}

		trigger_event = {
			on_action = stress_loss_inappetetic
		}
	}
	
	ai_potential = {
		has_trait = inappetetic
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 50
		}
	}
}

stress_loss_journaller_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stress_loss_journaller_decision_desc
	selection_tooltip = stress_loss_journaller_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = journaller
	}

	is_valid_showing_failures_only = {
		is_available = yes
		NOT = { has_character_modifier = stress_busy_writing }
	}

	effect = {
		
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			add_character_modifier = {
				modifier = stress_busy_writing
				years = 1
			}
		}

		trigger_event = {
			on_action = stress_loss_journaller
		}
	}
	
	ai_potential = {
		has_trait = journaller
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 10
		}
	}
}

stress_loss_confider_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	desc = stress_loss_confider_decision_desc
	selection_tooltip = stress_loss_confider_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = confider
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			every_courtier = {
				custom = all_courtiers_except_confidant
				limit = {
					NOT = {
						any_relation = {
							type = friend
							has_relation_flag = {
								target = root
								relation = friend
								flag = has_been_confided_in
							}
						}
					}
				}
				add_opinion = {
					target = root
					modifier = envy_opinion
					opinion = -10
				}
			}
			if = {
				limit = {
					any_relation = {
						type = friend
						has_relation_flag = {
							target = root
							relation = friend
							flag = has_been_confided_in
						}
					}
				}
				random_relation = {
					type = friend
					limit = {
						has_relation_flag = {
							target = root
							relation = friend
							flag = has_been_confided_in
						}
					}
					add_opinion = {
						target = root
						modifier = friendliness_opinion
						opinion = 5
					}
				}
			}
		}

		trigger_event = {
			on_action = stress_loss_confider
		}
	}
	
	ai_potential = {
		has_trait = confider
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 10
		}
	}
}

stress_loss_athletic_decision = { #by Linnéa Thimrén
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_activity.dds"
	}
	desc = stress_loss_athletic_decision_desc
	selection_tooltip = stress_loss_athletic_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 1095 }

	is_shown = {
		has_trait = athletic
	}

	is_valid_showing_failures_only = {
		is_available = yes
		NOT = { has_trait = infirm }
		NOT = { has_character_modifier = stress_smelling_of_sweat }
	}

	effect = {
		
		custom_tooltip = stress_loss_drunkard_decision_effect_tooltip

		show_as_tooltip = { #The effect is actually applied in the event itself
			add_character_modifier = {
				modifier = stress_smelling_of_sweat
				years = 1
			}
		}

		trigger_event = {
			on_action = stress_loss_athletic
		}
	}
	
	ai_potential = {
		has_trait = athletic
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			stress >= 10
		}
	}
}

write_muwashshah_poem_decision = {
	ai_check_interval = 160
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_misc.dds"
	}
	sort_order = 10
	decision_group_type = adventurer_minor

	cooldown = { years = 3 }

	is_shown = {
		has_trait = violet_poet
	}

	is_valid_showing_failures_only = {
		is_imprisoned = no
	}

	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "CHOOSE_POEM_DECISION_NEXT_STEP_BUTTON"
	

		item = { # To sell
			value = sell_poem_decision
			is_shown = {
				has_trait = violet_poet
			}
			is_valid = {
				has_trait = violet_poet
			}
			current_description = sell_poem_decision
			localization = sell_poem_decision
			icon = "gfx/interface/icons/court_position_types/bookmaker_court_position.dds"
			ai_chance = { #Keep the poet afloat
				value = 10
				if = {
					limit = {
						gold < 25
					}
					add = 50
				}
			}
		} 
		item = { #To keep
			value = keep_poem_decision
			is_shown = {
				has_trait = violet_poet
				any_artifact = {
					has_artifact_modifier = double_moon_modifier
				}
			}
			is_valid = {
				has_trait = violet_poet
				any_artifact = {
					has_artifact_modifier = double_moon_modifier
				}
			}
			current_description = keep_poem_decision
			localization = keep_poem_decision
			icon = "gfx/interface/icons/court_position_types/court_poet_court_position.dds"
			ai_chance = { value = 10 }
		}
		item = { #To distribute
			value = distribute_poem_decision
			is_shown = {
				has_trait = violet_poet
			}
			is_valid = {
				has_trait = violet_poet
			}
			current_description = distribute_poem_decision
			localization = distribute_poem_decision
			icon = "gfx/interface/icons/court_position_types/chief_qadi_court_position.dds"
			ai_chance = { value = 10 }
		}
	}

	effect = {
		add_trait_xp = {
			trait = violet_poet
			value = 5
		}
		custom_tooltip = write_muwashshah_poem_decision_tooltip
		hidden_effect = {

			if = { # Sell Poem
				limit = { scope:sell_poem_decision = yes }
				trigger_event = {
					id = ep3_story_cycle_violet_poet.0010
					days = { 15 30 }
				}
			}
			else_if = { # Keep Poem
				limit = { scope:keep_poem_decision = yes }
				trigger_event = {
					id = ep3_story_cycle_violet_poet.0011
					days = { 15 30 }
				}
			}
			else = { # Distribute Poem
				trigger_event = {
					id = ep3_story_cycle_violet_poet.0012
					days = { 15 30 }
				}
			}
		}
	}
	
	ai_potential = {
		is_playable_character = yes
		gold < 50
	}
}
