﻿#Effects used in Lifestyle Focus events


#####################################################################
# EFFECT LIST
#####################################################################
# !!! Remember to add all new effects with a short description here !!!

#LIFESTYLE FRIEND EFFECTS
#	save_potential_lifestyle_friend_effect


#SECONDARY LIFESTYLE EFFECTS
#	reveler_lifestyle_rank_up_check_effect
#	hunter_lifestyle_rank_up_check_effect
# 	hunter_progress_point_gain_effect
# 	physician_lifestyle_rank_up_effect
# 	mystic_lifestyle_rank_up_effect
# 	ai_mystic_lifestyle_rank_up_effect

######################################################################


#######################
# LIFESTYLE FRIEND EFFECTS
#######################

#Needs FOCUS and SCOPE_NAME
potential_lifestyle_friend_saving_effect = {
	hidden_effect = {
		save_temporary_scope_as = friend_checker
		save_temporary_scope_value_as = {
			name = friend_saving_focus
			value = flag:$FOCUS$
		}

		#PLAYERS
		if = {
			limit = { is_ai = no }

			#Add major characters to list
			get_characters_of_major_interest_effect = { LISTNAME = lifestyle_friend_list }

			#Step 1: Add characters of minor interest
			if = {
				limit = {
					any_in_list = {
						list = lifestyle_friend_list
						potential_lifestyle_friend_availability_trigger = { CHARACTER = scope:friend_checker FOCUS = $FOCUS$ }
						count = 0
					}
				}
			
				
				get_characters_of_minor_interest_effect = { LISTNAME = lifestyle_friend_list }
			}

			#Step 2: Randomize if we now have someone suitable
			if = {
				limit = {
					any_in_list = {
						list = lifestyle_friend_list
						potential_lifestyle_friend_availability_trigger = { CHARACTER = scope:friend_checker FOCUS = $FOCUS$ }
					}
				}
				#Randomize!
				random_in_list = {
					list = lifestyle_friend_list
					limit = { potential_lifestyle_friend_availability_trigger = { CHARACTER = scope:friend_checker FOCUS = $FOCUS$ } }
					weight = {
						base = 1
						modifier = {
							add = $FOCUS$_friend_points
						}
						modifier = {
							has_relation_potential_friend = scope:friend_checker
							add = 10
						}
						opinion_modifier = {
							opinion_target = scope:friend_checker
							multiplier = 0.2
						}
					}
					if = {
						limit = { is_ruler = yes }
						set_focus = $FOCUS$
					}
					save_scope_as = $SCOPE_NAME$
				}
			}
			#Step 3: Ok, there still was none. Try to force someone to switch focus
			else = {
				random_in_list = {
					list = lifestyle_friend_list
					limit = {
						is_ruler = yes
						opinion = {
							target = scope:friend_checker
							value >= 0
						}
						this != root
						trigger_if = {
							limit = {
								scope:friend_saving_focus = flag:diplomacy_foreign_affairs_focus
								scope:friend_saving_focus = flag:diplomacy_majesty_focus
								scope:friend_saving_focus = flag:diplomacy_family_focus
							}
							diplomacy >= decent_skill_rating
						}
						trigger_else_if = {
							limit = {
								scope:friend_saving_focus = flag:martial_strategy_focus
								scope:friend_saving_focus = flag:martial_authority_focus
							}
							martial >= decent_skill_rating
						}
						trigger_else_if = {
							limit = {
								scope:friend_saving_focus = flag:martial_chivalry_focus
							}
							prowess >= decent_skill_rating
						}
						trigger_else_if = {
							limit = {
								scope:friend_saving_focus = flag:stewardship_wealth_focus
								scope:friend_saving_focus = flag:stewardship_domain_focus
								scope:friend_saving_focus = flag:stewardship_duty_focus
							}
							stewardship >= decent_skill_rating
						}
						trigger_else_if = {
							limit = {
								scope:friend_saving_focus = flag:intrigue_skulduggery_focus
								scope:friend_saving_focus = flag:intrigue_temptation_focus
								scope:friend_saving_focus = flag:intrigue_intimidation_focus
							}
							intrigue >= decent_skill_rating
						}
						trigger_else_if = {
							limit = {
								scope:friend_saving_focus = flag:learning_medicine_focus
								scope:friend_saving_focus = flag:learning_scholarship_focus
								scope:friend_saving_focus = flag:learning_theology_focus
							}
							learning >= decent_skill_rating
						}
						# making the default behavior explicit if no other trigger_(else_)ifs are valid
						trigger_else = {
							always = yes
						}
					}
					weight = {
						base = 1
						modifier = {
							has_relation_potential_friend = scope:friend_checker
							add = 10
						}
						opinion_modifier = {
							opinion_target = scope:friend_checker
							multiplier = 0.2
						}
					}
					set_focus = $FOCUS$
					save_scope_as = $SCOPE_NAME$
				}
			}
		}

		#AI
		else = {
			every_vassal = {
				limit = { potential_lifestyle_friend_availability_trigger = { CHARACTER = scope:friend_checker FOCUS = $FOCUS$ } }
				add_to_temporary_list = lifestyle_friend_list
			}
			every_liege_or_above = {
				limit = { potential_lifestyle_friend_availability_trigger = { CHARACTER = scope:friend_checker FOCUS = $FOCUS$ } }
				add_to_temporary_list = lifestyle_friend_list
			}
			every_courtier = {
				limit = { potential_lifestyle_friend_availability_trigger = { CHARACTER = scope:friend_checker FOCUS = $FOCUS$ } }
				add_to_temporary_list = lifestyle_friend_list
			}
			random_in_list = {
				list = lifestyle_friend_list
				save_scope_as = $SCOPE_NAME$
			}
		}

		#FALLBACK GENERATION
		if = {
			limit = { NOT = { exists = scope:$SCOPE_NAME$ } }

			if = {
				limit = { exists = scope:friend_checker.capital_province }
				create_character = {
					location = scope:friend_checker.capital_province
					template = $FOCUS$_friend_template
					save_scope_as = $SCOPE_NAME$
					after_creation = {
						add_character_flag = created
					}
				}
			}
			else = {
				create_character = {
					location = scope:friend_checker.location
					template = $FOCUS$_friend_template
					save_scope_as = $SCOPE_NAME$
					after_creation = {
						add_character_flag = created
					}
				}
			}
			scope:$SCOPE_NAME$ = { visit_court_of = scope:friend_checker }
		}
	}
}


