namespace = stress_trait_ongoing
# Stress Trait Ongoing Events
#  - Drunkard: 		0001-0499
#  - Hashishiyah:	0501-0999
#  - Reclusive:		1001-1499
#  - Rakish:		1501-1999
#  - Irritable:		2001-2499
#  - Flagellant:	2501-2999
#  - Improvident:	3001-3499
#  - Profligate:	3501-3999
#  - Contrite:		4001-4499
#  - Comfort Eater:	4501-4999
#  - Inappetetic:	5001-5499
#  - Journaller:	5501-5999
#  - Confider:		6001-6499
#  - Athletic:		6501-7999

##################################################
# #A Relaxing Evening
# by Ewan Cowhig Croft
# #0501
##################################################

#	You consider a relaxing evening in with some hashish.
stress_trait_ongoing.0501 = {
	type = character_event
	title = stress_trait_ongoing.0501.t
	desc = stress_trait_ongoing.0501.desc
	theme = mental_break
	left_portrait = {
		character = root
		animation = worry
	}

	trigger = {
		is_available_at_peace_adult = yes
		NOT = { has_character_flag = had_event_stress_trait_ongoing_0501 }
		has_trait = hashishiyah
		stress >= major_stress_impact_loss
	}

	weight_multiplier = {
		base = 0
		
		#Adds between 2 (at minimum triggered stress) to 10 (at maximum stress)
		compare_modifier = {
			value = stress
			multiplier = { #0.03 per Stress
				value = 10
				divide = max_stress_gain_threshold
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stress_trait_ongoing_0501
			days = 1825
		}
		if = {
			limit = { diplomacy <= 10 }
			save_scope_value_as = {
				name = skill_ineptitude
				value = flag:diplomacy
			}
		}
		else_if = {
			limit = { martial <= 10 }
			save_scope_value_as = {
				name = skill_ineptitude
				value = flag:martial
			}
		}
		else_if = {
			limit = { stewardship <= 10 }
			save_scope_value_as = {
				name = skill_ineptitude
				value = flag:stewardship
			}
		}
		else_if = {
			limit = { intrigue <= 10 }
			save_scope_value_as = {
				name = skill_ineptitude
				value = flag:intrigue
			}
		}
		else_if = {
			limit = { learning <= 10 }
			save_scope_value_as = {
				name = skill_ineptitude
				value = flag:learning
			}
		}
		else = {
			save_scope_value_as = {
				name = skill_ineptitude
				value = flag:stewardship
			}
		}
	}

	#Go back to work.
	option = {
		name = stress_trait_ongoing.0501.a
		if = {
			limit = { scope:skill_ineptitude = flag:diplomacy }
			add_character_modifier = {
				modifier = overworking_diplomacy_modifier
				days = 1095
			}
		}
		if = {
			limit = { scope:skill_ineptitude = flag:martial }
			add_character_modifier = {
				modifier = overworking_martial_modifier
				days = 1095
			}
		}
		if = {
			limit = { scope:skill_ineptitude = flag:stewardship }
			add_character_modifier = {
				modifier = overworking_stewardship_modifier
				days = 1095
			}
		}
		if = {
			limit = { scope:skill_ineptitude = flag:intrigue }
			add_character_modifier = {
				modifier = overworking_intrigue_modifier
				days = 1095
			}
		}
		if = {
			limit = { scope:skill_ineptitude = flag:learning }
			add_character_modifier = {
				modifier = overworking_learning_modifier
				days = 1095
			}
		}
		stress_impact = { lazy = major_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.5	#Places to go! People to see!
				ai_honor = 0.25	#My people need me.
			}
			modifier = {	#I'm not hungry.
				add = 10
				has_trait = inappetetic
			}
			modifier = {	#Weight down for stress.
				add = -20
				has_trait = lazy
			}
		}
	}
	
	#Take an evening off
	option = {
		name = stress_trait_ongoing.0501.b
		add_stress = major_stress_loss
		stress_impact = { diligent = major_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.5	#Honestly, I just need another break.
				ai_rationality = 0.25	#An evening off will help me work better in future.
			}
			modifier = {	#I'm doubly-inclined to this behaviour.
				add = 20
				has_trait = comfort_eater
			}
			modifier = {	#Weight down for stress.
				add = -20
				has_trait = diligent
			}
		}
	}
}

##################################################
# #Sweet Relief
# by Ewan Cowhig Croft
# #0506
##################################################

scripted_trigger stress_ongoing_suitable_medical_problems = {
	OR = {
		#You're injured.
		has_trait_rank = {
			trait = wounded
			rank >= 1
		}
		#You have a permanent long-term injury.
		has_trait = maimed
		has_trait = one_eyed
		has_trait = one_legged
		has_trait = disfigured
		#You have a permanent long-term illness.
		has_trait = leper
		has_trait = gout_ridden
		has_trait = cancer
	}
}

scripted_trigger stress_ongoing_0506_valid_courtier_for_sharing = {
	is_available_ai_adult = yes
	OR = {
		is_claimant = yes
		diplomacy >= high_skill_rating
		martial >= high_skill_rating
		stewardship >= high_skill_rating
		intrigue >= high_skill_rating
		learning >= high_skill_rating
		prowess >= high_skill_rating
		is_councillor_of = root
		has_relation_potential_friend = root
		has_relation_friend = root
	}
	NOT = { has_relation_rival = root }
}

#	You medicate your pain with hashish.
stress_trait_ongoing.0506 = {
	type = character_event
	title = stress_trait_ongoing.0506.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { has_trait = leper }
				desc = stress_trait_ongoing.0506.desc_leper
			}
			triggered_desc = {
				trigger = { has_trait = gout_ridden }
				desc = stress_trait_ongoing.0506.desc_gout_ridden
			}
			triggered_desc = {
				trigger = { has_trait = cancer }
				desc = stress_trait_ongoing.0506.desc_cancer
			}
			triggered_desc = {
				trigger = { has_trait = disfigured }
				desc = stress_trait_ongoing.0506.desc_disfigured
			}
			triggered_desc = {
				trigger = { has_trait = maimed }
				desc = stress_trait_ongoing.0506.desc_maimed
			}
			triggered_desc = {
				trigger = { has_trait = one_eyed }
				desc = stress_trait_ongoing.0506.desc_one_eyed
			}
			triggered_desc = {
				trigger = { has_trait = one_legged }
				desc = stress_trait_ongoing.0506.desc_one_legged
			}
			triggered_desc = {
				trigger = {
					has_trait_rank = {
						trait = wounded
						rank >= 1
					}
				}
				desc = stress_trait_ongoing.0506.desc_wounded
			}
			desc = stress_trait_ongoing.0506.desc_fallback
		}
		desc = stress_trait_ongoing.0506.desc
	}
	theme = mental_break
	left_portrait = {
		character = root
		animation = sadness
	}
	right_portrait = {
		character = scope:medication_friend
		animation = worry
	}

	trigger = {
		is_available_at_peace_adult = yes
		NOT = { has_character_flag = had_event_stress_trait_ongoing_0506 }
		has_trait = hashishiyah
		stress >= major_stress_impact_loss
		stress_ongoing_suitable_medical_problems = yes
		any_courtier_or_guest = { stress_ongoing_0506_valid_courtier_for_sharing = yes }
	}

	weight_multiplier = {
		base = 0
		
		#Adds between 2 (at minimum triggered stress) to 10 (at maximum stress)
		compare_modifier = {
			value = stress
			multiplier = { #0.03 per Stress
				value = 10
				divide = max_stress_gain_threshold
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stress_trait_ongoing_0506
			days = 1825
		}
		#Select a viable potential evening guest.
		every_courtier_or_guest = {
			limit = { stress_ongoing_0506_valid_courtier_for_sharing = yes }
			add_to_list = valid_courtier_for_sharing_list
		}
		random_in_list = {
			list = valid_courtier_for_sharing_list
			weight = {
				base = 1
				modifier = {	#Claimants are interesting.
					is_claimant = yes
					add = 30
				}
				modifier = {	#Councillors are good to befriend.
					is_councillor_of = root
					add = 30
				}
				modifier = {	#Confirm friendships where possible.
					has_relation_potential_friend = root
					add = 20
				}
				modifier = {	#Existing friends are a bit lower priority, but should show up.
					has_relation_friend = root
					add = 10
				}
				#Aaaaaaand always weight up skilled characters.
				modifier = {
					diplomacy >= high_skill_rating
					add = 5
				}
				modifier = {
					martial >= high_skill_rating
					add = 5
				}
				modifier = {
					stewardship >= high_skill_rating
					add = 5
				}
				modifier = {
					intrigue >= high_skill_rating
					add = 5
				}
				modifier = {
					learning >= high_skill_rating
					add = 5
				}
				modifier = {
					prowess >= high_skill_rating					
					add = 5
				}
			}
			save_scope_as = medication_friend
		}
	}

	#Have it all by yourself.
	option = {
		name = stress_trait_ongoing.0506.a
		add_character_modifier = {
			modifier = hashish_alone_modifier
			days = 1825
		}
		add_stress = major_stress_loss
		stress_impact = { gregarious = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_energy = -0.25 }
			modifier = {	#Weight down for stress
				add = -10
				has_trait = gregarious
			}
		}
	}
	
	#Invite a likely friend.
	option = {
		name = stress_trait_ongoing.0506.b
		#True friendship binds tight.
		if = {
			limit = { has_relation_friend = scope:medication_friend }
			scope:medication_friend = {
				add_opinion = {
					target = root
					modifier = friendliness_opinion
					opinion = 40
				}
			}
		}
		#Otherwise, it's just a lovely time.
		else = {
			progress_towards_friend_effect = {
				CHARACTER = scope:medication_friend
				OPINION = 20
			}
		}
		add_character_modifier = {
			modifier = hashish_with_friend_modifier
			days = 1825
		}
		add_stress = major_stress_loss
		stress_impact = { shy = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_sociability = 0.25 }
			modifier = {	#Weight down for stress.
				add = -10
				has_trait = shy
			}
		}
	}
}