########################
# SECONDARY LIFESTYLE EFFECTS
########################
#Reveler (gained by feasts)
reveler_points_gain_effect = {
	if = {
		limit = { NOT = { has_variable = reveler_lifestyle_progress } }
		set_variable = {
			name = reveler_lifestyle_progress
			value = $CHANGE$
		}
	}
	else = {
		change_variable = {
			name = reveler_lifestyle_progress
			add = $CHANGE$
		}
	}
	#Random chance of additional increase to increase unpredictability
	random = {
		chance = 50
		change_variable = {
			name = reveler_lifestyle_progress
			add = $RANDOM_CHANGE$
		}
	}
	#Extra Random chance with the Festivities Tradition
	if = {
		limit = { 
			culture = { has_cultural_parameter = reveler_traits_more_common }
		} 
		random = {
			chance = 75
			change_variable = {
				name = reveler_lifestyle_progress
				add = 1
			}
		}
	}
}

reveler_lifestyle_rank_up_check_effect = {
	if = {
		limit = {
			NOT = { has_trait = lifestyle_reveler }
		}
		random = {
			chance = 15
			modifier = {
				add = -10
				faith = { trait_is_sin = lifestyle_reveler }
			}
			modifier = {
				add = -10
				has_trait = temperate
			}
			modifier = {
				add = -10
				has_trait = inappetetic
			}
			modifier = {
				add = 10
				culture = { has_cultural_parameter = reveler_traits_more_valued }
			}
			modifier = {
				add = 5
				has_trait = gluttonous
			}
			modifier = {
				add = 5
				has_trait = drunkard
			}
			modifier = {
				add = 5
				has_trait = comfort_eater
			}
			modifier = {
				add = 15
				exists = var:reveler_lifestyle_progress
				var:reveler_lifestyle_progress >= reveler_rank_up_3_threshold
			}
			modifier = {
				add = 15
				exists = var:reveler_lifestyle_progress
				var:reveler_lifestyle_progress >= reveler_rank_up_2_threshold
			}
			modifier = {
				add = 15
				exists = var:reveler_lifestyle_progress
				var:reveler_lifestyle_progress >= reveler_rank_up_1_threshold
			}
			trigger_event = feast.0050
			show_as_tooltip = {
				add_trait = lifestyle_reveler
			}
		}
	}
	else = {
		if = {
			limit = {
				NOT = { has_trait = lifestyle_reveler }
				exists = var:reveler_lifestyle_progress
				var:reveler_lifestyle_progress >= reveler_rank_up_3_threshold
			}
			add_trait_xp = {
				trait = lifestyle_reveler
				value = 10
			}
		}
		else_if = {
			limit = {
				exists = var:reveler_lifestyle_progress
				var:reveler_lifestyle_progress >= reveler_rank_up_2_threshold
			}
			add_trait_xp = {
				trait = lifestyle_reveler
				value = 5
			}
		}
		else_if = {
			limit = {
				exists = var:reveler_lifestyle_progress
				var:reveler_lifestyle_progress >= reveler_rank_up_1_threshold
			}
			add_trait_xp = {
				trait = lifestyle_reveler
				value = 3
			}
		}
		else = {
			add_trait_xp = {
				trait = lifestyle_reveler
				value = 1
			}
		}
		set_variable = {
			name = reveler_lifestyle_progress
			value = 0
		}
	}
}