##################################################
# #It Was Ever Thus
# by Ewan Cowhig Croft
# #0511
##################################################

#If you get a chance, read some medieval Islamic comments on these damned hashishiyah youths, and how they're ruining society with their reddened eyes, lack of jobs, and long, meandering conversations that go nowhere. Eight hundred years separate, and the humans involved are exactly the same.

scripted_trigger stress_ongoing_0511_valid_crusty_old_person = {
	is_available_ai_adult = yes
	age >= 50	#Gotta be a decent age gap.
	faith = { this = root.faith }	#Faith must not approve of gluttony.
	NOR = {	#Hypocrisy is amusing, but let's keep it reasonable.
		has_trait = gluttonous
		has_trait = hashishiyah
	}
	OR = {
		has_government = theocracy_government	#Everyone loves church lectures!
		is_close_or_extended_family_of = root	#Everyone loves familial lectures!
		is_councillor = yes	#Everyone loves underling lectures!
		is_powerful_vassal = yes	#Everyone loves even underlingier lectures!
	}
}

#	An older person laments the recent moral decline of the youth.
stress_trait_ongoing.0511 = {
	type = character_event
	title = stress_trait_ongoing.0511.t
	desc = stress_trait_ongoing.0511.desc
	theme = mental_break
	left_portrait = {
		character = root
		animation = disbelief
	}
	right_portrait = {
		character = scope:crusty_old_person
		animation = disgust
	}

	trigger = {
		is_available_at_peace_adult = yes
		NOT = { has_character_flag = had_event_stress_trait_ongoing_0511 }
		has_trait = hashishiyah
		stress >= major_stress_impact_loss
		age <= 30	#Must be youthful-ish.
		faith = {	#If God says it's good, then it must be great.
			NOR = {
				trait_is_virtue = gluttonous
				trait_is_virtue = hashishiyah #Not possible, but just in case...
			}
		}
		#Gotta have at least one suitably crusty old person, right?
		OR = {
			any_vassal = { stress_ongoing_0511_valid_crusty_old_person = yes }
			any_courtier_or_guest = { stress_ongoing_0511_valid_crusty_old_person = yes }
		}
	}

	weight_multiplier = {
		base = 0
		
		#Adds between 2 (at minimum triggered stress) to 10 (at maximum stress)
		compare_modifier = {
			value = stress
			multiplier = { #0.03 per Stress
				value = 10
				divide = max_stress_gain_threshold
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stress_trait_ongoing_0511
			days = 1825
		}
		capital_barony = { save_scope_as = hashishiyah_capital }	#For loc.
		every_vassal = {
			limit = { stress_ongoing_0511_valid_crusty_old_person = yes }
			add_to_list = crusty_old_person_list
		}
		every_courtier_or_guest = {
			limit = { stress_ongoing_0511_valid_crusty_old_person = yes }
			add_to_list = crusty_old_person_list
		}
		random_in_list = {
			list = crusty_old_person_list
			weight = {
				base = 1
				modifier = {	#Always more fun, and impactful, if this is your realm priest.
					is_theocratic_lessee = yes
					add = 200
				}
				#Otherwise, just grab the oldest person you can from the list.
				modifier = {
					age >= 60
					add = 10
				}
				modifier = {
					age >= 70
					add = 10
				}
				modifier = {
					age >= 80
					add = 10
				}
				modifier = {
					age >= 90
					add = 10
				}
				modifier = {
					age >= 100
					add = 10
				}
			}
			save_scope_as = crusty_old_person
		}
	}

	#Shamefully agree and stop eating cakes.
	option = {
		name = stress_trait_ongoing.0511.a
		flavor = stress_trait_ongoing.0511.a_flavour
		scope:crusty_old_person = {
			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 30
			}
		}
		add_stress = major_stress_gain
		stress_impact = {
			gluttonous = major_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_boldness = -0.25
			}
			modifier = {	#Weight down for stress.
				add = -20
				has_trait = gluttonous
			}
			modifier = {	#Weight down for stress.
				add = -10
				has_trait = arrogant
			}
		}
	}
	
	#[deep breath] Agreed, elder. (/continue eating cakes)
	option = {
		name = stress_trait_ongoing.0511.b
		flavor = stress_trait_ongoing.0511.b_flavour
		scope:crusty_old_person = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
				opinion = -30
			}
		}
		add_stress = major_stress_loss
		stress_impact = {
			temperate = major_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.5
				ai_vengefulness = 0.25
			}
			modifier = {	#Weight down for stress.
				add = -20
				has_trait = temperate
			}
			modifier = {	#Weight down for stress.
				add = -10
				has_trait = humble
			}
		}
	}
}

##################################################
# #A Wandering Mi-Oh
# by Ewan Cowhig Croft
# #0516
##################################################

scripted_trigger stress_ongoing_0516_suitable_important_figure = {
	is_available_ai_adult = yes
	NOT = { is_at_war_with = root }	#Shouldn't be necessary, but just in case.
	diplomacy >= medium_skill_rating	#Make sure the challenge isn't too easy.
}