#Hunter (gained by hunting)
hunter_progress_point_gain_effect = {
	if = {
		limit = { is_alive = yes }
		if = {
			limit = {
				NOT = { exists = var:hunter_lifestyle_progress }
			}
			set_variable = {
				name = hunter_lifestyle_progress
				value = $CHANGE$
			}
		}
		else = {
			change_variable = {
				name = hunter_lifestyle_progress
				add = $CHANGE$
			}
		}
		save_scope_value_as = {
			name = hunt_base_increase
			value = $CHANGE$
		}
		# Tooltips
		if = {
			limit = { scope:hunt_base_increase <= 1 }
			custom_tooltip = hunt_progress_towards_trait_1_tt
		}
		else_if = {
			limit = { scope:hunt_base_increase = 2 }
			custom_tooltip = hunt_progress_towards_trait_2_tt
		}
		else = { custom_tooltip = hunt_progress_towards_trait_3_tt }
		#Random chance of additional point to increase unpredictability
		hidden_effect = {
			random = {
				chance = 50
				change_variable = {
					name = hunter_lifestyle_progress
					add = $RANDOM_CHANGE$
				}
			}
		}
		#Extra Random chance with the Hunters Tradition
		if = {
			limit = { 
				culture = { has_cultural_parameter = hunting_traits_more_common }
				involved_activity = {
					NOT = {
						has_activity_option = { category = special_type option = hunt_type_falconry }
					}
				}
			} 
			random = {
				chance = 75
				change_variable = {
					name = hunter_lifestyle_progress
					add = 1
				}
			}
		}
		else_if = {
			limit = { 
				culture = { has_cultural_parameter = falconer_traits_more_common }
				involved_activity = {
					has_activity_option = { category = special_type option = hunt_type_falconry }
				}
			} 
			random = {
				chance = 75
				change_variable = {
					name = hunter_lifestyle_progress
					add = 1
				}
			}
		}
	}
}

hunter_lifestyle_rank_up_check_effect = {
	save_scope_value_as = {
		name = falconry
		value = $FALCONRY$
	}
	if = {
		limit = {
			is_alive = yes
			NOT = { has_trait = lifestyle_hunter }
			exists = var:hunter_lifestyle_progress
		}
		add_trait = lifestyle_hunter
	}
	else_if = { # To show host trait gain for guests
		limit = {
			is_alive = yes
			exists = var:hunter_lifestyle_progress
			NOT = { has_character_flag = host_existing_hunter }
		}
		add_trait_force_tooltip = lifestyle_hunter
	}	
	if = {
		limit = {
			is_alive = yes 
			exists = var:hunter_lifestyle_progress
			has_trait = lifestyle_hunter
			scope:falconry = yes
		}
		send_interface_toast = {
			title = hunter_xp_gain_message
			if = {
				limit = { var:hunter_lifestyle_progress >= hunter_rank_up_3_threshold }
				add_trait_xp = {
					trait = lifestyle_hunter
					track = falconer
					value = 15
				}
			}
			else_if = {
				limit = { var:hunter_lifestyle_progress >= hunter_rank_up_2_threshold }
				add_trait_xp = {
					trait = lifestyle_hunter
					track = falconer
					value = 10
				}
			}
			else_if = {
				limit = { var:hunter_lifestyle_progress >= hunter_rank_up_1_threshold }
				add_trait_xp = {
					trait = lifestyle_hunter
					track = falconer
					value = 5
				}
			}
			else = {
				add_trait_xp = {
					trait = lifestyle_hunter
					track = falconer
					value = 3
				}
			}
		}
	}
	else_if = {
		limit = {
			is_alive = yes
			exists = var:hunter_lifestyle_progress
			has_trait = lifestyle_hunter
		}
		send_interface_toast = {
			title = hunter_xp_gain_message
			if = {
				limit = { var:hunter_lifestyle_progress >= hunter_rank_up_3_threshold }
				add_trait_xp = {
					trait = lifestyle_hunter
					track = hunter
					value = 15
				}
			}
			else_if = {
				limit = { var:hunter_lifestyle_progress >= hunter_rank_up_2_threshold }
				add_trait_xp = {
					trait = lifestyle_hunter
					track = hunter
					value = 10
				}
			}
			else_if = {
				limit = { var:hunter_lifestyle_progress >= hunter_rank_up_1_threshold }
				add_trait_xp = {
					trait = lifestyle_hunter
					track = hunter
					value = 5
				}
			}
			else = {
				add_trait_xp = {
					trait = lifestyle_hunter
					track = hunter
					value = 3
				}
			}
		}
	}
	set_variable = {
		name = hunter_lifestyle_progress
		value = 0
	}
}