#	You zone out while eating hashish cakes in an important meeting and forget why you're here.
stress_trait_ongoing.0516 = {
	type = character_event
	title = stress_trait_ongoing_0516.t
	desc = stress_trait_ongoing_0516.desc
	theme = mental_break
	left_portrait = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:important_guest
		animation = disapproval
	}

	trigger = {
		is_available_at_peace_adult = yes
		NOT = { has_character_flag = had_event_stress_trait_ongoing_0516 }
		has_trait = hashishiyah
		stress >= major_stress_impact_loss
		OR = {	#Must have at least one valid person to have an important meeting with.
			any_vassal = {
				is_powerful_vassal = yes
				stress_ongoing_0516_suitable_important_figure = yes
			}
			any_ally = { stress_ongoing_0516_suitable_important_figure = yes }
			any_councillor = { stress_ongoing_0516_suitable_important_figure = yes }
			any_neighboring_realm_same_rank_owner = { stress_ongoing_0516_suitable_important_figure = yes }
		}
	}

	weight_multiplier = {
		base = 0
		
		#Adds between 2 (at minimum triggered stress) to 10 (at maximum stress)
		compare_modifier = {
			value = stress
			multiplier = { #0.03 per Stress
				value = 10
				divide = max_stress_gain_threshold
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stress_trait_ongoing_0516
			days = 1825
		}
		every_vassal = {
			limit = {
				is_powerful_vassal = yes
				stress_ongoing_0516_suitable_important_figure = yes
			}
			add_to_list = suitable_important_figures_list
		}
		every_ally = {
			limit = { stress_ongoing_0516_suitable_important_figure = yes }
			add_to_list = suitable_important_figures_list
		}
		every_councillor = {
			limit = { stress_ongoing_0516_suitable_important_figure = yes }
			add_to_list = suitable_important_figures_list
		}
		every_neighboring_realm_same_rank_owner = {
			limit = { stress_ongoing_0516_suitable_important_figure = yes }
			add_to_list = suitable_important_figures_list
		}

		random_in_list = {
			list = suitable_important_figures_list
			weight = {
				base = 1
				modifier = {	#Allies are a rarer pick, so we always want to prioritise them.
					any_ally = { this = root }
					add = 100
				}
				modifier = {	#Military threats make for fun meetings.
					max_military_strength >= root.max_military_strength
					add = 40
				}
				modifier = {	#Realm priest should always be a thorn.
					is_theocratic_lessee = yes
					faith = {	#If God says it's good, then it must be great.
						NOR = {
							trait_is_virtue = gluttonous
							trait_is_virtue = hashishiyah #Not possible, but just in case...
						}
					}
					add = 30
				}
				modifier = {	#Weight up family for fun drama.
					is_close_or_extended_family_of = root
					add = 10
				}
			}
			save_scope_as = important_guest
		}
	}

	#Try to blag it through the meeting.
	option = {
		name = stress_trait_ongoing.0516.a
		duel = {
			skill = diplomacy
			target = scope:important_guest
			50 = {	#You impress your guest with your cool head and steady, measured thinking.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = stress_trait_ongoing.0516.a.tt_success
				send_interface_toast = {
					title = stress_trait_ongoing.0516.a.tt_success
					left_icon = scope:important_guest
					add_stress = major_stress_loss
					scope:important_guest = {
						add_opinion = {
							target = root
							modifier = trust_opinion
							opinion = 30
						}
					}
				}
			}
			50 = {	#You are obviously a fool, and as unable to take this seriously as you are unworth the time taken to speak to.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = stress_trait_ongoing.0516.a.tt_fail
				send_interface_toast = {	
					title = stress_trait_ongoing.0516.a.tt_fail
					left_icon = scope:important_guest
					add_stress = major_stress_gain
					scope:important_guest = {
						add_opinion = {
							target = root
							modifier = trust_opinion
							opinion = -30
						}
					}
				}
			}
		}
		stress_impact = { shy = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_honor = -0.5
			}
			modifier = {	#Weight down for stress.
				add = -10
				has_trait = shy
			}
		}
	}
	
	#Feign illness.
	option = {
		name = stress_trait_ongoing.0516.b
		flavor = stress_trait_ongoing.0516.b_flavour
		add_stress = major_stress_gain
		scope:important_guest = {
			add_opinion = {
				target = root
				modifier = pity_opinion
				opinion = 10
			}
		}
		if = {
			limit = { is_healthy = yes }	#Exemption for the excuse if you actually *are* sick.
			stress_impact = { honest = minor_stress_impact_gain }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_energy = -0.25
			}
			modifier = {	#Weight down for stress.
				add = -10
				has_trait = honest
			}
		}
	}

	#Invite them to join in.
	option = {
		name = stress_trait_ongoing.0516.c
		flavor = stress_trait_ongoing.0516.c_flavour
		trigger = {
			scope:important_guest = {
				OR = {
					has_trait = gluttonous
					has_trait = hashishiyah
				}
			}
		}
		add_stress = major_stress_loss
		scope:important_guest = {
			if = {
				limit = {
					NOT = { has_trait = hashishiyah }
				}
				add_trait = hashishiyah
			}
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 20
			}
		}
		stress_impact = { temperate = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.75
				ai_sociability = 0.25
			}
			modifier = {	#Weight down for stress.
				add = -10
				has_trait = temperate
			}
		}
	}
}