#Physician (for AI, gained through treatment events)
physician_lifestyle_rank_up_effect = {
	if = {
		limit = {
			NOT = { has_trait = lifestyle_physician }
		}
		add_trait = lifestyle_physician
	}
	else_if = {
		limit = {
			has_trait_xp = {
				trait = lifestyle_physician
				value < 100
			}
		}
		add_trait_xp = {
			trait = lifestyle_physician
			value = 10
		}
	}
}


#Blademaster (for AI, gained through knight events)
blademaster_lifestyle_rank_up_effect = {
	if = {
		limit = {
			NOT = { has_trait = lifestyle_blademaster }
		}
		add_trait = lifestyle_blademaster
	}
	else_if = {
		limit = {
			has_trait_xp = {
				trait = lifestyle_blademaster
				value < 100
			}
		}
		add_trait_xp = {
			trait = lifestyle_blademaster
			value = 10
		}
	}
}

# Mystic
mystic_lifestyle_rank_up_effect = {
	if = {
		limit = {
			NOT = { has_trait = lifestyle_mystic }
		}
		add_trait = lifestyle_mystic
	}
	else = {
		add_trait_xp = {
			trait = lifestyle_mystic
			value = 10
		}
	}
}

mystic_lifestyle_point_gain_effect = {
	# Expects VALUE

	# Tooltip stuff first:
	show_as_tooltip = {
		if = {
			limit = { # No further rank ups if you're already at max
				NAND = {
					has_trait = lifestyle_mystic
					has_trait_xp = {
						trait = lifestyle_mystic
						value >= 100
					}
				}
				exists = var:mystic_lifestyle_progress # This assumes you can never progress the lifestyle on the first point gain
			}
			# Show rank-up tooltip if relevant
			if = {
				limit = {
					has_trait = lifestyle_mystic
					has_trait_xp = {
						trait = lifestyle_mystic
						value >= 100
					}
				}
				set_local_variable = {
					name = mystic_check_tooltip_value
					value = mystic_second_rank_up_threshold
				}
			}
			else = {
				set_local_variable = {
					name = mystic_check_tooltip_value
					value = mystic_first_rank_up_threshold
				}
			}
			change_local_variable = {
				name = mystic_check_tooltip_value
				subtract = $VALUE$
			}
			if = {
				limit = {
					trigger_if = { # If Mystic 2, use the higher threshold
						limit = {
							AND = {
								has_trait = lifestyle_mystic
								has_trait_xp = {
									trait = lifestyle_mystic
									value >= 50
								}
								has_trait_xp = {
									trait = lifestyle_mystic
									value < 100
								}
							}
						}
						var:mystic_lifestyle_progress >= local_var:mystic_check_tooltip_value
					}
					trigger_else = {
						var:mystic_lifestyle_progress >= mystic_first_rank_up_threshold
					}
				}
				mystic_lifestyle_rank_up_effect = yes
			}
		}
	}
	# Actually run the lifestyle experience/rank-up gain effect:
	hidden_effect = {
		if = {
			limit = { # No further rank ups if you're already at max
				NAND = {
					has_trait = lifestyle_mystic
					has_trait_xp = {
						trait = lifestyle_mystic
						value >= 100
					}
				}
			}
			if = {
				limit = {
					NOT = { exists = var:mystic_lifestyle_progress }
				}
				set_variable = {
					name = mystic_lifestyle_progress
					value = $VALUE$
				}
			}
			else = {
				change_variable = {
					name = mystic_lifestyle_progress
					add = $VALUE$
				}
			}

			# Rank up if relevant
			if = {
				limit = {
					trigger_if = { # If Mystic 2, use the higher threshold
						limit = {
							has_trait = lifestyle_mystic
							has_trait_xp = {
								trait = lifestyle_mystic
								value >= 50
							}
						}
						var:mystic_lifestyle_progress >= mystic_second_rank_up_threshold
					}
					trigger_else = {
						var:mystic_lifestyle_progress >= mystic_first_rank_up_threshold
					}
				}
				mystic_lifestyle_rank_up_effect = yes
				# Remove the variable if you reach max rank
				if = {
					limit = {
						has_trait = lifestyle_mystic
							has_trait_xp = {
								trait = lifestyle_mystic
								value >= 100
							}
					}
					remove_variable = mystic_lifestyle_progress
				}
				# Set the variable back to 0 if you've ranked up
				else = {
					set_variable = {
						name = mystic_lifestyle_progress
						value = 0
					}
				}
			}
		}
	}
}