# Obsession
# 1501
# by Sean Hughes

scripted_trigger stress_trait_ongoing_1501_valid_obsession_target = {
	is_adult = yes
	save_temporary_scope_as = tmp_obsession
	root = {
		is_attracted_to_gender_of = scope:tmp_obsession
	}
	NOR = {
		is_consort_of = root
		is_close_family_of = root
		has_relation_lover = root
		has_relation_soulmate = root
		has_relation_rival = root
		has_relation_nemesis = root
	}

}

stress_trait_ongoing.1501 = {
	type = character_event
	title = stress_trait_ongoing.1501.t
	desc = {
		random_valid = {
			triggered_desc = {
				trigger = {	scope:obsession = { is_female = yes } }
				desc = stress_trait_ongoing.1501.desc_1_a
			}
			triggered_desc = {
				trigger = {	scope:obsession = { is_male = yes }	}
				desc = stress_trait_ongoing.1501.desc_1_b
			}
			triggered_desc = {
				trigger = {
					reverse_opinion = {
						target = scope:obsession
						value >= 10
					}
				}
				desc = stress_trait_ongoing.1501.desc_1_c
			}
			desc = stress_trait_ongoing.1501.desc_1_d
		}
		desc = stress_trait_ongoing.1501.bridge
		first_valid = {
			random_valid = {		
				triggered_desc = {
					trigger = {
						scope:obsession = {
							is_female = yes
							current_weight >= 10
						}
					}
					desc = stress_trait_ongoing.1501.desc_2_a
				}
				triggered_desc = {
					trigger = {	scope:obsession = {	current_weight >= 20 } }
					desc = stress_trait_ongoing.1501.desc_2_b
				}
				triggered_desc = {
					trigger = {	scope:obsession = {	is_male = yes } }
					desc = stress_trait_ongoing.1501.desc_2_c
				}
				triggered_desc = {
					trigger = {	scope:obsession = {	current_weight <= -20 } }
					desc = stress_trait_ongoing.1501.desc_2_d
				}
				triggered_desc = {
					trigger = {	scope:obsession = {	prowess >= decent_skill_rating current_weight > -20 } }
					desc = stress_trait_ongoing.1501.desc_2_e
				}
			}
			desc = stress_trait_ongoing.1501.desc_2_f
		}
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {	scope:obsession = {	current_weight <= -20 } }
					desc = stress_trait_ongoing.1501.desc_3_a
				}
				triggered_desc = {
					trigger = {	scope:obsession = {	current_weight >= 20 } }
					desc = stress_trait_ongoing.1501.desc_3_b
				}
				triggered_desc = {
					trigger = {	scope:obsession = {	prowess >= decent_skill_rating current_weight < 20 } }
					desc = stress_trait_ongoing.1501.desc_3_c
				}
				triggered_desc = {
					trigger = {	scope:obsession = {	diplomacy >= decent_skill_rating } }
					desc = stress_trait_ongoing.1501.desc_3_d
				}
				triggered_desc = {
					trigger = {	scope:obsession = {	intrigue >= decent_skill_rating } }
					desc = stress_trait_ongoing.1501.desc_3_e
				}
			}
			desc = stress_trait_ongoing.1501.desc_3_f
		}
		desc = stress_trait_ongoing.1501.end
		triggered_desc = {
			trigger = {
				NOT = { scope:obsession = { is_attracted_to_gender_of = root } }
			}
			desc = stress_trait_ongoing.1501.warning
		}
	}
	theme = mental_break
	left_portrait = scope:obsession

	trigger = {
		has_trait = rakish
		mgr_can_seduce = yes
		stress >= major_stress_impact_loss
		NOT = {
			has_character_flag = had_event_stress_trait_ongoing_1501
		}
		any_courtier_or_guest = {
			stress_trait_ongoing_1501_valid_obsession_target = yes
		}
	}

	weight_multiplier = {
		base = 0

		# Adds between 2 (at minimum triggered stress) to 10 (at maximum stress)
		compare_modifier = {
			value = stress
			multiplier = { # 0.03 per Stress)
				value = 10
				divide = max_stress_gain_threshold
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stress_trait_ongoing_1501
			years = 5
		}
		random_courtier_or_guest = {
			limit = {
				stress_trait_ongoing_1501_valid_obsession_target = yes
			}

			weight = {
				base = 25

				# Attraction Factors
				compare_modifier = {
					value = attraction
					multiplier = 5 # +5 attraction = 25, +20 attraction = +100
				}

				# Because special event text is more flavorful:
				modifier = {
					current_weight >= 25
					add = 50
				}
				modifier = {
					current_weight <= 25
					add = 50
				}
				modifier = {
					prowess >= decent_skill_rating
					add = 50
				}
				modifier = {
					diplomacy >= decent_skill_rating
					add = 25
				}
				modifier = {
					intrigue >= decent_skill_rating
					add = 25
				}

				# Mitigating Factors
				modifier = {
					opinion = {
						target = root
						value <= -25
					}
					factor = 0.25
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = root }
					factor = 0.1
				}
				modifier = {
					OR = {
						age > root.age_plus_10
						age < root.age_minus_10
					}
					factor = 0.5
				}
				modifier = {
					OR = {
						age > root.age_plus_25
						age < root.age_minus_25
					}
					factor = 0.05
				}
			}
			save_scope_as = obsession
		}
	}

	option = {
		trigger = {
			scope:obsession = { is_attracted_to_gender_of = root }
		}
		name = stress_trait_ongoing.1501.a
		flavor = stress_trait_ongoing.1501.a.flavor

		random_list = {
			50 = {
				desc = stress_trait_ongoing.1501.a.success
				show_chance = no
				simple_attraction_modifier = {
					WHO = root
					TARGET = scope:obsession
					MAX_PERSONALITY = 150 # -150 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 150 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				modifier = {
					scope:obsession = { NOT = { is_attracted_to_gender_of = root } }
					factor = 0
				}
				modifier = {
					is_ai = yes
					scope:obsession = { mgr_can_seduce = no }
					factor = 0
				}
				send_interface_toast = {
					title = stress_trait_ongoing.1501.a.success

					had_sex_with_effect = {
						CHARACTER = scope:obsession
						PREGNANCY_CHANCE = seduce_pregnancy_chance
					}
					stress_impact = {
						rakish = massive_stress_impact_loss
						lustful = medium_stress_impact_loss
						just = medium_stress_impact_gain
					}
					progress_towards_lover_effect = {
						CHARACTER = scope:obsession
						OPINION = 10
					}
				} 	
			}
			75 = {
				desc = stress_trait_ongoing.1501.a.failure
				show_chance = no
				modifier = {
					scope:obsession = {
						has_trait = chaste
					}
					add = 75
				}
				send_interface_toast = {
					title = stress_trait_ongoing.1501.a.failure

					stress_impact = {
						rakish = medium_stress_impact_gain
						lustful = minor_stress_impact_gain
						arrogant = minor_stress_impact_gain
					}
					reverse_add_opinion = {
						modifier = disgusted_opinion
						target = scope:obsession
						opinion = -30
					}
				} 	
			}
		}
	}

	option = {
		name = stress_trait_ongoing.1501.b
		flavor = stress_trait_ongoing.1501.b.flavor

		stress_impact = {
			rakish = minor_stress_impact_loss
			lustful = miniscule_stress_impact_loss
			just = miniscule_stress_impact_gain
		}

		# Chance that unactioned feelings continue to smoulder.
		if = {
			limit = {
				always = yes
			}
			hidden_effect = {
				random_list = {
					50 = { # Will only be 25% base chance by default due to attraction modifiers (see below).
						simple_attraction_modifier = {
							WHO = root
							TARGET = scope:obsession
							MAX_PERSONALITY = 150 # -150 at low trait combatibility, +150 at high trait combatibility.
							MAX_PHYSICAL = 150 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
						}
						modifier = {
							NOT = { scope:obsession = { is_attracted_to_gender_of = root } }
							factor = 0
						}
						set_relation_potential_lover = scope:obsession
					}
					75 = {
						# No Effect
					}
				}
			}
		}
	}
	
	option = {
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= medium_gold_value
			}
		}
		name = stress_trait_ongoing.1501.c
		flavor = stress_trait_ongoing.1501.c.flavor
		rakish_brothel_night_effect = yes
	}

	option = {
		name = stress_trait_ongoing.1501.d
		flavor = stress_trait_ongoing.1501.d.flavor
		stress_impact = {
			rakish = minor_stress_impact_gain
			lustful = minor_stress_impact_gain
			just = miniscule_stress_impact_loss
		}
	}
}


# Not A Bite To Eat
# 4501
# by Sean Hughes
stress_trait_ongoing.4501 = {
	type = character_event
	title = stress_trait_ongoing.4501.t
	desc = stress_trait_ongoing.4501.desc
	theme = mental_break
	left_portrait = {
		character = root
		animation = sadness
	}
	
	trigger = {
		has_trait = comfort_eater
		stress >= major_stress_impact_loss
		NOR = {
			has_trait = cannibal
			any_secret = {
				secret_type = secret_cannibal
			}
			has_character_flag = had_event_stress_trait_ongoing_4501
		}
	}

	weight_multiplier = {
		base = 0
		
		# Adds between 2 (at minimum triggered stress) to 10 (at maximum stress)
		compare_modifier = {
			value = stress
			multiplier = { # 0.03 per Stress)
				value = 10
				divide = max_stress_gain_threshold
			}
		}
	}

	immediate = {
		set_favorite_treat_effect = yes
		add_character_flag = {
			flag = had_event_stress_trait_ongoing_4501
			years = 5
		}
	}

	option = {
		name = stress_trait_ongoing.4501.a
		trigger = {
			OR = {
				is_ai = no
				short_term_gold >= minor_gold_value
			}
		}
		remove_short_term_gold = minor_gold_value
		stress_impact = {
			base = major_stress_impact_loss
		}

		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_greed = tiny_chance_impact_negative_ai_value
			}
		}
	}

	option = {
		name = stress_trait_ongoing.4501.b

		random_list = {
			30 = {
				desc = stress_trait_ongoing.4501.b.success
				show_chance = no

				send_interface_toast = {
					title = stress_trait_ongoing.4501.b.success

					stress_impact = {
						base = medium_stress_impact_loss
					}

					# Change the character's favorite treat.
					hidden_effect = {
						remove_variable = favorite_treat
						set_favorite_treat_effect = yes
					}
				} 			
			}
			30 = {
				desc = stress_trait_ongoing.4501.b.cannibal
				show_chance = no

				send_interface_toast = {
					title = stress_trait_ongoing.4501.b.cannibal

					add_secret = {
						type = secret_cannibal
					}
					stress_impact = {
						base = massive_stress_impact_loss
					}
				} 	
			}
			40 = {
				desc = stress_trait_ongoing.4501.b.failure
				show_chance = no

				send_interface_toast = {
					title = stress_trait_ongoing.4501.b.failure

					stress_impact = {
						base = minor_stress_impact_gain
					}
				}
			}
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = tiny_chance_impact_negative_ai_value
				ai_boldness = low_chance_impact_positive_ai_value
			}
		}
		
	}
	
	option = {
		name = stress_trait_ongoing.4501.c
		stress_impact = {
			base = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = tiny_chance_impact_positive_ai_value
				ai_boldness = low_chance_impact_negative_ai_value
			}
		}
	}
}