mystical_communion_outcome_effect = {
	# Limited to 2 effect lines due to showing up in a toast
	add_learning_lifestyle_xp = major_lifestyle_xp
	add_character_modifier = {
		modifier = divine_guidance_modifier
		years = 5
	}
	if = {
		limit = {
			has_trait = lifestyle_mystic
		}
		add_trait_xp = {
			trait = lifestyle_mystic
			value = lifestyle_mystic_xp_gain_minor_value
		}
	}
}

#Mystic (for AI, gained through treatment events)
ai_mystic_lifestyle_rank_up_effect = {
	if = {
		limit = {
			NOT = { has_trait = lifestyle_mystic }
		}
		add_trait = lifestyle_mystic
	}
	else = {
		add_trait_xp = {
			trait = lifestyle_mystic
			value = 10
		}
	}
}

# Remove all perk-unlocked traits when resetting
remove_all_perk_lifestyle_traits_effect = {
	if = {
		limit = {
			has_trait = diplomat
		}
		remove_trait = diplomat
	}
	if = {
		limit = {
			has_trait = family_first
		}
		remove_trait = family_first
	}
	if = {
		limit = {
			has_trait = august
		}
		remove_trait = august
	}
	if = {
		limit = {
			has_trait = strategist
		}
		remove_trait = strategist
	}
	if = {
		limit = {
			has_trait = overseer
		}
		remove_trait = overseer
	}
	if = {
		limit = {
			has_trait = gallant
		}
		remove_trait = gallant
	}
	if = {
		limit = {
			has_trait = architect
		}
		remove_trait = architect
	}
	if = {
		limit = {
			has_trait = administrator
		}
		remove_trait = administrator
	}
	if = {
		limit = {
			has_trait = avaricious
		}
		remove_trait = avaricious
	}
	if = {
		limit = {
			has_trait = schemer
		}
		remove_trait = schemer
	}
	if = {
		limit = {
			has_trait = seducer
		}
		remove_trait = seducer
	}
	if = {
		limit = {
			has_trait = torturer
		}
		remove_trait = torturer
	}
	if = {
		limit = {
			has_trait = whole_of_body
		}
		remove_trait = whole_of_body
	}
	if = {
		limit = {
			has_trait = scholar
		}
		remove_trait = scholar
	}
	if = {
		limit = {
			has_trait = theologian
		}
		remove_trait = theologian
	}
	if = {
		limit = {
			has_trait = lifestyle_surveyor
		}
		remove_trait = lifestyle_surveyor
	}
	if = {
		limit = {
			has_trait = lifestyle_wayfarer
		}
		remove_trait = lifestyle_wayfarer
	}
	if = {
		limit = {
			has_trait = lifestyle_voyager
		}
		remove_trait = lifestyle_voyager
	}
	hidden_effect = {
		set_absolute_country_control = no
	}
}