# The Hunger
# 4502
# by Sean Hughes
stress_trait_ongoing.4502 = {
	type = character_event
	title = stress_trait_ongoing.4502.t
	desc = stress_trait_ongoing.4502.desc
	theme = mental_break
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:courtier
		animation = fear
	}
	lower_right_portrait = scope:prisoner
	
	trigger = {
		OR = {
			has_trait = cannibal
			any_secret = {
				secret_type = secret_cannibal
			}
		}
		NOT = { has_character_flag = had_event_stress_trait_ongoing_4502 }
		NOT = { has_trait = inappetetic }
		NOT = { has_trait = temperate }
		any_courtier = {
			exists = this
		}
		exists = capital_county
	}

	weight_multiplier = {
		base = 0
		
		# Adds between 2 (at minimum triggered stress) to 10 (at maximum stress)
		compare_modifier = {
			value = stress
			multiplier = { # 0.03 per Stress)
				value = 10
				divide = max_stress_gain_threshold
			}
		}

		# Doubles the chance with the 'comfort_eater' trait.
		modifier = {
			factor = 2
			has_trait = comfort_eater
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stress_trait_ongoing_4502
			years = 5
		}

		ordered_courtier = {
			order_by = {
				value = 1
				
				if = {
					limit = {
						opinion = {
							target = root
							value < 0
						}
					}
					add = 10
				}
				if = {
					limit = {
						opinion = {
							target = root
							value < -20
						}
					}
					add = 20
				}
				if = {
					limit = {
						opinion = {
							target = root
							value < -50
						}
					}
					add = 30
				}
				if = {
					limit = {
						any_relation = {
							type = rival
							this = root
						}
					}
					add = 50
				}
				if = {
					limit = {
						is_close_family_of = root
					}
					add = -100
				}
			}
			save_scope_as = courtier
		}

		ordered_prisoner = {
			save_scope_as = prisoner
			
			order_by = {
				value = 5
				subtract = highest_held_title_tier
			}
		}

		capital_county = {
			ordered_in_de_jure_hierarchy = {
				limit = {
					tier = tier_barony
				}

				order_by = {
					value = 1

					if = {
						limit = {
							title_province = {
								has_building_or_higher = city_01
							}
						}
						add = 10
					}
					else_if = {
						limit = {
							title_province = {
								has_building_or_higher = temple_01
							}
						}
						add = 5
					}
				}
				save_scope_as = hapless_village
			}
		}
	}

	option = {
		name = stress_trait_ongoing.4502.a
		trigger = {
			exists = scope:prisoner
		}

		unknown_cannibal_murder_effect = {
			VICTIM = scope:prisoner
			MURDERER = root
		}

		if = {
			limit = {
				NOT = {
					has_trait = comfort_eater
				}
			}
			add_trait = comfort_eater
		}
		stress_impact = {
			base = major_stress_impact_loss
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_boldness = low_chance_impact_positive_ai_value
				ai_compassion = low_chance_impact_positive_ai_value
			}
		}
	}

	option = {
		name = stress_trait_ongoing.4502.b

		unknown_cannibal_murder_effect = {
			VICTIM = scope:courtier
			MURDERER = root
		}
		
		if = {
			limit = {
				NOT = {
					has_trait = comfort_eater
				}
			}
			add_trait = comfort_eater
		}
		stress_impact = {
			base = major_stress_impact_loss
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_boldness = low_chance_impact_negative_ai_value
				ai_compassion = low_chance_impact_negative_ai_value
			}
		}
	}
	
	option = {
		name = stress_trait_ongoing.4502.c
		scope:hapless_village = {
			county = {
				add_county_modifier = {
					modifier = county_mysterious_disappearances_modifier
					years = 5
				}
			}
		}
		stress_impact = {
			base = medium_stress_impact_loss
		}

		ai_chance = {
			base = 33
			ai_value_modifier = {
				ai_boldness = low_chance_impact_positive_ai_value
			}
		}
	}
}

scripted_trigger stress_trait_ongoing_5001_valid_giver_trigger = {
	ai_greed < 50
	ai_compassion > -50
	is_available_ai_adult = yes
}

stress_trait_ongoing.5001 = {
	type = character_event
	title = stress_trait_ongoing.5001.t
	desc = stress_trait_ongoing.5001.desc
	theme = mental_break
	override_background = {
		reference = feast
	}
	left_portrait = scope:giver

	trigger = {
		has_trait = inappetetic
		NOT = { has_character_flag = had_event_stress_trait_ongoing_5001 }
		get_characters_of_major_interest_trigger = { LISTNAME = potential_givers }
		any_in_list = {
			list = potential_givers
			stress_trait_ongoing_5001_valid_giver_trigger = yes
		}
	}

	weight_multiplier = {
		base = 0
		
		# Adds between 2 (at minimum triggered stress) to 10 (at maximum stress)
		compare_modifier = {
			value = stress
			multiplier = { # 0.03 per Stress)
				value = 10
				divide = max_stress_gain_threshold
			}
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_stress_trait_ongoing_5001
			years = 5
		}
		get_characters_of_major_interest_effect = { LISTNAME = potential_givers }
		random_in_list = {
			list = potential_givers

			limit = {
				stress_trait_ongoing_5001_valid_giver_trigger = yes
			}

			weight = {
				base = 1

				compare_modifier = {
					value = ai_greed
					multiplier = -1
				}
				compare_modifier = {
					value = ai_compassion
					multiplier = 1
				}
				compare_modifier = {
					value = intrigue
					multiplier = -2.5
				}
				modifier = {
					add = 25
					has_trait = gluttonous
				}
				modifier = {
					add = 25
					has_trait = comfort_eater
				}
			}
			save_scope_as = giver
		}

		if = {
			limit = {
				any_owned_story = { story_type = story_cycle_pet_dog }
			}
			random_owned_story = {
				limit = { story_type = story_cycle_pet_dog }
				save_scope_as = story
			}
			save_scope_value_as = {
				name = pet
				value = flag:dog
			}
		}
		else_if = {
			limit = {
				any_owned_story = {	story_type = story_cycle_pet_cat }
			}
			random_owned_story = {
				limit = { story_type = story_cycle_pet_cat }
				save_scope_as = story
			}
			save_scope_value_as = {
				name = pet
				value = flag:cat
			}
		}
		else = {
			save_scope_value_as = {
				name = pet
				value = flag:none
			}
		}
	}

	option = {
		name = stress_trait_ongoing.5001.a
		flavor = stress_trait_ongoing.5001.a.flavor
		stress_impact = {
			inappetetic = minor_stress_impact_gain
			temperate = minor_stress_impact_gain
			honest = minor_stress_impact_gain
		}
		reverse_add_opinion = {
			modifier = pleased_opinion
			target = scope:giver
			opinion = 20
		}
		target_weight_modifier_effect = {
			VALUE = 2
 		}
	}

	option = {
		name = stress_trait_ongoing.5001.b
		stress_impact = {
			inappetetic = medium_stress_impact_loss
			temperate = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		reverse_add_opinion = {
			modifier = insulted_opinion
			target = scope:giver
			opinion = -20
		}
		target_weight_modifier_effect = {
			VALUE = -2
 		}

	}
	
	option = {
		name = {
			trigger = { scope:pet = flag:dog }
			text = stress_trait_ongoing.5001.c.dog
		}
		name = {
			trigger = { scope:pet = flag:cat }
			text = stress_trait_ongoing.5001.c.cat
		}
		name = {
			trigger = { scope:pet = flag:none }
			text = stress_trait_ongoing.5001.c.no_pet
		}

		duel = {
			skill = intrigue
			target = scope:giver

			75 = {
				desc = stress_trait_ongoing.5001.c.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -74
				}

				send_interface_toast = {
					title = stress_trait_ongoing.5001.c.success
					reverse_add_opinion = {
						modifier = pleased_opinion
						target = scope:giver
						opinion = 20
					}
				}
			}
			25 = {
				desc = stress_trait_ongoing.5001.c.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -24
				}

				send_interface_toast = {
					title = stress_trait_ongoing.5001.c.failure
						reverse_add_opinion = {
						modifier = disappointed_opinion
						target = scope:giver
						opinion = -10
					}
				}
			}
		}

		stress_impact = {
			honest = minor_stress_impact_gain
		}
	}
}