#If you don't have a lifestyle focus, this will yield xp in a random lifestyle
##Takes the amount of _lifestyle_xp you want to hand out as an argument, from the scripted values
add_focused_lifestyle_xp_effect = {
	if = {
		limit = { has_lifestyle = diplomacy_lifestyle }
		add_diplomacy_lifestyle_xp = $AMOUNT$_lifestyle_xp
	}
	else_if = {
		limit = { has_lifestyle = martial_lifestyle }
		add_martial_lifestyle_xp = $AMOUNT$_lifestyle_xp
	}
	else_if = {
		limit = { has_lifestyle = stewardship_lifestyle }
		add_stewardship_lifestyle_xp = $AMOUNT$_lifestyle_xp
	}
	else_if = {
		limit = { has_lifestyle = intrigue_lifestyle }
		add_intrigue_lifestyle_xp = $AMOUNT$_lifestyle_xp
	}
	else_if = {
		limit = { has_lifestyle = learning_lifestyle }
		add_learning_lifestyle_xp = $AMOUNT$_lifestyle_xp
	}
	else_if = {
		limit = { has_lifestyle = wanderer_lifestyle }
		add_wanderer_lifestyle_xp = $AMOUNT$_lifestyle_xp
	}
	else = {
		random_list = {
			10 = { add_diplomacy_lifestyle_xp = $AMOUNT$_lifestyle_xp }
			10 = { add_martial_lifestyle_xp = $AMOUNT$_lifestyle_xp }
			10 = { add_stewardship_lifestyle_xp = $AMOUNT$_lifestyle_xp }
			10 = { add_intrigue_lifestyle_xp = $AMOUNT$_lifestyle_xp }
			10 = { add_learning_lifestyle_xp = $AMOUNT$_lifestyle_xp }
			# Excludes wanderer since it's picked less often
		}
	}
}

ai_chance_to_switch_to_travel_focus_effect = {
	if = {
		limit = {
			is_ai = yes
			is_adult = yes
			is_at_war = no
			is_landed = yes
			has_bp3_dlc_trigger = yes
			gold >= minor_gold_value
			highest_held_title_tier >= tier_county
			has_completed_one_tree_in_current_lifestyle_trigger = yes
			NOR = {
				has_focus = wanderer_internal_affairs_focus
				has_focus = wanderer_journey_focus
				has_focus = wanderer_destination_focus
				has_trait = reclusive
				is_incapable = yes
				has_character_modifier = isolating_modifier
			}
		}
		random = {
			chance = {
				value = 5
				if = {
					limit = {
						has_completed_current_lifestyle_trigger = yes # No good reason to stick with your lifestyle
					}
					add = 75
				}
				if = {
					limit = {
						has_trait_xp = {
							trait = lifestyle_traveler
							track = travel
							value >= 25
						}
					}
					add = 20
				}
				if = {
					limit = {
						has_trait_xp = {
							trait = lifestyle_traveler
							track = travel
							value >= 50
						}
					}
					add = 20
				}
				if = { # Busy doing.. other things
					limit = {
						has_focus = intrigue_temptation_focus
					}
					add = -20
				}
				if = { # Wants to get away
					limit = {
						has_trait = shy
					}
					add = {
						value = root.perk_points_assigned
						multiply = 3
					}
				}
				if = { # Very stressed
					limit = {
						stress >= 150
					}
					add = {
						value = root.perk_points_assigned
						multiply = 3
					}
				}
				if = { # Has an adventurous sort of personality
					limit = {
						ai_sociability >= 50
						ai_boldness >= 0
					}
					add = {
						value = root.perk_points_assigned
						multiply = 3
					}
				}
			}
			random_list = {
				1 = { # Stewards and realm-focused character
					modifier = {
						add = 99
						OR = {
							ai_has_economical_boom_personality = yes
							has_focus_stewardship = yes
							has_trait = greedy
						}
					}
					set_focus = wanderer_internal_affairs_focus
				}
				1 = { # Stressed or asocial characters
					modifier = {
						add = 99
						OR = {
							stress >= 50
							ai_sociability <= -25
						}
						NOT = {
							has_trait = impatient
						}
					}
					modifier = {
						add = 100
						stress >= 150
						NOT = {
							has_trait = impatient
						}
					}
					set_focus = wanderer_journey_focus
				}
				1 = { # Learning focused self-improvement characters
					modifier = {
						add = 99
						OR = {
							has_focus_learning = yes
							has_trait = impatient
							has_trait = ambitious
						}
					}
					set_focus = wanderer_destination_focus
				}
			}
		}
	}
}

