namespace = ep3_laamp_decision_event
################################
## Visit Local Settlement Decision
## ep3_laamp_decision_event.1000-1060
################################
# ep3_laamp_decision_event.1000 - Enter the Title of ProvinceName. What do you want to do?
# ep3_laamp_decision_event.1001 - Page 2
# ep3_laamp_decision_event.1010 - Stock up on supplies
# ep3_laamp_decision_event.1020 - Sell an artifact to local peddlers
# ep3_laamp_decision_event.1025 - Head to the Town Crier to spawn Contract(s)
#
# ep3_laamp_decision_event.1030 - Visit the local tavern
# ep3_laamp_decision_event.1031 - Storyteller
# ep3_laamp_decision_event.1033 - Recruitment
# ep3_laamp_decision_event.1035 - Spouse Material
# ep3_laamp_decision_event.1037 - Master Thief
#
# ep3_laamp_decision_event.1040 - Church Holding: Visit the local church grounds
# ep3_laamp_decision_event.1041 - Healer
# ep3_laamp_decision_event.1043 - Church
# ep3_laamp_decision_event.1045 - Garden
# ep3_laamp_decision_event.1047 - Recruit Physician
#
# ep3_laamp_decision_event.1050 - Castle Holding: Visit the local castle grounds
# ep3_laamp_decision_event.1051 - Training Grounds
# ep3_laamp_decision_event.1053 - Recruit at Garrison
# ep3_laamp_decision_event.1055 - Reinforce Men-at-Arms
# ep3_laamp_decision_event.1057 - Recruit Bodyguard
#
# ep3_laamp_decision_event.1060 - City Holding: Visit the local fine craftsmen
# ep3_laamp_decision_event.1061 - Weaponsmith
# ep3_laamp_decision_event.1063 - Armorsmith
# ep3_laamp_decision_event.1065 - Jeweler
# ep3_laamp_decision_event.1067 - Recruit Quartermaster
#

#The actual adding of the settlement
scripted_effect 1000_add_settlement_effect = {
	#A holding is a tad bit more memorable
	if = {
		limit = { 
			location = { has_holding = yes }
		}
		add_to_variable_list = {
			name = laamp_visited_settlements_list
			target = root.location
			years = 15
		}
	}
	#Otherwise just some rural settlement
	else = {
		add_to_variable_list = {
			name = laamp_visited_settlements_list
			target = root.location
			years = 10
		}
	}
}

#For loc flavor
scripted_effect 1000_remember_settlement_effect = {
	#Do we already remember this place?
	if = {
		limit = {
			has_variable = laamp_visited_settlements_list
			any_in_list = {
				variable = laamp_visited_settlements_list
				this = scope:visiting_location
			}
		}
		#Replace old entry with a new one
		remove_list_variable = {
			name = laamp_visited_settlements_list
			target = scope:visiting_location
		}
		1000_add_settlement_effect = yes
	}
	#Otherwise just add it to the list
	else = {
		1000_add_settlement_effect = yes
	}
}

#We return to the main event to peruse other options or leave
scripted_effect 1000_return_to_main_effect = {
	custom_tooltip = ep3_laamp_decision_event.return.tt
	trigger_event = ep3_laamp_decision_event.1000
}

#What was our last location?
scripted_effect 1000_update_last_location_effect = {
	if = {
		limit = { has_variable = return_from_location }
		remove_variable = return_from_location
		set_variable = {
			name = return_from_location
			value = $LOCATION_FLAG$
		}
	}
	else = {
		set_variable = {
			name = return_from_location
			value = $LOCATION_FLAG$
		}
	}
}

#Clean up variables when we leave the decision
scripted_effect 1000_clean_up_effect = {
	#Supplies
	remove_variable ?= supply_gold_cost
	remove_variable ?= 1010_guards_summoned
	#Artifacts
	scope:1020_first_artifact_to_sell ?= { 1020_remove_sell_variables_effect = yes } #If we didn't sell any artifacts
	scope:1020_second_artifact_to_sell ?= { 1020_remove_sell_variables_effect = yes }
	scope:1020_third_artifact_to_sell ?= { 1020_remove_sell_variables_effect = yes }
	remove_variable ?= 1021_artifact_sell_screen
	#Town Crier
	remove_variable ?= 1025_first_contract_desc
	remove_variable ?= 1025_second_contract_desc
	remove_variable ?= 1025_third_contract_desc
	#Healer
	scope:1041_health_artifact ?= { remove_variable ?= 1065_accessory_value }
	remove_variable ?= 1041_healer_aptitude
	remove_variable ?= 1041_partner_healer_aptitude
	#Church
	remove_variable ?= 1043_collect_gold_difficulty
	#Weaponsmith
	scope:1061_first_weapon ?= { remove_variable ?= 1061_weapon_value } #If we didn't buy any of the items
	scope:1061_second_weapon ?= { remove_variable ?= 1061_weapon_value }
	scope:1061_third_weapon ?= { remove_variable ?= 1061_weapon_value }
	#Armorer
	scope:1063_first_armor ?= { remove_variable ?= 1063_armor_value } #If we didn't buy any of the items
	scope:1063_second_armor ?= { remove_variable ?= 1063_armor_value }
	scope:1063_third_armor ?= { remove_variable ?= 1063_armor_value }
	#Jeweler
	scope:1065_first_accessory ?= { remove_variable ?= 1065_accessory_value } #If we didn't buy any of the items
	scope:1065_second_accessory ?= { remove_variable ?= 1065_accessory_value }
	scope:1065_third_accessory ?= { remove_variable ?= 1065_accessory_value }
	#Main
	clear_variable_list = list_of_options
	remove_variable ?= list_of_options
	remove_variable ?= return_from_location
	#Un-engage us from the decision
	remove_variable ?= ep3_laamp_decision_1000_is_visiting
}

#Find someone whos company you tolerate
scripted_trigger 1000_appropriate_visiting_partner_basic_trigger = {
	location = root.location
	is_available = yes
	age >= 10
	OR = {
		opinion = {
			target = root
			value >= 25
		}
		has_any_good_relationship_with_character_trigger = { CHARACTER = root }
	}
	NOR = {
		has_relation_potential_rival = root
		has_relation_victim = root
		has_relation_bully = root
		#... don't bring your second-in-command while away, duh
		has_court_position = second_camp_officer
		has_variable = 1010_payment_child
	}
}

#Are we not in a city?
scripted_trigger 1000_is_a_nomadic_holding_trigger = {
	scope:visiting_location = {
		is_nomadic_location_trigger = yes
		OR = {
			has_holding_type = tribal_holding
			has_holding_type = nomad_holding
			has_holding_type = herder_holding
		}
	}
}

#No options left - I tried to do this the easy way, but checking the existence of variable_lists wouldn't let me
scripted_trigger 1000_time_to_go_home_trigger = {
	has_variable = return_from_location
	#Did we have, and are we done with the Tribal / No Settlement option?
	exists = scope:laamp_decision_finished_tavern_option
	#Did we have, and are we done with the Church Holding option?
	trigger_if = {
		limit = { 
			scope:visiting_location = { 
				OR = {
					has_holding_type = church_holding
					has_holding_type = temple_citadel_holding
				}
			}
		}
		exists = scope:laamp_decision_finished_church_option
	}
	#Did we have, and are we done with the Castle Holding option?
	trigger_if = {
		limit = { 
			scope:visiting_location = { has_holding_type = castle_holding } 
		}
		exists = scope:laamp_decision_finished_castle_option
	}
	#Did we have, and are we done with the City Holding option?
	trigger_if = {
		limit = { 
			scope:visiting_location = { has_holding_type = city_holding } 
		}
		exists = scope:laamp_decision_finished_craftsmen_option
	}
	#Did we have, and are we done with the Sell Artifact option?
	trigger_if = {
		limit = { 
			OR = {
				is_target_in_variable_list = {
					name = list_of_options
					target = flag:has_artifact_option
				}
				exists = scope:1020_first_artifact_to_sell 
			}
		}
		exists = scope:laamp_decision_sold_artifact
	}
	#Did we have, and are we done with the Buy Supplies option?
	trigger_if = {
		limit = { 
			domicile ?= { provisions = max_provisions }
		}
		always = yes
	}
	trigger_else = { exists = scope:laamp_decision_bought_supplies }	
	#Did we have, and are we done with the Contract option?
	OR = {
		has_variable = 1025_has_contracted_recently
		exists = scope:laamp_decision_has_contracted
	}
}

#Don't sell levelling banners
scripted_trigger 1000_is_unsellable_artifact_trigger = {
	OR = {
		has_variable = banner_house
		has_variable = banner_dynasty
		has_variable = 1025_treasure_map
	}
}

#Prioritize sick or ill people if we're heading to a Church Holding
scripted_trigger 1000_has_illness_or_wound_to_treat_trigger = {
	OR = {
		has_treatable_disease_trigger = yes
		has_trait = wounded_1
		has_wounds_trigger = yes
	}
}

#It's either this or a massive, nested trigger_if in the Main Square event :eyes:
scripted_trigger 1000_done_with_second_trigger = {
	exists = scope:been_to_second
	OR = {
		#Only had Supply & Contract
		AND = {
			OR = {
				exists = scope:laamp_decision_bought_supplies
				domicile ?= { provisions = max_provisions }
			}	
			NOT = {
				is_target_in_variable_list = {
					name = list_of_options
					target = flag:has_artifact_option
				}
			}
			OR = {
				exists = scope:laamp_decision_has_contracted
				has_variable = 1025_has_contracted_recently
			}	
		}
		#Done all of them
		AND = {
			OR = {
				exists = scope:laamp_decision_bought_supplies
				domicile ?= { provisions = max_provisions }
			}	
			is_target_in_variable_list = {
				name = list_of_options
				target = flag:has_artifact_option
			}
			exists = scope:laamp_decision_sold_artifact
			exists = scope:laamp_decision_has_contracted
		}
	}
}

#Set up some reusable trait triggers
scripted_trigger 1010_has_friendly_traits = {
	OR = {
		has_trait = gregarious
		has_trait = trusting
		has_trait = compassionate
		has_trait = forgiving
		has_trait = generous
		has_trait = fickle
		has_trait = calm
	}
}

scripted_trigger 1010_has_uninterested_traits = {
	OR = {
		has_trait = callous
		has_trait = cynical
		has_trait = arrogant
		has_trait = fickle
		has_trait = arbitrary
		has_trait = patient
		has_trait = sadistic
	}
}

scripted_trigger 1010_has_commerce_traits = {
	OR = {
		has_trait = greedy
		has_trait = deceitful
		has_trait = ambitious
		has_trait = diligent
		has_trait = impatient
	}
}

scripted_trigger 1010_has_standoffish_traits = {
	OR = {
		has_trait = shy
		has_trait = craven
		has_trait = humble
		has_trait = paranoid
	}
}

scripted_trigger 1010_has_irrational_traits = {
	OR = {
		has_trait = eccentric
		has_trait = lunatic
		has_trait = possessed
	}
}

scripted_trigger 1011_has_no_applicable_traits = {
	1010_has_friendly_traits = no
	1010_has_uninterested_traits = no
	1010_has_commerce_traits = no
	1010_has_standoffish_traits = no
	1010_has_irrational_traits = no
}


######################################################################
# MAIN
# ep3_laamp_decision_event.1000
######################################################################
# > Visit Tavern
# > Holding Option (Visit Church / Visit Castle Grounds / Visit Craftsmen District)
# > Page 2
# > Leave Settlement



#Enter the Title of BaronyName (Constantinople etc). What do you want to do?
ep3_laamp_decision_event.1000 = {
	type = character_event
	title = ep3_laamp_decision_event.1000.t	
	window = visit_settlement_window
	desc = {
		#INTRO: Action / Unique Location / Holding Variations
		first_valid = {
			##RETURN: We've returned to this scene, now what
			#RETURN: We have no options left - time to go home
			triggered_desc = {
				trigger = { 1000_time_to_go_home_trigger = yes }
				desc = ep3_laamp_decision_event.1000.desc_intro_returned_home
			}
			#RETURN: Return from where?
			first_valid = {
				#RETURN: Unique locations
				#Constantinople
				triggered_desc = { 
					trigger = { 
						has_variable = return_from_location
						exists = scope:is_constantinople
					}
					desc = ep3_laamp_decision_event.1000.desc_intro_returned_constantinople_01
				}
				random_valid = {
					#RETURN: We've returned from Page 2 
					triggered_desc = {
						trigger = { var:return_from_location ?= flag:second }
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_from_second
					}
					#RETURN: We've returned from the Tavern
					triggered_desc = {
						trigger = { var:return_from_location ?= flag:tavern }
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_from_tavern
					}
					#RETURN: We've returned from the Church
					triggered_desc = {
						trigger = { var:return_from_location ?= flag:church_grounds }
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_from_church
					}
					#RETURN: We've returned from the Castle grounds
					triggered_desc = {
						trigger = { var:return_from_location ?= flag:castle_grounds }
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_from_castle
					}
					#RETURN: We've returned from the Craftsmen
					triggered_desc = {
						trigger = { var:return_from_location ?= flag:craftsmen }
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_from_craftsmen
					}
					#RETURN: Generics to mix in
					#Generics
					triggered_desc = { 
						trigger = { 
							has_variable = return_from_location
							exists = scope:neighboring_county
						}
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_generic_01
					}
					triggered_desc = { 
						trigger = { has_variable = return_from_location }
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_generic_02
					}
					triggered_desc = { 
						trigger = { has_variable = return_from_location }
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_generic_03
					}
					triggered_desc = { 
						trigger = { 
							has_variable = return_from_location
							scope:visiting_location = { has_holding = yes }
						}
						desc = ep3_laamp_decision_event.1000.desc_intro_returned_generic_04
					}
				}
			}	
			##FIRST TIME: Opening scene, paint a picture
			#FIRST TIME: Unique locations: Constantinople
			triggered_desc = { 
				trigger = { exists = scope:is_constantinople }
				desc = ep3_laamp_decision_event.1000.desc_intro_constantinople
			}
			#FIRST TIME: Holding: Intro depending on type of holding (tribal/church/castle/city)
			random_valid = {
				triggered_desc = { 
					trigger = { 
						scope:visiting_location = {
							OR = {
								has_holding_type = tribal_holding
								has_holding_type = nomad_holding
								has_holding_type = herder_holding
							}
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_intro_tribal_holding_01
				}
				triggered_desc = { 
					trigger = { 
						scope:visiting_location = {
							OR = {
								has_holding_type = tribal_holding
								has_holding_type = nomad_holding
								has_holding_type = herder_holding
							}
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_intro_tribal_holding_02
				}
			}
			triggered_desc = { 
				trigger = { 
					scope:visiting_location = { 
						OR = {
							has_holding_type = church_holding
							has_holding_type = temple_citadel_holding
						}
					}
				}
				desc = ep3_laamp_decision_event.1000.desc_intro_church_holding
			}
			triggered_desc = { 
				trigger = { 
					scope:visiting_location = { has_holding_type = castle_holding } 
				}
				desc = ep3_laamp_decision_event.1000.desc_intro_castle_holding
			}
			triggered_desc = { 
				trigger = { 
					scope:visiting_location = { has_holding_type = city_holding } 
				}
				desc = ep3_laamp_decision_event.1000.desc_intro_city_holding
			}	
		}
		#OUTRO: Returned to main square
		first_valid = {
			##RETURN HOME
			#RETURN HOME: No partner, time to go home
			triggered_desc = {
				trigger = { 
					1000_time_to_go_home_trigger = yes
					NOT = { exists = scope:visiting_partner }
				}
				desc = ep3_laamp_decision_event.1000.desc_outro_home
			}
			#RETURN HOME: Partner feels it's time to go home
			triggered_desc = {
				trigger = { 
					1000_time_to_go_home_trigger = yes
					exists = scope:visiting_partner 
				}
				desc = ep3_laamp_decision_event.1000.desc_outro_partner_home
			}
			##RETURN
			#RETURN: We've returned to this scene, what do you see
			##Weather fx
			first_valid = {
				#RETURN: Region - Scandinavia - Summer
				triggered_desc = {
					trigger = { 
						has_variable = return_from_location
						NOT = { exists = scope:is_unique_location } #Block all RETURN outros for unique locations, they are handled in unique RETURN intro
						middle_of_year_season_trigger = yes #Light out
						NOR = {
							has_variable = 1000_is_currently_raining
							has_variable = 1000_is_currently_snowing
						}
						scope:visiting_location = { geographical_region = world_europe_north }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_scandinavia_summer_returned_01
				}
				triggered_desc = {
					trigger = { 
						has_variable = return_from_location
						NOT = { exists = scope:is_unique_location }
						has_variable = 1000_is_currently_raining
						scope:visiting_location = { geographical_region = world_europe_north }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_scandinavia_summer_returned_02
				}
				#RETURN: Region - Scandinavia - Winter
				triggered_desc = {
					trigger = { 
						has_variable = return_from_location
						NOT = { exists = scope:is_unique_location }
						scope:visiting_location = { geographical_region = world_europe_north }
						has_variable = 1000_is_currently_snowing
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_scandinavia_winter_returned_01
				}
				random_valid = {
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							end_of_year_season_trigger = yes #Dark out
							scope:visiting_location = { geographical_region = world_europe_north }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_scandinavia_winter_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							end_of_year_season_trigger = yes #Dark out
							scope:visiting_location = { geographical_region = world_europe_north }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_scandinavia_winter_returned_03
					}
				}
				#RETURN: Region - Britannia
				triggered_desc = {
					trigger = { 
						has_variable = return_from_location
						NOT = { exists = scope:is_unique_location }
						NOR = {
							has_variable = 1000_is_currently_raining
							has_variable = 1000_is_currently_foggy
						}
						scope:visiting_location = { geographical_region = world_europe_west_britannia }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_britannia_returned_01
				}
				triggered_desc = {
					trigger = { 
						has_variable = return_from_location
						NOT = { exists = scope:is_unique_location }
						has_variable = 1000_is_currently_raining
						scope:visiting_location = { geographical_region = world_europe_west_britannia }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_britannia_returned_02
				}
				triggered_desc = {
					trigger = { 
						has_variable = return_from_location
						NOT = { exists = scope:is_unique_location }
						has_variable = 1000_is_currently_foggy
						scope:visiting_location = { geographical_region = world_europe_west_britannia }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_britannia_returned_03
				}
				##No Weather fx
				random_valid = {
					#RETURN: Region - Europe
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							middle_of_year_season_trigger = yes
							scope:visiting_location = { 
								geographical_region = world_europe
								NOT = { geographical_region = world_europe_north }
							}
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_europe_returned_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { 
								geographical_region = world_europe
								NOT = { geographical_region = world_europe_north }
							}
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_europe_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { 
								geographical_region = world_europe
								NOT = { geographical_region = world_europe_north }
								NEOW_religion_is_broadly_christian_trigger = yes
							}
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_europe_returned_03
					}
					#RETURN: Region - Iberia
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_europe_west_iberia }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_iberia_returned_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_europe_west_iberia }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_iberia_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_europe_west_iberia }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_iberia_returned_03
					}
					#RETURN: Region - Middle East
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_middle_east }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_middle_east_returned_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_middle_east }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_middle_east_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_middle_east }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_middle_east_returned_03
					}
					#RETURN: Region - India
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_india }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_india }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_india }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_03
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_india }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_04
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_india }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_05
					}

					#RETURN: Region - Steppe
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_steppe }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_steppe_returned_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_steppe }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_steppe_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_steppe }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_steppe_returned_03
					}
					#RETURN: Region - North Africa
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							middle_of_year_season_trigger = yes
							scope:visiting_location = { geographical_region = world_africa_north }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_north_africa_returned_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_north }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_north_africa_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_north }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_north_africa_returned_03
					}
					#RETURN: Region - West Africa
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_west }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_west_africa_returned_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_west }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_west_africa_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_west }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_west_africa_returned_03
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_west }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_west_africa_returned_04
					}
					#RETURN: Region - East Africa
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_east }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_east_africa_returned_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_east }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_east_africa_returned_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_east }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_east_africa_returned_03
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_location = { geographical_region = world_africa_east }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_regional_east_africa_returned_04
					}
					#RETURN: Region - Generic
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_02
					}
					triggered_desc = {
						trigger = {		
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							current_season_summer = yes
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_03
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_04 
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_05
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							middle_of_year_season_trigger = yes
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_06
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							middle_of_year_season_trigger = yes
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_07
					}
					#RETURN: Partner looks around
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_partner ?= {
								NOR = {
									has_trait = cynical
									has_trait = paranoid
									has_trait = callous
								}
							}
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_01
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_partner ?= { is_adult = no }
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_02
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_partner ?= { is_adult = no }
							NOR = {
								has_trait = irritable
								has_trait = wrathful
							}
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_03
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_partner ?= { 
								NOR = {
									has_trait = cynical
									has_trait = lifestyle_reveler
									any_secret = {
										type = secret_non_believer
									}
								}
							}
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_04
					}
					triggered_desc = {
						trigger = { 
							has_variable = return_from_location
							NOT = { exists = scope:is_unique_location }
							scope:visiting_partner ?= {
								OR = {
									has_relation_friend = root
									has_relation_lover = root
									is_close_family_of = root
								}
							}
						}
						desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_05
					}
				}
			}
			##FIRST TIME
			#FIRST TIME: Revisiting Constantinople
			triggered_desc = {
				trigger = {
					NOT = { has_variable = return_from_location }
					exists = scope:is_constantinople
					any_in_list = {
						variable = laamp_visited_settlements_list
						this = scope:visiting_location
					}
				}
				desc = ep3_laamp_decision_event.1000.desc_outro_revisit_constantinople
			}
			#FIRST TIME: It's Constantinople
			triggered_desc = {
				trigger = {
					NOT = { has_variable = return_from_location }
					exists = scope:is_constantinople 
				}
				desc = ep3_laamp_decision_event.1000.desc_outro_constantinople
			}
			#FIRST TIME: Our visiting partner flavor
			random_valid = {
				triggered_desc = {
					trigger = {
						NOT = { has_variable = return_from_location }
						NOT = { exists = scope:is_unique_location }
						exists = scope:visiting_partner
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_partner_01 
				}
			}
			#FIRST TIME: We've been to this settlement before
			triggered_desc = {
				trigger = {
					NOT = { has_variable = return_from_location }
					NOT = { exists = scope:is_unique_location }
					any_in_list = {
						variable = laamp_visited_settlements_list
						this = scope:visiting_location
					}
				}
				desc = ep3_laamp_decision_event.1000.desc_outro_revisit
			}
			#FIRST TIME: New place
			triggered_desc = {
				trigger = { 
					NOT = { has_variable = return_from_location } 
					NOT = { exists = scope:is_unique_location }
				}
				desc = ep3_laamp_decision_event.1000.desc_outro_new
			}	
		}
	}
	theme = landless_adventurer
	#Backgrounds & fx
		#Church Holding
		override_sound = { 
			trigger = { 
				scope:visiting_location = { 
					OR = {
						has_holding_type = church_holding
						has_holding_type = temple_citadel_holding
					}
				}
			}
			reference = "event:/SFX/Events/Themes/sfx_event_theme_type_faith"
		}
		#Castle Holding
		override_sound = { 
			trigger = { 
				scope:visiting_location = { has_holding_type = castle_holding } 
			}
			reference = "event:/SFX/Events/Themes/sfx_event_theme_type_martial"
		}
		#City Holding
		override_sound = { 
			trigger = { 
				scope:visiting_location = { has_holding_type = city_holding } 
			}
			reference = "event:/SFX/Events/Themes/sfx_event_theme_type_stewardship"
		}
		#Swedish summer
		override_effect_2d = {
			trigger = { has_variable = 1000_is_currently_raining }
	  		reference = rain	
		}
		widget = {
			is_shown = {
				has_variable = return_from_location
				NOT = { exists = scope:is_unique_location }
				scope:visiting_location = { geographical_region = world_europe_north }
				has_variable = 1000_is_currently_snowing
			}
			gui = "event_window_widget_vfx_snow"
			container = "foreground_shader_vfx_container"
		}
		#HOME: Tribe
		override_background = {
			trigger = { 
				1000_time_to_go_home_trigger = yes
				scope:visiting_location = {
					OR = {
						has_holding_type = tribal_holding
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
			}
			reference = bp1_bonfire
		}
		#HOME
		override_background = {
			trigger = { 1000_time_to_go_home_trigger = yes}
			reference = alley_night
		}
		#Snowing in tribal Scandinavia
		override_background = {
			trigger = { is_snowy_rural_scandinavia_location_trigger = yes }
			reference = ep2_hunt_snowy_forest
		}
		#Tribal Holding 
		override_background = {
			trigger = { 
				scope:visiting_location = { has_holding_type = tribal_holding }
			}
			reference = village
		}
		override_background = {
			trigger = { 
				scope:visiting_location = {
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
			}
			reference = mpo_camp_steppe
		}
		#Constantinople
		override_background = { 
			trigger = { exists = scope:is_constantinople }
			reference = ep3_constantinople
		}
		#Church Holding
		override_background = { 
			trigger = { 
				scope:visiting_location = { 
					OR = {
						has_holding_type = church_holding
						has_holding_type = temple_citadel_holding
					}
				}
			}
			reference = holy_site_generic
		}
		#Castle Holding
		override_background = { 
			trigger = { 
				scope:visiting_location = { has_holding_type = castle_holding } 
			}
			reference = courtyard_location 
		}
		#City Holding
		override_background = { 
			trigger = { 
				scope:visiting_location = { has_holding_type = city_holding } 
			}
			reference = ep3_city_gate
		}
		#Fallback
		override_background = { reference = market }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#Time to go home
		triggered_animation = {
			trigger = { 1000_time_to_go_home_trigger = yes }
			animation = boredom
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_friendly_traits = yes } 
			}
			animation = personality_forgiving
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_commerce_traits = yes } 
			}
			animation = personality_greedy
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_uninterested_traits = yes } 
			}
			animation = personality_cynical
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_irrational_traits = yes } 
			}
			animation = personality_irrational
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_standoffish_traits = yes } 
			}
			animation = personality_coward
		}
		animation = personality_compassionate
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { 1010_has_irrational_traits = yes }
			animation = personality_irrational
		}
		triggered_animation = {
			trigger = { 1010_has_standoffish_traits = yes }
			animation = personality_coward
		}
		triggered_animation = {
			trigger = { 1010_has_uninterested_traits = yes }
			animation = personality_callous
		}
		animation = personality_content
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#For loc purposes
		if = {
			limit = {
				NOT = { exists = scope:visiting_location }
			}
			location = { save_scope_as = visiting_location }
		}
		if = {
			limit = {
				NOT = { exists = scope:neighboring_county }
			}
			location = {
				random_neighboring_province = { 
					limit = { is_location_valid_for_travel_event_on_land = yes }
					save_scope_as = neighboring_county
				}
			}
		}
		random_dummy_gender_effect = yes
		#To rain or not to rain
		if = {
			limit = {
				has_variable = return_from_location
				NOT = { exists = scope:is_unique_location }
				middle_of_year_season_trigger = yes
				location_has_winter_trigger = no
				scope:visiting_location = {
					OR = { 
						geographical_region = world_europe_north
						geographical_region = world_europe_west_britannia
					}
				}
			}
			random_list = {
				50 = {
					#No rain
				}
				50 = {
					set_variable = 1000_is_currently_raining
				}
			}
		}
		#To snow or not to snow
		if = {
			limit = {
				has_variable = return_from_location
				NOT = { exists = scope:is_unique_location }
				end_of_year_season_trigger = yes
				location_has_winter_trigger = yes
				scope:visiting_location = { geographical_region = world_europe_north }
			}
			random_list = {
				50 = {
					#No rain
				}
				50 = {
					set_variable = 1000_is_currently_snowing
				}
			}
		}
		#To fog or not to fog
		if = {
			limit = {
				has_variable = return_from_location
				NOT = { exists = scope:is_unique_location }
				scope:visiting_location = { geographical_region = world_europe_west_britannia }
			}
			random_list = {
				50 = {
					#No rain
				}
				50 = {
					set_variable = 1000_is_currently_foggy
				}
			}
		}
		#This. Is. _Constantinople_
		if = {
			limit = { scope:visiting_location.barony = title:b_constantinople }
			save_scope_as = is_constantinople
			save_scope_as = is_unique_location #In case we add more unique locations
		}
		#Assemble the list of options the first time this window pops
		if = {
			limit = {
				NOT = { exists = scope:first_pass }
			}
			#Buy supply option - not really any gate since it might change during your visit

			#Sell artifact option
			if = {
				#We actually have an artifact to sell
				limit = {
					any_character_artifact = { 
						count >= 1
						1000_is_unsellable_artifact_trigger = no
					}
				}
				add_to_variable_list = {
					name = list_of_options
					target = flag:has_artifact_option
				}
			}
			#Town Crier option - not really any gate, as long as we don't cap amount of contracts I guess?

			#Visit the local tavern, added for all holding types
			add_to_variable_list = {
				name = list_of_options
				target = flag:has_tavern_option
			}
			#Church Holding: Visit the local church grounds
			if = {
				limit = {
					scope:visiting_location = { 
						OR = {
							has_holding_type = church_holding
							has_holding_type = temple_citadel_holding
						}
					}	
				}
				add_to_variable_list = {
					name = list_of_options
					target = flag:has_church_option
				}
			}
			#Castle Holding: Visit the local castle grounds
			if = {
				limit = {
					scope:visiting_location = { has_holding_type = castle_holding }	
				}
				add_to_variable_list = {
					name = list_of_options
					target = flag:has_castle_option
				}
			}
			#City Holding: Visit the local fine craftsmen
			if = {
				limit = {
					scope:visiting_location = { has_holding_type = city_holding }	
				}
				add_to_variable_list = {
					name = list_of_options
					target = flag:has_craftsman_option
				}
			}
			#Also find someone to bring with you from your crew to display in the bottom-left corner - Spouse/Friend/Marshal/Bodyguard
			if = {
				limit = {
					NOT = { exists = scope:visiting_partner }
				}
				if = {
					limit = {
						any_courtier = { 1000_appropriate_visiting_partner_basic_trigger = yes }
					}
					random_courtier = {
						limit = { 1000_appropriate_visiting_partner_basic_trigger = yes }
						weight = {
							base = 1
							#If we desparately want to bring sick relatives to the doctor
							modifier = {
								add = 1000
								is_close_family_of = root
								1000_has_illness_or_wound_to_treat_trigger = yes
								scope:visiting_location = { 
									OR = {
										has_holding_type = church_holding
										has_holding_type = temple_citadel_holding
									}
								}
							}
							modifier = {
								add = 500
								is_spouse_of = root
								1000_has_illness_or_wound_to_treat_trigger = yes
								scope:visiting_location = { 
									OR = {
										has_holding_type = church_holding
										has_holding_type = temple_citadel_holding
									}
								}
							}
							modifier = {
								add = 100
								has_relation_lover = root
								scope:visiting_location = { 
									OR = {
										has_holding_type = church_holding
										has_holding_type = temple_citadel_holding
									}
								}
							}
							modifier = {
								add = 20
								is_spouse_of = root
							}
							modifier = {
								add = 15
								is_primary_heir_of = root
							}
							modifier = {
								add = 10
								OR = {
									has_court_position = bodyguard_court_position
									has_court_position = quartermaster_camp_officer
									has_court_position = master_of_spoils_camp_officer
								}
							}
							modifier = {
								add = 5
								is_close_family_of = root
							}
							modifier = {
								add = 2
								has_trait = ambitious
							}
							modifier = {
								add = -5
								has_trait = lazy
							}
						}
						save_scope_as = visiting_partner
					}
					
				}
			}
			save_scope_as = first_pass
		}
	}
	#Church Holding Option: Visit the local church grounds
	option = {
		name = {
			text = {
				first_valid = {
					#Return to look at the church
					triggered_desc = {
						trigger = { exists = scope:been_to_church_grounds }
						desc = ep3_laamp_decision_event.1000.b_second
					}
					#First time looking at the church
					desc = ep3_laamp_decision_event.1000.b
				}
			}
		}
		trigger = {
			#Do we actually have the church option available
			custom_tooltip = {
				text = tapped_out.tt
				is_target_in_variable_list = {
					name = list_of_options
					target = flag:has_church_option
				}
				NOT = { exists = scope:laamp_decision_finished_church_option }
			}
		}
		show_as_unavailable = {
			#Hide the options when we're _all_ done
			trigger_if = {
				limit = { 
					exists = scope:laamp_decision_finished_church_option
					1000_time_to_go_home_trigger = no
				}
				always = yes
			}
			trigger_else = { always = no }
		}
		reason = church_holding
		#Actual transition event
		custom_tooltip = ep3_laamp_decision_event.1000.b.tt
		trigger_event = ep3_laamp_decision_event.1040
		ai_chance = { base = 100 }
	}
	#Castle Holding Option: Visit the local castle grounds
	option = {
		name = {
			text = {
				first_valid = {
					#Return to look at the castle
					triggered_desc = {
						trigger = { exists = scope:been_to_castle_grounds }
						desc = ep3_laamp_decision_event.1000.c_second
					}
					#First time looking at the castle 
					desc = ep3_laamp_decision_event.1000.c
				}
			}
		}
		trigger = {
			#Do we actually have the castle option available
			custom_tooltip = {
				text = tapped_out.tt
				is_target_in_variable_list = {
					name = list_of_options
					target = flag:has_castle_option
				}
				NOT = { exists = scope:laamp_decision_finished_castle_option }
			}
		}
		show_as_unavailable = {
			#Hide the options when we're _all_ done
			trigger_if = {
				limit = { 
					exists = scope:laamp_decision_finished_castle_option
					1000_time_to_go_home_trigger = no
				}
				always = yes
			}
			trigger_else = { always = no }
		}
		reason = castle_holding
		#Actual transition event
		custom_tooltip = ep3_laamp_decision_event.1000.c.tt
		trigger_event = ep3_laamp_decision_event.1050
		ai_chance = { base = 100 }
	}
	#City Holding Option: Visit the local fine craftsmen
	option = {
		name = {
			text = {
				first_valid = {
					#Return to look at the craftsmen
					triggered_desc = {
						trigger = { exists = scope:been_to_craftsmen }
						desc = ep3_laamp_decision_event.1000.d_second
					}
					#First time looking at craftsmen 
					desc = ep3_laamp_decision_event.1000.d
				}
			}
		}
		#Do we have few enough options to display this option on the main page
		trigger = {
			#Do we actually have the craftsmenned option available
			custom_tooltip = {
				text = tapped_out.tt
				is_target_in_variable_list = {
					name = list_of_options
					target = flag:has_craftsman_option
				}
				NOT = { exists = scope:laamp_decision_finished_craftsmen_option }
			}
		}
		show_as_unavailable = {
			#Hide the options when we're _all_ done
			trigger_if = {
				limit = { 
					exists = scope:laamp_decision_finished_craftsmen_option
					1000_time_to_go_home_trigger = no
				}
				always = yes
			}
			trigger_else = { always = no }
		}
		reason = city_holding
		#We got kick-off!
		1000_update_last_location_effect = { LOCATION_FLAG = flag:main_square }
		#Actual transition event
		custom_tooltip = ep3_laamp_decision_event.1000.d.tt
		trigger_event = ep3_laamp_decision_event.1060
		ai_chance = { base = 100 }
	}
	#Tribal Holding Option: Visit the local tavern
	option = {
		name = {
			text = {
				first_valid = {
					#Return to the tavern
					triggered_desc = {
						trigger = { exists = scope:been_to_tavern }
						desc = ep3_laamp_decision_event.1000.a_second
					}
					#They're nomads
					triggered_desc = {
						trigger = { 1000_is_a_nomadic_holding_trigger = yes }
						desc = ep3_laamp_decision_event.1000.a_nomads
					}
					#First time visiting the tavern
					desc = ep3_laamp_decision_event.1000.a_tavern
				}
			}
		}
		trigger = {
			#Do we actually have the tavern option available
			custom_tooltip = {
				text = tapped_out.tt
				is_target_in_variable_list = {
					name = list_of_options
					target = flag:has_tavern_option
				}
				NOT = { exists = scope:laamp_decision_finished_tavern_option }
			}
		}
		show_as_unavailable = {
			#Hide the options when we're _all_ done
			trigger_if = {
				limit = { 
					exists = scope:laamp_decision_finished_tavern_option
					1000_time_to_go_home_trigger = no
				}
				always = yes
			}
			trigger_else = { always = no }
		}
		reason = visit_tavern
		#Actual transition event
		if = {
			limit = { 1000_is_a_nomadic_holding_trigger = yes }
			custom_tooltip = ep3_laamp_decision_event.1000.a_nomads.tt
		}
		else = { custom_tooltip = ep3_laamp_decision_event.1000.a.tt }
		trigger_event = ep3_laamp_decision_event.1030
		ai_chance = { base = 100 }
	}
	#Page 2: Consider additional options
	option = {
		name = ep3_laamp_decision_event.1000.h
		trigger = {
			#If we were initially maxed out on provisions but lost provisions while visiting other parts...
			trigger_if = {
				limit = { 
					NOT = { exists = scope:been_to_second }
				}
				always = yes	
			}
			trigger_else_if = {
				limit = { exists = scope:been_to_second }
				custom_tooltip = {
					text = tapped_out.tt
					1000_done_with_second_trigger = no
				}	
			}
			#Otherwise we're just done here
			trigger_else = {
				custom_tooltip = {
					text = tapped_out.tt
					NOT = { exists = scope:laamp_decision_second_finished }
				}
			}
			#Nothing here for the AI
			is_ai = no
		}
		show_as_unavailable = {
			#Hide the options when we're _all_ done
			trigger_if = {
				limit = {
					OR = {
						AND = {
							exists = scope:laamp_decision_second_finished
							1000_time_to_go_home_trigger = no
						}
						AND = {
							exists = scope:been_to_second
							1000_time_to_go_home_trigger = no
						}	
					}
					
				}
				always = yes
			}
			trigger_else = { always = no }
		}
		#We got kick-off!
		1000_update_last_location_effect = { LOCATION_FLAG = flag:main_square }	
		#Actual transition event
		custom_tooltip = ep3_laamp_decision_event.1000.h.tt
		trigger_event = ep3_laamp_decision_event.1001
	}
	#Let's go back to the camp
	option = {
		name = {
			text = {
				first_valid = {
					#No options left, partner flavor
					triggered_desc = {
						trigger = { 
							1000_time_to_go_home_trigger = yes
							exists = scope:visiting_partner
						}
						desc = ep3_laamp_decision_event.1000.i_home_partner
					}
					#No options left
					triggered_desc = {
						trigger = { 1000_time_to_go_home_trigger = yes }
						desc = ep3_laamp_decision_event.1000.i_home
					}
					#Let's get outta here
					desc = ep3_laamp_decision_event.1000.i
				}
			}
		}
		custom_tooltip = ep3_laamp_decision_event.1000.i.tt
		#For loc reasons
		1000_remember_settlement_effect = yes
		1000_clean_up_effect = yes
		ai_chance = { base = 50 }
	}
	after = {
		remove_variable ?= 1000_is_currently_raining
		remove_variable ?= 1000_is_currently_snowing
		remove_variable ?= 1000_is_currently_foggy
		#For all options that are NOT Page 2
		if = {
			limit = {
				has_variable = return_from_location
				NOT = { var:return_from_location = flag:main_square }
			}
			#We got kick-off!
			1000_update_last_location_effect = { LOCATION_FLAG = flag:main_square }	
		}
	}
}


######################################################################
# PAGE 2
# ep3_laamp_decision_event.1001
######################################################################
# > Buy Supplies
# > Sell Artifact
# > Town Crier
# > Back to Main Square

#Return to Page 2
scripted_effect 1001_return_to_second_effect = {
	custom_tooltip = ep3_laamp_decision_event.return.tt
	trigger_event = ep3_laamp_decision_event.1001
}

scripted_effect 1001_been_to_second_effect = {
	if = {
		limit = {
			NOT = { exists = scope:been_to_second }
		}
		save_scope_as = been_to_second
	}
}


#Page 2 - Consider additional options
ep3_laamp_decision_event.1001 = {
	type = character_event
	title = ep3_laamp_decision_event.1000.t	
	window = visit_settlement_window
	desc = {
		#INTRO
		first_valid = {
			##RETURN: We've returned to this scene, now what
			#RETURN: We have no options left - time to go home
			triggered_desc = {
				trigger = { 1000_done_with_second_trigger = yes }
				desc = ep3_laamp_decision_event.1001.desc_intro_return_finished
			}
			#RETURN: You just returned from assaulting the supply merchant
			triggered_desc = {
				trigger = {
					var:return_from_location ?= flag:supply_merchant
					has_variable = 1010_guards_summoned
				}
				desc = ep3_laamp_decision_event.1001.desc_intro_returned_from_assaulting_supplies
			}
			#RETURN: Return from where?
			random_valid = {	
				#RETURN: We've returned from Supply Merchant
				triggered_desc = {
					trigger = { var:return_from_location ?= flag:supply_merchant }
					desc = ep3_laamp_decision_event.1001.desc_intro_returned_from_supplies
				}
				#RETURN: We've returned from Artifact Peddler
				triggered_desc = {
					trigger = { var:return_from_location ?= flag:artifact_peddler }
					desc = ep3_laamp_decision_event.1001.desc_intro_returned_from_artifacts
				}
				#RETURN: We've returned from Town Crier
				triggered_desc = {
					trigger = { var:return_from_location ?= flag:contract }
					desc = ep3_laamp_decision_event.1001.desc_intro_returned_from_contract
				}
				#RETURN: Generics to mix in
				random_valid = {
					#Generics
					triggered_desc = { 
						trigger = { exists = scope:been_to_second }
						desc = ep3_laamp_decision_event.1001.desc_intro_returned_generic_01
					}
					triggered_desc = { 
						trigger = { exists = scope:been_to_second }
						desc = ep3_laamp_decision_event.1001.desc_intro_returned_generic_02
					}
				}
			}
			#FIRST TIME
			triggered_desc = {
				trigger = {
					scope:visiting_location = {
						OR = {
							has_holding_type = tribal_holding
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
					NOT = { exists = scope:been_to_second }
				}
				desc = ep3_laamp_decision_event.1001.desc_intro_nomads
			}
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_second }
				}
				desc = ep3_laamp_decision_event.1001.desc_intro
			}
		}
		#OUTRO
		first_valid = {
			##RETURN HOME
			#RETURN HOME: No partner, time to go home
			triggered_desc = {
				trigger = { 
					1000_done_with_second_trigger = yes
					NOT = { exists = scope:visiting_partner }
				}
				desc = ep3_laamp_decision_event.1001.desc_outro_return_finished
			}
			#RETURN HOME: Partner feels it's time to go home
			triggered_desc = {
				trigger = { 
					1000_done_with_second_trigger = yes
					exists = scope:visiting_partner 
				}
				desc = ep3_laamp_decision_event.1001.desc_outro_return_partner_finished
			}
			#RETURN: Virtually re-using the ones from Main Square
			random_valid = {
				#RETURN: Region - Europe
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						middle_of_year_season_trigger = yes
						scope:visiting_location = { 
							geographical_region = world_europe
							NOT = { geographical_region = world_europe_north }
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_europe_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { 
							geographical_region = world_europe
							NOT = { geographical_region = world_europe_north }
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_europe_returned_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { 
							geographical_region = world_europe
							NOT = { geographical_region = world_europe_north }
							NEOW_religion_is_broadly_christian_trigger = yes
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_europe_returned_03
				}
				#RETURN: Region - Iberia
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_europe_west_iberia }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_iberia_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_europe_west_iberia }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_iberia_returned_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_europe_west_iberia }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_iberia_returned_03
				}
				#RETURN: Region - Middle East
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_middle_east }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_middle_east_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_middle_east }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_middle_east_returned_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_middle_east }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_middle_east_returned_03
				}
				#RETURN: Region - India
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_india }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_india }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_india }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_03
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_india }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_04
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_india }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_india_returned_05
				}

				#RETURN: Region - Steppe
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_steppe }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_steppe_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_steppe }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_steppe_returned_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_steppe }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_steppe_returned_03
				}
				#RETURN: Region - North Africa
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						middle_of_year_season_trigger = yes
						scope:visiting_location = { geographical_region = world_africa_north }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_north_africa_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_north }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_north_africa_returned_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_north }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_north_africa_returned_03
				}
				#RETURN: Region - West Africa
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_west }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_west_africa_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_west }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_west_africa_returned_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_west }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_west_africa_returned_03
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_west }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_west_africa_returned_04
				}
				#RETURN: Region - East Africa
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_east }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_east_africa_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_east }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_east_africa_returned_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_east }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_east_africa_returned_03
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_location = { geographical_region = world_africa_east }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_regional_east_africa_returned_04
				}
				#RETURN: Region - Generic
				triggered_desc = {
					trigger = { exists = scope:been_to_second }
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_01
				}
				triggered_desc = {
					trigger = { exists = scope:been_to_second }
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_02
				}
				triggered_desc = {
					trigger = {		
						exists = scope:been_to_second
						middle_of_year_season_trigger = yes
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_03
				}
				triggered_desc = {
					trigger = { exists = scope:been_to_second }
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_04 
				}
				triggered_desc = {
					trigger = { exists = scope:been_to_second }
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_05
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						middle_of_year_season_trigger = yes
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_06
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						middle_of_year_season_trigger = yes
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_generic_07
				}
				#RETURN: Partner looks around
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_partner ?= {
							NOR = {
								has_trait = cynical
								has_trait = paranoid
								has_trait = callous
							}
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_partner ?= { is_adult = no }
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_02
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_partner ?= { is_adult = no }
						NOR = {
							has_trait = irritable
							has_trait = wrathful
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_03
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_partner ?= { 
							NOR = {
								has_trait = cynical
								has_trait = lifestyle_reveler
								any_secret = {
									type = secret_non_believer
								}
							}
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_04
				}
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_second
						scope:visiting_partner ?= {
							OR = {
								has_relation_friend = root
								has_relation_lover = root
								is_close_family_of = root
							}
						}
					}
					desc = ep3_laamp_decision_event.1000.desc_outro_returned_partner_generic_05
				}
			}

		}
	}
	theme = landless_adventurer
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	#Indenting backgrounds for easier folding
		#HOME: Tribe
		override_background = {
			trigger = { 
				1000_time_to_go_home_trigger = yes
				scope:visiting_location = {
					OR = {
						has_holding_type = tribal_holding
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
			}
			reference = bp1_bonfire
		}
		#HOME
		override_background = {
			trigger = { 1000_time_to_go_home_trigger = yes}
			reference = alley_night
		}
		#Snowing in tribal Scandinavia
		override_background = {
			trigger = { is_snowy_rural_scandinavia_location_trigger = yes }
			reference = ep2_hunt_snowy_forest
		}
		#Tribe Holding
		override_background = {
			trigger = { 
				scope:visiting_location = { has_holding_type = tribal_holding }
			}
			reference = village
		}
		override_background = {
			trigger = { 
				scope:visiting_location = {
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
			}
			reference = mpo_camp_steppe
		}
		#Constantinople
		override_background = { 
			trigger = { exists = scope:is_constantinople }
			reference = ep3_constantinople
		}
		#Church Holding
		override_background = { 
			trigger = { 
				scope:visiting_location = { 
					OR = {
						has_holding_type = church_holding
						has_holding_type = temple_citadel_holding
					}
				}
			}
			reference = holy_site_generic
		}
		#Castle Holding
		override_background = { 
			trigger = { 
				scope:visiting_location = { has_holding_type = castle_holding } 
			}
			reference = courtyard_location 
		}
		#City Holding
		override_background = { 
			trigger = { 
				scope:visiting_location = { has_holding_type = city_holding } 
			}
			reference = ep3_city_gate
		}
		#Fallback
		override_background = { reference = market }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#Time to go home
		triggered_animation = {
			trigger = { 1000_time_to_go_home_trigger = yes }
			animation = boredom
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_friendly_traits = yes } 
			}
			animation = personality_content
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_commerce_traits = yes } 
			}
			animation = thinking
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_uninterested_traits = yes } 
			}
			animation = personality_callous
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_irrational_traits = yes } 
			}
			animation = eccentric
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_standoffish_traits = yes } 
			}
			animation = shame
		}
		animation = personality_bold
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { 1010_has_irrational_traits = yes }
			animation = personality_irrational
		}
		triggered_animation = {
			trigger = { 1010_has_standoffish_traits = yes }
			animation = personality_coward
		}
		triggered_animation = {
			trigger = { 1010_has_uninterested_traits = yes }
			animation = personality_cynical
		}
		animation = personality_rational
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#It just works. (To get the appropriate loc when you snub the artifact vendor at the last minute, then refresh when we exit & re-enter)
		remove_variable ?= 1021_artifact_sell_screen	
	}
	#Option: Stock up on supplies
	option = {
		name = {
			text = {
				first_valid = {
					#Return to look at supplies
					triggered_desc = {
						trigger = { exists = scope:did_not_buy_supplies }
						desc = ep3_laamp_decision_event.1001.a_second
					}
					#First time looking at supplies 
					desc = ep3_laamp_decision_event.1001.a
				}
			}
		}
		trigger = {
			#You recently botched threatening this merchant
			trigger_if = {
				limit = { has_variable = 1010_guards_summoned }
				custom_tooltip = {
					text = guards_were_summoned.tt
					NOT = { has_variable = 1010_guards_summoned }
				}
			}
			#Already got a hand-out from this merchant
			trigger_else_if = {
				limit = { scope:laamp_decision_bought_supplies ?= flag:handout }
				custom_tooltip = {
					text = already_received_supplies.tt
					NOT = { scope:laamp_decision_bought_supplies ?= flag:handout }
				}
			}
			#Already bought provisions this visit
			trigger_else_if = {
				limit = { exists = scope:laamp_decision_bought_supplies }
				custom_tooltip = {
					text = already_bought_supplies.tt
					NOT = { exists = scope:laamp_decision_bought_supplies }
				}
			}
			#Already at max provisions
			trigger_else = {
				custom_tooltip = {
					text = full_on_supplies.tt
					NOT = { 
						domicile ?= { provisions = max_provisions }
					}
				}
			}
		}
		#Since this is semi-dynamic, show it always
		show_as_unavailable = { always = yes }
		reason = buy_provisions
		#For loc
		1001_been_to_second_effect = yes
		#Actual transition event
		custom_tooltip = ep3_laamp_decision_event.1001.a.tt	
		trigger_event = ep3_laamp_decision_event.1010
	}
	#Option: Sell an artifact to local peddlers
	option = {
		name = {
			text = {
				first_valid = {
					#Return to sell artifacts
					triggered_desc = {
						trigger = { exists = scope:did_not_sell_artifact }
						desc = ep3_laamp_decision_event.1001.b_second
					}
					#First time selling artifacts
					desc = ep3_laamp_decision_event.1001.b
				}
			}
		}
		trigger = {
			#Do we actually have the artifact option available
			trigger_if = {
				limit = {
					is_target_in_variable_list = {
						name = list_of_options
						target = flag:has_artifact_option
					}
				}
				always = yes
			}
			trigger_else_if = {
				limit = { exists = scope:laamp_decision_sold_artifact }
				custom_tooltip = {
					text = already_sold_artifact.tt
					#We haven't already sold an artifact
					NOT = { exists = scope:laamp_decision_sold_artifact }
				}
			}
			trigger_else = { always = no }
		}
		show_as_unavailable = {
			#Only show it if it was available from the start
			trigger_if = {
				limit = { exists = scope:laamp_decision_sold_artifact }
				always = yes 
			}
			trigger_else = { always = no }
		}
		reason = sell_artifacts
		#For loc
		1001_been_to_second_effect = yes
		#Actual transition event
		custom_tooltip = ep3_laamp_decision_event.1001.b.tt
		#Back to smirk-town with you
		if = {
			limit = { exists = scope:attempted_artifact_haggle }
			trigger_event = ep3_laamp_decision_event.1021
		}
		#Otherwise regular peddler
		else = { trigger_event = ep3_laamp_decision_event.1020 }
	}
	#Option: Head to the Town Crier for contracts
	option = {
		name = {
			text = {
				first_valid = {
					#Return to look at contracts
					triggered_desc = {
						trigger = { exists = scope:been_to_contract }
						desc = ep3_laamp_decision_event.1001.c_second
					}
					#First time looking at contracts
					desc = ep3_laamp_decision_event.1001.c
				}
			}
		}
		trigger = {
			#You are still on cooldown (you can go in to the board once to realize the board is empty, then the option greys out)
			trigger_if = {
				limit = { scope:laamp_decision_has_contracted ?= flag:no }
				custom_tooltip = {
					text = no_contracts.tt
					always = no
				}
			}
			#You have spawned contracts during this visit
			trigger_else_if = {
				limit = { 
					OR = {
						has_variable = 1025_has_contracted_recently
						scope:laamp_decision_has_contracted ?= flag:yes
					}
				}
				custom_tooltip = {
					text = already_spawned_contracts.tt
					always = no
				}
			}
			#Otherwise, have a look (except for the AI, who take contracts through a different system)
			trigger_else = { is_ai = no }
		}
		#Notice board can be empty, so no real cooldown?
		show_as_unavailable = { always = yes }
		reason = spawn_contracts
		#For loc
		1001_been_to_second_effect = yes
		#Actual transition event
		custom_tooltip = ep3_laamp_decision_event.1001.c.tt
		trigger_event = ep3_laamp_decision_event.1025
	}
	#Go back to Main Square
	option = {
		name = ep3_laamp_decision_event.1001.d
		#Time to close off the option?
		if = {
			limit = { 1000_done_with_second_trigger = yes }
			save_scope_as = laamp_decision_second_finished
		}
		else_if = {
			limit = {
				NOT = { exists = scope:been_to_second }
			}
			save_scope_as = been_to_second
		}
		#We got kick-off!
		1000_update_last_location_effect = { LOCATION_FLAG = flag:second }
		#Go back to the main event
		1000_return_to_main_effect = yes
	}
}


######################################################################
# BUY SUPPLIES
# ep3_laamp_decision_event.1010
######################################################################

#Remember merchant for loc
scripted_effect 1010_remember_vendor_character_effect = {
	#Do we already remember them?
	if = {
		limit = {
			has_variable = laamp_remembered_$GUILD$s_list #Notice the 's' right after GUILD (= 'merchants' instead of 'merchant')
			any_in_list = {
				variable = laamp_remembered_$GUILD$s_list
				this = $CHARACTER$
			}
		}
		#Replace old entry with a new one
		remove_list_variable = {
			name = laamp_remembered_$GUILD$s_list
			target = $CHARACTER$
		}
		add_to_variable_list = {
			name = laamp_remembered_$GUILD$s_list
			target = $CHARACTER$
			years = 10
		}
	}
	#Otherwise just add 'em to the list
	else = {
		add_to_variable_list = {
			name = laamp_remembered_$GUILD$s_list
			target = $CHARACTER$
			years = 10
		}
	}
}

#Set the correct variable to adjust loc for the Buy Supply option
scripted_effect 1010_bought_supplies_effect = {
	save_scope_value_as = {
		name = laamp_decision_bought_supplies
		value = flag:none
	}
	#Go back to the main event
	hidden_effect = { 1001_return_to_second_effect = yes }
}

#No prisoners. No rivals. No service.
scripted_trigger 1010_basic_merchant_checks_trigger = {
	NOT = { 
		has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
	}
	is_available_adult = yes
	#No double-dipping
	trigger_if = {
		limit = { exists = scope:laamp_supply_merchant }
		this != scope:laamp_supply_merchant
	}
	trigger_if = {
		limit = { exists = scope:laamp_artifact_peddler }
		this != scope:laamp_artifact_peddler
	}
	trigger_if = {
		limit = { exists = scope:laamp_town_crier }
		this != scope:laamp_town_crier
	}

	#Tavern
	trigger_if = {
		limit = { exists = scope:laamp_storyteller }
		this != scope:laamp_storyteller
	}
	trigger_if = {
		limit = { exists = scope:laamp_first_recruit }
		this != scope:laamp_first_recruit
	}
	trigger_if = {
		limit = { exists = scope:laamp_second_recruit }
		this != scope:laamp_second_recruit
	}
	trigger_if = {
		limit = { exists = scope:laamp_third_recruit }
		this != scope:laamp_third_recruit
	}
	trigger_if = {
		limit = { exists = scope:laamp_generic_jane }
		this != scope:laamp_generic_jane
	}
	trigger_if = {
		limit = { exists = scope:laamp_spouse_material }
		this != scope:laamp_spouse_material
	}
	trigger_if = {
		limit = { exists = scope:laamp_hooded_figure }
		this != scope:laamp_hooded_figure
	}

	#Church
	trigger_if = {
		limit = { exists = scope:laamp_healer_character }
		this != scope:laamp_healer_character
	}
	trigger_if = {
		limit = { exists = scope:laamp_clergy_character }
		this != scope:laamp_clergy_character
	}
	trigger_if = {
		limit = { exists = scope:laamp_physician_recruit }
		this != scope:laamp_physician_recruit
	}

	#Castle
	trigger_if = {
		limit = { exists = scope:laamp_plain_guard }
		this != scope:laamp_plain_guard
	}
	trigger_if = {
		limit = { exists = scope:laamp_talented_guard }
		this != scope:laamp_talented_guard
	}
	trigger_if = {
		limit = { exists = scope:laamp_disgruntled_moa }
		this != scope:laamp_disgruntled_moa
	}
	trigger_if = {
		limit = { exists = scope:laamp_maa_reinforcer }
		this != scope:laamp_maa_reinforcer
	}
	trigger_if = {
		limit = { exists = scope:laamp_bodyguard_recruit }
		this != scope:laamp_bodyguard_recruit
	}

	#City
	trigger_if = {
		limit = { exists = scope:laamp_weaponsmith_craftsman }
		this != scope:laamp_weaponsmith_craftsman
	}
	trigger_if = {
		limit = { exists = scope:laamp_armorer_craftsman}
		this != scope:laamp_armorer_craftsman
	}
	trigger_if = {
		limit = { exists = scope:laamp_jeweler_craftsman }
		this != scope:laamp_jeweler_craftsman
	}
	trigger_if = {
		limit = { exists = scope:laamp_quartermaster_recruit }
		this != scope:laamp_quartermaster_recruit
	}
}

#Scripty-scripted repeat triggers to check if we already saved this character
scripted_trigger 1010_is_a_saved_merchant_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_merchants_list
			target = scope:saved_character_check
		}
	}
}

scripted_trigger 1010_is_a_saved_peddler_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_peddlers_list
			target = scope:saved_character_check
		}
	}
}

scripted_trigger 1010_is_a_saved_crier_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_criers_list
			target = scope:saved_character_check
		}
	}
}

#Tavern
scripted_trigger 1010_is_a_saved_storyteller_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_storytellers_list
			target = scope:saved_character_check
		}
	}
}

scripted_trigger 1010_is_a_saved_thief_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_thiefs_list #Don't judge me, 'thiefs' is most consequential
			target = scope:saved_character_check
		}
	}
}

#Church
scripted_trigger 1010_is_a_saved_healer_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_healers_list
			target = scope:saved_character_check
		}
	}
}

scripted_trigger 1010_is_a_saved_clergy_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_clergys_list
			target = scope:saved_character_check
		}
	}
}

scripted_trigger 1010_is_a_saved_physician_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_physicians_list
			target = scope:saved_character_check
		}
	}
}

#Castle
scripted_trigger 1010_is_a_saved_bodyguard_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_bodyguards_list
			target = scope:saved_character_check
		}
	}
}

#Craftsmen
scripted_trigger 1010_is_a_saved_weaponsmith_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_weaponsmiths_list
			target = scope:saved_character_check
		}
	}
}

scripted_trigger 1010_is_a_saved_armorer_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_armorers_list
			target = scope:saved_character_check
		}
	}
}

scripted_trigger 1010_is_a_saved_jeweler_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_jewelers_list
			target = scope:saved_character_check
		}
	}
}

scripted_trigger 1010_is_a_saved_quartermaster_trigger = {
	root = {
		is_target_in_variable_list = {
			name = laamp_remembered_quartermasters_list
			target = scope:saved_character_check
		}
	}
}

#Can we actually?
scripted_trigger 1010_would_trade_child_for_supplies_trigger = {
	OR = {
		AND = {
			#Normal people wouldn't trade away a child for a 'top-up'
			OR = {
				has_trait = greedy
				has_trait = callous
			}
			scope:1010_supply_less_than ?= flag:1010_less_than_100_supply
		}
		AND = {
			exists = scope:1010_supply_less_than 
			OR = {
				scope:1010_supply_less_than = flag:1010_less_than_20_supply
				scope:1010_supply_less_than = flag:1010_less_than_40_supply
				scope:1010_supply_less_than = flag:1010_less_than_60_supply
				scope:1010_supply_less_than = flag:1010_less_than_80_supply
			}
		}
	}
	exists = scope:payment_child
}

#Don't trade away your heir
scripted_trigger 1010_payment_child_trigger = {
	age >= 2
	age <= 15
	is_courtier_of = root
	NOT = { is_primary_heir_of = root }
	save_temporary_scope_as = child_check
	root.primary_title = {
		place_in_line_of_succession = {
			target = scope:child_check
			value >= 3
		}
	}
	is_available = yes
	location = scope:visiting_location
	#Let's just avoid some technical headaches if we brought a kid along
	trigger_if = {
		limit = { exists = scope:visiting_partner }
		this != scope:visiting_partner
	}
}

scripted_trigger 1010_is_thieving_character_trigger = {
	#intrigue >= extremely_high_skill_rating
	NOR = {
		has_trait = honest
		has_trait = just
	}
	is_adult = yes
}

#Mark that child
scripted_effect 1010_mark_chosen_child_effect = {
	scope:payment_child = {
		if = {
			limit = { has_variable = 1010_payment_child }
			remove_variable ?= 1010_payment_child
			set_variable = {
				name = 1010_payment_child
				days = visit_settlement_cooldown_days
			}
		}
		else = {
			set_variable = {
				name = 1010_payment_child
				days = visit_settlement_cooldown_days
			}
		}
	}
}

#Supply duel for your highest skill stat
scripted_effect 1010_highest_skill_duel_effect = {
	if = {
		limit = { highest_skill = diplomacy }
		1010_duel_effect = { SKILL = diplomacy }
	}
	else_if = {
		limit = { highest_skill = stewardship }
		1010_duel_effect = { SKILL = stewardship }
	}
	else_if = {
		limit = { highest_skill = intrigue }
		1010_duel_effect = { SKILL = intrigue }
	}
	else_if = {
		limit = { highest_skill = learning }
		1010_duel_effect = { SKILL = learning }
	}
	else_if = {
		limit = { highest_skill = martial }
		1010_duel_effect = { SKILL = martial }
	}
	else_if = {
		limit = { highest_skill_including_prowess = prowess }
		1010_duel_effect = { SKILL = prowess }
	}
}

#Actual supply duel effect
scripted_effect 1010_duel_effect = {
	duel = {
		skill = $SKILL$
		target = scope:laamp_supply_merchant
		#Success: Half supply for free
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			desc = ep3_laamp_decision_event.1010.a_$SKILL$.success
			send_interface_toast = {
				title = ep3_laamp_decision_event.1010.a_$SKILL$.success
				left_icon = root
				right_icon = scope:laamp_supply_merchant
				#Get 1/4 of your way to 100% (So if max is 100 and you have 20 provisions, you should gain 40 provisions)
				domicile ?= { change_provisions = quarter_to_max_provisions_value }
				#Set up the cooldown for the convince-ction
				set_variable = {
					name = 1010_has_convinced_recently
					value = flag:success
					days = visit_settlement_minimum_cooldown_days #Sync this with fail & critical_fail
				}
				#Determine why we can't return to this option
				save_scope_value_as = {
					name = laamp_decision_bought_supplies
					value = flag:handout
				}
				#Go back to the main event
				hidden_effect = { 1001_return_to_second_effect = yes }
			}
		}
		#Failure: Increased price for supplies
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -20
			}	
			desc = ep3_laamp_decision_event.1010.a_$SKILL$.failure
			send_interface_toast = {
				title = ep3_laamp_decision_event.1010.a_$SKILL$.failure
				left_icon = root
				right_icon = scope:laamp_supply_merchant
				custom_tooltip = ep3_laamp_decision_event.1010.a.failure.tt
				#Set up the cooldown for the convince-ction
				set_variable = {
					name = 1010_has_convinced_recently
					value = flag:fail
					days = visit_settlement_minimum_cooldown_days #Sync this with success, critical_fail & the tooltip, currently displayed in 'months' (plural)
				}
				#Price increased - try again
				1001_return_to_second_effect = yes
			}
		}
		#Critical Failure: The local guards are summoned
		5 = {
			trigger = {
				root = {
					OR = {
						highest_skill = martial 
						highest_skill_including_prowess = prowess
					}
				}			
			}
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
			}	
			min = 5
			desc = ep3_laamp_decision_event.1010.a_$SKILL$.critical_failure
			send_interface_toast = {
				title = ep3_laamp_decision_event.1010.a_$SKILL$.critical_failure
				left_icon = root
				right_icon = scope:laamp_supply_merchant
				custom_tooltip = ep3_laamp_decision_event.1010.a.failure.tt
				#Set up the cooldown for the convince-ction
				set_variable = {
					name = 1010_has_convinced_recently
					value = flag:fail
					days = visit_settlement_minimum_cooldown_days #Sync this with success & critical_fail
				}
				#Quite the tussle
				increase_wounds_effect = { REASON = fight }
				#This merchant doesn't want to see you again
				progress_towards_rival_effect = {
					REASON = rival_tried_to_intimidate_merchant
					CHARACTER = scope:laamp_supply_merchant
					OPINION = default_rival_opinion
				}
				#And you will not be going back to supply merchant, but feel free to look at the greyed out option
				set_variable = 1010_guards_summoned
				#Determine why we can't return to this option
				save_scope_value_as = {
					name = laamp_decision_bought_supplies
					value = flag:none
				}
				#Go back to the main event
				1001_return_to_second_effect = yes
			}
		}
	}
}


#Stock 'Em Up
ep3_laamp_decision_event.1010 = {
	type = character_event
	title = ep3_laamp_decision_event.1010.t
	window = visit_settlement_window
	desc = {
		#Intro
		first_valid = {
			#This is a CITY HOLDING, aschually. More refined buyers.
			triggered_desc = { 
				trigger = { 
					NOT = { exists = scope:did_not_buy_supplies }
					scope:visiting_location = { has_holding_type = city_holding }
				}
				desc = ep3_laamp_decision_event.1010.desc_posh_stalls
			}
			#We've returned to this scene
			triggered_desc = { 
				trigger = { exists = scope:did_not_buy_supplies }
				desc = ep3_laamp_decision_event.1010.desc_returned
			}
			#First time in this scene
			desc = ep3_laamp_decision_event.1010.desc
		}
		#Returning customer
		#FIRST TIME: The merchant remembers you
		random_valid = {
			#Friendly
			triggered_desc = { 
				trigger = {
					NOT = { exists = scope:did_not_buy_supplies }
					exists = scope:laamp_recurring_supply_merchant
					trigger_if = {
						limit = { exists = scope:laamp_friendly_supply_merchant }
						always = yes
					}
					trigger_else = { always = no }
				}
				desc = ep3_laamp_decision_event.1010.desc_reused_merchant_reaction_01
			}
			#Slightly standoff-ish
			triggered_desc = { 
				trigger = {
					NOT = { exists = scope:did_not_buy_supplies }
					exists = scope:laamp_recurring_supply_merchant
					trigger_if = {
						limit = { exists = scope:laamp_antagonistic_supply_merchant }
						always = yes
					}
					trigger_else = { always = no }
				}
				desc = ep3_laamp_decision_event.1010.desc_reused_merchant_reaction_02
			}
		}
		#FIRST TIME: The merchant remembers you: First INTRO part of DIALOGUE
		triggered_desc = {
			trigger = {
				NOT = { exists = scope:did_not_buy_supplies }
				exists = scope:laamp_recurring_supply_merchant
			}
			desc = ep3_laamp_decision_event.1010.desc_reused_merchant_intro
		}
		#FIRST TIME: The merchant remembers you: Random MID part of DIALOGUE
		random_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:did_not_buy_supplies }
					exists = scope:laamp_recurring_supply_merchant
				}
				desc = ep3_laamp_decision_event.1010.desc_reused_merchant_01
			}
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:did_not_buy_supplies }
					exists = scope:laamp_recurring_supply_merchant
				}
				desc = ep3_laamp_decision_event.1010.desc_reused_merchant_02
			}
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:did_not_buy_supplies }
					exists = scope:laamp_recurring_supply_merchant
				}
				desc = ep3_laamp_decision_event.1010.desc_reused_merchant_03
			}
		}
		#FIRST TIME: The merchant remembers you: Random OUTRO part of DIALOGUE
		random_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:did_not_buy_supplies }
					exists = scope:laamp_recurring_supply_merchant
				}
				desc = ep3_laamp_decision_event.1010.desc_reused_merchant_outro_01
			}
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:did_not_buy_supplies }
					exists = scope:laamp_recurring_supply_merchant
				}
				desc = ep3_laamp_decision_event.1010.desc_reused_merchant_outro_02
			}
		}
		#First time meeting merchant
		#FIRST TIME: Merchant REACTION
		first_valid = {
			#Friendly
			triggered_desc = {
				trigger = {
					NOR = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
					scope:laamp_supply_merchant = { 1010_has_friendly_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_gregarious_new
			}
			#Uninterested
			triggered_desc = {
				trigger = {
					NOR = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
					scope:laamp_supply_merchant = { 1010_has_uninterested_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_callous_new
			}
			#Business-minded
			triggered_desc = {
				trigger = {
					NOR = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
					scope:laamp_supply_merchant = { 1010_has_commerce_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_greedy_new
			}
			#A bit awkward
			triggered_desc = {
				trigger = {
					NOR = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
					scope:laamp_supply_merchant = { 1010_has_standoffish_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_shy_new
			}
			#Irrational
			triggered_desc = {
				trigger = {
					NOR = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_eccentric_new
			}
			#Generic
			random_valid = {
				triggered_desc = {
					trigger = {
						NOR = { 
							exists = scope:did_not_buy_supplies
							exists = scope:laamp_recurring_supply_merchant
						}
						scope:laamp_supply_merchant = { 1011_has_no_applicable_traits = yes }
					}
					desc = ep3_laamp_decision_event.1010.desc_generic_new_01
				}
				triggered_desc = {
					trigger = {
						NOR = { 
							exists = scope:did_not_buy_supplies
							exists = scope:laamp_recurring_supply_merchant
						}
						scope:laamp_supply_merchant = { 1011_has_no_applicable_traits = yes }
					}
					desc = ep3_laamp_decision_event.1010.desc_generic_new_01
				}
			}
		}
		#FIRST TIME in this scene: Random DIALOGUE
		random_valid = {
			triggered_desc = {
				trigger = {
					NOT = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_new_01
			}
			triggered_desc = {
				trigger = {
					NOT = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_new_02
			}
			triggered_desc = {
				trigger = {
					NOT = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_new_03
			}
			#"Cruel world innit?"
			triggered_desc = {
				trigger = {
					NOT = { 
						exists = scope:did_not_buy_supplies
						exists = scope:laamp_recurring_supply_merchant
					}
					scope:laamp_supply_merchant = {
						OR = {
							has_trait = compassionate
							AND = {
								age >= 30
								age >= root.age_plus_25
							}
						}
					}
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_special_new_04
			}
		}
		#Return to scene
		#RETURN: Merchant REACTION
		first_valid = {
			#Friendly
			triggered_desc = {
				trigger = {
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_friendly_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_gregarious_return
			}
			#Uninterested
			triggered_desc = {
				trigger = {
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_uninterested_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_callous_return
			}
			#Business-minded
			triggered_desc = {
				trigger = {
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_commerce_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_greedy_return
			}
			#A bit awkward
			triggered_desc = {
				trigger = {
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_standoffish_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_shy_return
			}
			#Irrational
			triggered_desc = {
				trigger = {
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_trait_eccentric_return
			}
			#Generic
			random_valid = {
				triggered_desc = {
					trigger = { 
						exists = scope:did_not_buy_supplies
						scope:laamp_supply_merchant = { 1011_has_no_applicable_traits = yes }
					}
					desc = ep3_laamp_decision_event.1010.desc_generic_returned_01
				}
				triggered_desc = {
					trigger = { 
						exists = scope:did_not_buy_supplies
						scope:laamp_supply_merchant = { 1011_has_no_applicable_traits = yes }
					}
					desc = ep3_laamp_decision_event.1010.desc_generic_returned_02
				}
			}
		}
		#RETURN: Random DIALOGUE
		random_valid = {
			triggered_desc = {
				trigger = { 
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = no } #For some quirkyness
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_returned_01
			}
			triggered_desc = {
				trigger = { 
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = no } #For some quirkyness
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_returned_02
			}
			triggered_desc = {
				trigger = { 
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = no } #For some quirkyness
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_returned_03
			}
			triggered_desc = {
				trigger = {
					#Irrational is seeing you for the first time (again)
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_new_01
			}
			triggered_desc = {
				trigger = {
					#Irrational is seeing you for the first time (again)
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_new_02
			}
			triggered_desc = {
				trigger = {
					#Irrational is seeing you for the first time (again)
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_new_03
			}
			triggered_desc = {
				trigger = {
					#Irrational is seeing you for the first time (again)
					exists = scope:did_not_buy_supplies
					scope:laamp_supply_merchant = { 1010_has_irrational_traits = yes }
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_special_new_04
			}
		}
		first_valid = {
			#RETURN: Sneaky Partner
			triggered_desc = {
				trigger = { 
					exists = scope:1010_potentiaL_thievery
					exists = scope:did_not_buy_supplies 
				}
				desc = ep3_laamp_decision_event.1010.desc_outro_sneaky_partner_returned
			}
			#FIRST TIME: Sneaky Partner
			triggered_desc = {
				trigger = { exists = scope:1010_potentiaL_thievery }
				desc = ep3_laamp_decision_event.1010.desc_outro_sneaky_partner
			}
		}
	}
	theme = stewardship
	override_background = {
		trigger = {
			scope:visiting_location = {
				OR = {
					has_holding_type = tribal_holding
					has_holding_type = nomad_holding
					has_holding_type = herder_holding
				}
			}
		}
		reference = army_camp
	}
	override_background = { reference = market }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#Potential thief
		triggered_animation = {
			trigger = { exists = scope:1010_potentiaL_thievery }
			animation = personality_dishonorable
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_friendly_traits = yes } 
			}
			animation = personality_forgiving
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_commerce_traits = yes } 
			}
			animation = personality_greedy
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_uninterested_traits = yes } 
			}
			animation = personality_cynical
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_irrational_traits = yes } 
			}
			animation = personality_irrational
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_standoffish_traits = yes } 
			}
			animation = personality_coward
		}
		animation = personality_content
	}
	center_portrait = {
		character = root
		camera = camera_event_scheme_center_look_semi_right
		animation = steward
	}
	right_portrait = {
		character = scope:laamp_supply_merchant
		#Friendly
		triggered_animation = {
			trigger = {
				scope:laamp_supply_merchant = { 1010_has_friendly_traits = yes }
			}
			animation = personality_compassionate
		}
		#Uninterested
		triggered_animation = {
			trigger = {
				scope:laamp_supply_merchant = { 1010_has_uninterested_traits = yes }
			}
			animation = personality_callous
		}
		#Business-minded
		triggered_animation = {
			trigger = {
				scope:laamp_supply_merchant = { 1010_has_commerce_traits = yes }
			}
			animation = admiration
		}
		#A bit awkward
		triggered_animation = {
			trigger = {
				scope:laamp_supply_merchant = { 1010_has_standoffish_traits = yes }
			}
			animation = personality_coward
		}
		#Irrational
		triggered_animation = {
			trigger = {
				scope:laamp_supply_merchant = { 1010_has_irrational_traits = yes }
			}
			animation = personality_irrational
		}
		animation = steward
	}
	lower_left_portrait = {
		trigger = { exists = scope:payment_child }
		character = scope:payment_child
	}
	lower_center_portrait = {
		trigger = { 
			exists = scope:other_parent
			trigger_if = {
				limit = { exists = scope:visiting_partner }
				scope:other_parent != scope:visiting_partner
			}
		}
		character = scope:other_parent
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Find our merchant
		if = {
			#Do we already have a merchant?
			limit = {
				NOT = { exists = scope:laamp_supply_merchant }
			}
			#Has this person been our supply merchant in the past 10 years?
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_merchant_trigger = yes
					1010_is_a_saved_peddler_trigger = no
					1010_is_a_saved_crier_trigger = no
					1010_is_a_saved_storyteller_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_healer_trigger = no
					1010_is_a_saved_clergy_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_weaponsmith_trigger = no
					1010_is_a_saved_armorer_trigger = no
					1010_is_a_saved_jeweler_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
				}
				save_scope_as = laamp_supply_merchant
				#Some more loc flavor shenanigans for these saved scopes
				save_scope_as = laamp_recurring_supply_merchant
				scope:laamp_supply_merchant = {
					if = {
						limit = {
							OR = {
								has_trait = greedy
								has_trait = craven
								has_trait = wrathful
								has_trait = deceitful
								1010_has_uninterested_traits = yes
							}
						}
						save_scope_as = laamp_antagonistic_supply_merchant
					}
					else_if = {
						limit = {
							NOT = { exists = scope:laamp_antagonistic_supply_merchant }
							OR = {
								has_trait = gregarious
								has_trait = compassionate
								has_trait = honest
								has_trait = eccentric
								has_trait = forgiving
								has_trait = trusting
							}
						}
						save_scope_as = laamp_friendly_supply_merchant
					}
				}	
			}
			#Otherwise find a merchant in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_supply_merchant }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					}
					save_scope_as = laamp_supply_merchant
				}
			}
			#Otherwise create a merchant
			if = {
				limit = {
					NOT = { exists = scope:laamp_supply_merchant }
				}
				#Create merchant to stuff in pool
				create_character = {
					template = generic_peasant_character
					location = scope:visiting_location
					dynasty = none
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_supply_merchant
				}
			}
			#Remember the merchant
			1010_remember_vendor_character_effect = { GUILD = merchant CHARACTER = scope:laamp_supply_merchant }
		}
		#Determine how much supply we are buying, reflect this in cost and options available (don't trade away children for 5% supply...)
		if = {
			limit = {
				OR = {
					#If we haven't bought provisions already
					NOT = { exists = scope:1010_supply_value }
					#Or if we went here, then used provisions elsewhere in the holding and came back
					AND = {
						exists = scope:1010_supply_value
						NOR = {
							scope:1010_supply_value = domicile.max_provisions
							scope:1010_supply_value = domicile.provisions
						}
					}
				}
			}
			if = {
				#Less than 20% supply
				limit = {
					domicile ?= { provisions <= twenty_percent_provisions_value }
				}
				save_scope_value_as = {
					name = 1010_supply_less_than
					value = flag:1010_less_than_20_supply
				}
			}
			else_if = {
				#Less than 40% supply
				limit = {
					domicile ?= { provisions <= forty_percent_provisions_value }
				}
				save_scope_value_as = {
					name = 1010_supply_less_than
					value = flag:1010_less_than_40_supply
				}
			}
			else_if = {
				#Less than 60% supply
				limit = {
					domicile ?= { provisions <= sixty_percent_provisions_value }
				}
				save_scope_value_as = {
					name = 1010_supply_less_than
					value = flag:1010_less_than_60_supply
				}
			}
			else_if = {
				#Less than 80% supply
				limit = {
					domicile ?= { provisions <= eighty_percent_provisions_value }
				}
				save_scope_value_as = {
					name = 1010_supply_less_than
					value = flag:1010_less_than_80_supply
				}
			}
			else_if = {
				#Less than 100% supply
				limit = {
					domicile ?= { provisions < max_provisions }
				}
				save_scope_value_as = {
					name = 1010_supply_less_than
					value = flag:1010_less_than_100_supply
				}
			}
			set_variable = {
				name = supply_gold_cost
				value = {
					value = domicile.max_provisions
					subtract = domicile.provisions
					#Now we have the missing provisions value
					multiply = 0.05
					round = yes
				}
			}
			save_scope_value_as = {
				name = 1010_supply_value
				value = domicile.provisions
			}
		}
		#Find a suitable child. Don't trade away your heir.
		if = {
			limit = {
				NOT = { exists = scope:payment_child }
				1010_would_trade_child_for_supplies_trigger = yes
			}
			#Did we already pick a child and are actually decision-scumming?
			if = {
				limit = {
					any_child = {
						1010_payment_child_trigger = yes
						has_variable = 1010_payment_child
					}
				}
				random_child = {
					limit = {
						1010_payment_child_trigger = yes
						has_variable = 1010_payment_child
					}
					save_scope_as = payment_child
					#Refresh the mark
					1010_mark_chosen_child_effect = yes
				}
			}
			#Otherwise pick a child
			if = {
				limit = {
					NOT = { exists = scope:payment_child }
					any_child = { 1010_payment_child_trigger = yes }
				}
				every_child = {
					limit = { 1010_payment_child_trigger = yes }
					add_to_list = list_of_unimportant_children
				}
				random_in_list = {
					list = list_of_unimportant_children
					weight = {
						base = 0
						#Look for children who can't inherit first
						modifier = {
							is_female = yes
							root = {
								OR = {
									faith = { has_doctrine_parameter = male_dominated_law }
									has_realm_law = male_only_law
								}	
							}
							add = 50
						}
						modifier = {
							is_male = yes
							root = {
								OR = {
									faith = { has_doctrine_parameter = female_dominated_law }
									has_realm_law = female_only_law
								}	
							}
							add = 50
						}
						#Then the ones you like less
						modifier = {
							opinion = {
								target = root
								value <= 50
							}
							add = 25
						}
						modifier = {
							opinion = {
								target = root
								value <= 30
							}
							add = 25
						}
						modifier = {
							opinion = {
								target = root
								value <= 10
							}
							add = 25
						}
						modifier = {
							opinion = {
								target = root
								value < 0
							}
							add = 25
						}
						modifier = {
							has_relation_friend = root
							factor = 0
						}
					}
					save_scope_as = payment_child
					#No decision-scumming
					1010_mark_chosen_child_effect = yes
				}
			}
			#Find the other parent of the child - should be adequately upset that you traded away their kid. You monster.
			if = {
				limit = { exists = scope:payment_child }
				if = {
					limit = { is_female = yes }
					if = {
						limit = {
							scope:payment_child.father = { is_alive = yes }
						}
						scope:payment_child.father = { save_scope_as = other_parent }
					}
				}
				else_if = {
					limit = { 
						scope:payment_child.mother = { is_alive = yes }
					}
					scope:payment_child.mother = { save_scope_as = other_parent }
				}
			}
		}
		#Is our partner actually a bit thieving?
		if = {
			#This looks a bit weird, localization-wise.
			limit = {
				#We're not a master thief
				NOT = { highest_skill = intrigue }
				#But our friend is a competent thief
				scope:visiting_partner ?= { 1010_is_thieving_character_trigger = yes }
				NOT = { exists = scope:1010_potentiaL_thievery }
			}
			if = {
				limit = {
					NOT = { has_variable = 1010_calculated_thievery_punishment }
				}
				set_variable = {
					name = 1010_calculated_thievery_punishment
					value = {
					    integer_range = {
					        min = medium_trait_xp
					        max = major_trait_xp
					    }
					}
					days = visit_settlement_small_cooldown_days
				}
			}
			save_scope_as = 1010_potentiaL_thievery
		}
		#Price tweaks!
		if = {
			limit = { exists = var:supply_gold_cost }
			#You botched a convince duel, price increased
			if = {
				limit = {
					var:1010_has_convinced_recently ?= flag:fail
					NOT = { exists = scope:1010_adjusted_provision_cost }
				}
				change_variable = {
					name = supply_gold_cost
					multiply = 1.3
				}
				save_scope_value_as = {
					name = 1010_adjusted_provision_cost
					value = flag:yes
				}
			}
			#Random selection of price reductions
			if = {
				limit = {
					NOT = { exists = scope:1010_applied_price_reductions }
				}
				#Perk discount
				if = {
					limit = {
						root = { has_perk = war_profiteer_perk }
					}
					change_variable = {
						name = supply_gold_cost
						multiply = 0.75
					}
				}
				#Cheaper supplies in City Holding
				if = {
					limit = {
						root.location = { has_holding_type = city_holding }
					}
					change_variable = {
						name = supply_gold_cost
						multiply = 0.7
					}
				}
				#Cheaper supplies from Camp Party
				if = {
					limit = {
						has_character_flag = cheaper_provisions_visit_holding_flag
					}
					change_variable = {
						name = supply_gold_cost
						multiply = 0.6
					}
				}
				save_scope_value_as = {
					name = 1010_applied_price_reductions
					value = flag:yes
				}
			}
		}
	}
	#Trade gold
	option = {
		name = ep3_laamp_decision_event.1010.b
		trigger = { short_term_gold >= var:supply_gold_cost }
		show_as_unavailable = { always = yes }
		#Pay gold
		remove_short_term_gold = var:supply_gold_cost
		#Get supplies
		domicile ?= { 
			change_provisions = {
				value = {
					value = max_provisions 
					subtract = provisions
				}
			}
		}
		#Set correct variables and reroute us to main square
		1010_bought_supplies_effect = yes
	}
	#Convince them to give you some supply for free
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { highest_skill = diplomacy }
						desc = ep3_laamp_decision_event.1010.a_diplomacy
					}
					triggered_desc = {
						trigger = { highest_skill = stewardship }
						desc = ep3_laamp_decision_event.1010.a_stewardship
					}
					triggered_desc = {
						trigger = { highest_skill = intrigue }
						desc = ep3_laamp_decision_event.1010.a_intrigue
					}
					triggered_desc = {
						trigger = { highest_skill = learning }
						desc = ep3_laamp_decision_event.1010.a_learning
					}
					triggered_desc = {
						trigger = { 
							OR = {
								highest_skill = martial 
								highest_skill_including_prowess = prowess
							}
						}
						desc = ep3_laamp_decision_event.1010.a_martial
					}
				}
			}
		}
		trigger = {
			#Are we on cooldown?
			custom_tooltip = {
				text = ep3_laamp_decision_event.1010.a.cooldown.tt
				NOT = { has_variable = 1010_has_convinced_recently }
			}
		}
		#Keep you informed of the cooldown
		show_as_unavailable = { always = yes }
		#Duel effect
		1010_highest_skill_duel_effect = yes
	}
	#Triggered Option: Trade child
	option = {
		name = {
			trigger = { has_trait = callous }
			text = ep3_laamp_decision_event.1010.c_callous
		}
		name = ep3_laamp_decision_event.1010.c
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { has_trait = callous }
					desc = ep3_laamp_decision_event.1010.c.flavor_callous
				}
				desc = ep3_laamp_decision_event.1010.c.flavor
			}
		}
		trigger = { 
			exists = scope:payment_child
			#For sanity reasons
			is_ai = no
		}
		highlight_portrait = scope:payment_child
		#Pay child
		scope:payment_child = {
			add_opinion = {
				modifier = traded_me_away_opinion
				target = root
				opinion = -50
			}
			progress_towards_rival_effect = {
				REASON = rival_traded_away_child
				CHARACTER = root
				OPINION = default_rival_opinion
			}
			move_to_pool = yes
		}
		if = {
			limit = { exists = scope:other_parent }
			scope:other_parent = {
				add_opinion = {
					modifier = traded_away_child_opinion
					target = root
					opinion = -50
				}
			}
		}
		#Get supplies
		domicile ?= { change_provisions = max_provisions }
		#Give appropriate amounts of stress
		stress_impact = {
			compassionate = major_stress_impact_gain
		}
		#Set correct variables and reroute us to main square
		1010_bought_supplies_effect = yes
	}
	#Triggered Option: Intrigue-y visiting partner steals some supply for you
	option = {
		name = ep3_laamp_decision_event.1010.d
		trigger = { 
			exists = scope:1010_potentiaL_thievery
			#Are we on cooldown?
			custom_tooltip = {
				text = ep3_laamp_decision_event.1010.d.cooldown.tt
				NOT = { has_variable = 1010_has_stolen_recently }
			}
		}
		flavor = ep3_laamp_decision_event.1010.d.flavor
		show_as_unavailable = { exists = scope:1010_potentiaL_thievery }
		scope:visiting_partner = {
			duel = {
				skill = intrigue
				target = scope:laamp_supply_merchant
				#Success: Supplies!
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					desc = ep3_laamp_decision_event.1010.d.success
					root = {
						send_interface_toast = {
							title = ep3_laamp_decision_event.1010.d.success
							left_icon = scope:visiting_partner
							right_icon = scope:laamp_supply_merchant
							#Successful theft!
							domicile ?= { change_provisions = half_to_max_provisions_value }
							#Set up the cooldown for the convince-action
							set_variable = {
								name = 1010_has_stolen_recently
								value = flag:success
								days = visit_settlement_minimum_cooldown_days #Sync this with fail
							}
							#Determine why we can't return to this option
							save_scope_value_as = {
								name = laamp_decision_bought_supplies
								value = flag:none
							}
							#Go back to the main event
							hidden_effect = { 1001_return_to_second_effect = yes }
						}
					}
					
				}
				#Failure: The local guards are summoned
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
					}	
					min = 5
					desc = ep3_laamp_decision_event.1010.d.failure
					root = {
						send_interface_toast = {
							title = ep3_laamp_decision_event.1010.d.failure
							left_icon = scope:visiting_partner
							right_icon = scope:laamp_supply_merchant
							#Quite the tussle
							scope:visiting_partner = { 
								increase_wounds_effect = { REASON = fight }
							}
							custom_tooltip = ep3_laamp_decision_event.1010.a.failure.tt
							#Set up the cooldown for the convince-action
							set_variable = {
								name = 1010_has_stolen_recently
								value = flag:fail
								days = visit_settlement_minimum_cooldown_days #Sync this with success
							}
							#This merchant doesn't want to see you again
							progress_towards_rival_effect = {
								REASON = rival_tried_to_steal_supplies
								CHARACTER = scope:laamp_supply_merchant
								OPINION = default_rival_opinion
							}
							#And you will not be going back to supply merchant, but feel free to look at the greyed out option
							set_variable = 1010_guards_summoned
							#Determine why we can't return to this option
							save_scope_value_as = {
								name = laamp_decision_bought_supplies
								value = flag:none
							}
							#Go back to the main event
							1001_return_to_second_effect = yes
						}
					}
				}
			}
		}
	}
	#I want to do something else
	option = {
		name = ep3_laamp_decision_event.1010.e
		#For desc flavor
		save_scope_as = did_not_buy_supplies
		#Go back to the main event
		1001_return_to_second_effect = yes
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:supply_merchant }
	}
}


######################################################################
# SELL ARTIFACT
# ep3_laamp_decision_event.1020
######################################################################

scripted_effect 1020_suppress_artifact_notifications_effect = {
	#Don't need no notification about this
	set_variable = {
		name = suppress_artifact_notifications
		value = yes
		days = 2
	}
}

scripted_effect 1020_remove_sell_variables_effect = {
	remove_variable ?= 1020_artifact_sell_value
	remove_variable ?= 1020_artifact_sell_high_value
	remove_variable ?= 1020_artifact_sell_low_value
}

#Set the correct variable to block off the Artifact option and remove the desc flavor variable
scripted_effect 1020_sold_artifact_effect = {
	scope:1020_first_artifact_to_sell ?= { 1020_remove_sell_variables_effect = yes }
	scope:1020_second_artifact_to_sell ?= { 1020_remove_sell_variables_effect = yes }
	scope:1020_third_artifact_to_sell ?= { 1020_remove_sell_variables_effect = yes }
	remove_list_variable = {
		name = list_of_options
		target = flag:has_artifact_option
	}
	remove_variable ?= 1021_artifact_sell_screen
	save_scope_as = laamp_decision_sold_artifact
	#Go back to the main event
	hidden_effect = { 1001_return_to_second_effect = yes }
}

#Reused effect to set the variable
scripted_effect 1020_set_artifact_value_variables_effect = {
	#Regular price
	set_variable = {
		name = 1020_artifact_sell_value
		value = {
			value = $GOLD_VALUE$
			#Better buyers in City Holding
			if = {
				limit = {
					scope:visiting_location = { has_holding_type = city_holding }
				}
				multiply = { 1.15 1.25 }
			}
			multiply = { 0.90 1.1 }
		}
	}
	#Haggle success / Outraged partner price
	set_variable = {
		name = 1020_artifact_sell_high_value
		value = {
			value = var:1020_artifact_sell_value
			#Better buyers in City Holding
			if = {
				limit = {
					scope:visiting_location = { has_holding_type = city_holding }
				}
				multiply = { 1.15 1.25 }
			}
			#Haggle success / Outraged partner price
			multiply = { 1.15 1.25 }
		}
	}
	#Haggle failed price
	set_variable = {
		name = 1020_artifact_sell_low_value
		value = {
			value = var:1020_artifact_sell_value
			#Better buyers in City Holding
			if = {
				limit = {
					scope:visiting_location = { has_holding_type = city_holding }
				}
				multiply = { 1.15 1.25 }
			}
			#Haggle failed price
			multiply = { 0.55 0.8 }
		}
	}
}

#Calculate how much the artifact is worth
scripted_effect 1020_calculate_artifact_value_effect = {
	#Very expensive
	if = {
		limit = { rarity = illustrious }
		1020_set_artifact_value_variables_effect = { GOLD_VALUE = root.massive_gold_value } 
	}
	#Expensive
	else_if = {
		limit = { rarity = famed }
		1020_set_artifact_value_variables_effect = { GOLD_VALUE = root.major_gold_value }
	}
	#OK price
	else_if = {
		limit = { rarity = masterwork }
		1020_set_artifact_value_variables_effect = { GOLD_VALUE = root.medium_gold_value }
	}
	#Cheap
	else_if = {
		limit = { rarity = common }
		1020_set_artifact_value_variables_effect = { GOLD_VALUE = root.minor_gold_value }
	}
}


#Sell an artifact to local peddlers
ep3_laamp_decision_event.1020 = {
	type = character_event
	title = ep3_laamp_decision_event.1020.t 
	window = visit_settlement_window
	desc = {
		#Intro
		first_valid = {
			#FIRST TIME: We've seen this peddler before
			triggered_desc = { 
				trigger = { 
					NOT = { exists = scope:did_not_sell_artifact }
					exists = scope:laamp_recurring_artifact_peddler
				}
				desc = ep3_laamp_decision_event.1020.desc_intro_reused_peddler
			}
			#FIRST TIME: This is a CITY HOLDING, aschually. More refined buyers.
			triggered_desc = { 
				trigger = { 
					NOT = { exists = scope:did_not_sell_artifact }
					scope:visiting_location = { has_holding_type = city_holding }
				}
				desc = ep3_laamp_decision_event.1020.desc_intro_posh_stalls
			}
			#RETURN SELL SCREEN: Guess we're thinking very hard
			random_valid = {
				triggered_desc = { 
					trigger = { has_variable = 1021_artifact_sell_screen }
					desc = ep3_laamp_decision_event.1020.desc_intro_intermediate_returned_01
				}
				triggered_desc = { 
					trigger = { has_variable = 1021_artifact_sell_screen }
					desc = ep3_laamp_decision_event.1020.desc_intro_intermediate_returned_02
				}
			}
			#RETURN: We've returned to this scene, now what
			random_valid = {
				triggered_desc = { 
					trigger = { exists = scope:did_not_sell_artifact }
					desc = ep3_laamp_decision_event.1020.desc_intro_returned_01
				}
				triggered_desc = { 
					trigger = { exists = scope:did_not_sell_artifact }
					desc = ep3_laamp_decision_event.1020.desc_intro_returned_02
				}
			}
			#FIRST TIME: Intro
			random_valid = {
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
					}
					desc = ep3_laamp_decision_event.1020.desc_intro_new_01
				}
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
					}
					desc = ep3_laamp_decision_event.1020.desc_intro_new_02
				}
			}
		}
		#FIRST TIME: Artifact Flavor
		first_valid = {
			#FIRST TIME: One artifact
			random_valid = {
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
						exists = scope:1020_first_artifact_to_sell
						NOT = { exists = scope:1020_second_artifact_to_sell }
						NOT = { exists = scope:1020_third_artifact_to_sell }
					}
					desc = ep3_laamp_decision_event.1020.desc_one_artifact_new_01
				}
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
						exists = scope:1020_first_artifact_to_sell
						NOT = { exists = scope:1020_second_artifact_to_sell }
						NOT = { exists = scope:1020_third_artifact_to_sell }
					}
					desc = ep3_laamp_decision_event.1020.desc_one_artifact_new_02
				}
			}
			#FIRST TIME: Two artifacts
			random_valid = {
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
						exists = scope:1020_first_artifact_to_sell
						exists = scope:1020_second_artifact_to_sell
						NOT = { exists = scope:1020_third_artifact_to_sell }
					}
					desc = ep3_laamp_decision_event.1020.desc_two_artifacts_new_01
				}
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
						exists = scope:1020_first_artifact_to_sell
						exists = scope:1020_second_artifact_to_sell
						NOT = { exists = scope:1020_third_artifact_to_sell }
					}
					desc = ep3_laamp_decision_event.1020.desc_two_artifacts_new_02
				}
			}
			#FIRST TIME: Three artifacts
			random_valid = {
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
						exists = scope:1020_first_artifact_to_sell
						exists = scope:1020_second_artifact_to_sell
						exists = scope:1020_third_artifact_to_sell
					}
					desc = ep3_laamp_decision_event.1020.desc_three_artifacts_new_01
				}
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
						exists = scope:1020_first_artifact_to_sell
						exists = scope:1020_second_artifact_to_sell
						exists = scope:1020_third_artifact_to_sell
					}
					desc = ep3_laamp_decision_event.1020.desc_three_artifacts_new_02
				}
			}
		}
		#Visiting Partner flavor
		first_valid = {
			#RETURN: We've returned with our outraged clever partner
			triggered_desc = { 
				trigger = { 
					exists = scope:did_not_sell_artifact
					exists = scope:1020_outraged_partner
				}
				desc = ep3_laamp_decision_event.1020.desc_outraged_partner_returned
			}
			#FIRST TIME: Outraged clever partner
			triggered_desc = { 
				trigger = { exists = scope:1020_outraged_partner }
				desc = ep3_laamp_decision_event.1020.desc_outraged_partner_new
			}
		}
	}
	theme = stewardship
	override_background = { reference = ep2_village_festival }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#Outraged
		triggered_animation = {
			trigger = { exists = scope:1020_outraged_partner }
			animation = rage
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_friendly_traits = yes } 
			}
			animation = personality_forgiving
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_commerce_traits = yes } 
			}
			animation = personality_greedy
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_uninterested_traits = yes } 
			}
			animation = personality_cynical
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_irrational_traits = yes } 
			}
			animation = personality_irrational
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_standoffish_traits = yes } 
			}
			animation = personality_coward
		}
		animation = personality_compassionate
	}
	center_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:laamp_artifact_peddler
		#Friendly
		triggered_animation = {
			trigger = {
				scope:laamp_artifact_peddler = { 1010_has_friendly_traits = yes }
			}
			animation = personality_compassionate
		}
		#Uninterested
		triggered_animation = {
			trigger = {
				scope:laamp_artifact_peddler = { 1010_has_uninterested_traits = yes }
			}
			animation = personality_callous
		}
		#Business-minded
		triggered_animation = {
			trigger = {
				scope:laamp_artifact_peddler = { 1010_has_commerce_traits = yes }
			}
			animation = admiration
		}
		#A bit awkward
		triggered_animation = {
			trigger = {
				scope:laamp_artifact_peddler = { 1010_has_standoffish_traits = yes }
			}
			animation = personality_coward
		}
		#Irrational
		triggered_animation = {
			trigger = {
				scope:laamp_artifact_peddler = { 1010_has_irrational_traits = yes }
			}
			animation = personality_irrational
		}
		animation = personality_forgiving
	}
	artifact = {
		trigger = { exists = scope:1020_first_artifact_to_sell }
		target = scope:1020_first_artifact_to_sell
		position = lower_left_portrait
	}
	artifact = {
		trigger = { exists = scope:1020_second_artifact_to_sell }
		target = scope:1020_second_artifact_to_sell
		position = lower_center_portrait
	}
	artifact = {
		trigger = { exists = scope:1020_third_artifact_to_sell }
		target = scope:1020_third_artifact_to_sell
		position = lower_right_portrait
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Do we have someone more clever in our company?
		if = {
			limit = {
				NOT = { exists = scope:1020_outraged_partner }
				scope:visiting_partner ?= {
					stewardship > root.stewardship
					stewardship >= average_skill_rating
				}
			}
			#Save outraged clever partner
			save_scope_as = 1020_outraged_partner
		}
		#Find our peddler
		if = {
			#Do we already have a peddler?
			limit = {
				NOT = { exists = scope:laamp_artifact_peddler }
			}
			#Has this person been our artifact peddler in the past 10 years?
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_peddler_trigger = yes
					1010_is_a_saved_merchant_trigger = no
					1010_is_a_saved_crier_trigger = no
					1010_is_a_saved_storyteller_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_healer_trigger = no
					1010_is_a_saved_clergy_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_weaponsmith_trigger = no
					1010_is_a_saved_armorer_trigger = no
					1010_is_a_saved_jeweler_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
				}
				save_scope_as = laamp_artifact_peddler
				#Some more loc flavor shenanigans for these saved scopes
				save_scope_as = laamp_recurring_artifact_peddler
			}
			#Otherwise find a peddler in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_artifact_peddler }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					}
					save_scope_as = laamp_artifact_peddler
				}
			}
			#Otherwise create a peddler
			if = {
				limit = {
					NOT = { exists = scope:laamp_artifact_peddler }
				}
				#Create peddler to stuff in pool
				create_character = {
					template = generic_peasant_character
					location = scope:visiting_location
					dynasty = none
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_artifact_peddler
				}
			}
			#Remember the peddler
			1010_remember_vendor_character_effect = { GUILD = peddler CHARACTER = scope:laamp_artifact_peddler }
		}
		#What artifacts are we selling?
		if = {
			limit = {
				NOT = { exists = scope:1020_first_artifact_to_sell }
			}
			every_character_artifact = {
				limit = { 1000_is_unsellable_artifact_trigger = no }
				add_to_list = list_of_potential_artifacts_to_sell
			}
			#Pick a random artifact in the list so we have a starting point
			random_in_list = {
				list = list_of_potential_artifacts_to_sell
				limit = { has_variable = 1020_interesting_artifact_to_sell }
				alternative_limit = { 
					#Empty, just pick an artifact from the list already
				}
				#Remember the artifact for next visit
				set_variable = {
					name = 1020_interesting_artifact_to_sell
					days = visit_settlement_cooldown_days
				}
				save_scope_as = 1020_first_artifact_to_sell
			}
			#Pick something the peddler saw on your character
			if = {
				limit = {
					any_in_list = {
						list = list_of_potential_artifacts_to_sell
						this != scope:1020_first_artifact_to_sell
					}
				}
				random_in_list = {
					list = list_of_potential_artifacts_to_sell
					limit = {
						has_variable = 1020_interesting_artifact_to_sell
						this != scope:1020_first_artifact_to_sell
						is_equipped = yes
					}
					alternative_limit = {
						this != scope:1020_first_artifact_to_sell
						is_equipped = no
					}
					alternative_limit = {
						this != scope:1020_first_artifact_to_sell
					}
					#Remember the artifact for next visit
					set_variable = {
						name = 1020_interesting_artifact_to_sell
						days = visit_settlement_cooldown_days
					}
					save_scope_as = 1020_second_artifact_to_sell
				}

			}
			#Pick something that isn't whatever old court artifact from when you used to be someone
			if = {
				limit = {
					any_in_list = {
						list = list_of_potential_artifacts_to_sell
						NOT = {
							this = scope:1020_first_artifact_to_sell
							this = scope:1020_second_artifact_to_sell
						}
					}
				}
				random_in_list = {
					list = list_of_potential_artifacts_to_sell
					limit = {
						has_variable = 1020_interesting_artifact_to_sell
						NOT = {
							this = scope:1020_first_artifact_to_sell
							this = scope:1020_second_artifact_to_sell
						}
						ep1_artifact_is_court_artifact_trigger = no
						is_unique = no
					}
					alternative_limit = {
						NOT = {
							this = scope:1020_first_artifact_to_sell
							this = scope:1020_second_artifact_to_sell
						}
						ep1_artifact_is_court_artifact_trigger = no
					}
					alternative_limit = {
						NOT = {
							this = scope:1020_first_artifact_to_sell
							this = scope:1020_second_artifact_to_sell
						}
						is_unique = no
					}
					alternative_limit = {
						NOT = {
							this = scope:1020_first_artifact_to_sell
							this = scope:1020_second_artifact_to_sell
						}
					}
					#Remember the artifact for next visit
					set_variable = {
						name = 1020_interesting_artifact_to_sell
						days = visit_settlement_cooldown_days
					}
					save_scope_as = 1020_third_artifact_to_sell
				}
			}
		}
		#Set the prices
		if = {
			#Always exists
			limit = {
				scope:1020_first_artifact_to_sell = { 
					NOT = { has_variable = 1020_artifact_sell_value }
				}
			}
			scope:1020_first_artifact_to_sell = { 
				1020_calculate_artifact_value_effect = yes
				#Don't need no notifications about this
				1020_suppress_artifact_notifications_effect = yes
			}
			#2nd Artifact
			if = {
				limit = { exists = scope:1020_second_artifact_to_sell }
				scope:1020_second_artifact_to_sell = { 
					1020_calculate_artifact_value_effect = yes
					#Don't need no notifications about this
					1020_suppress_artifact_notifications_effect = yes
				}		
			}
			#3rd Artifact
			if = {
				limit = { exists = scope:1020_third_artifact_to_sell }
				scope:1020_third_artifact_to_sell = { 
					1020_calculate_artifact_value_effect = yes
					#Don't need no notifications about this
					1020_suppress_artifact_notifications_effect = yes
				}	
			}
			#Let's not do this twice
		}
	}
	#Go to sell screen
	option = {
		name = ep3_laamp_decision_event.1020.a
		#Inform player
		custom_tooltip = ep3_laamp_decision_event.1020.a.tt
		#Show the current estimated prices so that you can compare
		custom_tooltip = ep3_laamp_decision_event.1020.a.first_artifact.tt
		#2nd Artifact
		if = {
			limit = { exists = scope:1020_second_artifact_to_sell }
			custom_tooltip = ep3_laamp_decision_event.1020.a.second_artifact.tt
		}
		#3rd Artifact
		if = {
			limit = { exists = scope:1020_third_artifact_to_sell }
			custom_tooltip = ep3_laamp_decision_event.1020.a.third_artifact.tt
		}
		if = { # Eagle
			limit = {
				can_laamp_sell_eagle_trigger = yes
			}
			custom_tooltip = ep3_laamp_decision_event.1020.eagle.tt
			custom_tooltip = ep3_laamp_decision_event.1020.eagle.price_tt
		}
		remove_variable ?= 1021_artifact_sell_screen
		#Go to sell screen
		trigger_event = ep3_laamp_decision_event.1021
	}
	#Attempt a haggle
	option = {
		name = ep3_laamp_decision_event.1020.b
		trigger = { 
			#You're on cooldown
			custom_tooltip = {
				text = ep3_laamp_decision_event.1020.b.cooldown.tt
				NOT = { has_variable = 1020_has_haggled_recently } 
			}
		}	
		duel = {
			skill = stewardship
			target = scope:laamp_artifact_peddler
			#Success: Artifact merchant looks contemplatively at you, increased price
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_laamp_decision_event.1020.b.success
				send_interface_toast = {
					title = ep3_laamp_decision_event.1020.b.success
					left_icon = root
					right_icon = scope:laamp_artifact_peddler
					#For loc and effects
					save_scope_value_as = {
						name = attempted_artifact_haggle
						value = flag:success
					}
					#Show the estimated success prices so that you can compare
					custom_tooltip = ep3_laamp_decision_event.1020.b.success.first_artifact.tt
					#2nd Artifact
					if = {
						limit = { exists = scope:1020_second_artifact_to_sell }
						custom_tooltip = ep3_laamp_decision_event.1020.b.success.second_artifact.tt
					}
					#3rd Artifact
					if = {
						limit = { exists = scope:1020_third_artifact_to_sell }
						custom_tooltip = ep3_laamp_decision_event.1020.b.success.third_artifact.tt
					}
					if = {
						limit = { has_lifestyle = stewardship_lifestyle }
						add_stewardship_lifestyle_xp = medium_lifestyle_xp
					}
					stress_impact = {
						greedy = minor_stress_impact_loss
						ambitious = minor_stress_impact_loss
					}
					#Go to sell screen with modified costs
					trigger_event = ep3_laamp_decision_event.1021
				}
			}
			#Failure: Artifact merchant smirks at you, decreased price
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}	
				desc = ep3_laamp_decision_event.1020.b.failure
				send_interface_toast = {
					title = ep3_laamp_decision_event.1020.b.failure
					left_icon = root
					right_icon = scope:laamp_artifact_peddler
					#For loc and effects
					save_scope_value_as = {
						name = attempted_artifact_haggle
						value = flag:failure
					}
					#Show the estimated failure prices so that you can compare
					custom_tooltip = ep3_laamp_decision_event.1020.b.failure.first_artifact.tt
					#2nd Artifact
					if = {
						limit = { exists = scope:1020_second_artifact_to_sell }
						custom_tooltip = ep3_laamp_decision_event.1020.b.failure.second_artifact.tt
					}
					#3rd Artifact
					if = {
						limit = { exists = scope:1020_third_artifact_to_sell }
						custom_tooltip = ep3_laamp_decision_event.1020.b.failure.third_artifact.tt
					}
					stress_impact = {
						base = minor_stress_impact_gain
						greedy = minor_stress_impact_gain
					}
					#Go to sell screen with modified costs
					trigger_event = ep3_laamp_decision_event.1021
				}
			}
		}
		set_variable = {
			name = 1020_has_haggled_recently
			days = visit_settlement_minimum_cooldown_days
		}
	}
	#Triggered Option: Outraged clever partner gets you a higher price for a random artifact
	option = {
		name = ep3_laamp_decision_event.1020.c
		#If we have an outraged clever partner
		trigger = { exists = scope:1020_outraged_partner }
		#... whom randomly sells one of the artifacts at a higher price
		random_list = {
			#This should always exist
			50 = {
				desc = ep3_laamp_decision_event.1020.c.first_artifact
				add_gold = scope:1020_first_artifact_to_sell.var:1020_artifact_sell_high_value
				scope:1020_first_artifact_to_sell = { set_owner = scope:laamp_artifact_peddler }
			}
			#Artifact #2
			50 = {
				trigger = { exists = scope:1020_second_artifact_to_sell }
				desc = ep3_laamp_decision_event.1020.c.second_artifact
				add_gold = scope:1020_second_artifact_to_sell.var:1020_artifact_sell_high_value
				scope:1020_second_artifact_to_sell = { set_owner = scope:laamp_artifact_peddler }
			}
			#Artifact #3
			50 = {
				trigger = { exists = scope:1020_third_artifact_to_sell }
				desc = ep3_laamp_decision_event.1020.c.third_artifact
				add_gold = scope:1020_third_artifact_to_sell.var:1020_artifact_sell_high_value
				scope:1020_third_artifact_to_sell = { set_owner = scope:laamp_artifact_peddler }
			}
		}
		#Set correct variables and reroute us to main square
		1020_sold_artifact_effect = yes
		stress_impact = {
			ambitious = minor_stress_impact_gain
			lazy = minor_stress_impact_loss
		}
		#Inform the player
		custom_tooltip = ep3_laamp_decision_event.return.tt	
	}
	#I want to do something else
	option = {
		name = ep3_laamp_decision_event.1020.d
		#For desc flavor
		save_scope_as = did_not_sell_artifact
		#Go back to the main event
		1001_return_to_second_effect = yes
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:artifact_peddler }
	}
}


#Sell (or destroy) artifact (if unique artifact)
scripted_effect ep3_laamp_decision_1021_sell_artifact_effect = {
	save_temporary_scope_as = artifact_to_sell #More descriptive than 'prev'
	#Get appropriate amount of gold
	root = {
		if = {
			limit = {
				exists = scope:attempted_artifact_haggle
				scope:attempted_artifact_haggle = flag:success
			}
			add_gold = scope:artifact_to_sell.var:1020_artifact_sell_high_value
		}
		else_if = {
			limit = {
				exists = scope:attempted_artifact_haggle
				scope:attempted_artifact_haggle = flag:failure
			}
			add_gold = scope:artifact_to_sell.var:1020_artifact_sell_low_value
		}
		else = { add_gold = scope:artifact_to_sell.var:1020_artifact_sell_value }
	}
	#Set the artifact owner
	if = {
		limit = { 
			scope:artifact_to_sell = { is_unique = yes }
		}
		#Destroy unique artifacts so they don't get stuck with the Pool People
		hidden_effect = { destroy_artifact = scope:artifact_to_sell }
	}
	else = { set_owner = scope:laamp_artifact_peddler }
}


#Actual sell screen
ep3_laamp_decision_event.1021 = {
	type = character_event
	window = visit_settlement_window
	title = {
		first_valid = {
			#Haggle Success
			triggered_desc = {
				trigger = { scope:attempted_artifact_haggle ?= flag:success }
				desc = ep3_laamp_decision_event.1021.t_success 
			}
			#Haggle Failure
			triggered_desc = {
				trigger = { scope:attempted_artifact_haggle ?= flag:failure }
				desc = ep3_laamp_decision_event.1021.t_failure
			}
			desc = ep3_laamp_decision_event.1021.t
		}
	}	
	desc = {
		first_valid = {
			#FIRST TIME: Haggle Success
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:did_not_sell_haggled_artifact }
					scope:attempted_artifact_haggle ?= flag:success
				}
				desc = ep3_laamp_decision_event.1021.desc_success
			}
			#FIRST TIME: Haggle Failure
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:did_not_sell_haggled_artifact }
					scope:attempted_artifact_haggle ?= flag:failure
				}
				desc = ep3_laamp_decision_event.1021.desc_failure
			}
			#FIRST TIME: Generic first-strings 
			random_valid = {
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
					}
					desc = ep3_laamp_decision_event.1021.desc_moment_of_purchase_01
				}
				triggered_desc = { 
					trigger = { 
						NOT = { exists = scope:did_not_sell_artifact }
					}
					desc = ep3_laamp_decision_event.1021.desc_moment_of_purchase_02
				}
			}
			#RETURN: Same as the generic first-strings
			random_valid = {
				triggered_desc = { 
					trigger = {
						NOT = { has_variable = 1021_artifact_sell_screen }
					}
					desc = ep3_laamp_decision_event.1021.desc_moment_of_purchase_01
				}
				triggered_desc = { 
					trigger = {
						NOT = { has_variable = 1021_artifact_sell_screen }
					}
					desc = ep3_laamp_decision_event.1021.desc_moment_of_purchase_02
				}
			}	
			#RETURN: Same as the return-strings in ep3_laamp_decision_event.1020
			random_valid = {
				triggered_desc = { 
					trigger = {
						OR = {
							exists = scope:did_not_sell_haggled_artifact
							exists = scope:did_not_sell_artifact
						}
					}
					desc = ep3_laamp_decision_event.1020.desc_intro_returned_01
				}
				triggered_desc = { 
					trigger = {
						OR = {
							exists = scope:did_not_sell_haggled_artifact
							exists = scope:did_not_sell_artifact
						}
					}
					desc = ep3_laamp_decision_event.1020.desc_intro_returned_02
				}
			}	
		}	
	}
	theme = stewardship
	override_background = { reference = ep2_village_festival }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#Outraged
		triggered_animation = {
			trigger = { exists = scope:1020_outraged_partner }
			animation = rage
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_friendly_traits = yes } 
			}
			animation = personality_forgiving
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_commerce_traits = yes } 
			}
			animation = personality_greedy
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_uninterested_traits = yes } 
			}
			animation = personality_cynical
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_irrational_traits = yes } 
			}
			animation = personality_irrational
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_standoffish_traits = yes } 
			}
			animation = personality_coward
		}
		animation = personality_compassionate
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				exists = scope:attempted_artifact_haggle
				scope:attempted_artifact_haggle = flag:failure
			}
			animation = shame
		}
		triggered_animation = {
			trigger = {
				can_laamp_sell_eagle_trigger = yes
			}
			animation = hunting_falcon
		}
		animation = thinking
	}
	right_portrait = {
		character = scope:laamp_artifact_peddler
		triggered_animation = {
			trigger = { exists = scope:attempted_artifact_haggle }
			animation = disapproval
		}
		animation = steward
	}
	artifact = {
		trigger = { exists = scope:1020_first_artifact_to_sell }
		target = scope:1020_first_artifact_to_sell
		position = lower_left_portrait
	}
	artifact = {
		trigger = { exists = scope:1020_second_artifact_to_sell }
		target = scope:1020_second_artifact_to_sell
		position = lower_center_portrait
	}
	artifact = {
		trigger = { exists = scope:1020_third_artifact_to_sell }
		target = scope:1020_third_artifact_to_sell
		position = lower_right_portrait
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
	}
	#Sell artifact #1
	option = {
		name = ep3_laamp_decision_event.1021.a
		#Sell the artifact, price depending on if you haggled or not etc
		scope:1020_first_artifact_to_sell = { ep3_laamp_decision_1021_sell_artifact_effect = yes }
		#Set correct variables and reroute us to main square
		1020_sold_artifact_effect = yes
	}
	#Sell artifact #2
	option = {
		name = ep3_laamp_decision_event.1021.b
		trigger = { exists = scope:1020_second_artifact_to_sell }
		#Sell the artifact, price depending on if you haggled or not etc
		scope:1020_second_artifact_to_sell = { ep3_laamp_decision_1021_sell_artifact_effect = yes }
		#Set correct variables and reroute us to main square
		1020_sold_artifact_effect = yes
	}
	#Sell artifact #3
	option = {
		name = ep3_laamp_decision_event.1021.c
		trigger = { exists = scope:1020_third_artifact_to_sell }
		#Sell the artifact, price depending on if you haggled or not etc
		scope:1020_third_artifact_to_sell = { ep3_laamp_decision_1021_sell_artifact_effect = yes }
		#Set correct variables and reroute us to main square
		1020_sold_artifact_effect = yes
	}
	option = {
		name = ep3_laamp_decision_event.1021.eagle
		trigger = {
			can_laamp_sell_eagle_trigger = yes
		}
		#Sell eagle :(
		add_character_flag = is_selling_eagle_flag
		show_as_tooltip = {
			sell_eagle_effect = {
				PRICE = hunting_eagle_sell_value
				RECIPIENT = scope:laamp_artifact_peddler
				SELLER = root
			}
		}

		#Stress
		stress_impact = {
			base = minor_stress_impact_gain
			greedy = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			loyal = minor_stress_impact_gain
		}

		#Set correct variables and reroute us to main square
		1020_sold_artifact_effect = yes
		
		ai_chance = {
			base = 15 # No one is really doing this unless they're giga broke
			modifier = {
				factor = 1.7
				short_term_gold <= 5
			}
			modifier = {
				add = 1.2
				has_character_modifier = weak_eagle_modifier
			}
			modifier = {
				add = 1.5
				has_character_modifier = very_weak_eagle_modifier
			}
			modifier = {
				add = 1.5
				eagle_is_old_trigger = yes
			}
			modifier = {
				add = 0.75
				OR = {
					has_character_modifier = strong_eagle_modifier
					has_eagle_personality_trait_trigger = yes
				}
			}
			ai_value_modifier = {
				ai_greed = 0.5
				ai_compassion = -0.5
			}
		}
	}
	#I've changed my mind
	option = {
		name = {
			text = {
				first_valid = {
					#Go back to main
					triggered_desc = { 
						trigger = { exists = scope:attempted_artifact_haggle }
						desc = ep3_laamp_decision_event.1020.d
					}
					#Go back to the previous screen
					desc = ep3_laamp_decision_event.1021.d
				}
			}
		}
		#For desc flavor
		if = {
			#We came through here the first time
			limit = {
				NOT = { exists = scope:did_not_sell_artifact }
			}
			save_scope_as = did_not_sell_artifact
		}
		#We came through here via haggling
		if = {
			limit = { exists = scope:attempted_artifact_haggle }
			if = {
				limit = {
					NOT = { exists = scope:did_not_sell_haggled_artifact }
				}
				save_scope_as = did_not_sell_haggled_artifact
			}
			#Go back to main
			custom_tooltip = ep3_laamp_decision_event.return.tt
			trigger_event = ep3_laamp_decision_event.1000
		}
		else = {
			#Go back to the previous screen
			trigger_event = ep3_laamp_decision_event.1020
		}
	}
	after = {
		#For loc
		if = {
			limit = {
				NOT = { has_variable = 1021_artifact_sell_screen }
			}
			set_variable = 1021_artifact_sell_screen
		}
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:artifact_peddler }
		hidden_effect = {
			# Put eagle selling option on cooldown
			if = {
				limit = {
					has_available_eagle_trigger = yes
				}
				add_character_flag = {
					flag = cant_sell_eagle
					months = 6
				} 
			}
			# Actually sell the eagle if applicable
			if = {
				limit = {
					has_character_flag = is_selling_eagle_flag
				}
				sell_eagle_effect = {
					PRICE = hunting_eagle_sell_value
					RECIPIENT = scope:laamp_artifact_peddler
					SELLER = root
				}
				remove_character_flag = is_selling_eagle_flag
			}
		}
	}
}


######################################################################
# TOWN CRIER
# ep3_laamp_decision_event.1025
######################################################################

#For hubs. All events that use this need to account for loc in relation to the value being 0, 1, or 2 (e.g. scope:church_grounds_loc_tracker ?= 0 )
scripted_effect 1025_set_and_check_hub_loc_tracker_scope_effect = {
	if = {
		limit = {
			NOT = { exists = scope:$HUB$_loc_tracker }	#e.g. scope:church_grounds_loc_tracker
		}
		save_scope_value_as = {
			name = $HUB$_loc_tracker
			value = 0
		}
	}
	else_if = {
		limit = { scope:$HUB$_loc_tracker ?= 2 }
		save_scope_value_as = {
			name = $HUB$_loc_tracker
			value = 0
		}
	}
	else_if = {
		limit = { scope:$HUB$_loc_tracker ?= 0 }
		save_scope_value_as = {
			name = $HUB$_loc_tracker
			value = 1
		}
	}
	else = {
		save_scope_value_as = {
			name = $HUB$_loc_tracker
			value = 2
		}			
	}
}

#Technically these could be rolled into the HUB variant if we add a 3rd random loc for all current SCENEs
#For scenes. All events that use this need to account for loc in relation to the value being 0 or 1 (e.g. scope:weaponsmith_loc_tracker ?= 0 )
scripted_effect 1025_set_and_check_scene_loc_tracker_scope_effect = {
	if = {
		limit = {
			NOT = { exists = scope:$SCENE$_loc_tracker }	#e.g. scope:weaponsmith_loc_tracker
		}
		save_scope_value_as = {
			name = $SCENE$_loc_tracker
			value = 0
		}
	}
	else_if = {
		limit = { scope:$SCENE$_loc_tracker ?= 1 }
		save_scope_value_as = {
			name = $SCENE$_loc_tracker
			value = 0
		}
	}
	else = {
		save_scope_value_as = {
			name = $SCENE$_loc_tracker
			value = 1
		}			
	}
}

#Set the correct variable to block off the Contract option and remove the desc flavor variable
scripted_effect 1025_finished_contract_effect = {
	#Set up the cooldown for the contract action
	set_variable = {
		name = 1025_has_contracted_recently
		days = visit_settlement_minimum_cooldown_days
	}
	#We're done here
	save_scope_value_as = { 
		name = laamp_decision_has_contracted 
		value = flag:yes	
	}
	#Go back to the main event
	hidden_effect = { 1001_return_to_second_effect = yes }
}

#Used in enough places
scripted_effect 1025_save_random_county_province_effect = {
	random_county_in_region = {
		region = $REGION$
		random_county_province = { save_scope_as = contract_province }	
	}
}

#Not too far away... Should probably be revisited sometime in the future. Use distance instead?
scripted_effect 1025_set_contract_location_effect = {
	random_list = {
		#North Europe
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_europe_north }
			}
			1025_save_random_county_province_effect = { REGION = world_europe_north }
		}
		#West Europe
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_europe_west }
			}
			1025_save_random_county_province_effect = { REGION = world_europe_west }
		}
		#East Europe
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_europe_east }
			}
			1025_save_random_county_province_effect = { REGION = world_europe_east }
		}
		#South Europe
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_europe_south }
			}
			1025_save_random_county_province_effect = { REGION = world_europe_south }
		}
		#Middle East
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_middle_east }
			}
			1025_save_random_county_province_effect = { REGION = world_middle_east }
		}
		#India
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_india }
			}
			1025_save_random_county_province_effect = { REGION = world_india }
		}
		#North Africa
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_africa_north }
			}
			1025_save_random_county_province_effect = { REGION = world_africa_north }
		}
		#West Africa
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_africa_west }
			}
			1025_save_random_county_province_effect = { REGION = world_africa_west }
		}
		#East Africa
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_africa_east }
			}
			1025_save_random_county_province_effect = { REGION = world_africa_east }
		}
		#Sahara
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_africa_sahara }
			}
			1025_save_random_county_province_effect = { REGION = world_africa_sahara }
		}
		#Siberia
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_siberia }
			}
			1025_save_random_county_province_effect = { REGION = world_siberia }
		}
		#West Steppe
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_steppe_west }
			}
			1025_save_random_county_province_effect = { REGION = world_steppe_west }
		}
		#Central Steppe
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_steppe_central }
			}
			1025_save_random_county_province_effect = { REGION = world_steppe_central }
		}
		#East Steppe
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_steppe_east }
			}
			1025_save_random_county_province_effect = { REGION = world_steppe_east }
		}
		#Tarim
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_steppe_tarim }
			}
			1025_save_random_county_province_effect = { REGION = world_steppe_tarim }
		}
		#Tibet
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_tibet }
			}
			1025_save_random_county_province_effect = { REGION = world_tibet }
		}
		# Burma
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_burma }
			}
			1025_save_random_county_province_effect = { REGION = world_burma }
		}
		# Mainland SE Asia
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_asia_southeast_mainland }
			}
			1025_save_random_county_province_effect = { REGION = world_asia_southeast_mainland }
		}
		# Maritime SE Asia
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_asia_southeast_islands }
			}
			1025_save_random_county_province_effect = { REGION = world_asia_southeast_islands }
		}
		#China
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_asia_china }
			}
			1025_save_random_county_province_effect = { REGION = world_asia_china }
		}
		#Japan
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_asia_japan }
			}
			1025_save_random_county_province_effect = { REGION = world_asia_japan }
		}
		#Korea
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_asia_korea }
			}
			1025_save_random_county_province_effect = { REGION = world_asia_korea }
		}
		#Sakhalin-Hokkaido
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_asia_sakhalin_hokkaido }
			}
			1025_save_random_county_province_effect = { REGION = world_asia_sakhalin_hokkaido }
		}
		#North East Asia
		10 = {
			trigger = {
				scope:visiting_location = { geographical_region = world_asia_north_east }
			}
			1025_save_random_county_province_effect = { REGION = world_asia_north_east }
		}
	}	
}

#Set contract type
scripted_effect 1025_randomize_and_remember_contract_type_effect = {
	#Find an employer to check the trigger against
	scope:visiting_location.county = {
		holder ?= {
			if = {
				limit = { 1025_is_appropriate_landed_contract_employer_trigger = yes }
				add_to_temporary_list = potential_contract_employers
			}
			every_vassal_or_below ?= {
				limit = { 1025_is_appropriate_landed_contract_employer_trigger = yes }
				add_to_temporary_list = potential_contract_employers 
			}	
			top_liege ?= {
				if = {
					limit = { 1025_is_appropriate_landed_contract_employer_trigger = yes }
					add_to_temporary_list = potential_contract_employers
				}
				every_vassal_or_below ?= {
					limit = { 1025_is_appropriate_landed_contract_employer_trigger = yes }
					add_to_temporary_list = potential_contract_employers 
				}	
			}
		}
		every_neighboring_county ?= { 
			holder ?= {
				if = {
					limit = { 1025_is_appropriate_landed_contract_employer_trigger = yes }
				}
				add_to_temporary_list = potential_contract_employers
				every_vassal_or_below ?= {
					limit = { 1025_is_appropriate_landed_contract_employer_trigger = yes }
					add_to_temporary_list = potential_contract_employers 
				}
				top_liege ?= {
					if = {
						limit = { 1025_is_appropriate_landed_contract_employer_trigger = yes }
						add_to_temporary_list = potential_contract_employers
					}
					every_vassal_or_below ?= {
						limit = { 1025_is_appropriate_landed_contract_employer_trigger = yes }
						add_to_temporary_list = potential_contract_employers 
					}	
				}
			}	
		}
	}
	#Pick actual contract groups
	random_list = {
		#Nothing at all!
		10 = { 
			modifier = {
				1000_is_a_nomadic_holding_trigger = yes
				factor = 2
			}
			modifier = {
				num_offered_task_contracts > 5
				add = 20
			}
			modifier = {
				num_offered_task_contracts > 10
				add = 20
			}
			#No contracts
		}
		#Treasure Map
		5 = {
			#Do we already have a treasure map contract?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:treasure_map_contract }
					}
					trigger_else = { always = no }
					#Do we already have an active Treasure Map contract?
					any_character_artifact = { has_variable = 1025_treasure_map }
					any_character_task_contract = { task_contract_type = laamp_treasure_map_contract }
					#Are we on cooldown?
					has_variable = 1025_had_treasure_map_contract_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:treasure_map_contract } 
				}
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:treasure_map_contract
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:treasure_map_contract
			}
		}
		#Legendary Contract
		5 = {
			#Did we spawn a legendary contract recently?
			trigger = {
				prestige_level >= tier_kingdom
				1025_can_create_legendary_contract_trigger = yes
				NOR = { 
					#Are we on cooldown?
					has_variable = 1025_had_legendary_contract_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:legendary_contract } 
				}
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:legendary_contract
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:legendary_contract
			}
			#Yes, I will whack you with a double cooldown on legendaries. It's shorter if you don't pick the option though
			set_variable = {
				name = 1025_had_legendary_contract_recently
				days = visit_settlement_minimum_cooldown_days
			}
		}
		#Transport Contracts
		20 = {
			#Did we spawn transport contracts recently?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:transport_contracts }
					}
					trigger_else = { always = no }
					#Are we on cooldown?
					has_variable = 1025_had_transport_contracts_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:transport_contracts } 
				}
				#Can we actually spawn any transport contracts?
				any_in_List = {
					list = potential_contract_employers
					save_temporary_scope_as = considered_employer
					can_create_transport_contract_trigger = { LAAMP = root EMPLOYER = scope:considered_employer }
				} 
			}
			#More transports for the baggage train
			modifier = {
				domicile ?= { has_domicile_building = baggage_train_01 }
				factor = 2
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:transport_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:transport_contracts
			}
		}
		#Criminal Contracts
		20 = {
			#Did we spawn criminal contracts recently?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:criminal_contracts }
					}
					trigger_else = { always = no }
					#Are we on cooldown?
					has_variable = 1025_had_criminal_contracts_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:criminal_contracts } 
				}
				#Can we actually spawn any criminal contracts?
				any_in_list = {
					list = potential_contract_employers
					save_temporary_scope_as = considered_employer
					can_create_criminal_contract_trigger = { LAAMP = root EMPLOYER = scope:considered_employer }
				} 
			}
			#More criminals... if corrupt location
			modifier = {
				scope:visiting_location.county = { has_county_corruption_trigger = yes }
				add = 10
			}
			modifier = {
				scope:visiting_location.county = { county_control <= 50 }
				add = 10
			}
			#Are you actually looking for criminal contracts?
			modifier = {
				has_trait = honest
				factor = 0.5
			}
			modifier = {
				has_trait = deceitful
				factor = 2
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:criminal_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:criminal_contracts
			}
		}
		#Justicar Contracts
		20 = { 
			#Did we spawn justicar contracts recently?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:justicar_contracts }
					}
					trigger_else = { always = no }
					#Are we on cooldown?
					has_variable = 1025_had_justicar_contracts_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:justicar_contracts } 
				}
				#Can we actually spawn any justicar contracts?
				any_in_list = {
					list = potential_contract_employers
					save_temporary_scope_as = considered_employer
					can_create_justicar_contract_trigger = { LAAMP = root EMPLOYER = scope:considered_employer }
				}
			}
			#More criminals... if corrupt location
			modifier = {
				scope:visiting_location.county = { has_county_corruption_trigger = yes }
				add = 10
			}
			modifier = {
				scope:visiting_location.county = { county_control <= 50 }
				add = 10
			}
			#You're pretty law-abiding?
			modifier = {
				OR = {
					has_trait = honest
					has_trait = just
					has_trait = gallant
					has_focus = martial_chivalry_focus
				}
				factor = 2
			}
			modifier = {
				has_trait = deceitful
				factor = 0.5
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:justicar_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:justicar_contracts
			}
		}
		#Hireling Contracts
		20 = { 
			#Did we spawn hireling contracts recently?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:hireling_contracts }
					}
					trigger_else = { always = no }
					#Are we on cooldown?
					has_variable = 1025_had_hireling_contracts_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:hireling_contracts } 
				}
				#Can we actually spawn any hireling contracts?
				any_in_list = {
					list = potential_contract_employers
					save_temporary_scope_as = considered_employer
					can_create_hireling_contract_trigger = { LAAMP = root EMPLOYER = scope:considered_employer }
				} 
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:hireling_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:hireling_contracts
			}
		}
		#Diplomacy Contracts
		20 = { 
			#Did we spawn diplomacy contracts recently?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:diplomacy_contracts }
					}
					trigger_else = { always = no }
					#Are we on cooldown?
					has_variable = 1025_had_diplomacy_contracts_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:diplomacy_contracts } 
				}
				#Can we actually spawn any diplomacy contracts?
				any_in_list = {
					list = potential_contract_employers
					save_temporary_scope_as = considered_employer
					can_create_diplomacy_contract_trigger = { LAAMP = root EMPLOYER = scope:considered_employer }
				} 
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:diplomacy_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:diplomacy_contracts
			}
		}
		#Stewardship Contracts
		20 = { 
			#Did we spawn stewardship contracts recently?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:stewardship_contracts }
					}
					trigger_else = { always = no }
					#Are we on cooldown?
					has_variable = 1025_had_stewardship_contracts_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:stewardship_contracts }
				}
				#Can we actually spawn any stewardship contracts?
				any_in_list = {
					list = potential_contract_employers
					save_temporary_scope_as = considered_employer
					can_create_stewardship_contract_trigger = { LAAMP = root EMPLOYER = scope:considered_employer }
				}
			}
			#More organization in highly developed areas
			modifier = {
				scope:visiting_location.county = { development_level > bad_development_level }
				add = 10
			}
			modifier = {
				scope:visiting_location.county = { development_level > medium_development_level }
				add = 10
			}
			#You're shrewd?
			modifier = {
				OR = {
					has_trait = governor
					has_trait = diligent
					has_trait = administrator
				}
				factor = 2
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:stewardship_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:stewardship_contracts
			}
		}
		#Learning Contracts
		20 = { 
			#Did we spawn learning contracts recently?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:learning_contracts }
					}
					trigger_else = { always = no }
					#Are we on cooldown?
					has_variable = 1025_had_learning_contracts_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:learning_contracts } 
				}
				#Can we actually spawn any learning contracts?
				any_in_list = {
					list = potential_contract_employers
					save_temporary_scope_as = considered_employer
					can_create_learning_contract_trigger = { LAAMP = root EMPLOYER = scope:considered_employer }
				}
			}
			modifier = {
				scope:visiting_location.county = { development_level > medium_development_level }
				add = 10
			}
			modifier = {
				scope:visiting_location = { 
					OR = {
						has_holding_type = church_holding
						has_holding_type = temple_citadel_holding
					}
				}
				add = 10
			}
			#You're... academic?
			modifier = {
				has_trait = scholar
				factor = 2
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:learning_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:learning_contracts
			}
		}
		#Intrigue Contracts
		20 = { 
			#Did we spawn intrigue contracts recently?
			trigger = {
				NOR = {
					#Is this contract type already saved from our last visit?
					trigger_if = {
						limit = { 1025_location_has_a_saved_contract_type_trigger = yes }
						1025_saved_location_contract_type_matches_this_type_trigger = { CONTRACT_TYPE_FLAG = flag:intrigue_contracts }
					}
					trigger_else = { always = no }
					#Are we on cooldown?
					has_variable = 1025_had_intrigue_contracts_recently
					#Has this contract type already been assigned to another contract scope this visit?
					1025_contract_type_is_assigned_trigger = { CONTRACT_TYPE_FLAG = flag:intrigue_contracts }
				}
				#Can we actually spawn any intrigue contracts?
				any_in_list = {
					list = potential_contract_employers
					save_temporary_scope_as = considered_employer
					can_create_intrigue_contract_trigger = { LAAMP = root EMPLOYER = scope:considered_employer }
				}
			}
			modifier = {
				scope:visiting_location = { 
					OR = {
						has_holding_type = church_holding
						has_holding_type = temple_citadel_holding
					}
				}
				add = 10
			}
			#You're... schemer?
			modifier = {
				has_trait = schemer
				factor = 2
			}
			#Set the type
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:intrigue_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			set_variable = {
				name = 1025_$NUM$_contract_desc
				value = flag:intrigue_contracts
			}
		}
		#Add more contract types below VV
	}
	scope:visiting_location = {
		#Clean up any old variables
		if = {
			limit = { has_variable = 1025_saved_$NUM$_contract_type }
			remove_variable = 1025_saved_$NUM$_contract_type
		}
		#We will not be saving legendary contracts as those are more volatile (does employer still exist? etc)
		if = {
			limit = { scope:1025_$NUM$_contract ?= flag:legendary_contract }
			#Nothing
		}
		else_if = {
			limit = { exists = scope:1025_$NUM$_contract }
			#Remember this to avoid decision-scumming
			set_variable = {
				name = 1025_saved_$NUM$_contract_type #i.e. 1025_saved_first_contract_type
				value = scope:1025_$NUM$_contract #i.e. flag:treasure_map_contract
				days = visit_settlement_minimum_cooldown_days
			}
		}
		else = {
			save_scope_value_as = {
				name = 1025_$NUM$_no_contract
				value = flag:no_contract
			}
			#Remember this to avoid decision-scumming
			set_variable = {
				name = 1025_saved_$NUM$_contract_type
				value = scope:1025_$NUM$_no_contract
				days = visit_settlement_minimum_cooldown_days
			}
		}
	}	
}

#Do we need an employer?
scripted_effect 1025_generate_employer_effect = {
	#Treasure Map
	if = {
		limit = { scope:1025_$NUM$_contract = flag:treasure_map_contract }
		#Find an employer for the treasure map contract
		random_pool_character = {
			province = scope:visiting_location
			limit = {
				1025_is_old_and_unable_trigger = yes
				1025_appropriate_contract_employer_trigger = yes
			}
			save_scope_as = 1025_$NUM$_contract_employer
		}
		#Or create someone
		if = {
			limit = {
				NOT = { exists = scope:1025_$NUM$_contract_employer }
			}
			create_character = {
				template = generic_peasant_character
				age = { 50 70 }
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				save_scope_as = 1025_$NUM$_contract_employer
			}
			scope:1025_$NUM$_contract_employer = {
				random_list = {
					10 = { add_trait = blind }
					10 = { add_trait = one_legged }
					10 = { add_trait = one_eyed }
					10 = { add_trait = infirm }
					10 = { add_trait = wounded_2 }
				}
			}
		}
	}
}

#This is where the lagg-ic happens... Probably needs revisiting later on.
scripted_effect 1025_find_ruler_and_spawn_legendary_contract_effect = { 
	#Saves us a scope:employing_ruler
	random_county_in_region = {
		region = $REGION$
		limit = { 1025_region_has_suitable_employer_trigger = yes }
		save_scope_as = contract_county
		#Find the ruler
		scope:contract_county.holder = { save_scope_as = employing_ruler }
	}
	#Legendary... contracts?
	random_list = {
		#Raid
		10 = {
			trigger = {
				can_create_task_contract = {
					type_name = laamp_raid_contract
					employer = scope:employing_ruler
				}
			}
			create_task_contract = {
				task_contract_type = laamp_raid_contract
				location = scope:employing_ruler.capital_province
				task_contract_employer = scope:employing_ruler
				task_contract_tier = task_contract_t3_value #Legendary!
				save_scope_as = 1025_legendary_contract
			}
		}
		10 = {
			trigger = {
				can_create_task_contract = {
					type_name = laamp_steal_artifact_contract
					employer = scope:employing_ruler
				}
			}
			create_task_contract = {
				task_contract_type = laamp_steal_artifact_contract
				location = scope:employing_ruler.capital_province
				task_contract_employer = scope:employing_ruler
				task_contract_tier = task_contract_t3_value #Legendary!
				save_scope_as = 1025_legendary_contract
			}
		}
		10 = {
			trigger = {
				can_create_task_contract = {
					type_name = laamp_treasure_hunting_contract
					employer = scope:employing_ruler
				}
			}
			create_task_contract = {
				task_contract_type = laamp_treasure_hunting_contract
				location = scope:employing_ruler.capital_province
				task_contract_employer = scope:employing_ruler
				task_contract_tier = task_contract_t3_value #Legendary!
				save_scope_as = 1025_legendary_contract
			}
		}
		10 = {
			trigger = {
				can_create_task_contract = {
					type_name = laamp_transport_vip
					employer = scope:employing_ruler
				}
			}
			create_task_contract = {
				task_contract_type = laamp_transport_vip
				location = scope:employing_ruler.capital_province
				task_contract_employer = scope:employing_ruler
				task_contract_tier = task_contract_t3_value #Legendary!
				save_scope_as = 1025_legendary_contract
			}
		}
		10 = {
			trigger = {
				can_create_task_contract = {
					type_name = laamp_transport_artifact
					employer = scope:employing_ruler
				}
			}
			create_task_contract = {
				task_contract_type = laamp_transport_artifact
				location = scope:employing_ruler.capital_province
				task_contract_employer = scope:employing_ruler
				task_contract_tier = task_contract_t3_value #Legendary!
				save_scope_as = 1025_legendary_contract
			}
		}
		10 = {
			trigger = {
				can_create_task_contract = {
					type_name = laamp_transport_gold
					employer = scope:employing_ruler
				}
			}
			create_task_contract = {
				task_contract_type = laamp_transport_gold
				location = scope:employing_ruler.capital_province
				task_contract_employer = scope:employing_ruler
				task_contract_tier = task_contract_t3_value #Legendary!
				save_scope_as = 1025_legendary_contract
			}
		}
		10 = {
			trigger = {
				can_create_task_contract = {
					type_name = laamp_transport_animal
					employer = scope:employing_ruler
				}
			}
			create_task_contract = {
				task_contract_type = laamp_transport_animal
				location = scope:employing_ruler.capital_province
				task_contract_employer = scope:employing_ruler
				task_contract_tier = task_contract_t3_value #Legendary!
				save_scope_as = 1025_legendary_contract
			}
		}
	}
	scope:1025_legendary_contract = {
		set_variable = {
			name = retain_despite_distance
			value = yes
		}
	}
}

#Spawn the actual contracts
scripted_effect 1025_option_picked_spawn_contract_effect = {
	#Treasure Map
	switch = {
		trigger = scope:1025_$NUM$_contract
		flag:treasure_map_contract = {
			hidden_effect = {
				#Create treasure map contract
				create_task_contract = {
					task_contract_type = laamp_treasure_map_contract
					location = scope:visiting_location
					task_contract_employer = scope:1025_$NUM$_contract_employer
					task_contract_tier = scope:1025_$NUM$_contract_employer.task_contract_tier_value
					save_scope_as = 1025_treasure_map_contract
				}
				scope:1025_treasure_map_contract ?= {
					#Pick treasure location
					1025_set_contract_location_effect = yes
					#Save location on contract
					if = {
						limit = { exists = scope:contract_province }
						set_variable = {
							name = contract_treasure_location
							value = scope:contract_province
						}
					}
					#Fallback
					else = {
						random_county_in_region = {
							region = world_asia_minor #Something something Bosnia
							random_county_province = { save_scope_as = treasure_province }	
						}
						set_variable = {
							name = contract_treasure_location
							value = scope:treasure_province
						}
					}
					#Save the pick-up location
					set_variable = {
						name = contract_picked_up_in_location
						value = scope:visiting_location
					}
				}
			}
			#What do you mean _in your face_ :c
			scope:1025_treasure_map_contract = {
				open_view_data = {
					view = task_contract
					player = root
				}
			}
		}
		#Legendary Contract
		flag:legendary_contract = {
			hidden_effect = { #Comment out this hidden_effect = { ... } to better survey what contracts become available while debugging
				#North Europe
				if = {
					limit = {
						scope:visiting_location = { geographical_region = world_europe_north }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_europe_north }
				}
				#West Europe
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_europe_west }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_europe_west }
				}
				#East Europe
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_europe_east }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_europe_east }
				}
				#South Europe
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_europe_south }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_europe_south }
				}
				#Middle East
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_middle_east }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_middle_east }
				}
				#India
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_india }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_india }
				}
				#North Africa
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_africa_north }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_africa_north }
				}
				#West Africa
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_africa_west }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_africa_west }
				}
				#East Africa
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_africa_east }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_africa_east }
				}
				#West Steppe
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_steppe_west }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_steppe_west }
				}
				#East Steppe
				else_if = {
					limit = {
						scope:visiting_location = { geographical_region = world_steppe_east }
					}
					1025_find_ruler_and_spawn_legendary_contract_effect = { REGION = world_steppe_east }
				}
				#YOLO
				else = {
					random_ruler = {
						limit = {
							save_temporary_scope_as = ruler_check
							valid_laamp_basic_trigger = {
								EMPLOYER = scope:ruler_check
								LAAMP = root
							}
						}
						save_scope_as = employing_ruler
					}
				}
			}
			#What do you mean _in your face_ :c
			scope:1025_legendary_contract ?= {
				open_view_data = {
					view = task_contract
					player = root
				}
			}
		}
		#Transport Contracts
		flag:transport_contracts = {
			hidden_effect = {
				populate_task_contracts_for_area = {
					location = scope:visiting_location
					amount = num_contracts_spawned_value
					group = { laamp_contracts_transport_group }
				}
			}	
		}
		#Criminal Contracts
		flag:criminal_contracts = {
			hidden_effect = {
				populate_task_contracts_for_area = {
					location = scope:visiting_location
					amount = num_contracts_spawned_value
					group = { laamp_contracts_criminal_group }
				}
			}	
		}
		#Justicar Contracts
		flag:justicar_contracts = {
			hidden_effect = {
				populate_task_contracts_for_area = {
					location = scope:visiting_location
					amount = num_contracts_spawned_value
					group = { laamp_contracts_justicar_group }
				}
			}	
		}
		#Hireling Contracts
		flag:hireling_contracts = {
			hidden_effect = {
				populate_task_contracts_for_area = {
					location = scope:visiting_location
					amount = num_contracts_spawned_value
					group = { laamp_contracts_hireling_group laamp_contracts_martial_group } #Stashing martial here, for now
				}
			}	
		}
		#Diplomacy Contracts
		flag:diplomacy_contracts = {
			hidden_effect = {
				populate_task_contracts_for_area = {
					location = scope:visiting_location
					amount = num_contracts_spawned_value
					group = { laamp_contracts_diplomacy_group }
				}
			}	
		}
		#Stewardship Contracts
		flag:stewardship_contracts = { 
			hidden_effect = {
				populate_task_contracts_for_area = {
					location = scope:visiting_location
					amount = num_contracts_spawned_value
					group = { laamp_contracts_stewardship_group }
				}
			}	
		}
		#Learning Contracts
		flag:learning_contracts = { 
			hidden_effect = {
				populate_task_contracts_for_area = {
					location = scope:visiting_location
					amount = num_contracts_spawned_value
					group = { laamp_contracts_learning_group }
				}
			}	
		}
		#Intrigue Contracts
		flag:intrigue_contracts = {
			hidden_effect = {
				populate_task_contracts_for_area = {
					location = scope:visiting_location
					amount = num_contracts_spawned_value
					group = { laamp_contracts_intrigue_group }
				}
			}	
		}
		#Add more contract types below VV
	}
}

#Set up the tooltip, cooldown and prestige cost
scripted_effect 1025_option_tooltip_and_cooldown_contract_type_effect = {
	#Contract stuff
	switch = {
		trigger = scope:1025_$NUM$_contract
		#Treasure Map
		flag:treasure_map_contract = {
			custom_tooltip = ep3_laamp_decision_event.1025.treasure_map_contract_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_treasure_map_contract_recently
				days = visit_settlement_large_cooldown_days
			}
			#Prestige cost
			add_prestige = minor_prestige_loss
		}
		#Legendary Contract
		flag:legendary_contract = {
			custom_tooltip = ep3_laamp_decision_event.1025.legendary_contract_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_legendary_contract_recently
				days = visit_settlement_large_cooldown_days
			}
			#Prestige cost
			add_prestige = medium_prestige_loss
		}
		#Transport Contracts
		flag:transport_contracts = {
			custom_tooltip = ep3_laamp_decision_event.1025.transport_contracts_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_transport_contracts_recently
				days = visit_settlement_cooldown_days
			}
			#Prestige cost
			add_prestige = minor_prestige_loss
		}
		#Criminal Contracts
		flag:criminal_contracts = {
			custom_tooltip = ep3_laamp_decision_event.1025.criminal_contracts_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_criminal_contracts_recently
				days = visit_settlement_cooldown_days
			}
			#No prestige cost
		}
		#Justicar Contracts
		flag:justicar_contracts = {
			custom_tooltip = ep3_laamp_decision_event.1025.justicar_contracts_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_justicar_contracts_recently
				days = visit_settlement_cooldown_days
			}
			#Prestige cost
			add_prestige = minor_prestige_loss
		}
		#Hireling Contracts
		flag:hireling_contracts = {
			custom_tooltip = ep3_laamp_decision_event.1025.hireling_contracts_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_hireling_contracts_recently
				days = visit_settlement_cooldown_days
			}
			#Prestige cost
			add_prestige = minor_prestige_loss
		}
		#Diplomacy Contracts
		flag:diplomacy_contracts = {
			custom_tooltip = ep3_laamp_decision_event.1025.diplomacy_contracts_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_diplomacy_contracts_recently
				days = visit_settlement_cooldown_days
			}
			#Prestige cost
			add_prestige = minor_prestige_loss
		}
		#Stewardship Contracts
		flag:stewardship_contracts = {
			custom_tooltip = ep3_laamp_decision_event.1025.stewardship_contracts_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_stewardship_contracts_recently
				days = visit_settlement_cooldown_days
			}
			#Prestige cost
			add_prestige = minor_prestige_loss
		}
		#Learning Contracts
		flag:learning_contracts = {
			custom_tooltip = ep3_laamp_decision_event.1025.learning_contracts_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_learning_contracts_recently
				days = visit_settlement_cooldown_days
			}
			#Prestige cost
			add_prestige = minor_prestige_loss
		}
		#Intrigue Contracts
		flag:intrigue_contracts = {
			custom_tooltip = ep3_laamp_decision_event.1025.intrigue_contracts_tt
			#Set up the cooldown for the contract type
			set_variable = {
				name = 1025_had_intrigue_contracts_recently
				days = visit_settlement_cooldown_days
			}
			#Prestige cost
			add_prestige = minor_prestige_loss
		}
		#Add more contract types below VV
	}	
}

#Remember, remember (... but not legendary contracts)
scripted_effect 1025_translate_variable_into_flag_effect = {
	scope:visiting_location = {
		#The Nothingness
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:no_contract }
			#Nothing
		}
		#Treasure Map
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:treasure_map_contract }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:treasure_map_contract
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:treasure_map_contract
				}
			}
		}
		#Transport Contracts
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:transport_contracts }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:transport_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:transport_contracts
				}
			}
		}
		#Criminal Contracts
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:criminal_contracts }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:criminal_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:criminal_contracts
				}
			}
		}
		#Justicar Contracts
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:justicar_contracts }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:justicar_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:justicar_contracts
				}
			}
		}
		#Hireling Contracts
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:hireling_contracts }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:hireling_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:hireling_contracts
				}
			}
		}
		#Diplomacy Contracts
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:diplomacy_contracts }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:diplomacy_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:diplomacy_contracts
				}
			}
		}
		#Stewardship Contracts
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:stewardship_contracts }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:stewardship_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:stewardship_contracts
				}
			}
		}
		#Learning Contracts
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:learning_contracts }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:learning_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:learning_contracts
				}
			}
		}
		#Intrigue Contracts
		if = {
			limit = { var:1025_saved_$NUM$_contract_type ?= flag:intrigue_contracts }
			save_scope_value_as = {
				name = 1025_$NUM$_contract
				value = flag:intrigue_contracts
			}
			#Save as a temporary variable that is removed after exiting the decision to avoid desc-bloat
			root = {
				set_variable = {
					name = 1025_$NUM$_contract_desc
					value = flag:intrigue_contracts
				}
			}
		}
		#Add more contract types below VV
	}
}

#This location has a saved contract variable
scripted_trigger 1025_location_has_a_saved_contract_type_trigger = {
	scope:visiting_location = {
		OR = { 
			has_variable = 1025_saved_first_contract_type
			has_variable = 1025_saved_second_contract_type
			has_variable = 1025_saved_third_contract_type
		}
	}
}

#The saved contract variable is of CONTRACT_TYPE_FLAG-type
scripted_trigger 1025_saved_location_contract_type_matches_this_type_trigger = {
	scope:visiting_location = {
		OR = {
			var:1025_saved_first_contract_type ?= $CONTRACT_TYPE_FLAG$
			var:1025_saved_second_contract_type ?= $CONTRACT_TYPE_FLAG$
			var:1025_saved_third_contract_type ?= $CONTRACT_TYPE_FLAG$
		}
	}
}

#Used more than 3 times eh
scripted_trigger 1025_region_has_suitable_employer_trigger = {	
	holder = { 
		highest_held_title_tier > tier_duchy
		NOT = { is_in_list = checked_holders }
		save_temporary_scope_as = holder_check
		valid_laamp_basic_trigger = {
			EMPLOYER = scope:holder_check
			LAAMP = root
		}
		#Copying the special contracts from the character interaction, for now. MUST match the random_list in 1025_find_ruler_and_spawn_legendary_contract_effect
		root = {
			OR = {
				can_create_task_contract = {
					type_name = laamp_raid_contract
					employer = scope:holder_check
				}
				can_create_task_contract = {
					type_name = laamp_steal_artifact_contract
					employer = scope:holder_check
				}
				can_create_task_contract = {
					type_name = laamp_treasure_hunting_contract
					employer = scope:holder_check
				}
				can_create_task_contract = {
					type_name = laamp_transport_vip
					employer = scope:holder_check
				}
				can_create_task_contract = {
					type_name = laamp_transport_artifact
					employer = scope:holder_check
				}
				can_create_task_contract = {
					type_name = laamp_transport_gold
					employer = scope:holder_check
				}
				can_create_task_contract = {
					type_name = laamp_transport_animal
					employer = scope:holder_check
				}
			}
		}
		add_to_temporary_list = checked_holders
	}
}

#... well, can we?
scripted_trigger 1025_can_create_legendary_contract_trigger = {
	OR = {
		#North Europe
		AND = {
			scope:visiting_location = { geographical_region = world_europe_north }
			any_county_in_region = {
				region = world_europe_north
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#West Europe
		AND = {
			scope:visiting_location = { geographical_region = world_europe_west }
			any_county_in_region = {
				region = world_europe_west
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#East Europe
		AND = {
			scope:visiting_location = { geographical_region = world_europe_east }
			any_county_in_region = {
				region = world_europe_east
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#South Europe
		AND = {
			scope:visiting_location = { geographical_region = world_europe_south }
			any_county_in_region = {
				region = world_europe_south
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#Middle East
		AND = {
			scope:visiting_location = { geographical_region = world_middle_east }
			any_county_in_region = {
				region = world_middle_east
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#India
		AND = {
			scope:visiting_location = { geographical_region = world_india }
			any_county_in_region = {
				region = world_india
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#North Africa
		AND = {
			scope:visiting_location = { geographical_region = world_africa_north }
			any_county_in_region = {
				region = world_africa_north
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#West Africa
		AND = {
			scope:visiting_location = { geographical_region = world_africa_west }
			any_county_in_region = {
				region = world_africa_west
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#East Africa
		AND = {
			scope:visiting_location = { geographical_region = world_africa_east }
			any_county_in_region = {
				region = world_africa_east
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#West Steppe
		AND = {
			scope:visiting_location = { geographical_region = world_steppe_west }
			any_county_in_region = {
				region = world_steppe_west
				1025_region_has_suitable_employer_trigger = yes
			}
		}
		#East Steppe
		AND = {
			scope:visiting_location = { geographical_region = world_steppe_east }
			any_county_in_region = {
				region = world_steppe_east
				1025_region_has_suitable_employer_trigger = yes
			}
		}
	}
}

#Don't duplicate contract types between contract scopes
scripted_trigger 1025_contract_type_is_assigned_trigger = {
	OR = {
		scope:1025_first_contract ?= $CONTRACT_TYPE_FLAG$
		scope:1025_second_contract ?= $CONTRACT_TYPE_FLAG$
		scope:1025_third_contract ?= $CONTRACT_TYPE_FLAG$
	}
}

#Since the treasure map contract doesn't have a time limit, make 'em old and unfit
scripted_trigger 1025_is_old_and_unable_trigger = {
	age > 50
	is_imprisoned = no
	OR = {
		has_trait = blind
		has_trait = one_legged
		has_trait = one_eyed
		has_trait = infirm
		has_trait = wounded_1
	}
}

#Standard checks
scripted_trigger 1025_appropriate_contract_employer_trigger = {
	# Players shouldn't get tangled up in contracts, ever.
	is_ai = yes
	# Plus some standard stuff.
	is_alive = yes
	is_adult = yes
	is_incapable = no
	# Don't offer to work with those who've wronged us.
	NOR = {
		government_has_flag = government_is_landless_adventurer
		# No one we're at war with.
		is_at_war_with = root
		# Rivals are cheap to grab.
		has_relation_rival = root
		# Expulsion
		custom_tooltip = {
			text = adventurer_expelled_trigger_tt
			OR = {
				has_opinion_modifier = {
					target = root
					modifier = eviction_ignored_opinion
				}
				any_liege_or_above = {
					has_opinion_modifier = {
						target = root
						modifier = eviction_ignored_opinion
					}
				}
			}
		}
	}
}

#Landed checks
scripted_trigger 1025_is_appropriate_landed_contract_employer_trigger = {
	1025_appropriate_contract_employer_trigger = yes
	this.capital_province ?= {
		squared_distance = {
			target = root.domicile.domicile_location
			value < define:NTaskContract|ADVENTURER_DISTANCE_RESTRICTION
		}
	}
}

#In too deep, man
scripted_trigger 1025_is_gated_due_to_thievery_trigger = {
	has_trait = gallowsbait
	has_trait_xp = {
		trait = gallowsbait
		track = thief
		value >= 60
	}
}

#Should we be gated from contracts?
scripted_trigger 1025_is_renowned_thief_trigger = {
	trigger_if = {
		limit = { scope:1025_$NUM$_contract = flag:treasure_map_contract }
		custom_tooltip = {
			text = gallowsbait_thief_blocked_from_contract.tt
			1025_is_gated_due_to_thievery_trigger = no
		}
	}
	trigger_else = { always = yes }
}

#Nothing at all!
scripted_trigger 1025_no_contracts_trigger = {
	OR = {
		#All contract types are on cooldown, I guess
		NOR = { 
			exists = scope:1025_first_contract
			exists = scope:1025_second_contract 
			exists = scope:1025_third_contract 
		}
		has_variable = 1025_has_contracted_recently
	} 
}


#Head to the Town Crier to spawn Contract(s)
ep3_laamp_decision_event.1025 = {
	type = character_event
	title = ep3_laamp_decision_event.1025.t
	window = visit_settlement_window
	desc = {
		#What're they doing?
		first_valid = {
			#We've returned to this scene, now what
			#Use this when we have all contract types on cooldown. Should be a bored crier.
			##COOLDOWN
			triggered_desc = {
				trigger = { 1025_no_contracts_trigger = yes }
				desc = ep3_laamp_decision_event.1025.desc_nothing
			}
			#RETURN: Tribal - Legendary contract
			random_valid = {
				triggered_desc = { 
					trigger = {
						scope:visiting_location = {
							OR = {
								has_holding_type = tribal_holding
								has_holding_type = nomad_holding
								has_holding_type = herder_holding
							}
						}
						exists = scope:been_to_contract
						scope:contract_loc_tracker ?= 0
						OR = {
							scope:1025_first_contract ?= flag:legendary_contract
							scope:1025_second_contract ?= flag:legendary_contract
							scope:1025_third_contract ?= flag:legendary_contract
						}
					}
					desc = ep3_laamp_decision_event.1025.desc_tribal_legendary_returned_01 
				}
				triggered_desc = { 
					trigger = {
						scope:visiting_location = {
							OR = {
								has_holding_type = tribal_holding
								has_holding_type = nomad_holding
								has_holding_type = herder_holding
							}
						}
						scope:contract_loc_tracker ?= 1
						OR = {
							scope:1025_first_contract ?= flag:legendary_contract
							scope:1025_second_contract ?= flag:legendary_contract
							scope:1025_third_contract ?= flag:legendary_contract
						}
					}
					desc = ep3_laamp_decision_event.1025.desc_tribal_legendary_returned_02
				}
			}
			#RETURN: Legendary contract
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_contract
						scope:contract_loc_tracker ?= 0
						OR = {
							scope:1025_first_contract ?= flag:legendary_contract
							scope:1025_second_contract ?= flag:legendary_contract
							scope:1025_third_contract ?= flag:legendary_contract
						}
					}
					desc = ep3_laamp_decision_event.1025.desc_legendary_returned_01 
				}
				triggered_desc = { 
					trigger = { 
						scope:contract_loc_tracker ?= 1
						OR = {
							scope:1025_first_contract ?= flag:legendary_contract
							scope:1025_second_contract ?= flag:legendary_contract
							scope:1025_third_contract ?= flag:legendary_contract
						}
					}
					desc = ep3_laamp_decision_event.1025.desc_legendary_returned_02
				}
			}
			#RETURN: Tribal - No legendary contract
			random_valid = {
				triggered_desc = { 
					trigger = {
						scope:visiting_location = {
							OR = {
								has_holding_type = tribal_holding
								has_holding_type = nomad_holding
								has_holding_type = herder_holding
							}
						}
						exists = scope:been_to_contract
						scope:contract_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1025.desc_tribal_returned_01 
				}
				triggered_desc = { 
					trigger = {
						scope:visiting_location = {
							OR = {
								has_holding_type = tribal_holding
								has_holding_type = nomad_holding
								has_holding_type = herder_holding
							}
						}
						scope:contract_loc_tracker ?= 1 
					}
					desc = ep3_laamp_decision_event.1025.desc_tribal_returned_02
				}
			}
			#RETURN: No legendary contract
			random_valid = {
				triggered_desc = { 
					trigger = {
						exists = scope:been_to_contract
						scope:contract_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1025.desc_returned_01 
				}
				triggered_desc = { 
					trigger = { scope:contract_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1025.desc_returned_02
				}
			}
			#FIRST TIME: Tribal - Legendary contract - Reused Elder
			triggered_desc = {
				trigger = {
					scope:visiting_location = {
						OR = {
							has_holding_type = tribal_holding
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
					exists = scope:laamp_recurring_town_crier
					NOR = { 
						exists = scope:been_to_contract
						has_variable = 1025_has_contracted_recently
					}
					OR = {
						scope:1025_first_contract ?= flag:legendary_contract
						scope:1025_second_contract ?= flag:legendary_contract
						scope:1025_third_contract ?= flag:legendary_contract
					}
				}
				desc = ep3_laamp_decision_event.1025.desc_tribal_legendary_reused_crier
			}
			#FIRST TIME: Legendary contract - Reused Town Crier
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_town_crier
					NOR = { 
						exists = scope:been_to_contract
						has_variable = 1025_has_contracted_recently
					}
					OR = {
						scope:1025_first_contract ?= flag:legendary_contract
						scope:1025_second_contract ?= flag:legendary_contract
						scope:1025_third_contract ?= flag:legendary_contract
					}
				}
				desc = ep3_laamp_decision_event.1025.desc_legendary_reused_crier
			}
			#FIRST TIME: Tribal - Legendary contract
			triggered_desc = {
				trigger = {
					scope:visiting_location = {
						OR = {
							has_holding_type = tribal_holding
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
					NOR = { 
						exists = scope:been_to_contract
						has_variable = 1025_has_contracted_recently
					}
					OR = {
						scope:1025_first_contract ?= flag:legendary_contract
						scope:1025_second_contract ?= flag:legendary_contract
						scope:1025_third_contract ?= flag:legendary_contract
					}
				}
				desc = ep3_laamp_decision_event.1025.desc_tribal_legendary
			}
			#FIRST TIME: Legendary contract
			triggered_desc = {
				trigger = {
					NOR = { 
						exists = scope:been_to_contract
						has_variable = 1025_has_contracted_recently
					}
					OR = {
						scope:1025_first_contract ?= flag:legendary_contract
						scope:1025_second_contract ?= flag:legendary_contract
						scope:1025_third_contract ?= flag:legendary_contract
					}
				}
				desc = ep3_laamp_decision_event.1025.desc_legendary
			}
			#FIRST TIME: Tribal - No legendary contract - Reused Town Crier
			triggered_desc = {
				trigger = {
					scope:visiting_location = {
						OR = {
							has_holding_type = tribal_holding
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
					exists = scope:laamp_recurring_town_crier
					NOR = { 
						exists = scope:been_to_contract
						has_variable = 1025_has_contracted_recently
					}
				}
				desc = ep3_laamp_decision_event.1025.desc_tribal_reused_crier
			}
			#FIRST TIME: No legendary contract - Reused Town Crier
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_town_crier
					NOR = { 
						exists = scope:been_to_contract
						has_variable = 1025_has_contracted_recently
					}
				}
				desc = ep3_laamp_decision_event.1025.desc_reused_crier
			}
			#FIRST TIME: Tribal - No legendary contract
			triggered_desc = {
				trigger = {
					scope:visiting_location = {
						OR = {
							has_holding_type = tribal_holding
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
					NOR = { 
						exists = scope:been_to_contract
						has_variable = 1025_has_contracted_recently
					}
				}
				desc = ep3_laamp_decision_event.1025.desc_tribal
			}
			#FIRST TIME: No legendary contract
			triggered_desc = {
				trigger = {
					NOR = { 
						exists = scope:been_to_contract
						has_variable = 1025_has_contracted_recently
					}
				}
				desc = ep3_laamp_decision_event.1025.desc
			}
		}
		#Concatenated and outsourced to custom_loc - trust me, this is less cursed than the alternative
		#A exists
		triggered_desc = {
			trigger = { 
				exists = scope:1025_first_contract
				NOR = {
					exists = scope:1025_second_contract
					exists = scope:1025_third_contract
				}
			}
			desc = ep3_laamp_decision_event.1025.desc_concatenated_A
		}
		#AB exists
		triggered_desc = {
			trigger = { 
				exists = scope:1025_first_contract
				exists = scope:1025_second_contract
				NOT = { exists = scope:1025_third_contract }
			}
			desc = ep3_laamp_decision_event.1025.desc_concatenated_AB
		}
		#ABC exists
		triggered_desc = {
			trigger = { 
				exists = scope:1025_first_contract
				exists = scope:1025_second_contract
				exists = scope:1025_third_contract
			}
			desc = ep3_laamp_decision_event.1025.desc_concatenated_ABC
		}
		#B exists
		triggered_desc = {
			trigger = { 
				exists = scope:1025_second_contract
				NOR = {
					exists = scope:1025_first_contract
					exists = scope:1025_third_contract
				}
			}
			desc = ep3_laamp_decision_event.1025.desc_concatenated_B
		}
		#BC exists
		triggered_desc = {
			trigger = { 
				NOT = { exists = scope:1025_first_contract }
				exists = scope:1025_second_contract
				exists = scope:1025_third_contract
			}
			desc = ep3_laamp_decision_event.1025.desc_concatenated_BC
		}
		#C exists
		triggered_desc = {
			trigger = { 
				exists = scope:1025_third_contract
				NOR = {
					exists = scope:1025_first_contract
					exists = scope:1025_second_contract
				}
			}
			desc = ep3_laamp_decision_event.1025.desc_concatenated_C
		}
		#AC exists
		triggered_desc = {
			trigger = { 
				exists = scope:1025_first_contract
				exists = scope:1025_third_contract
				NOT = { exists = scope:1025_second_contract }
			}
			desc = ep3_laamp_decision_event.1025.desc_concatenated_AC
		}
	}
	theme = landless_adventurer
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_activity" }
	override_background = {
		trigger = { 1000_is_a_nomadic_holding_trigger = yes }
		reference = mpo_camp_steppe
	}
	override_background = { reference = garden_location }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		animation = survey
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { 1025_no_contracts_trigger = yes }
			animation = worry
		}
		animation = interested
	}
	right_portrait = {
		character = scope:laamp_town_crier
		triggered_animation = {
			trigger = { 1025_no_contracts_trigger = yes }
			animation = boredom
		}
		animation = debating
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = contract }
		#Run all of this once
		if = {
			limit = {
				NOT = { exists = scope:been_to_contract }
			}
			#Spawn a Town Crier
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_crier_trigger = yes
					1010_is_a_saved_merchant_trigger = no
					1010_is_a_saved_peddler_trigger = no
					1010_is_a_saved_storyteller_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_healer_trigger = no
					1010_is_a_saved_clergy_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_weaponsmith_trigger = no
					1010_is_a_saved_armorer_trigger = no
					1010_is_a_saved_jeweler_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
					#_Elder_
					trigger_if = {
						limit = { 
							scope:visiting_location = {
								OR = {
									has_holding_type = tribal_holding
									has_holding_type = nomad_holding
									has_holding_type = herder_holding
								}
							}
						}
						age >= 50
					}
				}
				save_scope_as = laamp_town_crier
				#Some more loc flavor shenanigans for these saved scopes
				save_scope_as = laamp_recurring_town_crier
			}
			#Otherwise find a Town Crier in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_town_crier }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						is_available_healthy_adult = yes
						NOT = { has_trait = shy }
						#_Elder_
						trigger_if = {
							limit = { 
								scope:visiting_location = {
									OR = {
										has_holding_type = tribal_holding
										has_holding_type = nomad_holding
										has_holding_type = herder_holding
									}
								}
							}
							age >= 50
						}
					}
					save_scope_as = laamp_town_crier
				}
			}
			#Otherwise create a Town Crier
			if = {
				limit = {
					NOT = { exists = scope:laamp_town_crier }
				}
				#Create Elder to stuff in pool
				if = {
					limit = { 
						scope:visiting_location = {
							OR = {
								has_holding_type = tribal_holding
								has_holding_type = nomad_holding
								has_holding_type = herder_holding
							}
						}
					}
					create_character = {
						template = generic_peasant_character
						location = scope:visiting_location
						age = { 50 60 }
						dynasty = none
						culture = scope:visiting_location.culture
						faith = scope:visiting_location.faith
						save_scope_as = laamp_town_crier
					}
				}
				#Create Town Crier to stuff in pool
				else = {
					create_character = {
						template = generic_peasant_character
						location = scope:visiting_location
						dynasty = none
						culture = scope:visiting_location.culture
						faith = scope:visiting_location.faith
						save_scope_as = laamp_town_crier
					}
				}
			}
			#Remember the Town Crier
			1010_remember_vendor_character_effect = { GUILD = crier CHARACTER = scope:laamp_town_crier }
			#First Contract
			if = {
				limit = {
					NOT = { exists = scope:1025_first_contract }
				}
				#Did we, or someone else, check for contracts here recently?
				if = {
					limit = {
						scope:visiting_location = { has_variable = 1025_saved_first_contract_type }
					}
					#Translating values from variable to flag translates to number?
					1025_translate_variable_into_flag_effect = { NUM = first }
				}
				#Otherwise generate a new type
				else = {
					1025_randomize_and_remember_contract_type_effect = { NUM = first }
				}	
			}
			#Set up the employer, if necessary
			if = {
				limit = { exists = scope:1025_first_contract }
				1025_generate_employer_effect = { NUM = first }
			}
			#Second Contract
			if = {
				limit = {
					NOT = { exists = scope:1025_second_contract }
				}
				#Did we, or someone else, check for contracts here recently?
				if = {
					limit = {
						scope:visiting_location = { has_variable = 1025_saved_second_contract_type }
					}
					#Translating values from variable to flag
					1025_translate_variable_into_flag_effect = { NUM = second }
				}
				#Otherwise generate a new type
				else = {
					1025_randomize_and_remember_contract_type_effect = { NUM = second }
				}
			}
			#Set up the employer, if necessary
			if = {
				limit = { exists = scope:1025_second_contract }
				1025_generate_employer_effect = { NUM = second }
			}
			#If no legendary contract, Third Contract
			if = {
				limit = {
					NOT = { exists = scope:1025_third_contract }
				}
				#Did we, or someone else, check for contracts here recently?
				if = {
					limit = {
						scope:visiting_location = { has_variable = 1025_saved_third_contract_type }
					}
					#Translating values from variable to flag
					1025_translate_variable_into_flag_effect = { NUM = third }
				}
				#Otherwise generate a new type
				else = {
					1025_randomize_and_remember_contract_type_effect = { NUM = third }
				}
			}
			#Set up the employer, if necessary
			if = {
				limit = { exists = scope:1025_third_contract }
				1025_generate_employer_effect = { NUM = third }
			}
		}
	}
	#Contract A
	option = {
		name = ep3_laamp_decision_event.1025.a
		trigger = { 
			exists = scope:1025_first_contract
			1025_is_renowned_thief_trigger = { NUM = first }
		}
		show_as_unavailable = { exists = scope:1025_first_contract }
		#Remove the remember-variable for A
		scope:visiting_location = { remove_variable ?= 1025_saved_first_contract_type }
		#Spawn contract(s)
		1025_option_picked_spawn_contract_effect = { NUM = first }
		#Pick tooltip and set up the cooldown for the contract type
		1025_option_tooltip_and_cooldown_contract_type_effect = { NUM = first }
		#Done here; go back to the main event
		1025_finished_contract_effect = yes
	}
	#Contract B
	option = {
		name = ep3_laamp_decision_event.1025.b
		trigger = { 
			exists = scope:1025_second_contract
			1025_is_renowned_thief_trigger = { NUM = second }
		}
		show_as_unavailable = { exists = scope:1025_second_contract }
		#Remove the remember-variable for B
		scope:visiting_location = { remove_variable ?= 1025_saved_second_contract_type }
		#Spawn contract(s)
		1025_option_picked_spawn_contract_effect = { NUM = second }
		#Pick tooltip and set up the cooldown for the contract type
		1025_option_tooltip_and_cooldown_contract_type_effect = { NUM = second }
		#Done here; go back to the main event
		1025_finished_contract_effect = yes
	}
	#Contract C
	option = {
		name = ep3_laamp_decision_event.1025.c
		trigger = { 
			exists = scope:1025_third_contract
			1025_is_renowned_thief_trigger = { NUM = third }
		}
		show_as_unavailable = { exists = scope:1025_third_contract }
		#Remove the remember-variable for C
		scope:visiting_location = { remove_variable ?= 1025_saved_third_contract_type }
		#Spawn contract(s)
		1025_option_picked_spawn_contract_effect = { NUM = third }
		#Pick tooltip and set up the cooldown for the contract type
		1025_option_tooltip_and_cooldown_contract_type_effect = { NUM = third }
		#Done here; go back to the main event
		1025_finished_contract_effect = yes
	}
	#I want to do something else
	option = {
		#Nothing here
		name = {
			trigger = {
				NOT = { 
					exists = scope:been_to_contract
					exists = scope:1025_first_contract
					exists = scope:1025_second_contract
					exists = scope:1025_third_contract
				}
			}
			text = ep3_laamp_decision_event.1025.d_nothing
		}
		name = ep3_laamp_decision_event.1025.d
		if = {
			limit = { 
				NOT = { 
					exists = scope:1025_first_contract
					exists = scope:1025_second_contract
					exists = scope:1025_third_contract
				}
			}
			save_scope_value_as = {
				name = laamp_decision_has_contracted
				value = flag:no
			}
		}
		#For desc flavor
		else = { save_scope_as = been_to_contract }
		#Go back to the main event
		1001_return_to_second_effect = yes
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:contract }
	}
}


######################################################################
# TAVERN
# ep3_laamp_decision_event.1030
######################################################################

#Withered workaround
scripted_effect 1030_save_hub_scope_effect = {
	if = {
		limit = {
			NOT = { exists = scope:been_to_$HUB$ }
		}
		save_scope_as = been_to_$HUB$
	}
}

#Set the correct variable to block off the Tavern option and remove the desc flavor variable
scripted_effect 1030_finished_tavern_effect = {
	remove_list_variable = {
		name = list_of_options
		target = flag:has_tavern_option
	}
	save_scope_as = laamp_decision_finished_tavern_option
}

#Nothing left for us to do
scripted_trigger 1030_done_with_tavern_trigger = {
	exists = scope:laamp_decision_has_storied
	exists = scope:laamp_decision_has_recruited
	trigger_if = {
		limit = { exists = scope:laamp_spouse_material } 
		exists = scope:laamp_decision_has_spoused
	}
	trigger_if = {
		limit = { exists = scope:laamp_hooded_figure }
		exists = scope:laamp_decision_recruited_hood
	}
}

#Should be an alright seedy fella
scripted_trigger 1030_gallowsbait_character_trigger = {
	intrigue > 15
	has_trait = gallowsbait
	OR = {
		has_trait_xp = {
			trait = gallowsbait
			track = bandit
			value = medium_lifestyle_random_xp_low
		}
		has_trait_xp = {
			trait = gallowsbait
			track = trickster
			value = medium_lifestyle_random_xp_low
		}
		has_trait_xp = {
			trait = gallowsbait
			track = thief
			value = medium_lifestyle_random_xp_low
		}
		has_trait_xp = {
			trait = gallowsbait
			track = poacher
			value = medium_lifestyle_random_xp_low
		}
		has_trait_xp = {
			trait = gallowsbait
			track = marauder
			value = medium_lifestyle_random_xp_low
		}
	}
}

#Not Emperors and Kings, except if...
scripted_trigger 1030_appropriate_noble_trigger = {
	is_available_ai_adult = yes
	NOR = { 
		is_contact_of = root
		has_variable = 1030_has_been_hooded_recently
		has_any_scripted_relation = root #Remember to disable this for rival should we revisit to add some form of murder option in the future
	}
	#... they're eccentric
	trigger_if = {
		limit = {
			NOT = { has_trait = eccentric }
		}
		highest_held_title_tier <= tier_duchy
	}
}

scripted_trigger 1030_not_already_used_character_trigger = {
	1010_basic_merchant_checks_trigger = yes
	save_temporary_scope_as = saved_character_check
	#Let's avoid double-dipping
	1010_is_a_saved_thief_trigger = no
	1010_is_a_saved_merchant_trigger = no
	1010_is_a_saved_peddler_trigger = no
	1010_is_a_saved_crier_trigger = no
	1010_is_a_saved_storyteller_trigger = no
	1010_is_a_saved_healer_trigger = no
	1010_is_a_saved_clergy_trigger = no
	1010_is_a_saved_physician_trigger = no
	1010_is_a_saved_bodyguard_trigger = no
	1010_is_a_saved_weaponsmith_trigger = no
	1010_is_a_saved_armorer_trigger = no
	1010_is_a_saved_jeweler_trigger = no
	1010_is_a_saved_quartermaster_trigger = no
}


#Visit the local tavern
ep3_laamp_decision_event.1030 = {
	type = character_event
	title = ep3_laamp_decision_event.1030.t
	window = visit_settlement_window
	desc = {
		#Intro
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: We've returned from Main Square
			random_valid = {
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						1000_is_a_nomadic_holding_trigger = no
						exists = scope:been_to_tavern
						OR = {
							scope:tavern_loc_tracker ?= 0
							scope:tavern_loc_tracker ?= 2
						}
					}
					desc = ep3_laamp_decision_event.1030.desc_returned_01
				}
				#Nomad variant
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						1000_is_a_nomadic_holding_trigger = yes
						exists = scope:been_to_tavern
						OR = {
							scope:tavern_loc_tracker ?= 0
							scope:tavern_loc_tracker ?= 2
						}
					}
					desc = ep3_laamp_decision_event.1030.desc_nomad_returned_01
				}
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						scope:tavern_loc_tracker ?= 1
					}
					desc = ep3_laamp_decision_event.1030.desc_returned_02
				}
			}
			#RETURN: We've returned from the Storyteller
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = no
					var:return_from_location ?= flag:storyteller 
				}
				desc = ep3_laamp_decision_event.1030.desc_returned_from_story
			}
			#Nomad variant
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = yes
					var:return_from_location ?= flag:storyteller 
				}
				desc = ep3_laamp_decision_event.1030.desc_nomad_returned_from_story
			}
			#RETURN: We've returned from the Recruitment
			triggered_desc = {
				trigger = { 
					1000_is_a_nomadic_holding_trigger = no
					var:return_from_location ?= flag:recruit 
				}
				desc = ep3_laamp_decision_event.1030.desc_returned_from_recruit
			}
			#Nomad variant
			triggered_desc = {
				trigger = { 
					1000_is_a_nomadic_holding_trigger = yes
					var:return_from_location ?= flag:recruit 
				}
				desc = ep3_laamp_decision_event.1030.desc_nomad_returned_from_recruit
			}
			#RETURN: We've returned from unwinding with the Spouse Material
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = no
					var:return_from_location ?= flag:spouse
					exists = scope:1035_unwinded_with_spouse_potential
				}
				desc = ep3_laamp_decision_event.1030.desc_returned_from_unwinding_spouse
			}
			#Nomad variant
			triggered_desc = {
				trigger = { 
					1000_is_a_nomadic_holding_trigger = yes
					var:return_from_location ?= flag:spouse
					exists = scope:1035_unwinded_with_spouse_potential
				}
				desc = ep3_laamp_decision_event.1030.desc_nomad_returned_from_unwinding_spouse
			}
			#RETURN: We've returned from the Spouse Material
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:spouse }
				desc = ep3_laamp_decision_event.1030.desc_returned_from_spouse
			}
			#RETURN: We failed to save noble Hooded Figure
			triggered_desc = {
				trigger = { 
					var:return_from_location ?= flag:hood
					scope:laamp_decision_recruited_hood ?= flag:wounded
				}
				desc = ep3_laamp_decision_event.1030.desc_returned_from_hood_noble_fail
			}
			#RETURN: We've returned from the noble Hooded Figure
			triggered_desc = {
				trigger = { 
					var:return_from_location ?= flag:hood
					exists = scope:laamp_disguised_noble
				}
				desc = ep3_laamp_decision_event.1030.desc_returned_from_hood_noble
			}
			#RETURN: We've returned from the Hooded Figure
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = no
					var:return_from_location ?= flag:hood 
				}
				desc = ep3_laamp_decision_event.1030.desc_returned_from_hood
			}
			#Nomad variant
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = yes
					var:return_from_location ?= flag:hood 
				}
				desc = ep3_laamp_decision_event.1030.desc_nomad_returned_from_hood
			}
			#FIRST TIME: Nomad dwelling
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = yes
					NOT = { exists = scope:been_to_tavern }
				}
				desc = ep3_laamp_decision_event.1030.desc_nomad
			}
			#FIRST TIME: First time here
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_tavern }
				}
				desc = ep3_laamp_decision_event.1030.desc
			}
		}
		#MID: Is there a spouse? Do we recognize them? Have we interacted with them?
		first_valid = {
			#RETURN: Reused spouse is still here
			triggered_desc = {
				trigger = { 
					exists = scope:been_to_tavern
					exists = scope:laamp_recurring_spouse
					NOR = { 
						exists = scope:been_to_spouse
						exists = scope:laamp_decision_has_spoused
					}
				}
				desc = ep3_laamp_decision_event.1030.desc_mid_return_reused_spouse
			}
			#FIRST TIME: You've seen this lass/lad before
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_tavern }
					exists = scope:laamp_recurring_spouse
				}
				desc = ep3_laamp_decision_event.1030.desc_mid_reused_spouse
			}
			#RETURN: Spouse is still here
			triggered_desc = {
				trigger = { 
					exists = scope:been_to_tavern
					exists = scope:laamp_spouse_material
					NOR = { 
						exists = scope:been_to_spouse
						exists = scope:laamp_decision_has_spoused
					}
				}
				desc = ep3_laamp_decision_event.1030.desc_mid_return_spouse
			}
			#FIRST TIME: Nomad dwelling
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = yes
					NOT = { exists = scope:been_to_tavern }
					exists = scope:laamp_spouse_material
				}
				desc = ep3_laamp_decision_event.1030.desc_nomad_mid_spouse
			}
			#Otherwise just exclude them
			triggered_desc = {
				trigger = { 
					1000_is_a_nomadic_holding_trigger = yes
					NOT = { exists = scope:been_to_tavern }
				}
				desc = ep3_laamp_decision_event.1030.desc_nomad_mid
			}
			#FIRST TIME
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_tavern }
					exists = scope:laamp_spouse_material
				}
				desc = ep3_laamp_decision_event.1030.desc_mid_spouse
			}
			#Otherwise just exclude them
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_tavern }
				}
				desc = ep3_laamp_decision_event.1030.desc_mid
			}
		}
		#Outro
		first_valid = {
			#FIRST TIME: First time here, look at the hood
			triggered_desc = {
				trigger = {
					exists = scope:laamp_hooded_figure
					NOT = { exists = scope:been_to_tavern }
				}
				desc = ep3_laamp_decision_event.1030.desc_outro_hooded
			}
			#FIRST TIME: First time here, curious partner
			triggered_desc = {
				trigger = {
					exists = scope:visiting_partner
					NOT = { exists = scope:been_to_tavern }
				}
				desc = ep3_laamp_decision_event.1030.desc_outro_partner
			}
			#FIRST TIME: First time here
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_tavern }
				}
				desc = ep3_laamp_decision_event.1030.desc_outro
			}
			#RETURN: Partner - there is nothing left for us here
			triggered_desc = {
				trigger = { 
					exists = scope:visiting_partner
					1030_done_with_tavern_trigger = yes 
				}
				desc = ep3_laamp_decision_event.1030.desc_outro_return_partner_finished
			}
			#RETURN: There is nothing left for us here
			triggered_desc = {
				trigger = { 1030_done_with_tavern_trigger = yes }
				desc = ep3_laamp_decision_event.1030.desc_outro_return_finished
			}
			#RETURN: Hood noble did not deviate, yet
			triggered_desc = {
				trigger = {
					exists = scope:laamp_hooded_figure
					exists = scope:laamp_disguised_noble
					NOR = { 
						exists = scope:laamp_decision_recruited_hood
						exists = scope:been_to_hood 
					}
				}
				desc = ep3_laamp_decision_event.1030.desc_outro_hooded_noble_return
			}
			#RETURN: Hood thief did not deviate, yet
			triggered_desc = {
				trigger = {
					exists = scope:laamp_hooded_figure
					NOR = { 
						exists = scope:laamp_decision_recruited_hood
						exists = scope:been_to_hood 
					}
				}
				desc = ep3_laamp_decision_event.1030.desc_outro_hooded_return
			}
			#RETURN: We've been here before
			random_valid = {
				#RETURN: Partner flavor
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						exists = scope:been_to_tavern
						scope:tavern_loc_tracker ?= 0
						has_variable = 1030_use_partner_animation_var
					}
					desc = ep3_laamp_decision_event.1030.desc_outro_return_partner_01
				}
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						scope:tavern_loc_tracker ?= 1
						has_variable = 1030_use_partner_animation_var
					}
					desc = ep3_laamp_decision_event.1030.desc_outro_return_partner_02
				}
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						scope:tavern_loc_tracker ?= 2
						has_variable = 1030_use_partner_animation_var
					}
					desc = ep3_laamp_decision_event.1030.desc_outro_return_partner_03
				}
				#RETURN: Generics
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_tavern
						scope:tavern_loc_tracker ?= 0
						NOT = { has_variable = 1030_use_partner_animation_var }
					}
					desc = ep3_laamp_decision_event.1030.desc_outro_return_01
				}
				triggered_desc = {
					trigger = { 
						scope:tavern_loc_tracker ?= 1
						NOT = { has_variable = 1030_use_partner_animation_var }
					}
					desc = ep3_laamp_decision_event.1030.desc_outro_return_02
				}
				triggered_desc = {
					trigger = { 
						scope:tavern_loc_tracker ?= 2
						NOT = { has_variable = 1030_use_partner_animation_var }
					}
					desc = ep3_laamp_decision_event.1030.desc_outro_return_03
				}
			}
		}
	}
	theme = landless_adventurer
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_social" }
	override_icon = { reference = "gfx/interface/icons/event_types/type_travel_stewardship.dds" }
	override_background = {
		trigger = { 1000_is_a_nomadic_holding_trigger = yes }
		reference = mpo_tent_interior_mongol
	}
	override_background = {
		trigger = { 
			scope:visiting_location = {
				has_holding_type = tribal_holding
			} 
		}
		reference = throne_room_tribal
	}
	override_background = { reference = tavern }
	#PARTNER / ROOT
	left_portrait = {
		trigger = {
			exists = scope:1030_first_character
			#Don't display this one if ROOT is in both portraits
			NAND = {
				scope:1030_first_character = root
				exists = scope:1030_second_character
				scope:1030_second_character = root
			}
		}
		character = scope:1030_first_character
		#PARTNER: If it's our (tired) visiting partner
		triggered_animation = {
			trigger = {
				1030_done_with_tavern_trigger = yes
				scope:visiting_partner ?= scope:1030_first_character
			}
			animation = boredom
		}
		#PARTNER: Variation 01
		triggered_animation = {
			trigger = { 
				scope:visiting_partner ?= scope:1030_first_character
				exists = scope:been_to_tavern
				scope:tavern_loc_tracker ?= 0
				root = { has_variable = 1030_use_partner_animation_var }
			}
			animation = interested
		}
		#PARTNER: Variation 02
		triggered_animation = {
			trigger = { 
				scope:visiting_partner ?= scope:1030_first_character
				scope:tavern_loc_tracker ?= 1
				root = { has_variable = 1030_use_partner_animation_var }
			}
			animation = laugh
		}
		#PARTNER: Variation 03
		triggered_animation = {
			trigger = { 
				scope:visiting_partner ?= scope:1030_first_character
				scope:tavern_loc_tracker ?= 2
				root = { has_variable = 1030_use_partner_animation_var }
			}
			animation = dancing
		}
		#PARTNER: If it's our visiting partner
		triggered_animation = {
			trigger = { scope:visiting_partner ?= scope:1030_first_character }
			animation = personality_content
		}
		#ROOT: Hooded figure!
		triggered_animation = {
			trigger = {
				scope:1030_first_character = root
				exists = scope:laamp_hooded_figure
				NOT = { exists = scope:been_to_hood }
			}
			animation = interested 
		}
		#ROOT: Eyeing the vixen at the bar
		triggered_animation = {
			trigger = {
				scope:1030_first_character = root
				exists = scope:laamp_spouse_material
				NOT = { exists = scope:been_to_spouse }
			}
			animation = admiration
		}
		#ROOT: Eh, why not
		triggered_animation = {
			trigger = {
				scope:1030_first_character = root
				OR = {
					has_trait = lunatic
					has_trait = possessed
					has_trait = eccentric
				}
			}
			animation = personality_irrational
		}
		#ROOT: That's.. a lot of people
		triggered_animation = {
			trigger = {
				scope:1030_first_character = root
				OR = {
					has_trait = paranoid
					has_trait = shy
				}
			}
			animation = personality_coward
		}
		#ROOT: My kind of people!
		triggered_animation = {
			trigger = {
				scope:1030_first_character = root
				OR = {
					has_trait = lifestyle_reveler
					has_trait = gregarious
				}
			}
			animation = happiness
		}
		#Fallback, we really shouldn't end up here
		animation = happiness
	}
	#SPOUSE / ROOT
	center_portrait = {
		trigger = { exists = scope:1030_second_character }
		camera = camera_event_scheme_vs_right_look_right
		character = scope:1030_second_character
		#SPOUSE: Untapped
		triggered_animation = {
			trigger = {
				scope:laamp_spouse_material ?= scope:1030_second_character
				NOT = { exists = scope:been_to_spouse }
			}
			animation = personality_rational
		}
		#SPOUSE: Been there
		triggered_animation = {
			trigger = { scope:laamp_spouse_material ?= scope:1030_second_character }
			animation = personality_cynical
		}
		#ROOT: Hooded figure!
		triggered_animation = {
			trigger = {
				scope:1030_second_character = root
				exists = scope:laamp_hooded_figure
				NOT = { exists = scope:been_to_hood }
			}
			animation = interested 
		}
		#ROOT: Eyeing the vixen at the bar
		triggered_animation = {
			trigger = {
				scope:1030_second_character = root
				exists = scope:laamp_spouse_material
				NOT = { exists = scope:been_to_spouse }
			}
			animation = admiration
		}
		#ROOT: Eh, why not
		triggered_animation = {
			trigger = {
				scope:1030_second_character = root
				OR = {
					has_trait = lunatic
					has_trait = possessed
					has_trait = eccentric
				}
			}
			animation = personality_irrational
		}
		#ROOT: That's.. a lot of people
		triggered_animation = {
			trigger = {
				scope:1030_second_character = root
				OR = {
					has_trait = paranoid
					has_trait = shy
				}
			}
			animation = personality_coward
		}
		#ROOT: My kind of people!
		triggered_animation = {
			trigger = {
				scope:1030_second_character = root
				OR = {
					has_trait = lifestyle_reveler
					has_trait = gregarious
				}
			}
			animation = happiness
		}
		#Fallback, we really shouldn't end up here
		animation = personality_rational
	}
	#HOOD / SPOUSE
	right_portrait = {
		trigger = { 
			exists = scope:1030_third_character
			#If this is root, then that means we have talked to the Hooded Figure and we don't have a Spouse to display, so let's disappear the portrait
			scope:1030_third_character != root
		}
		camera = camera_event_scheme_vs_center_look_left
		character = scope:1030_third_character
		#HOOD: Hood for the hooded figure
		triggered_outfit = {
			trigger = { scope:laamp_hooded_figure ?= scope:1030_third_character }
			outfit_tags = { western_stealth_hood }
		}
		#HOOD NOBLE: We've returned here and it's still the hooded noble
		triggered_animation = {
			trigger = { 
				scope:laamp_disguised_noble ?= scope:1030_third_character
				exists = scope:been_to_tavern
			}
			animation = drink_goblet
		}
		#HOOD THIEF: We've returned here and it's still the hooded thief
		triggered_animation = {
			trigger = {
				scope:laamp_hooded_figure ?= scope:1030_third_character
				exists = scope:been_to_tavern
			}
			animation = spymaster
		}
		#SPOUSE: Untapped
		triggered_animation = {
			trigger = {
				scope:laamp_spouse_material ?= scope:1030_third_character
				NOT = { exists = scope:been_to_spouse }
			}
			animation = personality_rational
		}
		#SPOUSE: Been there
		triggered_animation = {
			trigger = { scope:laamp_spouse_material ?= scope:1030_third_character }
			animation = personality_cynical
		}
		#Fallback, we really shouldn't end up here
		animation = personality_callous
	}
	#Shove the Spouse / Hood here if they exist, we've visited them but we haven't actioned them yet
	lower_left_portrait = {
		trigger = {
			NOT = { root ?= scope:1030_fourth_character }
		}
		character = scope:1030_fourth_character
	}
	lower_center_portrait = {
		trigger = { 
			NOT = { root ?= scope:1030_fifth_character }
		}
		character = scope:1030_fifth_character
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Set up the ancillary portraits to remind the player of the characters
		if = {
			#Hood _and_ Spouse exists
			limit = {
				#We've been to both at least once
				exists = scope:been_to_spouse
				exists = scope:been_to_hood
				#We're not done with them yet
				AND = {
					exists = scope:laamp_spouse_material
					NOT = { exists = scope:laamp_decision_has_spoused }
				}
				AND = {
					exists = scope:laamp_hooded_figure
					NOT = { exists = scope:laamp_decision_recruited_hood }
				}
				#This isn't already the state
				NAND = {
					exists = scope:1030_fourth_character
					scope:1030_fourth_character ?= scope:laamp_spouse_material
					exists = scope:1030_fifth_character
					scope:1030_fifth_character ?= scope:laamp_hooded_figure
				}
			}
			scope:laamp_spouse_material = { save_scope_as = 1030_fourth_character }
			scope:laamp_hooded_figure = { save_scope_as = 1030_fifth_character }
		}
		else_if = {
			#Only Spouse exists
			limit = {
				exists = scope:laamp_spouse_material
				NOR = {
					#We're not done with Spouse yet
					exists = scope:laamp_decision_has_spoused
					#This isn't already the state
					AND = {
						exists = scope:1030_fourth_character
						scope:1030_fourth_character ?= scope:laamp_spouse_material
					}
				}
				#We've been to Spouse at least once
				exists = scope:been_to_spouse
			}
			scope:laamp_spouse_material = { save_scope_as = 1030_fourth_character }
		}
		else_if = {
			#Hood exists but Spouse either never existed or got recruited
			limit = {
				exists = scope:laamp_hooded_figure
				NOR = {
					#We're not done with Hood yet
					exists = scope:laamp_decision_recruited_hood
					#This isn't already the state
					AND = {
						exists = scope:1030_fourth_character
						scope:1030_fourth_character ?= scope:laamp_hooded_figure
					}
				}
				#We've been to Hood at least once
				exists = scope:been_to_hood
				OR = {
					#Either the Spouse never existed
					NAND = { 
						exists = scope:laamp_spouse_material
						exists = scope:laamp_decision_has_spoused
					}
					#Or we've recruited the Spouse already
					AND = {
						exists = scope:laamp_spouse_material
						exists = scope:laamp_decision_has_spoused
					}
				}	
			}
			scope:laamp_hooded_figure = { save_scope_as = 1030_fourth_character }
			#If we've already attached Hood to the fifth portrait, overwrite it with ROOT to hide that portrait
			if = {
				limit = { exists = scope:1030_fifth_character }
				save_scope_as = 1030_fifth_character
			}
		}
		#Clean up any existing fourth/fifth portrait if we're done with all who exist
		if = {
			limit = {
				exists = scope:1030_fourth_character
				trigger_if = {
					limit = { 
						exists = scope:laamp_spouse_material
						exists = scope:laamp_hooded_figure
					}
					#We've recruited the Spouse already
					AND = {
						exists = scope:laamp_spouse_material
						exists = scope:laamp_decision_has_spoused
					}
					#We've recruited the Hood already
					AND = {
						exists = scope:laamp_hooded_figure
						exists = scope:laamp_decision_recruited_hood
					}
				}
				trigger_else_if = {
					limit = { 
						exists = scope:laamp_spouse_material
						NOT = { exists = scope:laamp_hooded_figure }
					}
					#We've recruited the Spouse already
					AND = {
						exists = scope:laamp_spouse_material
						exists = scope:laamp_decision_has_spoused
					}
				}
				trigger_else_if = {
					limit = { 
						exists = scope:laamp_hooded_figure
						NOT = { exists = scope:laamp_spouse_material }
					}
					#We've recruited the Hood already
					AND = {
						exists = scope:laamp_hooded_figure
						exists = scope:laamp_decision_recruited_hood
					}
				}
				trigger_else = { always = no }
				#This isn't already the state
				scope:1030_fourth_character != root
			}
			#Overwrite with ROOT to hide that portrait
			save_scope_as = 1030_fourth_character
		}
		if = {
			limit = {
				#We've recruited the Hood already
				AND = {
					exists = scope:laamp_hooded_figure
					exists = scope:laamp_decision_recruited_hood
				}
				#This isn't already the state
				exists = scope:1030_fifth_character
				scope:1030_fifth_character != root
			}
			#Overwrite with ROOT to hide that portrait
			save_scope_as = 1030_fifth_character
		}
		#Can we _not_ repeat the loc?
		1025_set_and_check_hub_loc_tracker_scope_effect = { HUB = tavern }
		#Some animation flavor
		random_list = {
			75 = {
				trigger = { 
					exists = scope:visiting_partner
					trigger_if = {
						limit = { exists = scope:laamp_hooded_figure }
						exists = scope:been_to_hood
					}
				}
				set_variable = 1030_use_partner_animation_var
			}
			25 = {
				#Nothing
			}
		}
		#Create the spouse character
		if = {
			limit = {
				OR = {
					#Do we remember someone?
					any_pool_character = {
						province = scope:visiting_location
						location = scope:visiting_location
						root = {
							is_target_in_variable_list = {
								name = 1025_remembered_spouse_potential_list
								target = prev  #The considered spouse character
							}
						}
					}
					#Or did we actually encounter them?
					any_pool_character = {
						province = scope:visiting_location
						location = scope:visiting_location
						is_target_in_variable_list = {
							name = 1030_marked_as_spouse_material_for_list
							target = root
						}
					}
				}
			}
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					OR = {
						root = {
							is_target_in_variable_list = {
								name = 1025_remembered_spouse_potential_list
								target = prev  #The considered spouse character
							}
						}
						is_target_in_variable_list = {
							name = 1030_marked_as_spouse_material_for_list
							target = root
						}
					}
				}
				save_scope_as = laamp_spouse_material
				#Some more loc flavor shenanigans for these saved scopes
				if = {
					#Only save them if we actually interacted with them
					limit = { 
						root = {
							is_target_in_variable_list = {
								name = 1025_remembered_spouse_potential_list
								target = prev  #The considered spouse character
							}
						}
					}
					save_scope_as = laamp_recurring_spouse
				}	
			}
		}
		#No? Then roll for a new spouse
		if = {
			limit = {
				NOR = { 
					exists = scope:laamp_spouse_material
					#Unless you're on local cooldown
					scope:visiting_location = {
						is_target_in_variable_list = {
							name = laamp_decisions_1000_checked_for_spouse_list
							target = root
						}
					}
				}	
				allowed_more_spouses = yes	
			}
			random_list = {
				75 = {
					#Maybe?
					modifier = {
						OR = {
							has_trait = seducer
							has_trait = rakish
						}
						add = -25
					}
					#No spouse
				}
				25 = { #Nerf this number into the ground to keep our LAAMP friends spouseless forever
					#Find a spouse in the pool
					if = {
						limit = {
							NOT = { exists = scope:laamp_spouse_material }
						}
						random_pool_character = {
							province = scope:visiting_location
							limit = { 
								1010_basic_merchant_checks_trigger = yes
								#We can marry them
								can_marry_character_trigger = { CHARACTER = root }
								#We want to marry them
								root = { is_attracted_to_gender_of = prev } #Prev is the spouse scope
								#They might want to marry us
								is_attracted_to_gender_of = root
							}
							save_scope_as = laamp_spouse_material
						}
					}
					#Otherwise create 'em
					if = {
						limit = {
							NOT = { exists = scope:laamp_spouse_material }
						}
						#Gender doesn't matter
						if = {
							limit = { allowed_to_marry_same_sex_trigger = yes }
							create_character = {
								template = generic_peasant_character
								location = scope:visiting_location
								dynasty = none
								culture = scope:visiting_location.culture
								faith = scope:visiting_location.faith
								diplomacy = { low_skill_rating high_skill_rating }
								martial = { low_skill_rating high_skill_rating }
								stewardship = { low_skill_rating high_skill_rating }
								intrigue = { low_skill_rating high_skill_rating }
								learning = { low_skill_rating high_skill_rating }
								save_scope_as = laamp_spouse_material
							}
						}
						#Straight female
						else_if = {
							limit = { is_female = yes }
							create_character = {
								template = generic_peasant_character
								location = scope:visiting_location
								dynasty = none
								gender = male
								culture = scope:visiting_location.culture
								faith = scope:visiting_location.faith
								diplomacy = { low_skill_rating high_skill_rating }
								martial = { low_skill_rating high_skill_rating }
								stewardship = { low_skill_rating high_skill_rating }
								intrigue = { low_skill_rating high_skill_rating }
								learning = { low_skill_rating high_skill_rating }
								save_scope_as = laamp_spouse_material
							}
						}
						#Straight male
						else = {
							create_character = {
								template = generic_peasant_character
								location = scope:visiting_location
								dynasty = none
								gender = female
								culture = scope:visiting_location.culture
								faith = scope:visiting_location.faith
								diplomacy = { low_skill_rating high_skill_rating }
								martial = { low_skill_rating high_skill_rating }
								stewardship = { low_skill_rating high_skill_rating }
								intrigue = { low_skill_rating high_skill_rating }
								learning = { low_skill_rating high_skill_rating }
								save_scope_as = laamp_spouse_material
							}
						}
					}
					#Some buffs pls?
					scope:laamp_spouse_material ?= {
						if = {
							limit = {
								NOT = { has_variable = 1030_has_rolled_for_congenital_traits }
								NOR = { 
									has_trait = beauty_good_1 
									has_trait = intellect_good_1
									has_trait = physique_good_1
									has_trait = fecund
									has_trait = strong
									has_trait = shrewd
								}
							}
							hidden_effect = {
								random = {
									chance = 5
									random_list = {
										10 = { add_trait = beauty_good_1 }
										10 = { add_trait = intellect_good_1 }
										10 = { add_trait = physique_good_1 }
										10 = { add_trait = fecund }
										10 = { add_trait = strong }
										10 = { add_trait = shrewd }
									}
								}
							}
						}
						#Give 'em a year
						add_to_variable_list = {
							name = 1030_marked_as_spouse_material_for_list
							target = root
							days = visit_settlement_minimum_cooldown_days
						}
						#... no more congenital traits rolls for them
						set_variable = 1030_has_rolled_for_congenital_traits
						#Funny as it looks when the tooltip wanders through all possible options, this is probs what looks more WAD
						if = {
							limit = {
								NOT = { has_variable = raunchy_compliment_noun }
							}
							set_raunchy_compliment_noun_effect = yes
						}
					}
				}
			}
			#Set up the cooldown per holding, so that you can hop around to different taverns
			scope:visiting_location = {
				add_to_variable_list = {
					name = laamp_decisions_1000_checked_for_spouse_list
					target = root
					days = visit_settlement_minimum_cooldown_days
				}
			}
		}
		#Rare: Spawn a hooded figure
		if = {
			limit = {
				NOT = { has_variable = laamp_decision_1000_checked_for_hood }
			}
			random_list = {
				75 = {
					#No Hooded Figure
				}
				#Shady Noble
				25 = {
					#Look for the holder first
					if = {
						limit = {
							scope:visiting_location.county.holder ?= {
								1030_appropriate_noble_trigger = yes
								location = scope:visiting_location
							}
						}
						scope:visiting_location.county.holder = { 
							save_scope_as = laamp_hooded_figure
							save_scope_as = laamp_disguised_noble
						}
					}
					#Otherwise a landed or ladmin in the same location
					if = {
						limit = {
							NOT = { exists = scope:laamp_hooded_figure }
						}
						scope:visiting_location = {
							random_character_in_location = {
								limit = {
									1030_appropriate_noble_trigger = yes
									is_landed_or_landless_administrative = yes		
								}
								save_scope_as = laamp_hooded_figure
								save_scope_as = laamp_disguised_noble
							}
							#... or a landed/ladmin in a neighboring province. Does this tank performance?
							if = {
								limit = {
									NOT = { exists = scope:laamp_hooded_figure }
								}
								random_neighboring_province = {
									limit = { is_sea_province = no }
									random_character_in_location = {
										limit = {
											1030_appropriate_noble_trigger = yes
											is_landed_or_landless_administrative = yes
										}
										save_scope_as = laamp_hooded_figure
										save_scope_as = laamp_disguised_noble
									}
								}
							}
						}		
					}
					scope:laamp_hooded_figure ?= {
						#Don't need to pull the same ruler several times
						set_variable = {
							name = 1030_has_been_hooded_recently
							days = visit_settlement_cooldown_days
						}
					}
				}
				#Master Thief
				25 = {
					#More common in Tribal/No Settlement
					modifier = { 
						scope:visiting_location = {
							OR = {
								has_holding_type = tribal_holding
								has_holding_type = nomad_holding
								has_holding_type = herder_holding
							}
						}
						factor = 2
					}
					#Has this person been our thief in the past 10 years?
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							1010_basic_merchant_checks_trigger = yes
							save_temporary_scope_as = saved_character_check
							#Let's avoid double-dipping
							1010_is_a_saved_thief_trigger = yes
							1010_is_a_saved_merchant_trigger = no
							1010_is_a_saved_peddler_trigger = no
							1010_is_a_saved_crier_trigger = no
							1010_is_a_saved_storyteller_trigger = no
							1010_is_a_saved_healer_trigger = no
							1010_is_a_saved_clergy_trigger = no
							1010_is_a_saved_physician_trigger = no
							1010_is_a_saved_bodyguard_trigger = no
							1010_is_a_saved_weaponsmith_trigger = no
							1010_is_a_saved_armorer_trigger = no
							1010_is_a_saved_jeweler_trigger = no
							1010_is_a_saved_quartermaster_trigger = no
						}
						save_scope_as = laamp_hooded_figure
						#Some more loc flavor shenanigans for these saved scopes
						save_scope_as = laamp_recurring_thief
					}
					#Otherwise find a thief in the pool
					if = {
						limit = { 
							NOT = { exists = scope:laamp_hooded_figure }
						}
						random_pool_character = {
							province = scope:visiting_location
							limit = { 
								1010_basic_merchant_checks_trigger = yes
								is_available_healthy_adult = yes
								1030_gallowsbait_character_trigger = yes
							}
							save_scope_as = laamp_hooded_figure
						}
					}
					#Otherwise create a thief
					if = {
						limit = {
							NOT = { exists = scope:laamp_hooded_figure }
						}
						#Create bodyguard to stuff in pool
						create_character = {
							template = bp1_yearly_2021_intrigue_person_template
							location = scope:visiting_location
							dynasty = none
							culture = scope:visiting_location.culture
							faith = scope:visiting_location.faith
							intrigue = { decent_skill_rating high_skill_rating }
							save_scope_as = laamp_hooded_figure
						}
						scope:laamp_hooded_figure ?= {
							#Chance to add a malus trait to this spectatular being
							if = {
								limit = { 
									NOR = { 
										has_trait = possessed_1 
										has_trait = lunatic_1
										has_trait = depressed_1
										has_trait = drunkard
										has_trait = hashishiyah
										has_trait = irritable
									}
								}
								hidden_effect = {
									random = {
										chance = 20
										random_list = {
											10 = { add_trait = possessed_1 }
											10 = { add_trait = lunatic_1 }
											10 = { add_trait = depressed_1 }
											10 = { add_trait = drunkard }
											10 = { add_trait = hashishiyah }
											10 = { add_trait = irritable }
										}
									}
								}
							}
							#... also, it's a criminal, so... yeah
							hidden_effect = {
								if = {
									limit = {
										NOT = { has_trait = gallowsbait }
									}
									add_trait = gallowsbait
									random_list = {
										#Bandit
										25 = {
											add_trait_xp = {
												trait = gallowsbait
												track = bandit
												value = {
												    integer_range = {
												        min = medium_lifestyle_random_xp_low
												        max = medium_lifestyle_random_xp_high
												    }
												}
											}
										}
										#Trickster
										25 = {
											add_trait_xp = {
												trait = gallowsbait
												track = trickster
												value = {
												    integer_range = {
												        min = medium_lifestyle_random_xp_low
												        max = medium_lifestyle_random_xp_high
												    }
												}
											}
										}
										#Thief
										25 = {
											add_trait_xp = {
												trait = gallowsbait
												track = thief
												value = {
												    integer_range = {
												        min = medium_lifestyle_random_xp_low
												        max = medium_lifestyle_random_xp_high
												    }
												}
											}
										}
										#Poacher
										25 = {
											add_trait_xp = {
												trait = gallowsbait
												track = poacher
												value = {
												    integer_range = {
												        min = medium_lifestyle_random_xp_low
												        max = medium_lifestyle_random_xp_high
												    }
												}
											}
										}
										#Marauder
										25 = {
											add_trait_xp = {
												trait = gallowsbait
												track = marauder
												value = {
												    integer_range = {
												        min = medium_lifestyle_random_xp_low
												        max = medium_lifestyle_random_xp_high
												    }
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			#For the portrait
			scope:laamp_hooded_figure ?= { save_scope_as = 1030_second_character }
			#No decision-scumming
			set_variable = {
				name = laamp_decision_1000_checked_for_hood
				days = visit_settlement_cooldown_days
			}
		}
		#Set up the initial portraits
		if = {
			limit = {
				NOT = { exists = scope:1030_portraits_setup }
			}
			if = {
				limit = {
					exists = scope:laamp_spouse_material
					exists = scope:laamp_hooded_figure
				}
				#Spouse, Hood and Partner exists
				if = {
					limit = { exists = scope:visiting_partner }
					scope:visiting_partner = { save_scope_as = 1030_first_character }
				}
				scope:laamp_spouse_material = { save_scope_as = 1030_second_character }
				scope:laamp_hooded_figure = { save_scope_as = 1030_third_character }
			}
			else_if = {
				limit = { exists = scope:laamp_spouse_material }
				#Spouse and Partner exists
				if = {
					limit = { exists = scope:visiting_partner }
					scope:visiting_partner = { save_scope_as = 1030_first_character }
				}
				#Save ROOT
				save_scope_as = 1030_second_character
				scope:laamp_spouse_material = { save_scope_as = 1030_third_character }
			}
			else_if = {
				limit = { exists = scope:laamp_hooded_figure }
				#Hood and Partner exists
				if = {
					limit = { exists = scope:visiting_partner }
					scope:visiting_partner = { save_scope_as = 1030_first_character }
				}
				#Save ROOT
				save_scope_as = 1030_second_character
				scope:laamp_hooded_figure = { save_scope_as = 1030_third_character }
			}
			else_if = {
				limit = { exists = scope:visiting_partner }
				#Only Partner exists
				scope:visiting_partner = { save_scope_as = 1030_first_character }
				#Save ROOT
				save_scope_as = 1030_second_character
			}
			else = {
				#You're alone - save ROOT
				save_scope_as = 1030_second_character
			}
			save_scope_as = 1030_portraits_setup
		}
	}
	#Listen to a story
	option = {
		name = {
			text = {
				first_valid = {
					#Return to the storyteller
					triggered_desc = {
						trigger = { exists = scope:been_to_storyteller }
						desc = ep3_laamp_decision_event.1030.a_second
					}
					#First time at the storyteller's
					desc = ep3_laamp_decision_event.1030.a
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1030.a.cooldown.tt
				NOT = { exists = scope:laamp_decision_has_storied }
			}
		}
		show_as_unavailable = { always = yes }
		reason = storyteller
		custom_tooltip = ep3_laamp_decision_event.1030.a.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = tavern }
		#Go to the storyteller
		trigger_event = ep3_laamp_decision_event.1031
		ai_chance = { base = 100 }
	}
	#Look for someone to recruit
	option = {
		name = {
			text = {
				first_valid = {
					#Return to the recruits
					triggered_desc = {
						trigger = { exists = scope:been_to_recruit }
						desc = ep3_laamp_decision_event.1030.b_second
					}
					#First time talking to recruits
					desc = ep3_laamp_decision_event.1030.b
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1030.b.cooldown.tt
				NOT = { exists = scope:laamp_decision_has_recruited }
			}
		}
		show_as_unavailable = { always = yes }
		reason = recruitment
		custom_tooltip = ep3_laamp_decision_event.1030.b.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = tavern }
		#Go to the recruits
		trigger_event = ep3_laamp_decision_event.1033
		ai_chance = { base = 100 }
	}
	#Check out that Spouse Material
	option = {
		name = {
			text = {
				first_valid = {
					#Already scoped out the spouse
					triggered_desc = {
						trigger = { 
							OR = {
								exists = scope:been_to_spouse
								exists = scope:laamp_recurring_spouse
							}
						}
						desc = ep3_laamp_decision_event.1030.c_second
					}
					#First time talking to spouse
					desc = ep3_laamp_decision_event.1030.c
				}
			}
		}
		trigger = {
			exists = scope:laamp_spouse_material
			#Recently recruited a spouse, settle down there
			trigger_if = {
				limit = { has_variable = 1035_has_spoused_recently }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1030.c.cooldown.tt
					always = no
				}
			}
			#Loc differences
			trigger_else_if = {
				limit = { scope:laamp_decision_has_spoused ?= flag:no }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1030.c.failure.cooldown.tt
					always = no
				}
			}
			trigger_else = { always = yes }
		}
		show_as_unavailable = {
			#Show it if we return here from the Spouse screen
			trigger_if = {
				limit = { exists = scope:laamp_spouse_material }
				always = yes 
			}
			#If we are already married, don't show it
			trigger_else = { always = no }
		}
		reason = potential_spouse
		highlight_portrait = scope:laamp_spouse_material
		#Been there once already
		if = {
			limit = {
				OR = {
					exists = scope:laamp_recurring_spouse
					exists = scope:been_to_spouse
				}
			}
			custom_tooltip = ep3_laamp_decision_event.1030.c.tt_second
		}
		else = {
			custom_tooltip = ep3_laamp_decision_event.1030.c.tt
		}
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = tavern }
		#Go to the spouse material
		trigger_event = ep3_laamp_decision_event.1035
		ai_chance = { base = 100 }
	}
	#Rare Option: Visit Hooded Figure
	option = {
		name = {
			text = {
				first_valid = {
					#Return to the Hood noble
					triggered_desc = {
						trigger = { 
							exists = scope:been_to_hood
							exists = scope:laamp_disguised_noble
						}
						desc = ep3_laamp_decision_event.1030.d_third
					}
					#Return to the Hood thief
					triggered_desc = {
						trigger = { exists = scope:been_to_hood }
						desc = ep3_laamp_decision_event.1030.d_second
					}
					#First time at the Hood
					desc = ep3_laamp_decision_event.1030.d
				}
			}
		}
		trigger = {
			exists = scope:laamp_hooded_figure
			NOT = { exists = scope:laamp_decision_recruited_hood }
			is_ai = no
		}
		reason = hooded_character
		#Been there once already
		if = {
			limit = { exists = scope:been_to_hood }
			custom_tooltip = ep3_laamp_decision_event.1030.d.tt_second
		}
		else = {
			custom_tooltip = ep3_laamp_decision_event.1030.d.tt
		}
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = tavern }
		#Go to the hooded figure screen
		trigger_event = ep3_laamp_decision_event.1037
	}
	#I want to do something else
	option = {
		name = {
			text = {
				first_valid = {
					#Nothing left to do
					triggered_desc = {
						trigger = { 1030_done_with_tavern_trigger = yes }
						desc = ep3_laamp_decision_event.1030.e_second
					}
					#Back to main square
					desc = ep3_laamp_decision_event.1030.e
				}
			}
		}
		#Have we done everything? Are we closing off the option?
		if = {
			limit = { 1030_done_with_tavern_trigger = yes }
			#Clean up unnecessary variables and close off the option
			1030_finished_tavern_effect = yes
		}
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = tavern }
		#Go back to the main event
		1000_return_to_main_effect = yes
		ai_chance = { base = 100 }
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:tavern }
		remove_variable ?= 1030_use_partner_animation_var
	}
}


#Return to the holding hub (church grounds, castle grounds etc) from a subsequent event
scripted_effect 1031_been_to_effect = {
	#For desc flavor
	if = {
		limit = {
			NOT = { exists = scope:been_to_$GUILD$ }
		}
		save_scope_as = been_to_$GUILD$
	}
	#Go back to the previous screen
	if = {
		limit = { var:return_from_location ?= flag:tavern }
		1031_return_to_tavern_effect = yes
	}
	#Go back to church grounds
	if = {
		limit = { var:return_from_location ?= flag:church_grounds }
		1041_return_to_church_grounds_effect = yes
	}
	#Go back to castle grounds
	if = {
		limit = { var:return_from_location ?= flag:castle_grounds }
		1051_return_to_castle_effect = yes
	}
	#Go back to craftsmen district
	if = {
		limit = { var:return_from_location ?= flag:craftsmen }
		1061_return_to_craftsmen_effect = yes
	}
}

#We return to the tavern main room to peruse other options
scripted_effect 1031_return_to_tavern_effect = {
	custom_tooltip = ep3_laamp_decision_event.1031.return.tt
	trigger_event = ep3_laamp_decision_event.1030
}

#Set the correct variable to block off the Storyteller option and remove the desc flavor variable
scripted_effect 1031_storied_effect = {
	save_scope_as = laamp_decision_has_storied
	#Go back to the tavern main room
	hidden_effect = { 1031_return_to_tavern_effect = yes }
}

#The one that ya want
scripted_effect 1031_actual_skill_increase_effect = {
	if = {
		limit = { scope:1031_skill_to_buff = flag:diplomacy }
		add_diplomacy_skill = 1
	}
	if = {
		limit = { scope:1031_skill_to_buff = flag:martial }
		add_martial_skill = 1
	}
	if = {
		limit = { scope:1031_skill_to_buff = flag:stewardship }
		add_stewardship_skill = 1
	}
	if = {
		limit = { scope:1031_skill_to_buff = flag:intrigue }
		add_intrigue_skill = 1
	}
	if = {
		limit = { scope:1031_skill_to_buff = flag:learning }
		add_learning_skill = 1
	}
}

#Participation prize
scripted_effect 1031_add_skill_modifier_effect = {
	if = {
		limit = { scope:1031_skill_to_buff = flag:diplomacy }
		add_character_modifier = {
			modifier = laamp_decision_exotic_story_diplomacy_gain_modifier
			days = visit_settlement_minimum_cooldown_days
		}
	}
	if = {
		limit = { scope:1031_skill_to_buff = flag:martial }
		add_character_modifier = {
			modifier = laamp_decision_exotic_story_martial_gain_modifier
			days = visit_settlement_minimum_cooldown_days
		}
	}
	if = {
		limit = { scope:1031_skill_to_buff = flag:stewardship }
		add_character_modifier = {
			modifier = laamp_decision_exotic_story_stewardship_gain_modifier
			days = visit_settlement_minimum_cooldown_days
		}
	}
	if = {
		limit = { scope:1031_skill_to_buff = flag:intrigue }
		add_character_modifier = {
			modifier = laamp_decision_exotic_story_intrigue_gain_modifier
			days = visit_settlement_minimum_cooldown_days
		}
	}
	if = {
		limit = { scope:1031_skill_to_buff = flag:learning }
		add_character_modifier = {
			modifier = laamp_decision_exotic_story_learning_gain_modifier
			days = visit_settlement_minimum_cooldown_days
		}
	}
}

#Modified by how low the skill is - lower means higher chance
scripted_effect 1031_boost_lowest_skill_effect = {
	random_list = {
		2 = {
			desc = ep3_laamp_decision_event.1031.a_success.desc
			trigger = {
				trigger_if = {
					limit = { has_variable = 1031_skill_gain_variable }
					var:1031_skill_gain_variable != visit_settlement_skill_gain_cap_value
				}
				trigger_else = { always = yes }
			}
			#Skill is less than low_skill_rating
			modifier = {
				scope:1031_skill_to_buff_value < low_skill_rating
				add = 23
			}
			#Skill is less than average_skill_rating
			modifier = {
				scope:1031_skill_to_buff_value >= low_skill_rating
				scope:1031_skill_to_buff_value < average_skill_rating
				add = 18
			}
			#Skill is less than medium_skill_rating
			modifier = {
				scope:1031_skill_to_buff_value >= average_skill_rating
				scope:1031_skill_to_buff_value < medium_skill_rating
				add = 13
			}
			#Skill is less than high_skill_rating
			modifier = {
				scope:1031_skill_to_buff_value >= medium_skill_rating
				scope:1031_skill_to_buff_value < high_skill_rating
				add = 8
			}
			#Skill is less than very_high_skill_rating
			modifier = {
				scope:1031_skill_to_buff_value >= high_skill_rating
				scope:1031_skill_to_buff_value < very_high_skill_rating
				add = 3
			}
			#What do you mean, only see one side of the argument?
			modifier = {
				has_trait = zealous
				factor = 0.8
			}
			#Easier time finding the silver lining. Probs.
			modifier = {
				has_trait = eccentric
				factor = 2
			}
			send_interface_toast = {
				type = event_toast_effect_good
				title = ep3_laamp_decision_event.1031.a_success.t
				desc = ep3_laamp_decision_event.1031.a_success.desc
				left_icon = root
				#Increase skill
				1031_actual_skill_increase_effect = yes
			}
			#We cap the max amount of skill points gained
			if = {
				limit = {
					NOT = { has_variable = 1031_skill_gain_variable }
				}
				set_variable = {
					name = 1031_skill_gain_variable
					value = 1
				}
			}
			else_if = {
				limit = {
					has_variable = 1031_skill_gain_variable
					var:1031_skill_gain_variable != visit_settlement_skill_gain_cap_value
				}
				change_variable = {
					name = 1031_skill_gain_variable
					add = 1
				}
			}
			else = {
				#Nothing happens
			}
		}
		25 = {
			desc = ep3_laamp_decision_event.1031.a_semi_success.desc
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = ep3_laamp_decision_event.1031.a_semi_success.t
				desc = ep3_laamp_decision_event.1031.a_semi_success.desc
				left_icon = root
				#Have some lifestyle xp
				if = {
					limit = { scope:1031_skill_to_buff = flag:diplomacy }
					add_diplomacy_lifestyle_xp = medium_lifestyle_xp
				}
				if = {
					limit = { scope:1031_skill_to_buff = flag:martial }
					add_martial_lifestyle_xp = medium_lifestyle_xp
				}
				if = {
					limit = { scope:1031_skill_to_buff = flag:stewardship }
					add_stewardship_lifestyle_xp = medium_lifestyle_xp
				}
				if = {
					limit = { scope:1031_skill_to_buff = flag:intrigue }
					add_intrigue_lifestyle_xp = medium_lifestyle_xp
				}
				if = {
					limit = { scope:1031_skill_to_buff = flag:learning }
					add_learning_lifestyle_xp = medium_lifestyle_xp
				}
			}
		}
		50 = {
			desc = ep3_laamp_decision_event.1031.a_failure.desc
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = ep3_laamp_decision_event.1031.a_failure.t
				desc = ep3_laamp_decision_event.1031.a_failure.desc
				left_icon = root
				#Apply temporary skill modifier
				1031_add_skill_modifier_effect = yes
			}
		}
	}
}

#Used often enough to warrant a trigger
scripted_trigger 1031_is_max_witty_trigger = {
	has_trait = tourney_participant
	has_trait_xp = {
		trait = tourney_participant
		track = wit
		value = 100
	} 
}


#Storyteller
ep3_laamp_decision_event.1031 = {
	type = character_event
	title = ep3_laamp_decision_event.1031.t
	window = visit_settlement_window
	desc = {
		#Stay a while, and listen!
		random_valid = {
			triggered_desc = {
				trigger = {
				 	OR = {
				 		var:1031_saved_storyteller_state ?= 1
				 		var:1031_saved_storyteller_state ?= 9
				 	}
				}
				desc = ep3_laamp_decision_event.1031.desc_01
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 2
						var:1031_saved_storyteller_state ?= 10
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_02
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 3
						var:1031_saved_storyteller_state ?= 11
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_03
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 4
						var:1031_saved_storyteller_state ?= 12
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_04
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 5
						var:1031_saved_storyteller_state ?= 13
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_05
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 6
						var:1031_saved_storyteller_state ?= 14
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_06
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 7
						var:1031_saved_storyteller_state ?= 15
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_07
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 8
						var:1031_saved_storyteller_state ?= 16
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_08
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 9
						var:1031_saved_storyteller_state ?= 1
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_09
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 10
						var:1031_saved_storyteller_state ?= 2
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_10
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 11
						var:1031_saved_storyteller_state ?= 3
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_11
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 12
						var:1031_saved_storyteller_state ?= 4
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_12
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 13
						var:1031_saved_storyteller_state ?= 5
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_13
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 14
						var:1031_saved_storyteller_state ?= 6
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_14
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 15
						var:1031_saved_storyteller_state ?= 7
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_15
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 16
						var:1031_saved_storyteller_state ?= 8
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_16
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 17
						var:1031_saved_storyteller_state ?= 9
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_17
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 18
						var:1031_saved_storyteller_state ?= 10
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_18
			}
			triggered_desc = {
				trigger = {
					OR = {
						var:1031_saved_storyteller_state ?= 19
						var:1031_saved_storyteller_state ?= 11
					}
				}
				desc = ep3_laamp_decision_event.1031.desc_19
			}
		}
		desc = ep3_laamp_decision_event.1031.desc_outro
	}
	theme = landless_adventurer
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_learning" }
	override_icon = { reference = "gfx/interface/icons/event_types/type_learning.dds" }
	override_background = {
		trigger = {
			scope:visiting_location = { 1000_is_a_nomadic_holding_trigger = yes }
		}
		reference = bp1_bonfire 
	}
	override_background = {
		trigger = { 
			scope:visiting_location = {
				OR = {
					has_holding_type = tribal_holding
					has_holding_type = nomad_holding
					has_holding_type = herder_holding
				}
			} 
		}
		reference = bp1_kitchen_western
	}
	override_background = { reference = relaxing_room_location }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		triggered_animation = {
			trigger = { has_trait = zealous }
			animation = personality_cynical
		}
		animation = interested
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = eccentric }
			animation = happiness
		}
		triggered_animation = {
			trigger = { has_trait = zealous }
			animation = dismissal
		}
		animation = thinking
	}
	right_portrait = {
		character = scope:laamp_storyteller
		camera = camera_event_scheme_far_right
		animation = storyteller
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Can we _not_ repeat the loc?
		if = {
			limit = { has_variable = 1031_saved_storyteller_state }
			#We're capped out? Reset.
			if = {
				limit = { var:1031_saved_storyteller_state = 19 }
				remove_variable ?= 1031_saved_storyteller_state
				set_variable = {
					name = 1031_saved_storyteller_state
					value = 1
					years = 10
				}
			}
			#No? Then just increment.
			else = {
				save_scope_value_as = {
					name = 1031_storyteller_state_cache
					value = var:1031_saved_storyteller_state
				}
				remove_variable ?= 1031_saved_storyteller_state
				set_variable = {
					name = 1031_saved_storyteller_state
					value = {
						value = scope:1031_storyteller_state_cache
						add = 1
					}
					years = 10
				}
			}
		}
		#Otherwise set up the counter
		else = {
			set_variable = {
				name = 1031_saved_storyteller_state
				value = {
					#Randomize where we start
					integer_range = {
						min = 1
						max = 16
					}
				}
				years = 10
			}
		}
		#Find our storyteller
		if = {
			#Do we already have a storyteller?
			limit = {
				NOT = { exists = scope:laamp_storyteller }
			}
			#Has this person been our storyteller in the past 10 years?
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					faith = scope:visiting_location.faith
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_storyteller_trigger = yes
					1010_is_a_saved_merchant_trigger = no
					1010_is_a_saved_peddler_trigger = no
					1010_is_a_saved_crier_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_healer_trigger = no
					1010_is_a_saved_clergy_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_weaponsmith_trigger = no
					1010_is_a_saved_armorer_trigger = no
					1010_is_a_saved_jeweler_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
				}
				save_scope_as = laamp_storyteller
			}
			#Otherwise find a storyteller in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_storyteller }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						has_trait = lifestyle_reveler
					}
					save_scope_as = laamp_storyteller
				}
			}
			#Otherwise create a storyteller
			if = {
				limit = {
					NOT = { exists = scope:laamp_storyteller }
				}
				#Create storyteller to stuff in pool
				create_character = {
					template = generic_peasant_character
					location = scope:visiting_location
					dynasty = none
					trait = lifestyle_reveler
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_storyteller
				}
			}
			#Make 'em a Reveler
			scope:laamp_storyteller ?= {
				if = {
					limit = {
						NOT = { has_trait = lifestyle_reveler }
					}
					add_trait = lifestyle_reveler
					add_trait_xp = {
						trait = lifestyle_reveler
						value = {
						    integer_range = {
						        min = small_lifestyle_random_xp_mid
						        max = small_lifestyle_random_xp_high
						    }
						}
					}
				}
			}
			#Remember the storyteller
			1010_remember_vendor_character_effect = { GUILD = storyteller CHARACTER = scope:laamp_storyteller }
		}
		#What skill do we buff?
		if = {
			limit = {
				NOT = { exists = scope:1031_skill_to_buff }
			}
			#Roll for which skill to boost
			random_list = {
				1 = {
					save_scope_value_as = {
						name = 1031_skill_to_buff
						value = flag:diplomacy
					}
					save_scope_value_as = {
						name = 1031_skill_to_buff_value
						value = diplomacy
					}
				}
				1 = {
					save_scope_value_as = {
						name = 1031_skill_to_buff
						value = flag:martial
					}
					save_scope_value_as = {
						name = 1031_skill_to_buff_value
						value = martial
					}
				}
				1 = {
					save_scope_value_as = {
						name = 1031_skill_to_buff
						value = flag:stewardship
					}
					save_scope_value_as = {
						name = 1031_skill_to_buff_value
						value = stewardship
					}
				}
				1 = {
					save_scope_value_as = {
						name = 1031_skill_to_buff
						value = flag:intrigue
					}
					save_scope_value_as = {
						name = 1031_skill_to_buff_value
						value = intrigue
					}
				}
				1 = {
					save_scope_value_as = {
						name = 1031_skill_to_buff
						value = flag:learning
					}
					save_scope_value_as = {
						name = 1031_skill_to_buff_value
						value = learning
					}
				}
			}
		}
		#Save the xp trait as a static number
		if = {
			limit = {
				NOR = {
					#We're not already maxed in Wit
					1031_is_max_witty_trigger = yes
					exists = scope:storyteller_xp
				}	
			}
			save_scope_value_as = {
				name = storyteller_xp
				value = {
				    integer_range = {
				        min = small_lifestyle_random_xp_low
				        max = small_lifestyle_random_xp_mid
				    }
				}
			}	
		}
	}
	#Contemplate the story
	option = {
		name = {
			text = {
				first_valid = {
					#Eccentric appreciates this
					triggered_desc = {
						trigger = { has_trait = eccentric }
						desc = ep3_laamp_decision_event.1031.a_eccentric
					}
					#Zealous does not appreciate this
					triggered_desc = {
						trigger = { has_trait = zealous }
						desc = ep3_laamp_decision_event.1031.a_zealous
					}
					#'s alright I guess
					desc = ep3_laamp_decision_event.1031.a
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1031.a.cooldown.tt
				NOT = { has_variable = 1031_has_storied_recently }
			}
		}
		show_as_unavailable = { always = yes }
		#Set the cooldown on the action
		set_variable = {
			name = 1031_has_storied_recently
			days = visit_settlement_minimum_cooldown_days
		}
		#Chance to boost your lowest skill
		1031_boost_lowest_skill_effect = yes
		if = {
			limit = {
				has_trait = zealous
				NOT = { has_trait = eccentric }
			}
			stress_impact = { zealous = miniscule_stress_impact_gain }
		}
		#Set the variables and redirect us back to the tavern main room
		1031_storied_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				has_variable = 1031_skill_gain_variable
				var:1031_skill_gain_variable < visit_settlement_skill_gain_cap_value
				add = 400 #Just do it
			}
		}
	}
	#Learn revelry or strong-arm the skill gain
	option = {
		name = {
			text = {
				first_valid = {
					#I know this one!
					triggered_desc = {
						trigger = { 1031_is_max_witty_trigger = yes }
						desc = ep3_laamp_decision_event.1031.b_reveler
					}
					#Yeeh narration!
					desc = ep3_laamp_decision_event.1031.b
				}
			}
		}
		trigger = {
			#Put a cooldown on strongarming it
			trigger_if = {
				limit = { 1031_is_max_witty_trigger = yes }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1031.b.cooldown.tt
					NOT = { has_variable = 1031_has_reveled_recently }
				}
			}
			#If we're zealous, we also need to be eccentric
			trigger_if = {
				limit = { has_trait = zealous }
				has_trait = eccentric
			}
			#Trigger for everyone else
			trigger_else = {
				always = yes
			}
		}
		show_as_unavailable = {
			#Hide if what you're missing is a trait
			trigger_if = {
				limit = { 
					has_trait = zealous
					NOT = { has_trait = eccentric }
				}
				always = no
			}
			trigger_else = { always = yes }	
		}
		#Strongarm it
		if = {
			limit = { 1031_is_max_witty_trigger = yes }
			1031_actual_skill_increase_effect = yes
			#Set the cooldown on the action
			set_variable = {
				name = 1031_has_reveled_recently
				months = visit_settlement_small_cooldown_days
			}
			stress_impact = {
				base = medium_stress_impact_gain
				ambitious = minor_stress_impact_loss
			}
		}
		#Otherwise learn something
		else = { 
			#Pay up
			pay_short_term_gold = {
				target = scope:laamp_storyteller
				gold = minor_gold_laamps_value
			}
			#Gain trait
			if = {
				limit = {
					NOT = { has_trait = tourney_participant }
				}
				add_trait = tourney_participant
				add_trait_xp = {
					trait = tourney_participant
					track = wit
					value = scope:storyteller_xp
				}
			}
			#Or be educated
			else = {
				add_trait_xp = {
					trait = tourney_participant
					track = wit
					value = scope:storyteller_xp
				}
			}
		}
		#Set the variables and redirect us back to the tavern main room
		1031_storied_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				1031_is_max_witty_trigger = no
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				1031_is_max_witty_trigger = yes
				stress_level > 1
				factor = 0
			}
		}
	}
	#Stress relief
	option = {
		name = {
			text = {
				first_valid = {
					#Blasphemy!
					triggered_desc = { 
						trigger = { has_trait = zealous }
						desc = ep3_laamp_decision_event.1031.c_zealous
					}
					#_I_ was entertained
					desc = ep3_laamp_decision_event.1031.c
				}
			}
		}
		trigger = {
			#Put a cooldown on relaxation
			custom_tooltip = {
				text = ep3_laamp_decision_event.1031.c.cooldown.tt
				NOT = { has_variable = 1031_has_relaxed_recently }
			}
		}
		show_as_unavailable = { always = yes }
		#Heathens!
		if = {
			limit = { has_trait = zealous }
			add_piety = minor_piety_gain
		}
		#Took my mind off of things
		stress_impact = { 
			base = miniscule_stress_impact_loss
			zealous = minor_stress_impact_loss
		}
		#Set the cooldown on the action
		set_variable = {
			name = 1031_has_relaxed_recently
			months = visit_settlement_minimum_cooldown_days
		}
		#Set the variables and redirect us back to the tavern main room
		1031_storied_effect = yes
		ai_chance = {
			base = 200 #Just do it
		}
	}
	#I want to go back
	option = {
		name = ep3_laamp_decision_event.1031.d
		#If you can't do anything, go in here, see the cooldown dates, go out and then we grey out the option
		if = {
			limit = {
				has_variable = 1031_has_storied_recently
				has_variable = 1031_has_reveled_recently
				has_variable = 1031_has_relaxed_recently
			}
			#Set the variables and redirect us back to the tavern main room
			1031_storied_effect = yes
		}
		else = {
			#Set the variables and redirect us back to the tavern main room
			1031_been_to_effect = { GUILD = storyteller }
		}
		ai_chance = { base = 100 }
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:storyteller }
	}
}


#Set the correct variable to block off the Recruitment option and remove the desc flavor variable
scripted_effect 1033_recruited_effect = {
	save_scope_as = laamp_decision_has_recruited
	#Go back to the tavern main room
	hidden_effect = { 1031_return_to_tavern_effect = yes }
}

#Tombola!
scripted_effect 1033_generate_character_effect = {
	random_list = {
		#Generic
		60 = {
			create_character = {
				template = generic_peasant_character
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				diplomacy = { decent_skill_rating high_skill_rating }
				save_scope_as = 1033_new_character
			}
		}
		#Diplomacy
		10 = {
			#Some variation
			modifier = {
				scope:visiting_location = {
					OR = {
						has_holding_type = tribal_holding
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				factor = 2
			}
			create_character = {
				template = bp1_yearly_2021_diplomacy_person_template
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				diplomacy = { decent_skill_rating high_skill_rating }
				save_scope_as = 1033_new_character
			}
		}
		#Martial
		10 = {
			modifier = {
				scope:visiting_location = { has_holding_type = castle_holding }
				factor = 2
			}
			create_character = {
				template = bp1_yearly_2021_martial_person_template
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				martial = { decent_skill_rating high_skill_rating }
				save_scope_as = 1033_new_character
			}
		}
		#Stewardship
		10 = {
			modifier = {
				scope:visiting_location = { has_holding_type = city_holding }
				factor = 2
			}
			create_character = {
				template = bp1_yearly_2021_stewardship_person_template
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				stewardship = { decent_skill_rating high_skill_rating }
				save_scope_as = 1033_new_character
			}
		}
		#Intrigue
		10 = {
			modifier = {
				scope:visiting_location = {
					OR = {
						has_holding_type = tribal_holding
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				factor = 2
			}
			create_character = {
				template = bp1_yearly_2021_intrigue_person_template
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				intrigue = { decent_skill_rating high_skill_rating }
				save_scope_as = 1033_new_character
			}
		}
		#Learning
		10 = {
			modifier = {
				scope:visiting_location = { 
					OR = {
						has_holding_type = church_holding
						has_holding_type = temple_citadel_holding
					}
				}
				factor = 2
			}
			create_character = {
				template = bp1_yearly_2021_learning_person_template
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				learning = { decent_skill_rating high_skill_rating }
				save_scope_as = 1033_new_character
			}
		}
		#... witch
		5 = {
			modifier = {
				scope:visiting_location = {
					OR = {
						has_holding_type = tribal_holding
						has_holding_type = nomad_holding
						has_holding_type = herder_holding
					}
				}
				factor = 2
			}
			create_character = {
				template = bp1_yearly_2021_learning_witch_template
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				learning = { decent_skill_rating high_skill_rating }
				save_scope_as = 1033_new_character
			}
		}
	}
	scope:1033_new_character ?= {
		#Chance to add a malus trait to this spectatular being
		if = {
			limit = { 
				NOR = { 
					has_trait = possessed_1 
					has_trait = lunatic_1
					has_trait = depressed_1
					has_trait = drunkard
					has_trait = hashishiyah
					has_trait = irritable
				}
			}
			hidden_effect = {
				random = {
					chance = 20
					random_list = {
						10 = { add_trait = possessed_1 }
						10 = { add_trait = lunatic_1 }
						10 = { add_trait = depressed_1 }
						10 = { add_trait = drunkard }
						10 = { add_trait = hashishiyah }
						10 = { add_trait = irritable }
					}
				}
			}
		}
	}
	if = {
		limit = { scope:laamp_first_recruit ?= $SCOPE$ }
		scope:1033_new_character = { save_scope_as = laamp_first_recruit }
	}
	if = {
		limit = { scope:laamp_second_recruit ?= $SCOPE$ }
		scope:1033_new_character = { save_scope_as = laamp_second_recruit }
	}
	if = {
		limit = { scope:laamp_third_recruit ?= $SCOPE$ }
		scope:1033_new_character = { save_scope_as = laamp_third_recruit }
	}
}

#Used enough to warrant an effect
scripted_effect 1033_add_courtier_with_opinion_effect = {
	if = {
		limit = {
			has_perk = professional_workforce_perk
		}
		$TARGET$ = {
			if = {
				limit = {
					highest_skill_including_prowess = prowess
				}
				add_prowess_skill = 5
			}
			else_if = {
				limit = {
					highest_skill = intrigue
				}
				add_intrigue_skill = 5
			}
			else_if = {
				limit = {
					highest_skill = martial
				}
				add_martial_skill = 5
			}
			else_if = {
				limit = {
					highest_skill = stewardship
				}
				add_stewardship_skill = 5
			}
			else_if = {
				limit = {
					highest_skill = diplomacy
				}
				add_diplomacy_skill = 5
			}
			else_if = {
				limit = {
					highest_skill = learning
				}
				add_learning_skill = 5
			}
			hidden_effect = {
				force_character_skill_recalculation = yes
			}
		}
	}
	add_courtier = $TARGET$
	hidden_effect = {
		$TARGET$ = {
			add_opinion = {
				modifier = recruited_me_opinion
				target = root
				opinion = 50
			}
		}
	}
}

scripted_effect 1033_set_cost_effect = {
	save_scope_value_as = {
		name = $VALUE_NAME$_sum_skills
		value = {
			add = $CHARACTER$.diplomacy
			add = $CHARACTER$.martial
			add = $CHARACTER$.stewardship
			add = $CHARACTER$.intrigue
			add = $CHARACTER$.learning
			add = $CHARACTER$.prowess
		}
	}
	save_scope_value_as = {
        name = $VALUE_NAME$
        value = {
            integer_range = {
                min = medium_gold_laamps_value
                max = major_gold_laamps_value
            }
            #Cheaper out in the wilds
            if = {
                limit = { 
                    scope:visiting_location = {
						OR = {
							has_holding_type = tribal_holding
							has_holding_type = nomad_holding
							has_holding_type = herder_holding
						}
					}
                }
                multiply = 0.6
            }
            if = { #They're stellar? More expensive. :elmofire:
                limit = { scope:$VALUE_NAME$_sum_skills >= 120 } #Good in all skills?
                multiply = 8 #20 in all skills
            }
            else_if = {
                limit = { scope:$VALUE_NAME$_sum_skills >= 100 } #Good in four skills?
                multiply = 5
            }
            else_if = {
                limit = { scope:$VALUE_NAME$_sum_skills >= 80 } #Good in three skills?
                multiply = 4
            }
            else_if = {
                limit = { scope:$VALUE_NAME$_sum_skills >= 60 } #Good in two skills?
                multiply = 3
            }
            else_if = {
                limit = { scope:$VALUE_NAME$_sum_skills >= 40 } #Good in one-and-a-half skill? Should be roughly 90-110 gold
                multiply = 2.5
            }
            else_if = {
                limit = { scope:$VALUE_NAME$_sum_skills >= 20 } #Good in one skill?
                multiply = 1.5
            }
            #Add perk discounts and other things here.
        }
    }
}

#This is a remotely interesting character
scripted_trigger 1033_has_interesting_skillset_trigger = {
	OR = {
		diplomacy > high_skill_rating
		martial > high_skill_rating
		stewardship > high_skill_rating
		intrigue > high_skill_rating
		learning > high_skill_rating
		prowess > high_skill_rating
	}
}


#Recruitment 
ep3_laamp_decision_event.1033 = {
	type = character_event
	title = ep3_laamp_decision_event.1033.t
	window = visit_settlement_window
	desc = {
		#What's going down in the recruitment corner
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: We have three recruits
			random_valid = {
				triggered_desc = { 
					trigger = {
						NOT = { exists = scope:laamp_generic_jane }
						exists = scope:been_to_recruit
						scope:recruit_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1033.desc_returned_01
				}
				triggered_desc = { 
					trigger = {
						NOT = { exists = scope:laamp_generic_jane }
						scope:recruit_loc_tracker ?= 1 
					}
					desc = ep3_laamp_decision_event.1033.desc_returned_02
				}
			}
			#RETURN: We have two recruits, and Jane
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_recruit
						scope:recruit_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1033.desc_returned_jane_01
				}
				triggered_desc = { 
					trigger = { scope:recruit_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1033.desc_returned_jane_02
				}
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_recruit }
				}
				desc = ep3_laamp_decision_event.1033.desc
			}	
		}
		#Do we have two or three potential recruits?
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:laamp_generic_jane
					NOT = { exists = scope:been_to_recruit }
				}
				desc = ep3_laamp_decision_event.1033.desc_mid_two
			}
			triggered_desc = {
				trigger = {
					NOT = { 
						exists = scope:been_to_recruit
						exists = scope:laamp_generic_jane
					}
				}
				desc = ep3_laamp_decision_event.1033.desc_mid_three
			}
		}
		#OUTRO:
		first_valid = {
			#We have a Visiting Partner
			triggered_desc = {
				trigger = {
					exists = scope:visiting_partner
					NOT = { exists = scope:laamp_generic_jane }
				}
				desc = ep3_laamp_decision_event.1033.desc_partner_outro
			}
			#We have a Generic Jane
			triggered_desc = {
				trigger = {
					exists = scope:laamp_generic_jane
					NOT = { exists = scope:been_to_recruit }
				}
				desc = ep3_laamp_decision_event.1033.desc_jane_outro
			}
			triggered_desc = {
				trigger = { exists = scope:laamp_generic_jane }
				desc = ep3_laamp_decision_event.1033.desc_returned_jane_outro
			}
			#We have no Visiting Partner or Generic Jane
			desc = ep3_laamp_decision_event.1033.desc_outro
		}
	}
	theme = landless_adventurer
	override_icon = { reference = "gfx/interface/icons/event_types/type_duty.dds" }
	override_background = { reference = feast }
	#Our recruits
	left_portrait = {
		trigger = { exists = scope:1033_first_character }
		character = scope:1033_first_character
		triggered_animation = {
			trigger = { 
				scope:recruit_loc_tracker ?= 1
				NOT = { scope:1033_first_character ?= scope:visiting_partner }
			}
			animation = flirtation
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:1033_first_character = { 1010_has_friendly_traits = yes } 
			}
			animation = admiration
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:1033_first_character = { 1010_has_commerce_traits = yes } 
			}
			animation = schadenfreude
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:1033_first_character = { 1010_has_uninterested_traits = yes } 
			}
			animation = personality_cynical
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:1033_first_character = { 1010_has_irrational_traits = yes } 
			}
			animation = personality_irrational
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:1033_first_character = { 1010_has_standoffish_traits = yes } 
			}
			animation = shame
		}
		animation = interested
	}
	center_portrait = {
		character = scope:1033_second_character
		triggered_animation = {
			trigger = { 
				scope:recruit_loc_tracker ?= 1
				scope:1033_second_character != root
			}
			animation = worry
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:1033_second_character = { 1010_has_friendly_traits = yes } 
			}
			animation = personality_compassionate
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:1033_second_character = { 1010_has_commerce_traits = yes } 
			}
			animation = personality_dishonorable
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:1033_second_character = { 1010_has_uninterested_traits = yes } 
			}
			animation = personality_callous
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:1033_second_character = { 1010_has_irrational_traits = yes } 
			}
			animation = laugh
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:1033_second_character = { 1010_has_standoffish_traits = yes } 
			}
			animation = disbelief
		}
		animation = hero_flex
	}
	right_portrait = {
		trigger = { exists = scope:1033_third_character }
		character = scope:1033_third_character
		camera = camera_event_scheme_center_forward
		triggered_animation = {
			trigger = { exists = scope:laamp_generic_jane }
			animation = personality_zealous
		}
		triggered_animation = {
			trigger = { 
				scope:recruit_loc_tracker ?= 1
				NOT = { exists = scope:laamp_generic_jane }
			}
			animation = disapproval
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:1033_third_character = { 1010_has_friendly_traits = yes } 
			}
			animation = personality_forgiving
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:1033_third_character = { 1010_has_commerce_traits = yes } 
			}
			animation = personality_greedy
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:1033_third_character = { 1010_has_uninterested_traits = yes } 
			}
			animation = disapproval
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:1033_third_character = { 1010_has_irrational_traits = yes } 
			}
			animation = eccentric
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:1033_third_character = { 1010_has_standoffish_traits = yes } 
			}
			animation = personality_coward
		}
		animation = scheme
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#For the background
		scope:visiting_location.county.holder = { save_scope_as = bg_override_char }
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = recruit }
		#Create the characters
		if = {
			limit = {
				NOT = { exists = scope:laamp_first_recruit }
			}
			#First character
			random_pool_character = {
				province = scope:visiting_location
				limit = { 
					1010_basic_merchant_checks_trigger = yes
					#Remotely interesting
					1033_has_interesting_skillset_trigger = yes
				}
				save_scope_as = laamp_first_recruit
			}
			#Otherwise create 'em
			if = {
				limit = {
					NOT = { exists = scope:laamp_first_recruit }
				}
				#Create first recruit to stuff in pool
				save_scope_as = laamp_first_recruit
				1033_generate_character_effect = { SCOPE = scope:laamp_first_recruit }
			}
			#Set their cost
			1033_set_cost_effect = { CHARACTER = scope:laamp_first_recruit VALUE_NAME = first_recruit_cost }
			#Second character
			random_pool_character = {
				province = scope:visiting_location
				limit = { 
					1010_basic_merchant_checks_trigger = yes
					#Remotely interesting
					1033_has_interesting_skillset_trigger = yes
					this != scope:laamp_first_recruit
				}
				save_scope_as = laamp_second_recruit
			}
			#Otherwise create 'em
			if = {
				limit = {
					NOT = { exists = scope:laamp_second_recruit }
				}
				#Create second recruit to stuff in pool
				save_scope_as = laamp_second_recruit
				1033_generate_character_effect = { SCOPE = scope:laamp_second_recruit }
			}
			#Set their cost
			1033_set_cost_effect = { CHARACTER = scope:laamp_second_recruit VALUE_NAME = second_recruit_cost }
			#You have no one? Well. Have a generic Joe
			if = {
				limit = { 
					any_courtier = { count <= 2 }
				}
				#Grab someone random
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						is_available_healthy_adult = yes
						NOR = { 
							this = scope:laamp_first_recruit 
							this = scope:laamp_second_recruit
						}
					}
					#More fun this way
					weight = {
						base = 1
						modifier = {
							any_secret = { exists = this }
							factor = 2
						}
					}
					save_scope_as = laamp_generic_jane
				}
				#Otherwise create 'em
				if = {
					limit = {
						NOT = { exists = scope:laamp_generic_jane }
					}
					#Create generic to stuff in pool
					create_character = {
						template = generic_peasant_character
						location = scope:visiting_location
						dynasty = none
						culture = scope:visiting_location.culture
						faith = scope:visiting_location.faith
						save_scope_as = laamp_generic_jane
					}
					#... you didn't think it would be _that_ easy, right?
					scope:laamp_generic_jane ?= {
						hidden_effect = {
							random = {
								chance = 20
								random_list = {
									#Have a murderer
									10 = { 
										trigger = { is_murderer_trigger = no }
							    		#Create a victim to kill
								    	create_character = {
											template = generic_peasant_character
											culture = scope:visiting_location.location.county.culture
											faith = scope:visiting_location.location.county.faith
											location = scope:visiting_location.location
											after_creation = { set_to_lowborn = yes }
											save_scope_as = 1030_previous_victim
										}
										scope:1030_previous_victim = {
											death = {
												death_reason = death_murder
												killer = scope:laamp_generic_jane
											}
										}
										#Set up secret
										scope:laamp_generic_jane = {
											add_secret = {
												type = secret_murder
												target = scope:1030_previous_victim
											}
										}
									}
									#Or a witch
									10 = { 
										trigger = { is_witch_trigger = no }
										add_secret = { type = secret_witch }
									}
									#Or a cannibal
									10 = { 
										trigger = { is_cannibal_trigger = no }
										add_secret = { type = secret_cannibal }
									}
									#Maybe a deviant?
									10 = { 
										trigger = { is_deviant_trigger = no }
										add_secret = { type = secret_deviant }
									}
								}		
							}
						}
					}
				}
			}
			#Third character
			if = {
				limit = {
					NOT = { exists = scope:laamp_generic_jane }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						#Remotely interesting
						1033_has_interesting_skillset_trigger = yes
						NOR = { 
							this = scope:laamp_first_recruit 
							this = scope:laamp_second_recruit
						}
					}
					save_scope_as = laamp_third_recruit
				}
				if = {
					limit = {
						NOT = { exists = scope:laamp_third_recruit }
					}
					#Create third recruit to stuff in pool
					save_scope_as = laamp_third_recruit
					1033_generate_character_effect = { SCOPE = scope:laamp_third_recruit }
				}	
				#Set their cost
				if = {
					limit = { exists = scope:laamp_third_recruit }
					1033_set_cost_effect = { CHARACTER = scope:laamp_third_recruit VALUE_NAME = third_recruit_cost }
				}
			}
		}
		#Determine whom to display
		if = {
			limit = {
				NOT = { exists = scope:1033_second_character }
			}
			if = {
				limit = { exists = scope:laamp_first_recruit }
				scope:laamp_first_recruit = { save_scope_as = 1033_first_character }
			}
			if = {
				limit = { exists = scope:laamp_second_recruit }
				scope:laamp_second_recruit = { save_scope_as = 1033_second_character }
			}
			if = {
				limit = { exists = scope:laamp_generic_jane }
				scope:laamp_generic_jane = { save_scope_as = 1033_third_character }
			}
			if = {
				limit = {
					NOT = { exists = scope:1033_third_character }
					exists = scope:laamp_third_recruit
				}
				scope:laamp_third_recruit = { save_scope_as = 1033_third_character }
			}
			if = {
				limit = {
					NOT = { exists = scope:1033_first_character }
					exists = scope:visiting_partner
				}
				scope:visiting_partner = { save_scope_as = 1033_first_character }
			}
			if = {
				limit = {
					NOT = { exists = scope:1033_second_character }
				}
				save_scope_as = 1033_second_character
			}
		}
	}
	#Recruit character A
	option = {
		name = ep3_laamp_decision_event.1033.a
		#Pay gold
		pay_short_term_gold = {
			target = scope:laamp_first_recruit
			gold = scope:first_recruit_cost
		}
		#Hire wo/manpower
		1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_first_recruit }
		#Set the variables and redirect us back to the tavern main room
		1033_recruited_effect = yes
		#Rewards for the Camp Party
		hidden_effect = {
			if = {
				limit = {
					has_character_flag = better_recruitment_visit_holding_flag
				}
				scope:laamp_first_recruit = {
					ep3_camp_party_visit_holding_skills_boost = yes
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				short_term_gold < scope:first_recruit_cost
				short_term_gold < laamp_ai_spending_pants_value
				any_courtier = { count <= 2 }
				factor = 0
			}
		}
	}
	#Recruit character B
	option = {
		name = ep3_laamp_decision_event.1033.b
		#Pay gold
		pay_short_term_gold = {
			target = scope:laamp_second_recruit
			gold = scope:second_recruit_cost
		}
		#Hire wo/manpower
		1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_second_recruit }
		#Set the variables and redirect us back to the tavern main room
		1033_recruited_effect = yes
		hidden_effect = {
			if = {
				limit = {
					has_character_flag = better_recruitment_visit_holding_flag
				}
				scope:laamp_second_recruit = {
					ep3_camp_party_visit_holding_skills_boost = yes
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				short_term_gold < scope:second_recruit_cost
				short_term_gold < laamp_ai_spending_pants_value
				any_courtier = { count <= 2 }
				factor = 0
			}
		}
	}
	#Recruit character C
	option = {
		name = ep3_laamp_decision_event.1033.c
		trigger = {
			NOT = { exists = scope:laamp_generic_jane }
		}
		#Pay gold
		pay_short_term_gold = {
			target = scope:laamp_third_recruit
			gold = scope:third_recruit_cost
		}
		#Hire wo/manpower
		1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_third_recruit }
		#Set the variables and redirect us back to the tavern main room
		1033_recruited_effect = yes
		hidden_effect = {
			if = {
				limit = {
					has_character_flag = better_recruitment_visit_holding_flag
				}
				scope:laamp_third_recruit = {
					ep3_camp_party_visit_holding_skills_boost = yes
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				short_term_gold < scope:third_recruit_cost
				short_term_gold < laamp_ai_spending_pants_value
				any_courtier = { count <= 2 }
				factor = 0
			}
		}
	}
	#Generic Jane keeps waving their hand
	option = {
		name = ep3_laamp_decision_event.1033.d
		trigger = { 
			custom_tooltip = {
				text = ep3_laamp_decision_event.1033.d.cooldown.tt
				NOT = { has_variable = 1033_generic_jane_cooldown }
				exists = scope:laamp_generic_jane
			}
		}
		show_as_unavailable = {
			#Show that it's unavailable if it would actually be available
			trigger_if = {
				limit = {
					exists = scope:laamp_generic_jane
					has_variable = 1033_generic_jane_cooldown
				}
				always = yes
			}
			trigger_else = { always = no }
		}
		#Add 'em
		1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_generic_jane }
		set_variable = {
			name = 1033_generic_jane_cooldown
			days = visit_settlement_minimum_cooldown_days
		}
		#Set the variables and redirect us back to the tavern main room
		1033_recruited_effect = yes
		hidden_effect = {
			if = {
				limit = {
					has_character_flag = better_recruitment_visit_holding_flag
				}
				scope:laamp_generic_jane = {
					ep3_camp_party_visit_holding_skills_boost = yes
				}
			}
		}
		ai_chance = {
			base = 1000 #Just do it
		}
	}
	#I want to go back
	option = {
		name = ep3_laamp_decision_event.1033.e
		#Set the variables and redirect us back to the tavern main room
		1031_been_to_effect = { GUILD = recruit }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 2
			}
		}
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:recruit }
	}
}


#Set the correct variable to block off the Spouse option and remove the desc flavor variable
scripted_effect 1035_spoused_effect = {
	save_scope_value_as = {
		name = laamp_decision_has_spoused
		value = flag:yes
	}
	#Cooldown for prowling
	set_variable = {
		name = 1035_has_spoused_recently
		days = visit_settlement_minimum_cooldown_days
	}
	#Go back to the tavern main room
	hidden_effect = { 1031_return_to_tavern_effect = yes }
}


#Spouse material
ep3_laamp_decision_event.1035 = {
	type = character_event
	title = ep3_laamp_decision_event.1035.t
	window = visit_settlement_window
	desc = {
		#Well, hello there
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: Generics
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_spouse
						scope:spouse_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1035.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:spouse_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1035.desc_returned_02
				}
			}
			#FIRST TIME: We've seen this spouse-r before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_spouse
					NOT = { exists = scope:been_to_spouse }
				}
				desc = ep3_laamp_decision_event.1035.desc_reused_spouse
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_spouse }
				}
				desc = ep3_laamp_decision_event.1035.desc
			}	
		}
	}
	theme = seduction
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_seduction" }
	override_background = {
		trigger = { 1000_is_a_nomadic_holding_trigger = yes }
		reference = ep3_military_tent #Give me other variations - like a yurt - and I'll use a yurt. Otherwise you get a tent.
	}
	override_background = {
		trigger = { 
			scope:visiting_location = {
				OR = {
					has_holding_type = tribal_holding
					has_holding_type = nomad_holding
					has_holding_type = herder_holding
				}
			} 
		}
		reference = tavern
	}
	override_background = { reference = tavern }
	center_portrait = {
		character = root
		camera = camera_event_scheme_vs_right_look_right
		triggered_animation = {
			trigger = { 
				OR = {
					has_trait = paranoid
					has_trait = craven
					has_trait = shy
				}
			}
			animation = shame
		}
		animation = ecstasy
	}
	right_portrait = {
		character = scope:laamp_spouse_material
		#First time engaging them
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:been_to_spouse }
			}
			animation = personality_callous
		}
		animation = personality_cynical
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Run this once: Re-save the portrait so the Spouse is not the 1030_second_character / 1030_third_character
		if = {
			limit = { scope:1030_second_character ?= scope:laamp_spouse_material }
			#If we have a partner, shuffle the portraits
			if = {
				limit = { exists = scope:visiting_partner }
				#Move ROOT into the second character slot
				save_scope_as = 1030_second_character
				scope:visiting_partner = { save_scope_as = 1030_first_character }
			}
			#Otherwise overwrite the portrait with ROOT to disappear the second one
			else = { save_scope_as = 1030_second_character }
		}
		else_if = {
			limit = { scope:1030_third_character ?= scope:laamp_spouse_material }
			#Overwrite the portrait with ROOT to disappear the third one
			save_scope_as = 1030_third_character
			#And move ROOT into the second character slot
			save_scope_as = 1030_second_character
		}
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = spouse }
		#Remember this potential spouse -- for a while, at least
		add_to_variable_list = {
			name = 1025_remembered_spouse_potential_list
			target = scope:laamp_spouse_material
			days = visit_settlement_minimum_cooldown_days
		}
		#Set the drink cost
		if = {
			limit = {
				NOT = { exists = scope:spouse_drink_cost }
			}
			save_scope_value_as = {
				name = spouse_drink_cost
				value = {
					integer_range = {
					    min = tiny_gold_laamps_value
					    max = minor_gold_laamps_value
					}
				}
			}
		}
		#Pick a pick-up line
		if = {
			limit = {
				NOT = { exists = scope:1035_saved_pickup_line }
			}
			random_list = {
				10 = {
					save_scope_value_as = {
						name = 1035_saved_pickup_line
						value = flag:first
					}
				}
				10 = {
					save_scope_value_as = {
						name = 1035_saved_pickup_line
						value = flag:second
					}
				}
				10 = {
					save_scope_value_as = {
						name = 1035_saved_pickup_line
						value = flag:third
					}
				}
				10 = {
					save_scope_value_as = {
						name = 1035_saved_pickup_line
						value = flag:fourth
					}
				}
				10 = {
					save_scope_value_as = {
						name = 1035_saved_pickup_line
						value = flag:fifth
					}
				}
			}
		}	
	}
	#Buy 'em a drink
	option = {
		name = ep3_laamp_decision_event.1035.a
		#Pay gold
		remove_short_term_gold = scope:spouse_drink_cost
		#Have them join your camp
		1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_spouse_material } 
		#Set the variables and redirect us back to the tavern main room
		1035_spoused_effect = yes
		ai_chance = {
			base = 300
			modifier = {
				short_term_gold < scope:spouse_drink_cost
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Intrigue Duel
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { scope:1035_saved_pickup_line ?= flag:first }
						desc = ep3_laamp_decision_event.1035.b_first
					}
					triggered_desc = {
						trigger = { scope:1035_saved_pickup_line ?= flag:second }
						desc = ep3_laamp_decision_event.1035.b_second
					}
					triggered_desc = {
						trigger = { scope:1035_saved_pickup_line ?= flag:third }
						desc = ep3_laamp_decision_event.1035.b_third
					}
					triggered_desc = {
						trigger = { scope:1035_saved_pickup_line ?= flag:fourth }
						desc = ep3_laamp_decision_event.1035.b_fourth
					}
					triggered_desc = {
						trigger = { scope:1035_saved_pickup_line ?= flag:fifth }
						desc = ep3_laamp_decision_event.1035.b_fifth
					}
					#Fallback
					desc = ep3_laamp_decision_event.1035.b_fallback
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1035.b.cooldown.tt
				NOT = { has_variable = 1035_spouse_duelled_recently }
			}
		}
		show_as_unavailable = { always = yes }
		duel = {
			skill = intrigue
			value = average_skill_rating
			#Success: Hire 'em up
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_laamp_decision_event.1035.b.success
				send_interface_toast = {
					title = ep3_laamp_decision_event.1035.b.success
					left_icon = root
					right_icon = scope:laamp_spouse_material
					#Yippee!
					1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_spouse_material }
					#This 'finished' is different since it changes between flag:yes and flag:no
					1035_spoused_effect = yes
				}
			}
			#Failure: Bye, now
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}	
				desc = ep3_laamp_decision_event.1035.b.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = ep3_laamp_decision_event.1035.b.failure
					desc = ep3_laamp_decision_event.1035.b.failure.tt
					left_icon = root
					right_icon = scope:laamp_spouse_material
					#Oh well
					custom_tooltip = ep3_laamp_decision_event.1035.b.failure.tt
					#This 'finished' is different since it changes between flag:yes and flag:no
					save_scope_value_as = {
						name = laamp_decision_has_spoused
						value = flag:no
					}
					#Go back to the tavern main room
					1031_return_to_tavern_effect = yes
				}
			}
		}
		#Cooldown for the action
		set_variable = {
			name = 1035_spouse_duelled_recently
			days = visit_settlement_minimum_cooldown_days
		}
		ai_chance = { base = 200 }
	}
	#Triggered Option: Seducer
	option = {
		name = ep3_laamp_decision_event.1035.c
		trigger = { 
			has_trait = seducer
			is_ai = no
			trigger_if = {
				limit = { has_variable = 1035_spouse_unwinded_recently }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1035.c.cooldown.tt
					always = no
				}
			}
		}
		show_as_unavailable = { always = yes } 
		#Pick 'em up
		progress_towards_lover_effect = {
			CHARACTER = scope:laamp_spouse_material
			REASON = lover_tavern_hookup
			OPINION = 50
		}
		add_courtier = scope:laamp_spouse_material
		save_scope_as = 1035_unwinded_with_spouse_potential
		#Cooldown for the action
		set_variable = {
			name = 1035_spouse_unwinded_recently
			months = visit_settlement_minimum_cooldown_days
		}
		#Set the variables and redirect us back to the tavern main room
		1035_spoused_effect = yes
	}
	#I want to go back
	option = {
		name = ep3_laamp_decision_event.1035.d
		#Set the variables and redirect us back to the tavern main room
		1031_been_to_effect = { GUILD = spouse }
		ai_chance = { base = 100 }
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:spouse }
	}
}


#Set the correct variable to block off the Hood option and remove the desc flavor variable
scripted_effect 1037_hooded_effect = {
	save_scope_value_as = {
		name = laamp_decision_recruited_hood
		value = flag:no
	}
	#Go back to the tavern main room
	hidden_effect = { 1031_return_to_tavern_effect = yes }
}

#This implementation hurts me as much as it hurts you
scripted_effect 1037_determine_highest_gallowsbait_track_effect = {
	if = {
		limit = { has_trait = gallowsbait }
		#Is any of it aced?
		if = {
			limit = {
				has_trait_xp = {
					trait = gallowsbait
					track = bandit
					value = 100 #Max value
				}
			}
			save_scope_as = ace_gallowsbait_bandit
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = gallowsbait
					track = trickster
					value = 100 #Max value
				}
			}
			save_scope_as = ace_gallowsbait_trickster
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = gallowsbait
					track = thief
					value = 100 #Max value
				}
			}
			save_scope_as = ace_gallowsbait_thief
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = gallowsbait
					track = poacher
					value = 100 #Max value
				}
			}
			save_scope_as = ace_gallowsbait_poacher
		}
		else_if = {
			limit = {
				has_trait_xp = {
					trait = gallowsbait
					track = marauder
					value = 100 #Max value
				}
			}
			save_scope_as = ace_gallowsbait_marauder
		}
		#If two are roughly the same, randomize it
		random_list = {
			10 = {
				trigger = { exists = scope:ace_gallowsbait_bandit }
				save_scope_value_as = {
					name = 1037_highest_gallowsbait_track
					value = flag:bandit
				}
			}
			10 = {
				trigger = { exists = scope:ace_gallowsbait_trickster }
				save_scope_value_as = {
					name = 1037_highest_gallowsbait_track
					value = flag:trickster
				}
			}
			10 = {
				trigger = { exists = scope:ace_gallowsbait_thief }
				save_scope_value_as = {
					name = 1037_highest_gallowsbait_track
					value = flag:thief
				}
			}
			10 = {
				trigger = { exists = scope:ace_gallowsbait_poacher }
				save_scope_value_as = {
					name = 1037_highest_gallowsbait_track
					value = flag:poacher
				}
			}
			10 = {
				trigger = { exists = scope:ace_gallowsbait_marauder }
				save_scope_value_as = {
					name = 1037_highest_gallowsbait_track
					value = flag:marauder
				}
			}
		}
		#No? Then find an intermediate.
		if = {
			limit = {
				NOT = { exists = scope:1037_highest_gallowsbait_track }
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = bandit
						value >= medium_lifestyle_random_xp_high
					}
				}
				save_scope_as = intermediate_gallowsbait_bandit
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = trickster
						value >= medium_lifestyle_random_xp_high
					}
				}
				save_scope_as = intermediate_gallowsbait_trickster
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = thief
						value >= medium_lifestyle_random_xp_high
					}
				}
				save_scope_as = intermediate_gallowsbait_thief
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = poacher
						value >= medium_lifestyle_random_xp_high
					}
				}
				save_scope_as = intermediate_gallowsbait_poacher
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = marauder
						value >= medium_lifestyle_random_xp_high
					}
				}
				save_scope_as = intermediate_gallowsbait_marauder
			}
			#If two are roughly the same, randomize it
			random_list = {
				10 = {
					trigger = { exists = scope:intermediate_gallowsbait_bandit }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:bandit
					}
				}
				10 = {
					trigger = { exists = scope:intermediate_gallowsbait_trickster }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:trickster
					}
				}
				10 = {
					trigger = { exists = scope:intermediate_gallowsbait_thief }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:thief
					}
				}
				10 = {
					trigger = { exists = scope:intermediate_gallowsbait_poacher }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:poacher
					}
				}
				10 = {
					trigger = { exists = scope:intermediate_gallowsbait_marauder }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:marauder
					}
				}
			}
		}
		#Still nothing? How about an average.
		if = {
			limit = {
				NOT = { exists = scope:1037_highest_gallowsbait_track }
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = bandit
						value >= medium_lifestyle_random_xp_low
					}
				}
				save_scope_as = average_gallowsbait_bandit
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = trickster
						value >= medium_lifestyle_random_xp_low
					}
				}
				save_scope_as = average_gallowsbait_trickster
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = thief
						value >= medium_lifestyle_random_xp_low
					}
				}
				save_scope_as = average_gallowsbait_thief
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = poacher
						value >= medium_lifestyle_random_xp_low
					}
				}
				save_scope_as = average_gallowsbait_poacher
			}
			if = {
				limit = {
					has_trait_xp = {
						trait = gallowsbait
						track = marauder
						value >= medium_lifestyle_random_xp_low
					}
				}
				save_scope_as = average_gallowsbait_marauder
			}
			#If two are roughly the same, randomize it
			random_list = {
				10 = {
					trigger = { exists = scope:average_gallowsbait_bandit }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:bandit
					}
				}
				10 = {
					trigger = { exists = scope:average_gallowsbait_trickster }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:trickster
					}
				}
				10 = {
					trigger = { exists = scope:average_gallowsbait_thief }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:thief
					}
				}
				10 = {
					trigger = { exists = scope:average_gallowsbait_poacher }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:poacher
					}
				}
				10 = {
					trigger = { exists = scope:average_gallowsbait_marauder }
					save_scope_value_as = {
						name = 1037_highest_gallowsbait_track
						value = flag:marauder
					}
				}
			}
		}
		#If we still don't have a scope here, we need to have another look at the character pool pull/create, 'cause then it didn't reach medium_lifestyle_random_xp_low in any track
	}
}

#Yupyup
scripted_effect 1037_hire_thief_effect = {
	hidden_effect = {
		reverse_add_opinion = {
			target = scope:laamp_hooded_figure
			modifier = recruited_me_opinion
			opinion = 30
		}
	}
	add_courtier = scope:laamp_hooded_figure
	#The actual effect happens in after
	show_as_tooltip = { 
		camp_officer_grant_effect = {
			EMPLOYER = root
			POS = master_thief
			CANDIDATE = scope:laamp_hooded_figure
		}
	}
	#This 'finished' is different since it changes between flag:yes and flag:no
	save_scope_value_as = {
		name = laamp_decision_recruited_hood
		value = flag:yes
	}
	#Go back to tavern
	hidden_effect = { 1031_return_to_tavern_effect = yes }
}

#Pretty self-explanatory
scripted_trigger 1037_maxed_gallowsbait_track_trigger = {
	OR = {
		has_trait_xp = {
			trait = gallowsbait
			track = bandit
			value = 100 #Max value
		}
		has_trait_xp = {
			trait = gallowsbait
			track = trickster
			value = 100 #Max value
		}
		has_trait_xp = {
			trait = gallowsbait
			track = thief
			value = 100 #Max value
		}
		has_trait_xp = {
			trait = gallowsbait
			track = poacher
			value = 100 #Max value
		}
		has_trait_xp = {
			trait = gallowsbait
			track = marauder
			value = 100 #Max value
		}
	}
}

scripted_effect 1037_noble_reward_effect = {
	add_contact = scope:laamp_disguised_noble
	add_hook_if_possible_default_length_effect = {
		TARGET = scope:laamp_disguised_noble 
		TYPE = favor_hook
	}
	progress_towards_friend_effect = {
		REASON = friend_rescued_from_tavern_brawl
		CHARACTER = scope:laamp_disguised_noble
		OPINION = default_friend_opinion
	}
}

#Duel for your highest skill stat
scripted_effect 1037_highest_skill_duel_effect = {
	if = {
		limit = { highest_skill = diplomacy }
		1037_duel_effect = { SKILL = diplomacy }
	}
	else_if = {
		limit = { highest_skill = stewardship }
		1037_duel_effect = { SKILL = stewardship }
	}
	else_if = {
		limit = { highest_skill = intrigue }
		1037_duel_effect = { SKILL = intrigue }
	}
	else_if = {
		limit = { highest_skill = learning }
		1037_duel_effect = { SKILL = learning }
	}
	else_if = {
		limit = { highest_skill = martial }
		1037_duel_effect = { SKILL = martial }
	}
	else_if = {
		limit = { highest_skill_including_prowess = prowess }
		1037_duel_effect = { SKILL = prowess }
	}
}

#Actual duel effect
scripted_effect 1037_duel_effect = {
	duel = {
		skill = $SKILL$
		value = medium_skill_rating
		#Success: Yay, free contact
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -49
			}
			desc = ep3_laamp_decision_event.1037.b.success
			send_interface_toast = {
				title = ep3_laamp_decision_event.1037.b.success.t
				left_icon = root
				right_icon = scope:laamp_disguised_noble
				#Woo rewards
				show_as_tooltip = { #Don't need two toasts for the hook
					add_contact = scope:laamp_disguised_noble
					progress_towards_friend_effect = {
						REASON = friend_rescued_from_tavern_brawl
						CHARACTER = scope:laamp_disguised_noble
						OPINION = default_friend_opinion
					}
				}
				hidden_effect = { 1037_noble_reward_effect = yes }
				#Go back to the main event
				1037_hooded_effect = yes
			}
		}
		#Failure: Whoopsie, they became wounded
		25 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -20
			}	
			desc = ep3_laamp_decision_event.1037.b.failure
			send_interface_toast = {
				title = ep3_laamp_decision_event.1037.b.failure.t
				left_icon = root
				right_icon = scope:laamp_disguised_noble
				random_list = {
					50 = {
						#Less chance that _we_ get hurt if we're buff
						compare_modifier = { value = prowess }
						#Oops
						scope:laamp_disguised_noble = {
							increase_wounds_effect = { REASON = fight }
						}
					}
					50 = {
						#Owwie
						increase_wounds_effect = { REASON = fight }
					}
				}
				save_scope_value_as = {
					name = laamp_decision_recruited_hood
					value = flag:wounded
				}
				#Go back to the tavern main room
				1037_hooded_effect = yes
			}
		}
	}
}


#The hooded figure
ep3_laamp_decision_event.1037 = {
	type = character_event
	window = visit_settlement_window
	title = {
		first_valid = {
			#Noble
			triggered_desc = {
				trigger = { exists = scope:laamp_disguised_noble }
				desc = ep3_laamp_decision_event.1037.t_noble
			}
			#Thief
			desc = ep3_laamp_decision_event.1037.t
		}
	}
	desc = {
		#Hello, hooded person
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: Noble
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_hood
						exists = scope:laamp_disguised_noble
						scope:hood_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1037.desc_noble_returned_01
				}
				triggered_desc = { 
					trigger = {
						exists = scope:laamp_disguised_noble
						scope:hood_loc_tracker ?= 1 
					}
					desc = ep3_laamp_decision_event.1037.desc_noble_returned_02
				}
			}
			#RETURN: Thief
			random_valid = {
				triggered_desc = { 
					trigger = {
						1000_is_a_nomadic_holding_trigger = no
						exists = scope:been_to_hood
						exists = scope:1037_neighboring_holding
						scope:hood_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1037.desc_returned_01
				}
				#Nomad variant
				triggered_desc = { 
					trigger = {
						1000_is_a_nomadic_holding_trigger = yes
						exists = scope:been_to_hood
						exists = scope:1037_neighboring_holding
						scope:hood_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1037.desc_nomad_returned_01
				}
				triggered_desc = { 
					trigger = {
						1000_is_a_nomadic_holding_trigger = no
						exists = scope:been_to_hood
						scope:hood_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1037.desc_returned_02
				}
				#Nomad variant
				triggered_desc = { 
					trigger = {
						1000_is_a_nomadic_holding_trigger = yes
						exists = scope:been_to_hood
						scope:hood_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1037.desc_nomad_returned_02
				}
				triggered_desc = { 
					trigger = { 
						1000_is_a_nomadic_holding_trigger = no
						scope:hood_loc_tracker ?= 1 
					}
					desc = ep3_laamp_decision_event.1037.desc_returned_03
				}
				#Nomad variant
				triggered_desc = { 
					trigger = {
						1000_is_a_nomadic_holding_trigger = yes
						scope:hood_loc_tracker ?= 1 
					}
					desc = ep3_laamp_decision_event.1037.desc_nomad_returned_03
				}
			}
			#FIRST TIME: We've seen this thief before
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = no
					exists = scope:laamp_recurring_thief
					NOT = { exists = scope:been_to_hood }
				}
				desc = ep3_laamp_decision_event.1037.desc_reused_thief
			}
			#Nomad variant
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = yes
					exists = scope:laamp_recurring_thief
					NOT = { exists = scope:been_to_hood }
				}
				desc = ep3_laamp_decision_event.1037.desc_nomad_reused_thief
			}
			#FIRST TIME: Hooded noble is in trouble!
			triggered_desc = {
				trigger = {
					exists = scope:laamp_disguised_noble
					NOT = { exists = scope:been_to_hood }
				}
				desc = ep3_laamp_decision_event.1037.desc_noble
			}
			#FIRST TIME: Hooded thief
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = no
					NOT = { exists = scope:been_to_hood }
				}
				desc = ep3_laamp_decision_event.1037.desc
			}
			#Nomad variant
			triggered_desc = {
				trigger = {
					1000_is_a_nomadic_holding_trigger = yes
					NOT = { exists = scope:been_to_hood }
				}
				desc = ep3_laamp_decision_event.1037.desc_nomad
			}	
		}
	}
	theme = landless_adventurer
	override_sound = {
		trigger = { exists = scope:laamp_disguised_noble }
		reference = "event:/SFX/Events/Themes/sfx_event_theme_type_dynasty" 
	}
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_intrigue" }
	override_icon = {
		trigger = {
			NOT = { exists = scope:laamp_disguised_noble }
		}
		reference = "gfx/interface/icons/event_types/type_intrigue.dds"
	}
	override_background = {
		trigger = { exists = scope:laamp_disguised_noble }
		reference = tavern
	}
	override_background = {
		trigger = { 1000_is_a_nomadic_holding_trigger = yes }
		reference = ep3_relaxing_tent
	}
	override_background = { reference = bp1_wine_cellar }
	left_portrait = {
		trigger = { exists = scope:1037_left_character }
		character = scope:1037_left_character
		#Noble: Engaging the noble
		triggered_animation = {
			trigger = { 
				exists = scope:laamp_disguised_noble
				NOT = { exists = scope:been_to_hood }
			}
			animation = disbelief
		}
		#Noble: They're fighting
		triggered_animation = {
			trigger = { exists = scope:laamp_disguised_noble }
			animation = personality_coward
		}
		animation = interested
	}
	center_portrait = {
		character = scope:1037_center_character
		camera = camera_event_scheme_center_look_semi_right
		#Noble: First time engaging the noble
		triggered_animation = {
			trigger = {
				exists = scope:laamp_disguised_noble
				NOT = { exists = scope:been_to_hood }
			}
			#_Seating tax_?!
			animation = anger
		}
		#Noble: I am NOT paying
		triggered_animation = {
			trigger = { exists = scope:laamp_disguised_noble }
			animation = disapproval
		}
		#Thief: Is... cleaning up blood?
		triggered_animation = {
			trigger = { scope:hood_loc_tracker ?= 1 }
			animation = disbelief
		}
		#Thief: Don't like this
		triggered_animation = {
			trigger = { has_trait = honest }
			animation = stress
		}
		#Thief
		animation = personality_rational
	}
	right_portrait = {
		character = scope:1037_right_character
		camera = camera_event_scheme_far_right
		#Noble: Ruffian: First time engaging the noble
		triggered_animation = {
			trigger = {
				exists = scope:laamp_disguised_noble
				NOT = { exists = scope:been_to_hood }
			}
			#Menacing
			animation = menacing
		}
		#Noble: Ruffian: I am NOT paying
		triggered_animation = {
			trigger = { exists = scope:laamp_disguised_noble }
			animation = threatening
		}
		#Thief: Just cleaned up some blood. 's fine.
		triggered_animation = {
			trigger = {
				1000_is_a_nomadic_holding_trigger = yes
				scope:hood_loc_tracker ?= 1
			}
			#Happy to see you
			animation = spymaster
		}
		#Thief: First time engaging the thief
		triggered_animation = {
			trigger = {
				exists = scope:laamp_recurring_thief
				NOT = { exists = scope:been_to_hood }
			}
			#Happy to see you
			animation = ecstasy
		}
		#Thief: Whadda ya want
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:been_to_hood }
			}
			#A bit reserved
			animation = disapproval
		}
		animation = chess_cocky
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Run this once: Re-save the portrait so the Hood is not the 1030_third_character
		if = {
			limit = { scope:1030_third_character ?= scope:laamp_hooded_figure }
			#Shuffle Spouse over, if they exist
			if = {
				limit = { scope:1030_second_character ?= scope:laamp_spouse_material }
				scope:laamp_spouse_material ?= { save_scope_as = 1030_third_character }
			}
			#Otherwise overwrite the portrait with ROOT to disappear the third one
			else = { save_scope_as = 1030_third_character }
			#Move ROOT into the second character slot
			if = {
				limit = {
					NOT = { scope:1030_second_character ?= root }
				}
				save_scope_as = 1030_second_character
			}
			#Remember the thief
			if = {
				limit = {
					NOT = { exists = scope:laamp_disguised_noble }
				}
				1010_remember_vendor_character_effect = { GUILD = thief CHARACTER = scope:laamp_hooded_figure }
			}
		}
		#Tweak the portraits for the noble-fight
		if = {
			limit = { 
				exists = scope:laamp_disguised_noble
				NOT = { scope:1037_left_character ?= root }
			}
			#Move ourselves to the left
			save_scope_as = 1037_left_character
			#Plonk the perilous noble in the middle
			scope:laamp_disguised_noble = { save_scope_as = 1037_center_character }
			#Shove a ruffian on the right
			create_character = {
				template = generic_peasant_character
				location = scope:visiting_location
				dynasty = none
				culture = scope:visiting_location.culture
				faith = scope:visiting_location.faith
				after_creation = { set_to_lowborn = yes }
				save_scope_as = 1037_local_ruffian
			}
			scope:1037_local_ruffian = { save_scope_as = 1037_right_character }
		}
		#Otherwise set up the thief situation
		else_if = {
			limit = {
				NOR = { 
					exists = scope:laamp_disguised_noble 
					exists = scope:1037_center_character
				}
			}
			#We go in the middle
			save_scope_as = 1037_center_character
			#... and the thief on the right
			scope:laamp_hooded_figure = { save_scope_as = 1037_right_character }
		}
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = hood }
		#Thief effects
		if = {
			limit = {
				NOR = {
					exists = scope:laamp_disguised_noble
					exists = scope:1037_neighboring_holding 
				}
			}
			#Save a neighboring holding
			location = {
				random_neighboring_province = { 
					limit = { 
						is_sea_province = no
						has_holding = yes
					}
					save_scope_as = 1037_neighboring_holding
				}
			}
			#Figure their highest Gallowbait track 
			scope:laamp_hooded_figure = { 1037_determine_highest_gallowsbait_track_effect = yes }
		}
		#Noble effects
		if = {
			limit = { exists = scope:laamp_disguised_noble }
			#Exactly how much does the hooded noble owe?
			save_scope_value_as = {
				name = noble_tab_value
				value = {
					value = scope:laamp_disguised_noble.medium_gold_value
					#Go outside of the city to drink, eh
					if = {
						limit = {
							scope:visiting_location = {
								OR = {
									has_holding_type = tribal_holding
									has_holding_type = nomad_holding
									has_holding_type = herder_holding
								}
							}
						}
						multiply = 0.5
					}
				}
			}
		}
	}
	#Noble: Pay their tab
	option = {
		name = ep3_laamp_decision_event.1037.a
		trigger = { exists = scope:laamp_disguised_noble }
		flavor = ep3_laamp_decision_event.1037.a.flavor
		#Pay up
		remove_short_term_gold = scope:noble_tab_value
		#Woo rewards
		1037_noble_reward_effect = yes
		#Quite the molah
		stress_impact = { greedy = minor_stress_impact_gain }
		#Set the variables and redirect us back to the tavern main room
		1037_hooded_effect = yes
	}
	#Noble: Duel the villain
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { highest_skill_including_prowess = diplomacy }
						desc = ep3_laamp_decision_event.1037.b_diplomacy
					}
					triggered_desc = {
						trigger = { highest_skill_including_prowess = stewardship }
						desc = ep3_laamp_decision_event.1037.b_stewardship
					}
					triggered_desc = {
						trigger = { highest_skill_including_prowess = intrigue }
						desc = ep3_laamp_decision_event.1037.b_intrigue
					}
					triggered_desc = {
						trigger = { highest_skill_including_prowess = learning }
						desc = ep3_laamp_decision_event.1037.b_learning
					}
					triggered_desc = {
						trigger = { 
							OR = {
								highest_skill_including_prowess = martial 
								highest_skill_including_prowess = prowess
							}
						}
						desc = ep3_laamp_decision_event.1037.b_martial
					}
				}
			}
		}
		trigger = { exists = scope:laamp_disguised_noble }
		flavor = ep3_laamp_decision_event.1037.b.flavor
		#Duel effect
		1037_highest_skill_duel_effect = yes
	}
	#Noble Triggered Option: We're pretty bad, bro
	option = {
		name = ep3_laamp_decision_event.1037.c
		trigger = { 
			exists = scope:laamp_disguised_noble
			has_trait = gallowsbait
			OR = {
				#Bandit
				has_trait_xp = {
					trait = gallowsbait
					track = bandit
					value > 50 #Half-way
				}
				#Trickster
				has_trait_xp = {
					trait = gallowsbait
					track = trickster
					value > 50 #Half-way
				}
				#Thief
				has_trait_xp = {
					trait = gallowsbait
					track = thief
					value > 50 #Half-way
				}
				#Poacher
				has_trait_xp = {
					trait = gallowsbait
					track = poacher
					value > 50 #Half-way
				}
				#Marauder
				has_trait_xp = {
					trait = gallowsbait
					track = marauder
					value > 50 #Half-way
				}
			}
		}
		flavor = ep3_laamp_decision_event.1037.c.flavor
		if = {
			limit = {
				NOT = {
					has_trait_xp = {
						trait = gallowsbait
						track = marauder
						value = 100 #Max
					}
				}
			}
			add_trait_xp = {
				trait = gallowsbait
				track = marauder
				value = small_lifestyle_random_xp_low
			}
		}
		#Woo rewards
		1037_noble_reward_effect = yes
		#I just don't like being criminal, OK?
		stress_impact = {
			honest = minor_stress_impact_gain
		}	
		#Set the variables and redirect us back to the tavern main room
		1037_hooded_effect = yes
	}
	#Thief: Recruit them (expensive)
	option = {
		name = {
			text = {
				first_valid = {
					#I have an open position...
					triggered_desc = {
						trigger = { can_employ_court_position_type = master_thief_camp_officer }
						desc = ep3_laamp_decision_event.1037.d_thief_position
					}
					#Standard reply
					desc = ep3_laamp_decision_event.1037.d
				}
			}
		}
		#Replace it with the strongarm option if we have aced a Gallowsbait track
		trigger = {
			1037_maxed_gallowsbait_track_trigger = no 
			#Not available if it's the hooded noble
			NOT = { exists = scope:laamp_disguised_noble }
		}
		#Half if you can offer them an attractive position
		if = {
			limit = { can_employ_court_position_type = master_thief_camp_officer } #If we, sometime in the future, easily can determine which track of a scaling trait is highest, let's gate it to Thief track
			pay_short_term_gold = {
				target = scope:laamp_hooded_figure
				gold = {
					value = major_gold_laamps_value
					divide = 2
				}
			}
			#Hire them (effect in After)
			1037_hire_thief_effect = yes
		}
		#Otherwise pay up
		else = {
			pay_short_term_gold = {
				target = scope:laamp_hooded_figure
				gold = major_gold_laamps_value
			}
			#Have them join your camp
			1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_hooded_figure }
			#Set the variables and redirect us back to the tavern main room
			1037_hooded_effect = yes
		}
	}
	#Thief: Intrigue Duel
	option = {
		name = ep3_laamp_decision_event.1037.e
		#Replace it with the strongarm option if we have aced a Gallowsbait track
		trigger = {
			1037_maxed_gallowsbait_track_trigger = no 
			#Not available if it's the hooded noble
			NOT = { exists = scope:laamp_disguised_noble }
		}
		duel = {
			skill = intrigue
			target = scope:laamp_hooded_figure
			#Success: Hire 'em up
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 2
				desc = ep3_laamp_decision_event.1037.e.success
				send_interface_toast = {
					title = ep3_laamp_decision_event.1037.e.success
					left_icon = root
					right_icon = scope:laamp_hooded_figure
					#Yippee!
					if = {
						limit = { can_employ_court_position_type = master_thief_camp_officer }
						#Hire them (effect in After)
						1037_hire_thief_effect = yes
					}
					else = {
						1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_hooded_figure }

						#This 'finished' is different since it changes between flag:yes and flag:no
						save_scope_value_as = {
							name = laamp_decision_recruited_hood
							value = flag:yes
						}
						#Go back to tavern
						hidden_effect = { 1031_return_to_tavern_effect = yes }
					}
				}
			}
			#Failure: Bye, now
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}	
				desc = ep3_laamp_decision_event.1037.e.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = ep3_laamp_decision_event.1037.e.failure
					desc = ep3_laamp_decision_event.1037.e.failure.tt
					left_icon = root
					right_icon = scope:laamp_hooded_figure
					#Oh well
					custom_tooltip = ep3_laamp_decision_event.1037.e.failure.tt
					#This 'finished' is different since it changes between flag:yes and flag:no
					1037_hooded_effect = yes
				}
			}
		}
	}
	#Thief: Teach me about Gallowsbait...
	option = {
		name = ep3_laamp_decision_event.1037.f
		trigger = {
			#Unless you are full in whatever the hooded figure offers
			NOR = {
				#Bandit
				AND = { 
					has_trait = gallowsbait
					has_trait_xp = {
						trait = gallowsbait
						track = bandit
						value >= 100 #Max value
					}
					scope:1037_highest_gallowsbait_track ?= flag:bandit
				}
				#Trickster
				AND = { 
					has_trait = gallowsbait
					has_trait_xp = {
						trait = gallowsbait
						track = trickster
						value >= 100 #Max value
					}
					scope:1037_highest_gallowsbait_track ?= flag:trickster
				}
				#Thief
				AND = { 
					has_trait = gallowsbait
					has_trait_xp = {
						trait = gallowsbait
						track = thief
						value >= 100 #Max value
					}
					scope:1037_highest_gallowsbait_track ?= flag:thief
				}
				#Poacher
				AND = { 
					has_trait = gallowsbait
					has_trait_xp = {
						trait = gallowsbait
						track = poacher
						value >= 100 #Max value
					}
					scope:1037_highest_gallowsbait_track ?= flag:poacher
				}
				#Marauder
				AND = { 
					has_trait = gallowsbait
					has_trait_xp = {
						trait = gallowsbait
						track = marauder
						value >= 100 #Max value
					}
					scope:1037_highest_gallowsbait_track ?= flag:marauder
				}
			}
			#Not available if it's the hooded noble
			NOT = { exists = scope:laamp_disguised_noble }
		}
		#Get trait
		if = {
			limit = {
				NOT = { has_trait = gallowsbait }
			}
			add_trait = gallowsbait
		}
		#Or get a significant amount of experience in trait
		else = {
			#Pay gold
			pay_short_term_gold = {
				target = scope:laamp_hooded_figure
				gold = medium_gold_laamps_value
			}
			if = {
				limit = { scope:1037_highest_gallowsbait_track ?= flag:bandit }
				add_trait_xp = {
					trait = gallowsbait
					track = bandit
					value = trait_third_level_value
				}
			}
			else_if = {
				limit = { scope:1037_highest_gallowsbait_track ?= flag:trickster }
				add_trait_xp = {
					trait = gallowsbait
					track = trickster
					value = trait_third_level_value
				}
			}
			else_if = {
				limit = { scope:1037_highest_gallowsbait_track ?= flag:thief }
				add_trait_xp = {
					trait = gallowsbait
					track = thief
					value = trait_third_level_value
				}
			}
			else_if = {
				limit = { scope:1037_highest_gallowsbait_track ?= flag:poacher }
				add_trait_xp = {
					trait = gallowsbait
					track = poacher
					value = trait_third_level_value
				}
			}
			else_if = {
				limit = { scope:1037_highest_gallowsbait_track ?= flag:marauder }
				add_trait_xp = {
					trait = gallowsbait
					track = marauder
					value = trait_third_level_value
				}
			}
		}
		#Some Intrigue lifestyle gain, coming up
		add_intrigue_lifestyle_xp = medium_lifestyle_xp
		#Stressful for honest characters 
		stress_impact = {
			honest = minor_stress_impact_gain
		}
		#Set the variables and redirect us back to the tavern main room
		1037_hooded_effect = yes
	}
	#Thief Triggered Option: You have aced Gallowsbait in a track
	option = {
		name = ep3_laamp_decision_event.1037.g
		trigger = {
			has_trait = gallowsbait
			1037_maxed_gallowsbait_track_trigger = yes
			#Not available if it's the hooded noble
			NOT = { exists = scope:laamp_disguised_noble }
		}
		1033_add_courtier_with_opinion_effect = { TARGET = scope:laamp_hooded_figure }
		#Set the variables and redirect us back to the tavern main room
		1037_hooded_effect = yes
		ai_chance = {
			base = 100
		}
	}
	#I want to go back
	option = {
		name = ep3_laamp_decision_event.1037.h
		#Set the variables and redirect us back to the tavern main room
		1031_been_to_effect = { GUILD = hood }
	}
	after = {
		if = {
			limit = { scope:laamp_decision_recruited_hood ?= flag:yes }
			#Appoint them
			if = {
				limit = {
					can_appoint_char_to_court_position = {
						CHAR = scope:laamp_hooded_figure
						COURT_POS = master_thief_camp_officer
					}
				}
				camp_officer_grant_effect = {
					EMPLOYER = root
					POS = master_thief
					CANDIDATE = scope:laamp_hooded_figure
				}
			}
		}
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:hood }
	}
}


######################################################################
# CHURCH GROUNDS
# ep3_laamp_decision_event.1040
######################################################################

#Set the correct variable to block off the Church option and remove the desc flavor variable
scripted_effect 1040_finished_churched_effect = {
	remove_list_variable = {
		name = list_of_options
		target = flag:has_church_option
	}
	save_scope_as = laamp_decision_finished_church_option
}

#Nothing left for us to do
scripted_trigger 1040_done_with_church_trigger = {
	exists = scope:laamp_decision_has_healed
	exists = scope:laamp_decision_has_churched
	exists = scope:laamp_decision_has_gardened
	trigger_if = {
		limit = { exists = scope:laamp_physician_recruit }
		exists = scope:laamp_decision_recruited_physician
	}
}

#One of your sick kids who wouldn't fit the visiting_partner trigger
scripted_trigger 1040_sickly_minor_trigger = {
	location = root.location
	is_courtier_of = root
	is_travelling = no
	is_imprisoned = no
	1000_has_illness_or_wound_to_treat_trigger = yes
	age < 10
}


#Church Holding: Visit the local church grounds
ep3_laamp_decision_event.1040 = {
	type = character_event
	title = ep3_laamp_decision_event.1040.t
	window = visit_settlement_window
	desc = {
		#Intro
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: We've returned from Main Square
			random_valid = {
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						exists = scope:been_to_church_grounds
						OR = {
							scope:church_grounds_loc_tracker ?= 0
							scope:church_grounds_loc_tracker ?= 2
						}
					}
					desc = ep3_laamp_decision_event.1040.desc_returned_01
				}
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						scope:church_grounds_loc_tracker ?= 1
					}
					desc = ep3_laamp_decision_event.1040.desc_returned_02
				}
			}
			#RETURN: We've returned from the Healer
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:healer }
				desc = ep3_laamp_decision_event.1040.desc_returned_from_healer
			}
			#RETURN: We've returned from the Church
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:church }
				desc = ep3_laamp_decision_event.1040.desc_returned_from_church
			}
			#RETURN: We've returned from the Garden
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:garden }
				desc = ep3_laamp_decision_event.1040.desc_returned_from_garden
			}
			#RETURN: We've returned from the Physician
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:physician }
				desc = ep3_laamp_decision_event.1040.desc_returned_from_physician
			}
			#FIRST TIME: First time here
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_church_grounds }
				}
				desc = ep3_laamp_decision_event.1040.desc
			}
		}
		#Outro
		first_valid = {
			#FIRST TIME: For some reason, you have both Sickly Minor and Physician
			triggered_desc = {
				trigger = {
					exists = scope:laamp_physician_recruit
					exists = scope:1040_sickly_minor
					NOT = { exists = scope:been_to_church_grounds }
				}
				desc = ep3_laamp_decision_event.1040.desc_outro_physician_sickly_minor
			}
			#FIRST TIME: First time here, look at the physician
			triggered_desc = {
				trigger = {
					exists = scope:laamp_physician_recruit
					NOT = { exists = scope:been_to_church_grounds }
				}
				desc = ep3_laamp_decision_event.1040.desc_outro_physician
			}
			#FIRST TIME: First time here, sickly minor
			triggered_desc = {
				trigger = {
					exists = scope:1040_sickly_minor
					NOT = { exists = scope:been_to_church_grounds }
				}
				desc = ep3_laamp_decision_event.1040.desc_outro_sickly_minor
			}
			#FIRST TIME: First time here, curious partner
			triggered_desc = {
				trigger = {
					exists = scope:visiting_partner
					NOT = { exists = scope:been_to_church_grounds }
				}
				desc = ep3_laamp_decision_event.1040.desc_outro_partner
			}
			#FIRST TIME: First time here
			triggered_desc = {
				trigger = {
					NOT = {  exists = scope:been_to_church_grounds }
				}
				desc = ep3_laamp_decision_event.1040.desc_outro
			}
			#RETURN: Partner - there is nothing left for us here
			triggered_desc = {
				trigger = { 
					exists = scope:visiting_partner
					1040_done_with_church_trigger = yes 
				}
				desc = ep3_laamp_decision_event.1040.desc_outro_return_partner_finished
			}
			#RETURN: There is nothing left for us here
			triggered_desc = {
				trigger = { 1040_done_with_church_trigger = yes }
				desc = ep3_laamp_decision_event.1040.desc_outro_return_finished
			}
			#RETURN: Physician did not move to their study, yet
			triggered_desc = {
				trigger = {
					exists = scope:laamp_physician_recruit
					NOR = { 
						exists = scope:been_to_physician
						exists = scope:laamp_decision_recruited_physician
					}
				}
				desc = ep3_laamp_decision_event.1040.desc_outro_physician_return
			}
			#RETURN: We've been here before
			first_valid = {
				#RETURN: Sickly minor is still at the healer's
				triggered_desc = {
					trigger = {
						exists = scope:1040_sickly_minor
						var:return_from_location ?= flag:healer
						scope:1040_sickly_minor = { has_any_illness = yes }
					}
					desc = ep3_laamp_decision_event.1040.desc_outro_sickly_minor_return
				}
				random_valid = {
					#RETURN: Partner flavor
					triggered_desc = {
						trigger = {
							exists = scope:visiting_partner
							exists = scope:been_to_church_grounds
							scope:church_grounds_loc_tracker ?= 0
						}
						desc = ep3_laamp_decision_event.1040.desc_outro_return_partner_01
					}
					triggered_desc = {
						trigger = {
							exists = scope:visiting_partner
							scope:church_grounds_loc_tracker ?= 1
						}
						desc = ep3_laamp_decision_event.1040.desc_outro_return_partner_02
					}
					triggered_desc = {
						trigger = {
							exists = scope:visiting_partner
							scope:church_grounds_loc_tracker ?= 2
						}
						desc = ep3_laamp_decision_event.1040.desc_outro_return_partner_03
					}
					#RETURN: Generics
					triggered_desc = {
						trigger = { 
							exists = scope:been_to_church_grounds
							scope:church_grounds_loc_tracker ?= 0
						}
						desc = ep3_laamp_decision_event.1040.desc_outro_return_01
					}
					triggered_desc = {
						trigger = { scope:church_grounds_loc_tracker ?= 1 }
						desc = ep3_laamp_decision_event.1040.desc_outro_return_02
					}
					triggered_desc = {
						trigger = { scope:church_grounds_loc_tracker ?= 2 }
						desc = ep3_laamp_decision_event.1040.desc_outro_return_03
					}
				}
			}
		}
	}
	theme = faith
	#Get outta here already
	override_effect_2d = {
		trigger = { 
			1040_done_with_church_trigger = yes
			scope:visiting_location = { is_drylands_or_desert_trigger = no }
		}
  		reference = rain	
	}
	override_background = { 
		trigger = {
			location = {
				culture = { has_graphical_east_asia_culture_group_trigger = no }
				geographical_region = world_asia_southeast
			}
		}
		reference = holy_site_generic
	}
	override_background = { reference = courtyard_location }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#If it's our (tired) visiting partner
		triggered_animation = {
			trigger = { 1040_done_with_church_trigger = yes }
			animation = boredom
		}
		#Concerned about our kid
		triggered_animation = {
			trigger = {
				exists = scope:1040_sickly_minor
				is_close_family_of = scope:1040_sickly_minor
				OR = {
					AND = {
						var:return_from_location ?= flag:healer
						scope:1040_sickly_minor = { has_any_illness = yes }
					}
					NOT = { exists = scope:been_to_church_grounds }
				}
			}
			animation = stress
		}
		#Zealous dudette
		triggered_animation = {
			trigger = {
				scope:visiting_partner = { has_trait = zealous }
			}
			animation = personality_zealous
		}
		#Cynical dude
		triggered_animation = {
			trigger = {
				scope:visiting_partner = { has_trait = cynical }
			}
			animation = personality_cynical
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_friendly_traits = yes } 
			}
			animation = personality_forgiving
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_commerce_traits = yes } 
			}
			animation = personality_greedy
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_uninterested_traits = yes } 
			}
			animation = personality_callous
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_irrational_traits = yes } 
			}
			animation = personality_irrational
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_standoffish_traits = yes } 
			}
			animation = personality_coward
		}
		animation = survey
	}
	center_portrait = {
		character = root
		#Concerned about our kid
		triggered_animation = {
			trigger = {
				exists = scope:1040_sickly_minor
				OR = {
					AND = {
						var:return_from_location ?= flag:healer
						scope:1040_sickly_minor = { has_any_illness = yes }
					}
					NOT = { exists = scope:been_to_church_grounds }
				}
			}
			animation = worry
		}
		#Bah, humbug
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = cynical
					any_secret = { type = secret_non_believer }
				}
			}
			animation = boredom
		}
		animation = personality_content
	}
	#Do we have a Physician?
	right_portrait = {
		trigger = { 
			exists = scope:1040_third_character
			#If this is root, then that means we have talked to the Physician, so let's disappear the portrait
			scope:1040_third_character != root
		}
		camera = camera_event_scheme_center_forward
		character = scope:1040_third_character
		#Otherwise it's the Physician
		animation = personality_zealous
	}
	#Shove the Physician as long as we've visited them but haven't actioned them
	lower_left_portrait = {
		trigger = {
			exists = scope:1040_fourth_character
			#Unless we've actioned them and overwritten them with ROOT
			scope:1040_fourth_character != root
		}
		character = scope:1040_fourth_character
	}
	#Show the kid here if not actioned
	lower_center_portrait = {
		trigger = { 
			exists = scope:1040_fifth_character
			scope:1040_sickly_minor = { has_any_illness = yes } 
			scope:1040_fifth_character != root
		}
		character = scope:1040_fifth_character
	}	
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Set up the ancillary portraits to remind the player of the characters
		if = {
			#Physician exists
			limit = {
				#We've been to them at least once
				exists = scope:been_to_physician
				#We're not done with them yet
				AND = {
					exists = scope:laamp_physician_recruit
					NOT = { exists = scope:laamp_decision_recruited_physician }
				}
				#This isn't already the state
				NAND = {
					exists = scope:1040_fourth_character
					scope:1040_fourth_character ?= scope:laamp_physician_recruit
				}
			}
			scope:laamp_physician_recruit = { save_scope_as = 1040_fourth_character }
		}
		#Clear out the ancillary portrait(s)
		if = {
			limit = { 
				exists = scope:1040_fourth_character
				scope:laamp_physician_recruit ?= scope:1040_fourth_character
				exists = scope:laamp_decision_recruited_physician
			}
			#Overwrite with ROOT to hide that portrait
			save_scope_as = 1040_fourth_character
		}
		if = {
			limit = {
				exists = scope:1040_fifth_character
				scope:1040_sickly_minor ?= scope:1040_fifth_character
				exists = scope:laamp_decision_has_healed
			}
			#Overwrite with ROOT to hide that portrait
			save_scope_as = 1040_fifth_character
		}
		#Can we _not_ repeat the loc?
		1025_set_and_check_hub_loc_tracker_scope_effect = { HUB = church_grounds }
		#Do we have a sick minor we snuck along?
		if = {
			limit = {
				NOT = { exists = scope:1040_sickly_minor }
				any_close_family_member = { 1040_sickly_minor_trigger = yes }
			}
			random_close_family_member = {
				limit = { 1040_sickly_minor_trigger = yes }
				save_scope_as = 1040_sickly_minor
				save_scope_as = 1040_fifth_character
			}
		}
		#Rare: Spawn a spectacular Physician
		if = {
			limit = {
				NOT = { has_variable = laamp_decision_1000_checked_for_physician }
			}
			random_list = {
				80 = {
					#No Physician
				}
				20 = {
					#Has this person been our physician in the past 10 years?
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							1010_basic_merchant_checks_trigger = yes
							save_temporary_scope_as = saved_character_check
							#Let's avoid double-dipping
							1010_is_a_saved_physician_trigger = yes
							1010_is_a_saved_merchant_trigger = no
							1010_is_a_saved_peddler_trigger = no
							1010_is_a_saved_crier_trigger = no
							1010_is_a_saved_storyteller_trigger = no
							1010_is_a_saved_thief_trigger = no
							1010_is_a_saved_healer_trigger = no
							1010_is_a_saved_clergy_trigger = no
							1010_is_a_saved_bodyguard_trigger = no
							1010_is_a_saved_weaponsmith_trigger = no
							1010_is_a_saved_armorer_trigger = no
							1010_is_a_saved_jeweler_trigger = no
							1010_is_a_saved_quartermaster_trigger = no	
						}
						save_scope_as = laamp_physician_recruit
						#Some more loc flavor shenanigans for these saved scopes
						save_scope_as = laamp_recurring_physician
					}
					#Otherwise find a physician in the pool
					if = {
						limit = { 
							NOT = { exists = scope:laamp_physician_recruit }
						}
						random_pool_character = {
							province = scope:visiting_location
							limit = { 
								1010_basic_merchant_checks_trigger = yes
								has_trait = devoted
								learning >= 15
								OR = {
									has_trait = lifestyle_physician
									has_trait = lifestyle_herbalist
									has_trait = lifestyle_mystic
								}
							}
							save_scope_as = laamp_physician_recruit
						}
					}
					#Otherwise create a physician
					if = {
						limit = {
							NOT = { exists = scope:laamp_physician_recruit }
						}
						#Create physician to stuff in pool
						create_character = {
							template = bp1_yearly_2021_learning_person_template
							location = scope:visiting_location
							dynasty = none
							culture = scope:visiting_location.culture
							faith = scope:visiting_location.faith
							learning = { decent_skill_rating high_skill_rating }
							save_scope_as = laamp_physician_recruit
						}
						scope:laamp_physician_recruit ?= {
							#Chance to add a malus trait to this spectatular being
							if = {
								limit = { 
									NOR = { 
										has_trait = possessed_1 
										has_trait = lunatic_1
										has_trait = depressed_1
										has_trait = drunkard
										has_trait = hashishiyah
										has_trait = irritable
										any_secret = { type = secret_witch }
									}
								}
								hidden_effect = {
									random = {
										chance = 20
										random_list = {
											10 = { add_trait = possessed_1 }
											10 = { add_trait = lunatic_1 }
											10 = { add_trait = depressed_1 }
											10 = { add_trait = drunkard }
											10 = { add_trait = hashishiyah }
											10 = { add_trait = irritable }
											10 = { 
												add_secret = { type = secret_witch }
											}
										}
									}
								}
							}
							if = {
								limit = {
									NOT = { has_trait = devoted }
								}
								add_trait = devoted
							}
						}
					}
					scope:laamp_physician_recruit = { save_scope_as = 1040_third_character }
					#Remember the physician
					1010_remember_vendor_character_effect = { GUILD = physician CHARACTER = scope:laamp_physician_recruit }
				}
			}
			#No decision-scumming
			set_variable = {
				name = laamp_decision_1000_checked_for_physician
				days = visit_settlement_cooldown_days
			}
		}
		#Make sure we remember the church isn't available because you were a thieving heathen
		if = {
			limit = {
				NOT = { exists = scope:laamp_decision_has_churched }
				has_variable = 1040_caught_stealing
			}
			save_scope_as = laamp_decision_has_churched
		}
	}
	#Attempt to improve your health // OR // Attempt to cure (curable) illness
	option = {
		name = {
			text = {
				first_valid = {
					#Sickly child is still waiting at the healer's
					triggered_desc = {
						trigger = { 
							exists = scope:been_to_healer
							exists = scope:1040_sickly_minor
							NOT = { exists = scope:laamp_decision_has_healed }
						}
						desc = ep3_laamp_decision_event.1040.a_second_sickly_minor
					}
					#Return to healer
					triggered_desc = {
						trigger = { exists = scope:been_to_healer }
						desc = ep3_laamp_decision_event.1040.a_second
					}
					#We are meeting a sickly child at the healer's
					triggered_desc = {
						trigger = { exists = scope:1040_sickly_minor }
						desc = ep3_laamp_decision_event.1040.a_sickly_minor
					}
					#First time going to healer
					desc = ep3_laamp_decision_event.1040.a
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1040.a.cooldown.tt
				NOT = { exists = scope:laamp_decision_has_healed }
			}
		}
		show_as_unavailable = { always = yes }
		reason = visit_healer
		custom_tooltip = ep3_laamp_decision_event.1040.a.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = church_grounds }
		#Go to the Healer screen
		trigger_event = ep3_laamp_decision_event.1041
		ai_chance = { base = 100 }
	}
	#Visit church
	option = {
		name = {
			text = {
				first_valid = {
					#Return to church
					triggered_desc = {
						trigger = { exists = scope:been_to_church }
						desc = ep3_laamp_decision_event.1040.b_second
					}
					#First time at church
					desc = ep3_laamp_decision_event.1040.b
				}
			}
		}
		trigger = {
			#You were recently caught stealing from the church
			trigger_if = {
				limit = { has_variable = 1040_caught_stealing }
				custom_tooltip = {
					text = caught_stealing.tt
					always = no
				}
			}
			trigger_else = {
				custom_tooltip = {
					text = ep3_laamp_decision_event.1040.b.cooldown.tt
					NOT = { exists = scope:laamp_decision_has_churched }
				}
			}
		}
		show_as_unavailable = { always = yes }
		reason = visit_church
		custom_tooltip = ep3_laamp_decision_event.1040.b.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = church_grounds }
		#Go to the Church screen
		trigger_event = ep3_laamp_decision_event.1043
		ai_chance = {
			base = 100
			modifier = {
				has_trait = zealous
				factor = 2
			}
			modifier = {
				has_trait = pilgrim
				factor = 2
			}
		}
	}
	#Convert to local faith // OR // Contemplate faith
	option = {
		name = {
			text = {
				first_valid = {
					#Convert to faith
					triggered_desc = {
						trigger = { exists = scope:been_to_garden }
						desc = ep3_laamp_decision_event.1040.c_second
					}
					#Contemplate faith
					desc = ep3_laamp_decision_event.1040.c
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1040.c.cooldown.tt
				NOT = { exists = scope:laamp_decision_has_gardened }
			}
		}
		show_as_unavailable = { always = yes }
		reason = visit_garden
		custom_tooltip = ep3_laamp_decision_event.1040.c.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = church_grounds }
		#Go to the Garden screen
		trigger_event = ep3_laamp_decision_event.1045
		ai_chance = {
			base = 100
			modifier = {
				stress_level >= 2
				add = 400
			}
		}
	}
	#Rare Option: Hire cheaper, skilled, Physician
	option = {
		name = {
			text = {
				first_valid = {
					#Return to talk to physician
					triggered_desc = {
						trigger = { exists = scope:been_to_physician }
						desc = ep3_laamp_decision_event.1040.d_second
					}
					#First time talking to physician
					desc = ep3_laamp_decision_event.1040.d
				}
			}
		}
		trigger = {
			exists = scope:laamp_physician_recruit
			NOT = { exists = scope:laamp_decision_recruited_physician }
		}
		reason = recruit_physician
		custom_tooltip = ep3_laamp_decision_event.1040.d.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = church_grounds }
		#For the Physician screen
		trigger_event = ep3_laamp_decision_event.1047
		ai_chance = {
			base = 1000 #Just do it
		}
	}
	#I want to do something else
	option = {
		name = {
			text = {
				first_valid = {
					#Nothing left to do
					triggered_desc = {
						trigger = { 1040_done_with_church_trigger = yes }
						desc = ep3_laamp_decision_event.1040.e_second
					}
					#Back to main square
					desc = ep3_laamp_decision_event.1040.e
				}
			}
		}
		#Have we done everything? Are we closing off the option?
		if = {
			limit = { 1040_done_with_church_trigger = yes }
			#Clean up unnecessary variables and close off the option
			1040_finished_churched_effect = yes
		}
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = church_grounds }
		#Go back to the main event
		1000_return_to_main_effect = yes
		ai_chance = { base = 100 }
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:church_grounds }
	}
}


#Pretty straight forward
scripted_effect 1041_chance_to_buff_item_rarity_effect = {
	random_list = {
		20 = {
			trigger = {
				exists = scope:laamp_healer_character
				$VENDOR$ = scope:laamp_healer_character
			}
			set_artifact_rarity_famed = yes
		}
		40 = {
			modifier = {
				exists = scope:laamp_jeweler_craftsman
				$VENDOR$ = scope:laamp_jeweler_craftsman
				factor = 2
			}
			set_artifact_rarity_masterwork = yes
		}
		80 = {
			set_artifact_rarity_common = yes
		}
	}
}

#Reused effect to set the value variables
scripted_effect 1041_set_item_value_effect = {
	#Weapon cost
	if = {
		limit = { has_variable = 1061_laamp_decision_weapon }
		if = {
			limit = { rarity = masterwork }
			set_variable = {
				name = 1061_weapon_value
				value = {
					value = root.major_gold_value
					multiply = { 1 1.5 }
				}
			}
		}
		else = {
			set_variable = {
				name = 1061_weapon_value
				value = {
					value = root.medium_gold_value
					multiply = { 0.75 1.25 }
				}
			}
		}
	}
	#Armor cost
	if = {
		limit = { has_variable = 1063_laamp_decision_armor }
		if = {
			limit = { rarity = masterwork }
			set_variable = {
				name = 1063_armor_value
				value = {
					value = root.major_gold_value
					multiply = { 1.5 2 }
				}
			}
		}
		else = {
			set_variable = {
				name = 1063_armor_value
				value = {
					value = root.medium_gold_value
					multiply = { 1.25 1.75 }
				}
			}
		}
	}
	#Accessory cost
	if = {
		limit = { 
			OR = {
				has_variable = 1041_laamp_decision_health_artifact
				has_variable = 1065_laamp_decision_accessory 
			}
		}
		if = {
			limit = { 
				rarity = famed
				has_variable = 1041_laamp_decision_health_artifact
			}
			set_variable = {
				name = 1065_accessory_value
				value = {
					value = root.massive_gold_value
					multiply = { 1 1.5 }
				}
			}
		}
		else_if = {
			limit = { rarity = masterwork }
			set_variable = {
				name = 1065_accessory_value
				value = {
					value = root.major_gold_value
					multiply = { 1.25 1.75 }
				}
			}
		}
		else = {
			set_variable = {
				name = 1065_accessory_value
				value = {
					value = root.medium_gold_value
					multiply = { 1 1.5 }
				}
			}
		}
	}
}

#We return to the church grounds event to peruse other options
scripted_effect 1041_return_to_church_grounds_effect = {
	custom_tooltip = ep3_laamp_decision_event.1041.return.tt
	trigger_event = ep3_laamp_decision_event.1040
}

#Set the correct variable to block off the Healer option and remove the desc flavor variable
scripted_effect 1041_healed_effect = {
	scope:1041_health_artifact = { remove_variable ?= 1065_accessory_value }
	remove_variable ?= 1041_healer_aptitude
	remove_variable ?= 1041_partner_healer_aptitude
	save_scope_as = laamp_decision_has_healed
	#Go back to church grounds
	hidden_effect = { 1041_return_to_church_grounds_effect = yes }
}

#Determine the variable effect based on their aptitude, one for the healer and one for the physician-partner
scripted_effect 1041_calculate_aptitude_modifier_effect = {
	if = {
		limit = {
			$CHARACTER$ = {
				aptitude = {
					court_position = court_physician_court_position
					value >= 1
				}
			}	
		}
		change_variable = {
			name = $VARIABLE$
			add = 1
		}
	}
	if = {
		limit = {
			$CHARACTER$ = {
				aptitude = {
					court_position = court_physician_court_position
					value >= 2
				}
			}	
		}
		change_variable = {
			name = $VARIABLE$
			add = 1
		}
	}
	if = {
		limit = {
			$CHARACTER$ = {
				aptitude = {
					court_position = court_physician_court_position
					value >= 3
				}
			}	
		}
		change_variable = {
			name = $VARIABLE$
			add = 1
		}
	}
	if = {
		limit = {
			$CHARACTER$ = {
				aptitude = {
					court_position = court_physician_court_position
					value >= 4
				}
			}	
		}
		change_variable = {
			name = $VARIABLE$
			add = 1
		}
	}
	if = {
		limit = {
			$CHARACTER$ = {
				aptitude = {
					court_position = court_physician_court_position
					value >= 5
				}
			}	
		}
		change_variable = {
			name = $VARIABLE$
			add = 1
		}
	}
}

#The actual removal-of-illness
scripted_effect 1041_remove_illness_or_wound_effect = {
	random_list = {
		100 = {
			trigger = { has_character_modifier = infected_wound_modifier }
			remove_character_modifier = infected_wound_modifier
		}
		100 = {
			trigger = { has_character_modifier = gangrene_modifier }
			remove_character_modifier = gangrene_modifier
		}
		100 = {
			trigger = { has_trait = wounded_1 }
			remove_trait = wounded_1
		}
		100 = {
			trigger = { has_trait = wounded_2 }
			remove_trait = wounded_2
		}
		100 = {
			trigger = { has_trait = wounded_3 }
			remove_trait = wounded_3
		}
		100 = {
			trigger = { has_trait = ill }
			remove_trait = ill
		}
		100 = {
			trigger = { has_trait = pneumonic }
			remove_trait = pneumonic
		}
		50 = {
			trigger = { has_trait = typhus }
			remove_trait = typhus
		}
		50 = {
			trigger = { has_trait = gout_ridden }
			remove_trait = gout_ridden
		}
		50 = {
			trigger = { has_trait = consumption }
			remove_trait = consumption
		}
		50 = {
			trigger = { has_trait = smallpox }
			remove_trait = smallpox
		}
		50 = {
			trigger = { has_trait = great_pox }
			remove_trait = great_pox
		}
		25 = {
			trigger = { has_trait = cancer }
			remove_trait = cancer
		}
		25 = {
			trigger = { has_trait = bubonic_plague }
			remove_trait = bubonic_plague
		}
		25 = {
			trigger = { has_trait = leper }
			remove_trait = leper
		}
	}
}

#Do you feel lucky?
scripted_effect 1041_treatment_roll_effect = {
	random_list = {
		#Failure
		70 = {
			#Some weighting based on the aptitude of the performing party (healer/physician-partner)
			modifier = {
				exists = $VARIABLE$
				$VARIABLE$ >= 5
				add = -15
			}
			modifier = {
				exists = $VARIABLE$
				$VARIABLE$ >= 4
				add = -15
			}
			modifier = {
				exists = $VARIABLE$
				$VARIABLE$ >= 3
				add = -15
			}
			#Notify us about the outcome
			if = {
				limit = { 
					NOT = { $TARGET_CHARACTER$ = root } #If our partner gets treated
				}
				send_interface_toast = {
					type = event_toast_text_bad
					title = ep3_laamp_decision_event.1041.treatment_failure.t
					desc = ep3_laamp_decision_event.1041.treatment_failure.desc
					left_icon = root
					right_icon = $TARGET_CHARACTER$
				}
			}
			else = {
				send_interface_toast = {
					type = event_toast_text_bad #If we get treated
					title = ep3_laamp_decision_event.1041.treatment_failure.t
					desc = ep3_laamp_decision_event.1041.treatment_failure.desc
					left_icon = root
				}
			}
			#Nothing happens
		}
		#Success
		30 = {
			modifier = {
				NOT = { $TARGET_CHARACTER$ = root } #The scoped character is either visiting_partner or sickly_minor
				$TARGET_CHARACTER$ = {
					age < 20
					is_child_of = root
				}
				add = 30
			}
			modifier = {
				NOT = { $TARGET_CHARACTER$ = root } #... a cold-hearted person can tweak this back later on when people complain about too low child mortality rates
				$TARGET_CHARACTER$ = {
					age < 10
					is_child_of = root
				}
				add = 30
			}
			#If our partner gets treated
			if = {
				limit = { 
					NOT = { $TARGET_CHARACTER$ = root } #The scoped character is either visiting_partner or sickly_minor
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ep3_laamp_decision_event.1041.treatment_success.t
					left_icon = root
					right_icon = $TARGET_CHARACTER$
					$TARGET_CHARACTER$ = { 1041_remove_illness_or_wound_effect = yes }	
				}
			}
			#If we get treated, automatic toast
			else = { 1041_remove_illness_or_wound_effect = yes }	
		}
	}
}

#Someone learn-y or mystic
scripted_trigger 1041_physician_partner_trigger = {
	OR = {
		learning >= 15
		has_trait = lifestyle_physician
		has_trait = lifestyle_mystic
		has_trait = witch
	}
}


#Visit Healer
ep3_laamp_decision_event.1041 = {
	type = character_event
	title = ep3_laamp_decision_event.1041.t
	window = visit_settlement_window
	desc = {
		#What are they up to?
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: A sick minor... is still here
			triggered_desc = {
				trigger = {
					exists = scope:1040_sickly_minor
					exists = scope:been_to_healer
				}
				desc = ep3_laamp_decision_event.1041.desc_returned_sickly_minor
			}
			#RETURN: Physician partner wants a stab at it
			triggered_desc = {
				trigger = {
					scope:visiting_partner ?= { 
						1041_physician_partner_trigger = yes
						1000_has_illness_or_wound_to_treat_trigger = no
					}
					exists = scope:been_to_healer
				}
				desc = ep3_laamp_decision_event.1041.desc_returned_physician_partner
			}
			#RETURN: Generics
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_healer
						scope:healer_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1041.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:healer_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1041.desc_returned_02
				}
			}
			#FIRST TIME: A sick minor was snuck along
			triggered_desc = {
				trigger = {
					exists = scope:1040_sickly_minor
					NOT = { exists = scope:been_to_healer }
				}
				desc = ep3_laamp_decision_event.1041.desc_sickly_minor
			}
			#FIRST TIME: Our partner is actually pretty physician-y
			triggered_desc = {
				trigger = {
					scope:visiting_partner ?= { 
						1041_physician_partner_trigger = yes
						1000_has_illness_or_wound_to_treat_trigger = no
					}
					NOT = { exists = scope:been_to_healer }
				}
				desc = ep3_laamp_decision_event.1041.desc_physician_partner
			}
			#FIRST TIME: We've seen this healer before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_healer_character
					NOT = { exists = scope:been_to_healer }
				}
				desc = ep3_laamp_decision_event.1041.desc_reused_healer
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_healer }
				}
				desc = ep3_laamp_decision_event.1041.desc
			}	
		}
		#Describe the artifact
		first_valid = {
			#RETURN: Horn artifact
			triggered_desc = {
				trigger = { 
					exists = scope:been_to_healer
					scope:1041_health_artifact = { has_variable = health_horn }
				}
				desc = ep3_laamp_decision_event.1041.desc_outro_return_horn
			}
			#FIRST TIME: Horn artifact
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_healer }
					scope:1041_health_artifact = { has_variable = health_horn }
				}
				desc = ep3_laamp_decision_event.1041.desc_outro_horn
			}
			#RETURN: Other artifacts
			triggered_desc = {
				trigger = { 
					exists = scope:been_to_healer
					scope:1041_health_artifact = { 
						NOT = { has_variable = health_horn }
					}
				}
				desc = ep3_laamp_decision_event.1041.desc_outro_return_artifact
			}
			#FIRST TIME: Other artifacts
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_healer }
					scope:1041_health_artifact = { 
						NOT = { has_variable = health_horn }
					}
				}
				desc = ep3_laamp_decision_event.1041.desc_outro_artifact
			}
		}
	}
	theme = medicine
	#Someone close to you is sick
	override_sound = { 
		trigger = { 
			OR = {
				scope:visiting_partner ?= { 1000_has_illness_or_wound_to_treat_trigger = yes }
				exists = scope:1040_sickly_minor
			}
		}
		reference = "event:/MUSIC/Cues/Events/Illness/mx_cue_illness"
	}
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_medicine" }
	override_background = { reference = physicians_study }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#If it's our (tired) visiting partner
		triggered_animation = {
			trigger = { 1040_done_with_church_trigger = yes }
			animation = boredom
		}
		#Concerned about our kid
		triggered_animation = {
			trigger = {
				exists = scope:1040_sickly_minor
				is_close_family_of = scope:1040_sickly_minor
			}
			animation = stress
		}
		#Sick dudette
		triggered_animation = {
			trigger = { 1000_has_illness_or_wound_to_treat_trigger = yes }
			animation = pain
		}
		#Doctor dude
		triggered_animation = {
			trigger = { 1041_physician_partner_trigger = yes }
			animation = ecstasy
		}
		animation = thinking
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:1040_sickly_minor }
			animation = worry
		}
		animation = personality_content
	}
	right_portrait = {
		character = scope:laamp_healer_character
		camera = camera_event_scheme_far_right
		animation = physician
	}
	#Do we have a sick minor?
	lower_left_portrait = {
		trigger = { exists = scope:1040_sickly_minor }
		character = scope:1040_sickly_minor
	}
	artifact = {
		target = scope:1041_health_artifact
		position = lower_right_portrait
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = healer }
		#Find our healer
		if = {
			#Do we already have a healer?
			limit = {
				NOT = { exists = scope:laamp_healer_character }
			}
			#Has this person been our healer in the past 10 years?
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_healer_trigger = yes
					1010_is_a_saved_merchant_trigger = no
					1010_is_a_saved_peddler_trigger = no
					1010_is_a_saved_crier_trigger = no
					1010_is_a_saved_storyteller_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_clergy_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_weaponsmith_trigger = no
					1010_is_a_saved_armorer_trigger = no
					1010_is_a_saved_jeweler_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
				}
				save_scope_as = laamp_healer_character
				#Some more loc flavor shenanigans for these saved scopes
				save_scope_as = laamp_recurring_healer_character
			}
			#Otherwise find a healer in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_healer_character }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						has_trait = lifestyle_physician
					}
					save_scope_as = laamp_healer_character
				}
			}
			#Otherwise create a healer
			if = {
				limit = {
					NOT = { exists = scope:laamp_healer_character }
				}
				#Create healer to stuff in pool
				create_character = {
					template = physician_high_character_template
					location = scope:visiting_location
					dynasty = none
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_healer_character
				}
			}
			#Remember the healer
			1010_remember_vendor_character_effect = { GUILD = healer CHARACTER = scope:laamp_healer_character }
			#Find our healing artifact
			if = {
				limit = {
					NOT = { exists = scope:1041_health_artifact }
				}
				scope:laamp_healer_character ?= {
					#Have we created healing artifacts recently, which we can pull?
					if = {
						limit = {
							any_character_artifact ?= { has_variable = 1041_laamp_decision_health_artifact }
						}
						random_character_artifact = {
							limit = { has_variable = 1041_laamp_decision_health_artifact }
							save_scope_as = 1041_health_artifact
						}
					}
					#If we don't have any old healing artifacts; generate a new one!
					hidden_effect_new_object = { #HAZMAT SUIT OF ERROR SUPRESSION
						if = {
							limit = {
								NOT = { exists = scope:1041_health_artifact }
							}
							#Set rarity, maybe
							1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_healer_character }
							#Generate healing artifact
							generate_health_trinket_effect = yes
							#Finalization
							scope:newly_created_health_artifact ?= {
								set_variable = {
									name = 1041_laamp_decision_health_artifact
									days = visit_settlement_cooldown_days
								}
								#Belt & suspenders
								set_variable = 1041_laamp_decision_health_artifact
								#Don't need no notification about this
								1020_suppress_artifact_notifications_effect = yes
								save_scope_as = 1041_health_artifact
							}
						}
						#Set the value of the health artifact
						scope:1041_health_artifact = { 1041_set_item_value_effect = yes }
					}
				}
			}
			if = {
				limit = {
					exists = scope:laamp_healer_character
					NOT = { has_variable = 1041_healer_aptitude }
				}
				#Calculate the healer's aptitude
				set_variable = {
					name = 1041_healer_aptitude
					value = 0
				}
				1041_calculate_aptitude_modifier_effect = { CHARACTER = scope:laamp_healer_character VARIABLE = 1041_healer_aptitude }
				#Calculate our physician friend's aptitude
				if = {
					limit = { 
						scope:visiting_partner ?= { 1041_physician_partner_trigger = yes }
					}
					set_variable = {
						name = 1041_partner_healer_aptitude
						value = 0
					}
					1041_calculate_aptitude_modifier_effect = { CHARACTER = scope:visiting_partner VARIABLE = 1041_partner_healer_aptitude }
				}
			}
		}
		#For the background
		scope:laamp_healer_character = {
			if = {
				limit = {
					is_ruler = no
					exists = court_owner
				}
				court_owner = { save_scope_as = bg_override_char }
			}
			else = {
				save_scope_as = bg_override_char
			}
		}
	}
	#Attempt to improve your health // OR // Attempt to cure (curable) illness
	option = {
		name = {
			text = {
				first_valid = {
					#We're ill
					triggered_desc = {
						trigger = { 1000_has_illness_or_wound_to_treat_trigger = yes }
						desc = ep3_laamp_decision_event.1041.a_ill
					}
					#Just a standard procedure
					desc = ep3_laamp_decision_event.1041.a
				}
			}
		}
		#We're ill, roll for some treatment
		if = {
			limit = { 1000_has_illness_or_wound_to_treat_trigger = yes }
			1041_treatment_roll_effect = { TARGET_CHARACTER = root VARIABLE = var:1041_healer_aptitude }
		}
		#Standard procedure health modifier
		else = {
			if = {
				limit = { has_character_modifier = laamp_decision_church_health_modifier }
				hidden_effect = { remove_character_modifier = laamp_decision_church_health_modifier }
			}
			add_character_modifier = {
				modifier = laamp_decision_church_health_modifier
				days = visit_settlement_cooldown_days
			}
		}
		pay_short_term_gold = {
			target = scope:laamp_healer_character
			gold = minor_gold_value
		}
		#Set the variables and redirect us back to the Church Grounds
		1041_healed_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < minor_gold_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				1000_has_illness_or_wound_to_treat_trigger = no
				has_character_modifier = laamp_decision_church_health_modifier
				factor = 0
			}
		}
	}
	#Buy the health artifact
	option = {
		name = ep3_laamp_decision_event.1041.b
		scope:1041_health_artifact = {
			root = {
				pay_short_term_gold = {
					target = scope:laamp_healer_character
					gold = prev.var:1065_accessory_value
				}
			}
			set_owner = root
		}
		#Set the variables and redirect us back to the Church Grounds
		1041_healed_effect = yes
		ai_chance = {
			base = 50
			modifier = {
				short_term_gold < scope:1041_health_artifact.var:1065_accessory_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Triggered Option: Your partner wants to try their hand at the procedure
	option = {
		name = ep3_laamp_decision_event.1041.c
		trigger = {
			scope:visiting_partner ?= { 
				1041_physician_partner_trigger = yes
				1000_has_illness_or_wound_to_treat_trigger = no
			}
			NOT = { exists = scope:1040_sickly_minor }
		}
		flavor = ep3_laamp_decision_event.1041.c.flavor
		#We're ill, roll for some treatment
		if = {
			limit = { 1000_has_illness_or_wound_to_treat_trigger = yes }
			1041_treatment_roll_effect = { TARGET_CHARACTER = root VARIABLE = var:1041_partner_healer_aptitude }
		}
		#Standard procedure health modifier
		else = {
			if = {
				limit = { has_character_modifier = laamp_decision_church_health_partner_modifier }
				hidden_effect = { remove_character_modifier = laamp_decision_church_health_partner_modifier }
			}
			add_character_modifier = {
				modifier = laamp_decision_church_health_partner_modifier
				days = visit_settlement_cooldown_days
			}
		}
		progress_towards_friend_effect = {
			REASON = friend_allowed_to_treat
			CHARACTER = scope:visiting_partner
			OPINION = default_friend_opinion
		}
		scope:visiting_partner = {
			if = {
				limit = {
					NOT = { has_trait = lifestyle_physician }
				}
				add_trait = lifestyle_physician
			}
			else_if = {
				limit = {
					has_trait = lifestyle_physician
					has_trait_xp = {
						trait = lifestyle_physician
						value < 100
					}
				}
				add_trait_xp = {
					trait = lifestyle_physician
					value = 40
				}
			}
			else = {
				add_learning_skill = 1
			}
		}
		#Set the variables and redirect us back to the Church Grounds
		1041_healed_effect = yes
		ai_chance = { base = 200 }
	}
	#Triggered Option: Your partner or sickly minor is ill
	option = {
		name = {
			text = ep3_laamp_decision_event.1041.d
			trigger = { exists = scope:1040_sickly_minor }
		}
		name = {
			text = ep3_laamp_decision_event.1041.d.partner
			trigger = { exists = scope:visiting_partner }
		}
		trigger = {
			OR = {
				scope:visiting_partner ?= { 1000_has_illness_or_wound_to_treat_trigger = yes }
				exists = scope:1040_sickly_minor
			}
		}
		if = {
			limit = { exists = scope:1040_sickly_minor }
			1041_treatment_roll_effect = { TARGET_CHARACTER = scope:1040_sickly_minor VARIABLE = var:1041_healer_aptitude }
			progress_towards_friend_effect = {
				REASON = friend_got_treatment
				CHARACTER = scope:1040_sickly_minor
				OPINION = default_friend_opinion
			}
		}
		else = {
			1041_treatment_roll_effect = { TARGET_CHARACTER = scope:visiting_partner VARIABLE = var:1041_healer_aptitude }
			progress_towards_friend_effect = {
				REASON = friend_got_treatment
				CHARACTER = scope:visiting_partner
				OPINION = default_friend_opinion
			}
		}
		pay_short_term_gold = {
			target = scope:laamp_healer_character
			gold = minor_gold_value
		}	
		#Set the variables and redirect us back to the Church Grounds
		1041_healed_effect = yes
		ai_chance = {
			base = 300
			modifier = {
				short_term_gold < minor_gold_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#I want to go back
	option = {
		name = ep3_laamp_decision_event.1041.e
		#Sets variables and returns us to church grounds screen
		1031_been_to_effect = { GUILD = healer }
		ai_chance = { base = 100 }
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:healer }
	}
}


#Set the correct variable to block off the Church option and remove the desc flavor variable
scripted_effect 1043_churched_effect = {
	save_scope_as = laamp_decision_has_churched
	#Go back to church grounds
	hidden_effect = { 1041_return_to_church_grounds_effect = yes }
}

#Not really into religion
scripted_trigger 1043_is_unzealous_trigger = {
	OR = {
		has_trait = cynical
		any_secret = { type = secret_non_believer }
	}
}


#Visit Church
ep3_laamp_decision_event.1043 = {
	type = character_event
	title = ep3_laamp_decision_event.1043.t
	window = visit_settlement_window
	desc = {
		#What are they up to?
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: Generics
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_church
						scope:church_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1043.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:church_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1043.desc_returned_02
				}
			}
			#FIRST TIME: We've seen this NunMonk before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_clergy_character
					NOT = { exists = scope:been_to_church }
				}
				desc = ep3_laamp_decision_event.1043.desc_reused_clergy
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_church }
				}
				desc = ep3_laamp_decision_event.1043.desc
			}	
		}
		#How about some theft
		first_valid = {
			#RETURN: Longing master thief
			triggered_desc = {
				trigger = {
					scope:visiting_partner ?= { has_court_position = master_thief_camp_officer }
					exists = scope:been_to_church
				}
				desc = ep3_laamp_decision_event.1043.desc_return_outro_thief
			}
			#RETURN: Outro
			triggered_desc = {
				trigger = { exists = scope:been_to_church }
				desc = ep3_laamp_decision_event.1043.desc_return_outro
			}
			#FIRST TIME: Longing master thief
			triggered_desc = {
				trigger = {
					scope:visiting_partner ?= { has_court_position = master_thief_camp_officer }
					NOT = { exists = scope:been_to_church }
				}
				desc = ep3_laamp_decision_event.1043.desc_outro_thief
			}
			#FIRST TIME: Outro
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_church }
				}
				desc = ep3_laamp_decision_event.1043.desc_outro
			}
		}
	}
	theme = faith
	override_sound = { reference = "event:/MUSIC/Cues/Events/Sacral Happening/mx_cue_epic_sacral_moment" }
	override_background = { reference = temple }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#Master thief
		triggered_animation = {
			trigger = { has_court_position = master_thief_camp_officer }
			animation = scheme
		}
		#Unzealous
		triggered_animation = {
			trigger = { 1043_is_unzealous_trigger = yes }
			animation = personality_cynical
		}
		#Zealous
		triggered_animation = {
			trigger = {
				scope:visiting_partner = { has_trait = zealous }
			}
			animation = ecstasy
		}
		#Friendly
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_friendly_traits = yes } 
			}
			animation = interested
		}
		#Business-minded
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_commerce_traits = yes } 
			}
			animation = personality_greedy
		}
		#Uninterested
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_uninterested_traits = yes } 
			}
			animation = boredom
		}
		#Irrational
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_irrational_traits = yes } 
			}
			animation = personality_irrational
		}
		#A bit awkward
		triggered_animation = {
			trigger = { 
				scope:visiting_partner = { 1010_has_standoffish_traits = yes } 
			}
			animation = disapproval
		}
		animation = personality_honorable
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { 1043_is_unzealous_trigger = yes }
			animation = disapproval
		}
		animation = personality_content
	}
	right_portrait = {
		character = scope:laamp_clergy_character
		animation = personality_forgiving
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#For the background
		scope:visiting_location.county.holder = { save_scope_as = bg_override_char }
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = church }
		#Find our clergy
		if = {
			#Do we already have a clergy?
			limit = {
				NOT = { exists = scope:laamp_clergy_character }
			}
			#Has this person been our clergy in the past 10 years?
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					faith = scope:visiting_location.faith
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_clergy_trigger = yes
					1010_is_a_saved_merchant_trigger = no
					1010_is_a_saved_peddler_trigger = no
					1010_is_a_saved_crier_trigger = no
					1010_is_a_saved_storyteller_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_healer_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_weaponsmith_trigger = no
					1010_is_a_saved_armorer_trigger = no
					1010_is_a_saved_jeweler_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
				}
				save_scope_as = laamp_clergy_character
				#Some more loc flavor shenanigans for these saved scopes
				save_scope_as = laamp_recurring_clergy_character
			}
			#Otherwise find a clergy in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_clergy_character }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						has_trait = devoted
						faith = scope:visiting_location.faith
					}
					save_scope_as = laamp_clergy_character
				}
			}
			#Otherwise create a clergy
			if = {
				limit = {
					NOT = { exists = scope:laamp_clergy_character }
				}
				#Create clergy to stuff in pool
				create_character = {
					template = generic_peasant_character
					location = scope:visiting_location
					dynasty = none
					trait = devoted
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_clergy_character
				}
			}
			#Remember the clerger
			1010_remember_vendor_character_effect = { GUILD = clergy CHARACTER = scope:laamp_clergy_character }
		}
		#How much gold is in the collect; and how difficult is it?
		if = {
			limit = {
				NOT = { exists = scope:1043_collect_gold_value }
			}
			#Randomize the initial value
			set_variable = {
				name = 1043_collect_gold_difficulty
				value = {
					integer_range = {
						min = 0
						max = 2
					}
				}
			}
			#Then add difficulty based on how much gold is in the collect
			random_list = {
				10 = {
					save_scope_value_as = {
						name = 1043_collect_gold_value
						value = minor_gold_laamps_value
					}
					change_variable = {
						name = 1043_collect_gold_difficulty
						add = 1
					}
				}
				10 = {
					save_scope_value_as = {
						name = 1043_collect_gold_value
						value = medium_gold_laamps_value
					}
					change_variable = {
						name = 1043_collect_gold_difficulty
						add = 2
					}
				}
				10 = {
					save_scope_value_as = {
						name = 1043_collect_gold_value
						value = major_gold_laamps_value
					}
					change_variable = {
						name = 1043_collect_gold_difficulty
						add = 3
					}
				}
			}
			#Did we go robbing a bunch of churches previously?
			if = {
				limit = { 
					has_variable = 1043_heightened_security
					exists = var:1043_collect_gold_difficulty
				}
				change_variable = {
					name = 1043_collect_gold_difficulty
					add = var:1043_heightened_security
				}

			}
			#Set the difficulty
			if = {
				limit = { exists = var:1043_collect_gold_difficulty }
				if = {
					limit = { var:1043_collect_gold_difficulty >= 5 }
					save_scope_value_as = {
						name = 1043_collect_gold_difficulty_rating
						value = monumentally_high_skill_rating #Had to invent a new difficulty, just for you :hmmyes:
					}
				}
				else_if = {
					limit = { var:1043_collect_gold_difficulty = 4 }
					save_scope_value_as = {
						name = 1043_collect_gold_difficulty_rating
						value = extremely_high_skill_rating
					}
				}
				else_if = {
					limit = { var:1043_collect_gold_difficulty = 3 }
					save_scope_value_as = {
						name = 1043_collect_gold_difficulty_rating
						value = high_skill_rating
					}
				}
				else_if = {
					limit = { var:1043_collect_gold_difficulty = 2 }
					save_scope_value_as = {
						name = 1043_collect_gold_difficulty_rating
						value = medium_skill_rating
					}
				}
				else = {
					save_scope_value_as = {
						name = 1043_collect_gold_difficulty_rating
						value = low_skill_rating
					}
				}
			}
		}
	}
	#Donate some gold for piety
	option = {
		name = ep3_laamp_decision_event.1043.a
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { 1043_is_unzealous_trigger = yes }
					desc = ep3_laamp_decision_event.1043.a.flavor_unzealous
				}
			}
		}
		if = {
			limit = { NOT = { exists = var:visit_settlement_church_donation } }
			set_variable = {
				name = visit_settlement_church_donation
				years = visit_settlement_medium_cooldown_year
				value = 1
			}
		}
		else = {
			set_local_variable = {
				name = visit_settlement_church_donation_temp
				value = var:visit_settlement_church_donation
			}
			set_variable = {
				name = visit_settlement_church_donation
				years = visit_settlement_medium_cooldown_year
				value = {
					value = local_var:visit_settlement_church_donation_temp
					add = 1
				}
			}
		}
		#Pay gold, feel more pious
		pay_short_term_gold = {
			target = scope:laamp_clergy_character
			gold = minor_gold_value
		}
		add_piety = visit_settlement_piety_gain_value
		#Roll for epiphanous clergy
		hidden_effect = {
			scope:laamp_clergy_character = {
				random_list = {
					95 = {
						modifier = { 
							has_trait = possessed_1
							factor = 0.5
						}
						#Nothing happens
					}
					5 = {
						modifier = {
							piety_level = high_piety_level
							add = 5
						}
						modifier = {
							piety_level = very_high_piety_level
							add = 5
						}
						modifier = {
							piety_level = max_piety_level
							add = 5
						}
						set_variable = 1043_is_epiphanous
					}
				}
			}
		}	
		stress_impact = {
			greedy = minor_stress_impact_gain
			zealous = minor_stress_impact_loss
			generous = minor_stress_impact_loss
			improvident = medium_stress_impact_loss #Throw 'em a bone
		}
		trigger_event = ep3_laamp_decision_event.1044
		ai_chance = {
			base = 100
			modifier = {
				has_trait = greedy
				factor = 0
			}
			modifier = {
				short_term_gold < minor_gold_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Ask for blessing
	option = {
		name = ep3_laamp_decision_event.1043.b
		trigger = {
			NOR = { 
				has_character_modifier = laamp_decision_church_blessing_stress_loss_modifier
				has_character_modifier = laamp_decision_church_blessing_stress_gain_modifier
				piety_level < low_piety_level
			}
		}
		show_as_unavailable = { always = yes }
		reason = piety
		#Pokémon blue?
		add_character_modifier = {
			modifier = laamp_decision_church_blessing_stress_loss_modifier
			years = 5
		}
		#Set the variables and redirect us back to the Church Grounds
		1043_churched_effect = yes
		ai_chance = {
			base = 200
			modifier = {
				piety_level > medium_piety_level
				add = 300
			}
		}
	}
	#'Borrow' gold from the collect
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:visiting_partner ?= { has_court_position = master_thief_camp_officer }
						}
						desc = ep3_laamp_decision_event.1043.c_master_thief
					}
					triggered_desc = {
						trigger = { has_variable = 1043_heightened_security }
						desc = ep3_laamp_decision_event.1043.c_guarded
					}
					desc = ep3_laamp_decision_event.1043.c
				}
			}
		}
		trigger = { is_ai = no }
		flavor = {
			first_valid = {
				triggered_desc = {
					trigger = { 
						has_variable = 1043_heightened_security
						var:1043_heightened_security != 0
					}
					desc = ep3_laamp_decision_event.1043.c.flavor_guarded
				}
				desc = ep3_laamp_decision_event.1043.c.flavor
			}
		}
		duel = {
			skill = intrigue
			value = scope:1043_collect_gold_difficulty_rating
			#Success: Coin!
			50 = {
				modifier = {
					scope:visiting_partner ?= { has_court_position = master_thief_camp_officer }
					factor = 2
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = ep3_laamp_decision_event.1043.c.thievery_success.desc
				send_interface_toast = {
					title = ep3_laamp_decision_event.1043.c.thievery_success.t
					left_icon = root
					add_gold = scope:1043_collect_gold_value
				}
				hidden_effect = {
					#... fool me twice; shame on you.
					if = {
						limit = { has_variable = 1043_heightened_security }
						random_list = {
							50 = {
								#Nothing
							}
							50 = {
								#Save old value as temp
								set_variable = {
									name = 1043_heightened_security_temp
									value = var:1043_heightened_security
								}
								#Remove the variable we'll refresh
								remove_variable ?= 1043_heightened_security
								#Set the new proper variable and add the old value as well
								set_variable = {
									name = 1043_heightened_security
									value = {
										value = var:1043_heightened_security_temp
										add = 1
									}
									years = visit_settlement_medium_cooldown_year
								}
								#Then remove the temp
								remove_variable ?= 1043_heightened_security_temp
							}
						}
					}
					#Fool me once, shame on me...
					else = {
						set_variable = {
							name = 1043_heightened_security
							value = 0
							years = visit_settlement_medium_cooldown_year
						}
					}
				}
			}
			#Failure: Banished!
			50 = {
				modifier = {
					scope:visiting_partner ?= { has_court_position = master_thief_camp_officer }
					factor = 0.5
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = ep3_laamp_decision_event.1043.c.thievery_failure.desc
				send_interface_toast = {
					type = event_toast_text_bad
					title = ep3_laamp_decision_event.1043.c.thievery_failure.t
					desc = ep3_laamp_decision_event.1043.c.thievery_failure.desc
					left_icon = root
					custom_tooltip = ep3_laamp_decision_event.1041.return.tt
					#Shame on you
					add_piety = medium_piety_loss
					#Shame shame
					if = {
						limit = {
							NOT = { has_trait = gallowsbait }
						}
						add_trait = gallowsbait
					}
					else_if = {
						limit = {
							has_trait = gallowsbait
							has_trait_xp = {
								trait = gallowsbait
								track = thief
								value < 100
							}
						}
						add_trait_xp = {
							trait = gallowsbait
							track = thief
							value = small_lifestyle_random_xp_low
						}
					}
				}
				#You will not be going back to the church any time soon
				set_variable = {
					name = 1040_caught_stealing
					days = visit_settlement_small_cooldown_days
				}
			}
			#Critical Failure: The local guards are summoned
			10 = {
				trigger = {
					trigger_if = {
						limit = { exists = scope:visiting_partner }
						NOT = { 
							scope:visiting_partner = { has_court_position = master_thief_camp_officer } 
						}
					}
					trigger_else = { always = yes }
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}	
				min = 5
				desc = ep3_laamp_decision_event.1043.c.thievery_critical_failure.desc
				send_interface_toast = {
					title = ep3_laamp_decision_event.1043.c.thievery_critical_failure.t
					left_icon = root
					#Quite the tussle
					increase_wounds_effect = { REASON = fight }
					#Shame on you
					add_piety = medium_piety_loss
					#Violent shame, even
					if = {
						limit = {
							NOT = { has_trait = gallowsbait }
						}
						add_trait = gallowsbait
					}
					else_if = {
						limit = {
							has_trait = gallowsbait
							has_trait_xp = {
								trait = gallowsbait
								track = bandit
								value < 100
							}
						}
						add_trait_xp = {
							trait = gallowsbait
							track = bandit
							value = small_lifestyle_random_xp_mid
						}
					}
				}	
				#You will not be going back to the church any time soon
				set_variable = {
					name = 1040_caught_stealing
					days = visit_settlement_small_cooldown_days
				}
			}
		}
		#Super-stressful for honest characters and zealous characters, IF you share faith
		if = {
			limit = { scope:visiting_location.county.faith = root.faith }
			stress_impact = {
				honest = major_stress_impact_gain
				zealous = major_stress_impact_gain
				deceitful = minor_stress_impact_loss
				greedy = minor_stress_impact_loss
			}
		}
		else = {
			stress_impact = {
				honest = major_stress_impact_gain
				deceitful = minor_stress_impact_loss
			}
		}
		#Set the variables and redirect us back to the Church Grounds
		1043_churched_effect = yes
	}
	#I want to go back
	option = {
		name = ep3_laamp_decision_event.1043.d
		#Sets variables and returns us to church grounds screen
		1031_been_to_effect = { GUILD = church }
		ai_chance = { base = 200 }
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:church }
	}
}

#Post-Donation
ep3_laamp_decision_event.1044 = {
	type = character_event
	title = ep3_laamp_decision_event.1043.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			#Strange person thinks you're a reincarnation or something? Why not.
			triggered_desc = {
				trigger = {
					scope:laamp_clergy_character = { has_variable = 1043_is_epiphanous }
				}
				desc = ep3_laamp_decision_event.1044.desc_epiphany
			}
			desc = ep3_laamp_decision_event.1044.desc
		}
	}
	theme = faith
	override_sound = {
		trigger = {
			scope:laamp_clergy_character = { has_variable = 1043_is_epiphanous }
		}
		reference = "event:/DLC/FP4/MUSIC/Stingers/mx_stinger_legends_lvl_03" 
	}
	override_sound = { reference = "event:/MUSIC/Cues/Events/Low Key Positive/mx_cue_low_key_postive" }
	override_background = { reference = temple }
	override_effect_2d = {
		trigger = { 
			scope:laamp_clergy_character = { has_variable = 1043_is_epiphanous }
		}
		reference = legend_glow #Too much?
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { 
				scope:laamp_clergy_character = { has_variable = 1043_is_epiphanous }
			}
			animation = disbelief
		}
		triggered_animation = {
			trigger = { 1043_is_unzealous_trigger = yes }
			animation = shock
		}
		animation = admiration
	}
	right_portrait = {
		character = scope:laamp_clergy_character
		triggered_animation = {
			trigger = { has_variable = 1043_is_epiphanous }
			animation = shock
		}
		animation = happiness
	}
	#Do we have someone to display?
	lower_left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		hidden_effect = {
			scope:laamp_clergy_character = {
				if = {
					limit = { has_variable = 1043_is_epiphanous }
					add_trait = loyal
					add_trait = holy_warrior
				}
			}
		}
	}
	#Ask for blessing
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:laamp_clergy_character = { has_variable = 1043_is_epiphanous }
						}
						desc = ep3_laamp_decision_event.1044.a_epiphany
					}
					desc = ep3_laamp_decision_event.1044.a
				}
			}
		}
		trigger = {
			NOR = { 
				has_character_modifier = laamp_decision_church_blessing_stress_loss_modifier
				has_character_modifier = laamp_decision_church_blessing_stress_gain_modifier
				piety_level < low_piety_level
			}
		}
		show_as_unavailable = { always = yes }
		reason = piety
		#Or Pokémon red?
		add_character_modifier = {
			modifier = laamp_decision_church_blessing_stress_gain_modifier
			years = 5
		}	
		ai_chance = {
			base = 100
			modifier = {
				piety_level > medium_piety_level
				add = 300
			}
		}
	}
	#Triggered Option: Clergy Person wants to join your camp
	option = {
		name = ep3_laamp_decision_event.1044.b
		trigger = {
			scope:laamp_clergy_character = { has_variable = 1043_is_epiphanous }
		}
		add_courtier = scope:laamp_clergy_character
		ai_chance = {
			base = 100
			modifier = {
				has_trait = paranoid
				factor = 0
			}
		}
	}
	#Nah
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:laamp_clergy_character = { has_variable = 1043_is_epiphanous }
						}
						desc = ep3_laamp_decision_event.1044.c_epiphany
					}
					desc = ep3_laamp_decision_event.1044.c
				}
			}
		}
		#Tooltip so we know where we're going
		custom_tooltip = ep3_laamp_decision_event.1041.return.tt
		ai_chance = {
			base = 100
		}
	}
	after = {
		#Set the variables and redirect us back to the Church Grounds
		1043_churched_effect = yes
	}
}


#Set the correct variable to block off the Garden option and remove the desc flavor variable
scripted_effect 1045_gardened_effect = {
	save_scope_as = laamp_decision_has_gardened
	#Go back to church grounds
	hidden_effect = { 1041_return_to_church_grounds_effect = yes }
}

#Right?
scripted_trigger 1045_probably_knows_gardening_trigger = {
	OR = {
		has_trait = lifestyle_gardener
		has_trait = lifestyle_herbalist
		learning > high_skill_rating
	}	
}

#Used in enough places to warrant a trigger
scripted_trigger 1045_could_harvest_garden_trigger = {
	OR = {
		trigger_if = {
			limit = { exists = scope:visiting_partner }
			scope:visiting_partner = { 1045_probably_knows_gardening_trigger = yes }
		}
		1045_probably_knows_gardening_trigger = yes
	}
}

#Ditto
scripted_trigger 1045_could_unwind_in_garden_trigger = {
	scope:visiting_partner ?= { 
		OR = {
			AND = {
				has_relation_potential_lover = root
				root = { might_cheat_on_every_partner_trigger = yes }
			}
			has_relation_lover = root 
		}
	}
}


#Visit Garden
ep3_laamp_decision_event.1045 = {
	type = character_event
	title = ep3_laamp_decision_event.1045.t
	window = visit_settlement_window
	desc = {
		#What's going down in the garden
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: Generics
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_garden
						scope:garden_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1045.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:garden_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1045.desc_returned_02
				}
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_garden }
				}
				desc = ep3_laamp_decision_event.1045.desc
			}	
		}
		#Hey look, some plants
		first_valid = {
			#RETURN: Still partner plants
			triggered_desc = {
				trigger = {
					scope:visiting_partner ?= { 1045_probably_knows_gardening_trigger = yes }
					exists = scope:been_to_garden
				}
				desc = ep3_laamp_decision_event.1045.desc_outro_return_partner
			}
			#RETURN: Still plants
			triggered_desc = {
				trigger = {
					1045_probably_knows_gardening_trigger = yes
					exists = scope:been_to_garden
				}
				desc = ep3_laamp_decision_event.1045.desc_outro_return_gardener
			}
			#FIRST TIME: Partner PLAAANTSSS
			triggered_desc = {
				trigger = {
					scope:visiting_partner ?= { 1045_probably_knows_gardening_trigger = yes }
					NOT = { exists = scope:been_to_garden }
				}
				desc = ep3_laamp_decision_event.1045.desc_outro_partner
			}
			#FIRST TIME: PLAAANTSSS
			triggered_desc = {
				trigger = {
					1045_probably_knows_gardening_trigger = yes
					NOT = { exists = scope:been_to_garden }
				}
				desc = ep3_laamp_decision_event.1045.desc_outro_gardener
			}
		}
	}
	theme = faith
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_health_good" }
	override_background = { reference = garden }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		triggered_animation = {
			trigger = {
				NOT = { has_variable = 1045_has_harvested_recently }
				1045_probably_knows_gardening_trigger = yes 
			}
			animation = survey
		}
		animation = happiness
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				NOT = { has_variable = 1045_has_harvested_recently }
				scope:visiting_partner ?= { 1045_probably_knows_gardening_trigger = yes }
			}
			animation = interested
		}
		triggered_animation = {
			trigger = { 1045_probably_knows_gardening_trigger = yes }
			animation = survey
		}
		triggered_animation = {
			trigger = { faith != scope:visiting_location.faith }
			animation = stress
		}
		animation = thinking
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#For the background
		scope:visiting_location.county.holder = { save_scope_as = bg_override_char }
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = garden }
	}
	#Convert / contemplate faith
	option = {
		name = {
			text = {
				first_valid = {
					#Convert to faith
					triggered_desc = {
						trigger = { 
							faith != scope:visiting_location.faith
						}
						desc = ep3_laamp_decision_event.1045.a_convert
					}
					#Contemplate faith
					desc = ep3_laamp_decision_event.1045.a
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1045.a.cooldown.tt
				NOT = { has_variable = 1045_contemplated_garden_recently }
			}	
		}
		show_as_unavailable = { always = yes }
		#Convert
		if = {
			limit = {
				faith != scope:visiting_location.faith
			}
			set_character_faith = scope:visiting_location.faith
			if = {
				limit = { 
					scope:visiting_location.faith = { has_doctrine = doctrine_monotheist }
				}
				custom_description_no_bullet = { text = mandala_monotheist_warning_tt }
			}
			stress_impact = {
				base = minor_stress_impact_loss
				zealous = major_stress_impact_gain
			}
		}
		#Contemplate faith
		else = {
			stress_impact = {
				base = medium_stress_impact_loss
				content = minor_stress_impact_loss
				zealous = medium_stress_impact_loss
			}
		}
		#Cooldown for the action
		set_variable = {
			name = 1045_contemplated_garden_recently
			days = visit_settlement_minimum_cooldown_days
		}
		#Set the variables and redirect us back to the Church Grounds
		1045_gardened_effect = yes
		ai_chance = { 
			base = 100
			modifier = {
				faith != scope:visiting_location.faith
				has_trait = zealous
				factor = 0
			}
			modifier = {
				faith != scope:visiting_location.faith
				any_secret ?= { secret_type = secret_non_believer }
				add = 300
			}
		}
	}
	#Triggered Option: Those plants look edible
	option = {
		name = {
			text = {
				first_valid = {
					#Gardener friend
					triggered_desc = {
						trigger = { 
							scope:visiting_partner ?= { 1045_probably_knows_gardening_trigger = yes }
						}
						desc = ep3_laamp_decision_event.1045.b_partner
					}
					#Gardener self
					desc = ep3_laamp_decision_event.1045.b
				}
			}
		}
		trigger = {
			trigger_if = {
				limit = { has_variable = 1045_has_harvested_recently }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1045.b.cooldown.tt
					always = no 
				}	
			}
			trigger_else = { 1045_could_harvest_garden_trigger = yes }	
		}
		show_as_unavailable = {
			#Only show it if you could've actually done it
			trigger_if = {
				limit = { 1045_could_harvest_garden_trigger = yes }
				always = yes
			}
			trigger_else = { always = no }
		}
		#Get some provisions
		if = {
			limit = {
				domicile ?= { provisions < max_provisions }
			}
			domicile ?= { 
				change_provisions = {
					value = {
						value = root.minor_gold_laamps_value
						multiply = {
							value = max_provisions
							divide = 250
							round = yes
							min = 1
						}
					}
				}
			}
		}
		#... or sell the morsels, if capped
		else = { add_gold = minor_gold_laamps_value }
		#Probably holy somewhere
		if = {
			limit = {
				faith = {
					OR = {
						has_doctrine = tenet_sanctity_of_nature
						trait_is_virtue = lifestyle_gardener
						trait_is_virtue = lifestyle_herbalist					
					}
				}
			}
			add_piety = medium_piety_gain
		}
		#Cooldown for the action
		set_variable = {
			name = 1045_has_harvested_recently
			days = visit_settlement_minimum_cooldown_days
		}
		#Set the variables and redirect us back to the Church Grounds
		1045_gardened_effect = yes
		ai_chance = {
			base = 1000 #Just do it
		}
	}
	#Triggered Option: Stress relief? Stress relief.
	option = {
		name = ep3_laamp_decision_event.1045.c
		trigger = {
			trigger_if = {
				limit = { has_variable = 1045_garden_unwinded_recently }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1045.c.cooldown.tt
					always = no 
				}	
			}
			trigger_else = { 1045_could_unwind_in_garden_trigger = yes }	
		}
		show_as_unavailable = {
			#Only show it if you could've actually done it
			trigger_if = {
				limit = { 1045_could_unwind_in_garden_trigger = yes }
				always = yes
			}
			trigger_else = { always = no }
		}
		#Stress relief
		had_sex_with_effect = { CHARACTER = scope:visiting_partner PREGNANCY_CHANCE = pregnancy_chance }
		progress_towards_lover_effect = {
			CHARACTER = scope:visiting_partner
			REASON = lover_contemplative_sex
			OPINION = default_lover_opinion
		}
		#Probably holy to some?
		if = {
			limit = {
				faith = { has_doctrine = tenet_carnal_exaltation }
			}
			add_piety = medium_piety_gain
		}
		#Or not
		else_if = {
			limit = {
				faith = {
					OR = {
						trait_is_sin = lustful
						trait_is_sin = rakish
						trait_is_sin = seducer
					}
				}
			}
			add_piety = minor_piety_loss
		}
		#Cooldown for the action
		set_variable = {
			name = 1045_garden_unwinded_recently
			days = visit_settlement_minimum_cooldown_days
		}
		#Stress loss with some factors
		stress_impact = {
			base = medium_stress_impact_loss
			rakish = medium_stress_impact_loss
			seducer = minor_stress_impact_loss
			lustful = minor_stress_impact_loss
			paranoid = minor_stress_impact_gain
			chaste = minor_stress_impact_gain
		}
		#Set the variables and redirect us back to the Church Grounds
		1045_gardened_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				has_trait = lustful
				add = 500
			}
			modifier = {
				has_trait = rakish
				add = 500
			}
			modifier = {
				has_trait = chaste
				factor = 0
			}
		}
	}
	#I want to go back
	option = {
		name = ep3_laamp_decision_event.1045.d
		#Everything is on cooldown, I guess
		if = {
			limit = {
				has_variable = 1045_contemplated_garden_recently
				trigger_if = {
					limit = { 1045_could_harvest_garden_trigger = yes }
					has_variable = 1045_has_harvested_recently
				}
				trigger_if = {
					limit = { 1045_could_unwind_in_garden_trigger = yes }
					has_variable = 1045_garden_unwinded_recently
				}
			}
			1045_gardened_effect = yes
		}
		else = {
			#Sets variables and returns us to church grounds screen
			1031_been_to_effect = { GUILD = garden }
		}
		ai_chance = { base = 100 }
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:garden }
	}
}


#Hire the Physician, show/set the effects and variables 
scripted_effect 1047_hire_physician_effect = {
	hidden_effect = {
		reverse_add_opinion = {
			target = scope:laamp_physician_recruit
			modifier = recruited_me_opinion
			opinion = 30
		}
	}
	add_courtier = scope:laamp_physician_recruit
	#The actual effect happens in after
	show_as_tooltip = { 
		court_position_grant_effect = {
			EMPLOYER = root
			POS = court_physician
			CANDIDATE = scope:laamp_physician_recruit
		}
	}
	#This 'finished' is different since it changes between flag:yes and flag:no
	save_scope_value_as = {
		name = laamp_decision_recruited_physician
		value = flag:yes
	}
	#Go back to church grounds
	hidden_effect = { 1041_return_to_church_grounds_effect = yes }
}


#Visit Physician
ep3_laamp_decision_event.1047 = {
	type = character_event
	title = ep3_laamp_decision_event.1047.t
	window = visit_settlement_window
	desc = {
		#What're they doing?
		first_valid = {
			#We've returned to this scene, now what
			#RETURN:
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_physician
						scope:physician_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1047.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:physician_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1047.desc_returned_02
				}
				triggered_desc = { 
					trigger = { scope:physician_loc_tracker ?= 2 }
					desc = ep3_laamp_decision_event.1047.desc_returned_03
				}
			}
			#FIRST TIME: We've seen this physician before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_physician
					NOT = { exists = scope:been_to_physician }
				}
				desc = ep3_laamp_decision_event.1047.desc_reused_physician
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_physician }
				}
				desc = ep3_laamp_decision_event.1047.desc
			}	
		}
	}
	theme = learning
	override_sound = { reference = "event:/MUSIC/Cues/Events/Positive/mx_cue_postive_effect" }
	override_background = { reference = location_study }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		triggered_animation = {
			trigger = { 1041_physician_partner_trigger = yes }
			animation = interested
		}
		animation = personality_compassionate
	}
	center_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:laamp_physician_recruit
		camera = camera_event_scheme_far_right
		animation = reading
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Run this once: Re-save the portrait so the Physician is not the 1040_third_character (since they narratively moved to their study)
		if = {
			limit = { scope:1040_third_character = scope:laamp_physician_recruit }
			#Overwrite with ROOT to block off the portrait
			save_scope_as = 1040_third_character
			#Remember the bodyguard
			1010_remember_vendor_character_effect = { GUILD = physician CHARACTER = scope:laamp_physician_recruit }
		}
		#Can we _not_ repeat the loc?
		1025_set_and_check_hub_loc_tracker_scope_effect = { HUB = physician }
	}
	#Pay gold
	option = {
		name = ep3_laamp_decision_event.1047.a
		pay_short_term_gold = {
			target = scope:laamp_physician_recruit
			gold = minor_gold_value
		}
		#Wrap effect to hire 'em, set scope & return to church
		1047_hire_physician_effect = yes
		ai_chance = {
			base = 100 
			modifier = {
				short_term_gold < minor_gold_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Have x piety
	option = {
		name = ep3_laamp_decision_event.1047.b
		trigger = { piety >= 1000 }
		show_as_unavailable = { always = yes }
		reason = piety
		#Wrap effect to hire 'em, set scope & return to church
		1047_hire_physician_effect = yes
		ai_chance = {
			base = 1000 #Just do it
		}
	}
	#Learning duel
	option = {
		name = ep3_laamp_decision_event.1047.c
		duel = {
			skill = learning
			value = average_skill_rating
			#Success: Hire 'em up
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					OR = {
						has_trait = scholar
						has_trait = whole_of_body
						has_trait = crusader_king
					}
					factor = 2
				}
				desc = ep3_laamp_decision_event.1047.c.success
				send_interface_toast = {
					title = ep3_laamp_decision_event.1047.c.success
					left_icon = root
					right_icon = scope:laamp_physician_recruit
					#Yippee!
					1047_hire_physician_effect = yes
				}
			}
			#Failure: Bye, now
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				modifier = {
					has_trait = zealous
					factor = 0.5
				}
				desc = ep3_laamp_decision_event.1047.c.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = ep3_laamp_decision_event.1047.c.failure
					desc = ep3_laamp_decision_event.1047.c.failure.tt
					left_icon = root
					right_icon = scope:laamp_physician_recruit
					#Oh well
					custom_tooltip = ep3_laamp_decision_event.1047.c.failure.tt
					#This 'finished' is different since it changes between flag:yes and flag:no
					save_scope_value_as = {
						name = laamp_decision_recruited_physician
						value = flag:no
					}
					1041_return_to_church_grounds_effect = yes
				}
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				piety >= 1000
				factor = 0
			}
		}
	}
	#I want to go back
	option = {
		name = ep3_laamp_decision_event.1047.d
		#Sets variables and returns us to church grounds screen
		1031_been_to_effect = { GUILD = physician }
		ai_chance = {
			base = 100
			modifier = {
				employs_court_position = court_physician_court_position
				factor = 2
			}
		}
	}
	after = {
		if = {
			limit = { scope:laamp_decision_recruited_physician ?= flag:yes }
			#Appoint them
			if = {
				limit = {
					can_appoint_char_to_court_position = {
						CHAR = scope:laamp_physician_recruit
						COURT_POS = court_physician_court_position
					}
				}
				court_position_grant_effect = {
					EMPLOYER = root
					POS = court_physician
					CANDIDATE = scope:laamp_physician_recruit
				}
			}
		}
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:physician }
	}
}



######################################################################
# CASTLE GROUNDS
# ep3_laamp_decision_event.1050
######################################################################

#Set the correct variable to block off the Castle option and remove the desc flavor variable
scripted_effect 1050_finished_castle_effect = {
	remove_list_variable = {
		name = list_of_options
		target = flag:has_castle_option
	}
	save_scope_as = laamp_decision_finished_castle_option
}

#Can reinforce MaA
scripted_trigger 1050_has_maa_to_reinforce_trigger = {
	any_maa_regiment ?= { maa_current_troops_count < maa_max_troops_count }
}

#Nothing left for us to do
scripted_trigger 1050_done_with_castle_trigger = {
	exists = scope:laamp_decision_has_trained
	exists = scope:laamp_decision_has_garrisoned
	trigger_if = {
		limit = { 1050_has_maa_to_reinforce_trigger = yes }
		exists = scope:laamp_decision_has_reinforced
	}
	trigger_if = {
		limit = { exists = scope:laamp_bodyguard_recruit }
		exists = scope:laamp_decision_recruited_bodyguard
	}
}


#Castle Holding: Visit the local castle grounds 
ep3_laamp_decision_event.1050 = {
	type = character_event
	title = ep3_laamp_decision_event.1050.t
	window = visit_settlement_window
	desc = {
		#Intro
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: We've returned from Main Square
			random_valid = {
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						exists = scope:been_to_castle_grounds
						OR = {
							scope:castle_loc_tracker ?= 0
							scope:castle_loc_tracker ?= 2
						}
					}
					desc = ep3_laamp_decision_event.1050.desc_returned_01
				}
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						scope:castle_loc_tracker ?= 1
					}
					desc = ep3_laamp_decision_event.1050.desc_returned_02
				}
			}
			#RETURN: We've returned from the Training ground
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:training }
				desc = ep3_laamp_decision_event.1050.desc_returned_from_training
			}
			#RETURN: We've returned from the Garrison
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:garrison }
				desc = ep3_laamp_decision_event.1050.desc_returned_from_garrison
			}
			#RETURN: We've returned from the Reinforcers
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:reinforcers }
				desc = ep3_laamp_decision_event.1050.desc_returned_from_reinforcers
			}
			#RETURN: We've returned from the Bodyguard
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:bodyguard }
				desc = ep3_laamp_decision_event.1050.desc_returned_from_bodyguard
			}
			#FIRST TIME: First time here
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_castle_grounds }
				}
				desc = ep3_laamp_decision_event.1050.desc
			}
		}
		#Mid - MaA option or not?
		first_valid = {
			#FIRST TIME: Yup, we can reinforce MaA
			triggered_desc = {
				trigger = {
					1050_has_maa_to_reinforce_trigger = yes
					NOT = { exists = scope:been_to_castle_grounds }
				}
				desc = ep3_laamp_decision_event.1050.mid_maa
			}
			#FIRST TIME: Nope, no MaA to reinforce
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_castle_grounds }
				}
				desc = ep3_laamp_decision_event.1050.mid_no_maa
			}
		}
		#Outro
		first_valid = {
			#FIRST TIME: First time here, look at the bodyguard
			triggered_desc = {
				trigger = {
					exists = scope:laamp_bodyguard_recruit
					NOT = { exists = scope:been_to_castle_grounds }
				}
				desc = ep3_laamp_decision_event.1050.desc_outro_bodyguard
			}
			#FIRST TIME: First time here, curious partner
			triggered_desc = {
				trigger = {
					exists = scope:visiting_partner
					NOT = { exists = scope:been_to_castle_grounds }
				}
				desc = ep3_laamp_decision_event.1050.desc_outro_partner
			}
			#FIRST TIME: First time here
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_castle_grounds }
				}
				desc = ep3_laamp_decision_event.1050.desc_outro
			}
			#RETURN: Partner - there is nothing left for us here
			triggered_desc = {
				trigger = { 
					exists = scope:visiting_partner
					1050_done_with_castle_trigger = yes 
				}
				desc = ep3_laamp_decision_event.1050.desc_outro_return_partner_finished
			}
			#RETURN: There is nothing left for us here
			triggered_desc = {
				trigger = { 1050_done_with_castle_trigger = yes }
				desc = ep3_laamp_decision_event.1050.desc_outro_return_finished
			}
			#RETURN: Bodyguard did not deviate, yet
			triggered_desc = {
				trigger = {
					exists = scope:laamp_bodyguard_recruit
					NOR = { 
						exists = scope:been_to_bodyguard
						exists = scope:laamp_decision_recruited_bodyguard
					}
				}
				desc = ep3_laamp_decision_event.1050.desc_outro_bodyguard_return
			}
			#RETURN: We've been here before
			random_valid = {
				#RETURN: Partner flavor
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						exists = scope:been_to_castle_grounds
						scope:castle_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1050.desc_outro_return_partner_01
				}
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						scope:castle_loc_tracker ?= 1
					}
					desc = ep3_laamp_decision_event.1050.desc_outro_return_partner_02
				}
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						scope:castle_loc_tracker ?= 2
					}
					desc = ep3_laamp_decision_event.1050.desc_outro_return_partner_03
				}
				#RETURN: Generics
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_castle_grounds
						scope:castle_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1050.desc_outro_return_01
				}
				triggered_desc = {
					trigger = { scope:castle_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1050.desc_outro_return_02
				}
				triggered_desc = {
					trigger = { scope:castle_loc_tracker ?= 2 }
					desc = ep3_laamp_decision_event.1050.desc_outro_return_03
				}
			}
		}
	}
	theme = martial
	#Get outta here already
	override_effect_2d = {
		trigger = { 
			1050_done_with_castle_trigger = yes
			scope:visiting_location = { is_drylands_or_desert_trigger = no }
		}
  		reference = rain	
	}
	override_background = {
		trigger = {
			scope:visiting_location = { 
				geographical_region = world_europe
				NOT = { geographical_region = world_europe_west_iberia }
			}
		}
		reference = gallows 
	}
	override_background = { reference = ep3_city_gate }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#If it's our (tired) visiting partner
		triggered_animation = {
			trigger = { 1050_done_with_castle_trigger = yes }
			animation = boredom
		}
		animation = survey
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { 
				exists = scope:laamp_bodyguard_recruit
				NOR = { 
					exists = scope:been_to_bodyguard
					exists = scope:laamp_decision_recruited_bodyguard
				}
			}
			animation = interested
		}
		triggered_animation = {
			trigger = { prowess < average_skill_rating }
			animation = personality_coward
		}
		animation = personality_bold
	}
	#Do we have someone to display?
	right_portrait = {
		trigger = { 
			exists = scope:1050_third_character
			#If this is root, then that means we have talked to the Bodyguard, so let's disappear the portrait
			scope:1050_third_character != root
		}
		character = scope:1050_third_character
		camera = camera_event_scheme_vs_extra_right_look_right
		#We've returned here and it's still the bodyguard
		triggered_animation = {
			trigger = { exists = scope:been_to_castle_grounds }
			animation = disapproval
		}
		#Otherwise some seething to go
		animation = rage
	}
	lower_left_portrait = {
		trigger = { 
			exists = scope:1050_fourth_character 
			scope:1050_fourth_character != root
		}
		character = scope:1050_fourth_character
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Set up the ancillary portraits to remind the player of the characters
		if = {
			#Bodyguard exists
			limit = {
				#We've been to them at least once
				exists = scope:been_to_bodyguard
				#We're not done with them yet
				AND = {
					exists = scope:laamp_bodyguard_recruit
					NOT = { exists = scope:laamp_decision_recruited_bodyguard }
				}
				#This isn't already the state
				NAND = {
					exists = scope:1050_fourth_character
					scope:1050_fourth_character ?= scope:laamp_bodyguard_recruit
				}
			}
			scope:laamp_bodyguard_recruit = { save_scope_as = 1050_fourth_character }
		}
		#Clear out the ancillary portrait(s)
		if = {
			limit = { 
				exists = scope:1050_fourth_character
				scope:laamp_bodyguard_recruit ?= scope:1050_fourth_character
				exists = scope:laamp_decision_recruited_bodyguard
			}
			#Overwrite with ROOT to hide that portrait
			save_scope_as = 1050_fourth_character
		}
		#Can we _not_ repeat the loc?
		1025_set_and_check_hub_loc_tracker_scope_effect = { HUB = castle }
		#Rare: Spawn a spectacular Bodyguard
		if = {
			limit = {
				NOT = { has_variable = laamp_decision_1000_checked_for_bodyguard }
			}
			random_list = {
				80 = {
					#No Bodyguard
				}
				20 = {
					#Has this person been our bodyguard in the past 10 years?
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							1010_basic_merchant_checks_trigger = yes
							save_temporary_scope_as = saved_character_check
							#Let's avoid double-dipping
							1010_is_a_saved_bodyguard_trigger = yes
							1010_is_a_saved_merchant_trigger = no
							1010_is_a_saved_peddler_trigger = no
							1010_is_a_saved_crier_trigger = no
							1010_is_a_saved_storyteller_trigger = no
							1010_is_a_saved_thief_trigger = no
							1010_is_a_saved_healer_trigger = no
							1010_is_a_saved_clergy_trigger = no
							1010_is_a_saved_physician_trigger = no
							1010_is_a_saved_weaponsmith_trigger = no
							1010_is_a_saved_armorer_trigger = no
							1010_is_a_saved_jeweler_trigger = no
							1010_is_a_saved_quartermaster_trigger = no
							can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:saved_character_check }
						}
						save_scope_as = laamp_bodyguard_recruit
						#Some more loc flavor shenanigans for these saved scopes
						save_scope_as = laamp_recurring_bodyguard
					}
					#Otherwise find a bodyguard in the pool
					if = {
						limit = { 
							NOT = { exists = scope:laamp_bodyguard_recruit }
						}
						random_pool_character = {
							province = scope:visiting_location
							limit = { 
								1010_basic_merchant_checks_trigger = yes
								is_available_healthy_adult = yes
								prowess > 15
								can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = this }
							}
							save_scope_as = laamp_bodyguard_recruit
						}
					}
					#Otherwise create a bodyguard
					if = {
						limit = {
							NOT = { exists = scope:laamp_bodyguard_recruit }
						}
						#Create bodyguard to stuff in pool
						create_character = {
							template = bp1_yearly_2021_martial_person_template
							location = scope:visiting_location
							dynasty = none
							culture = scope:visiting_location.culture
							faith = scope:visiting_location.faith
							prowess = { decent_skill_rating high_skill_rating }
							save_scope_as = laamp_bodyguard_recruit
						}
						scope:laamp_bodyguard_recruit ?= {
							#Chance to add a malus trait to this spectatular being
							if = {
								limit = { 
									NOR = { 
										has_trait = possessed_1 
										has_trait = lunatic_1
										has_trait = depressed_1
										has_trait = drunkard
										has_trait = hashishiyah
										has_trait = irritable
									}
								}
								hidden_effect = {
									random = {
										chance = 20
										random_list = {
											10 = { add_trait = possessed_1 }
											10 = { add_trait = lunatic_1 }
											10 = { add_trait = depressed_1 }
											10 = { add_trait = drunkard }
											10 = { add_trait = hashishiyah }
											10 = { add_trait = irritable }
										}
									}
								}
							}
						}
					}
					scope:laamp_bodyguard_recruit = { save_scope_as = 1050_third_character }
				}
			}
			#No decision-scumming
			set_variable = {
				name = laamp_decision_1000_checked_for_bodyguard
				days = visit_settlement_cooldown_days
			}
		}
	}
	#Train prowess
	option = {
		name = {
			text = {
				first_valid = {
					#Return to the training grounds
					triggered_desc = {
						trigger = { exists = scope:been_to_training }
						desc = ep3_laamp_decision_event.1050.a_second
					}
					#First time at the training grounds
					desc = ep3_laamp_decision_event.1050.a
				}
			}
		}
		trigger = {
			#Recruited the Master of Arms
			trigger_if = {
				limit = {
					exists = scope:laamp_disgruntled_moa
					scope:laamp_decision_has_trained ?= flag:no 
				}
				custom_tooltip = {
					text = recruited_maa.tt
					always = no
				}
			}
			#Been there, done that
			trigger_else_if = {
				limit = { scope:laamp_decision_has_trained ?= flag:yes }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1050.a.cooldown.tt
					always = no
				}
			}
			trigger_else = { always = yes }
		}
		show_as_unavailable = { always = yes }
		reason = visit_training_grounds
		custom_tooltip = ep3_laamp_decision_event.1050.a.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = castle_grounds }
		#Go to the training grounds
		trigger_event = ep3_laamp_decision_event.1051
		ai_chance = { base = 100 }
	}
	#Scout knights at the garrison
	option = {
		name = {
			text = {
				first_valid = {
					#Return to the garrison
					triggered_desc = {
						trigger = { exists = scope:been_to_garrison }
						desc = ep3_laamp_decision_event.1050.b_second
					}
					#First time at the garrison
					desc = ep3_laamp_decision_event.1050.b
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1050.b.cooldown.tt
				NOT = { exists = scope:laamp_decision_has_garrisoned }
			}
		}
		show_as_unavailable = { always = yes }
		reason = visit_garrison
		custom_tooltip = ep3_laamp_decision_event.1050.b.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = castle_grounds }
		#Go to the garrison screen
		trigger_event = ep3_laamp_decision_event.1053
		ai_chance = { base = 100 }
	}
	#Check out the demoralized soldiers
	option = {
		name = {
			text = {
				first_valid = {
					#Already scoped out contract
					triggered_desc = {
						trigger = { exists = scope:been_to_reinforcers }
						desc = ep3_laamp_decision_event.1050.c_second
					}
					#First time reading contract
					desc = ep3_laamp_decision_event.1050.c
				}
			}
		}
		trigger = {
			trigger_if = {
				limit = { exists = scope:laamp_decision_has_reinforced }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1050.c.cooldown.tt
					NOT = { exists = scope:laamp_decision_has_reinforced }
				}
			}
			trigger_else_if = {
				limit = {
					any_in_list = {
						variable = 1055_reinforced_recently
						this = scope:visiting_location
					}
				}
				custom_tooltip = {
					text = ep3_laamp_decision_event.1050.c.cooldown_province.tt
					NOT = {
						any_in_list = {
							variable = 1055_reinforced_recently
							this = scope:visiting_location
						}
					}
				}
			}
			trigger_else = { 1050_has_maa_to_reinforce_trigger = yes }
		}
		show_as_unavailable = { 
			OR = {
				1050_has_maa_to_reinforce_trigger = yes
				exists = scope:laamp_decision_has_reinforced
			}
		}
		reason = reinforce_maa
		custom_tooltip = ep3_laamp_decision_event.1050.c.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = castle_grounds }
		#Go to the Town Crier
		trigger_event = ep3_laamp_decision_event.1055
		ai_chance = { base = 100 }
	}
	#Rare Option: Hire cheaper, skilled, Bodyguard
	option = {
		name = {
			text = {
				first_valid = {
					#Return to the Bodyguard
					triggered_desc = {
						trigger = { exists = scope:been_to_bodyguard }
						desc = ep3_laamp_decision_event.1050.d_second
					}
					#First time at the Bodyguard
					desc = ep3_laamp_decision_event.1050.d
				}
			}
		}
		trigger = {
			exists = scope:laamp_bodyguard_recruit
			NOT = { exists = scope:laamp_decision_recruited_bodyguard }
		}
		reason = recruit_bodyguard
		#Been there once already
		if = {
			limit = { exists = scope:been_to_bodyguard }
			custom_tooltip = ep3_laamp_decision_event.1050.d.tt_second
		}
		else = {
			custom_tooltip = ep3_laamp_decision_event.1050.d.tt
		}
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = castle_grounds }
		#Go to the bodyguard screen
		trigger_event = ep3_laamp_decision_event.1057
		ai_chance = {
			base = 500
		}
	}
	#I want to do something else
	option = {
		name = {
			text = {
				first_valid = {
					#Nothing left to do
					triggered_desc = {
						trigger = { 1050_done_with_castle_trigger = yes }
						desc = ep3_laamp_decision_event.1050.e_second
					}
					#Back to main square
					desc = ep3_laamp_decision_event.1050.e
				}
			}
		}
		#Have we done everything? Are we closing off the option?
		if = {
			limit = { 1050_done_with_castle_trigger = yes }
			#Clean up unnecessary variables and close off the option
			1050_finished_castle_effect = yes
		}
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = castle_grounds }
		#Go back to the main event
		1000_return_to_main_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = paranoid
				}
				add = 300
			}
		}
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:castle_grounds }
	}
}


#We return to the castle event to peruse other options
scripted_effect 1051_return_to_castle_effect = {
	custom_tooltip = ep3_laamp_decision_event.1051.return.tt
	trigger_event = ep3_laamp_decision_event.1050
}

#One, two, one, two, hepp-hepp-hepp
scripted_effect 1051_actual_training_effect = {
	#Pay for training if it ain't scope:visiting_partner
	if = {
		limit = { $TRAINER$ = scope:laamp_disgruntled_moa }
		pay_short_term_gold = {
			target = scope:laamp_disgruntled_moa
			gold = visit_settlement_paid_training_value
		}
	}
	#Add the prowess
	random_list = {
		#Athletisism!
		10 = {
			trigger = { 
				has_trait = athletic
				1051_skill_cap_trigger = no
			}
			desc = ep3_laamp_decision_event.1051.a_athletic.desc
			send_interface_toast = {
				type = event_toast_effect_good
				title = travel_events.2007.a_success_tt
				desc = ep3_laamp_decision_event.1051.a_athletic.desc
				left_icon = root
				#Increase skill
				add_prowess_skill = 2
			}
			hidden_effect = { 1051_increment_skill_gain_effect = yes }
		}
		#Regular prowess
		25 = {
			trigger = { 1051_skill_cap_trigger = no }
			desc = ep3_laamp_decision_event.1051.a.desc
			send_interface_toast = {
				type = event_toast_effect_good
				title = travel_events.2032.a_learning.tt
				desc = ep3_laamp_decision_event.1051.a.desc
				left_icon = root
				#Increase skill
				add_prowess_skill = 1
			}
			hidden_effect = { 1051_increment_skill_gain_effect = yes }
		}
		#Blademaster
		25 = { 
			trigger = {
				1051_skill_cap_trigger = yes
				1051_maxed_blademaster_trigger = no 
			}
			desc = ep3_laamp_decision_event.1051.a.desc
			send_interface_toast = {
				type = event_toast_effect_good
				title = travel_events.2007.a_soft_success_tt
				desc = ep3_laamp_decision_event.1051.a.desc
				left_icon = root
				#Gain trait
				if = {
					limit = {
						NOT = { has_trait = lifestyle_blademaster }
					}
					add_trait = lifestyle_blademaster
					add_trait_xp = {
						trait = lifestyle_blademaster
						value = scope:blademaster_xp
					}
				}
				#Or be educated
				else = {
					add_trait_xp = {
						trait = lifestyle_blademaster
						value = scope:blademaster_xp
					}
				}
			}
		}
		#... fallback.
		25 = { 
			trigger = {
				1051_skill_cap_trigger = yes
				1051_maxed_blademaster_trigger = yes
			}
			desc = ep3_laamp_decision_event.1051.a.desc
			send_interface_toast = {
				type = event_toast_effect_good
				title = travel_events.2003.b_success_tt
				desc = ep3_laamp_decision_event.1051.a.desc
				left_icon = root
				#Gain martial lifestyle xp
				add_martial_lifestyle_xp = medium_lifestyle_xp
				#... and some stress relief?
				stress_impact = {
					base = medium_stress_impact_loss
				}
			}
		}
		#Too much joshing around
		25 = {
			trigger = { scope:visiting_partner ?= $TRAINER$ }
			desc = ep3_laamp_decision_event.1051.c_joshing.desc
			send_interface_toast = {
				type = event_toast_text_neutral
				title = ep3_laamp_decision_event.1051.c_joshing.t
				desc = ep3_laamp_decision_event.1051.c_joshing.desc
				left_icon = root
				right_icon = scope:visiting_partner
			}
		}
		#Too much joshing around
		5 = {
			trigger = { scope:visiting_partner ?= $TRAINER$ }
			min = 5
			desc = ep3_laamp_decision_event.1051.c_wounded.desc
			send_interface_toast = {
				type = event_toast_text_neutral
				title = ep3_laamp_decision_event.1051.c_wounded.t
				desc = ep3_laamp_decision_event.1051.c_wounded.desc
				left_icon = root
				right_icon = scope:visiting_partner
				scope:visiting_partner = {
					increase_wounds_effect = { REASON = training_accident }
				}
			}
		}
	}
	#Set the variables and redirect us back to the Castle
	1051_finished_training_effect = yes
}

scripted_effect 1051_increment_skill_gain_effect = {
	#We cap the max amount of skill points gained
	if = {
		limit = {
			NOT = { has_variable = 1051_skill_gain_variable }
		}
		set_variable = {
			name = 1051_skill_gain_variable
			value = 1
		}
	}
	else_if = {
		limit = {
			has_variable = 1051_skill_gain_variable
			var:1051_skill_gain_variable != visit_settlement_skill_gain_cap_value
		}
		change_variable = {
			name = 1051_skill_gain_variable
			add = 1
		}
	}
	else = {
		#Nothing happens
	}
}

#Set the correct variable to block off the Training option and remove the desc flavor variable
scripted_effect 1051_finished_training_effect = {
	save_scope_value_as = {
		name = laamp_decision_has_trained
		value = flag:yes
	}
	#Go back to castle grounds
	hidden_effect = { 1051_return_to_castle_effect = yes }
}

#Find someone who isn't saved, doesn't dislike you and is pretty martial
scripted_trigger 1051_random_martial_character_trigger = {
	1010_basic_merchant_checks_trigger = yes
	save_temporary_scope_as = saved_character_check
	#Let's avoid double-dipping
	1010_is_a_saved_merchant_trigger = no
	1010_is_a_saved_peddler_trigger = no
	1010_is_a_saved_crier_trigger = no
	1010_is_a_saved_storyteller_trigger = no
	1010_is_a_saved_thief_trigger = no
	1010_is_a_saved_healer_trigger = no
	1010_is_a_saved_clergy_trigger = no
	1010_is_a_saved_physician_trigger = no
	1010_is_a_saved_bodyguard_trigger = no
	1010_is_a_saved_weaponsmith_trigger = no
	1010_is_a_saved_armorer_trigger = no
	1010_is_a_saved_jeweler_trigger = no
	1010_is_a_saved_quartermaster_trigger = no
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:saved_character_check }
	OR = {
		martial >= average_skill_rating
		prowess >= high_skill_rating
	}
}

scripted_trigger 1051_can_sparr_trigger = {
	is_adult = yes 
	scope:visiting_partner ?= {
		is_adult = yes
		is_healthy = yes
		martial >= high_skill_rating
		can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
	}
}

scripted_trigger 1051_skill_cap_trigger = {
	has_variable = 1051_skill_gain_variable
	var:1051_skill_gain_variable >= visit_settlement_skill_gain_cap_value
}

scripted_trigger 1051_maxed_blademaster_trigger = {
	has_trait = lifestyle_blademaster
	has_trait_xp = {
		trait = lifestyle_blademaster
		value = 100 #Max
	}
}

#Training Grounds
ep3_laamp_decision_event.1051 = { 
	type = character_event
	title = ep3_laamp_decision_event.1051.t
	window = visit_settlement_window
	desc = {
		#What're they doing?
		first_valid = {
			#We've returned to this scene, now what
			#RETURN:
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_training
						scope:training_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1051.desc_returned_01 
				}
				triggered_desc = { 
					trigger = { scope:training_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1051.desc_returned_02
				}
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_training }
				}
				desc = ep3_laamp_decision_event.1051.desc
			}	
		}
		#Martial partner outro
		first_valid = {
			#RETURN:
			triggered_desc = {
				trigger = { 
					exists = scope:been_to_training
					1051_can_sparr_trigger = yes
				}
				desc = ep3_laamp_decision_event.1051.desc_outro_return_martial_partner
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_training }
					1051_can_sparr_trigger = yes
				}
				desc = ep3_laamp_decision_event.1051.desc_outro_martial_partner
			}
		}
	}
	theme = martial
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_activity" }
	override_background = { reference = ep2_tournament }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		triggered_animation = {
			trigger = { 1051_can_sparr_trigger = yes }
			animation = marshal_shield
		}
		animation = thinking
	}
	center_portrait = {
		character = root
		animation = marshal
	}
	right_portrait = {
		character = scope:laamp_disgruntled_moa
		camera = camera_event_scheme_far_right
		animation = disapproval
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = training }
		#Find our potential Master of Arms (MoA) character
		if = {
			#Do we already have a MoA?
			limit = {
				NOT = { exists = scope:laamp_disgruntled_moa }
			}
			#Don't really care about saving this character in a list
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1051_random_martial_character_trigger = yes
					has_trait = overseer
					has_trait = disloyal
				}
				alternative_limit = {
					1051_random_martial_character_trigger = yes
					has_trait = overseer
				}
				alternative_limit = {
					1051_random_martial_character_trigger = yes
					has_trait = disloyal
				}
				alternative_limit = { 1051_random_martial_character_trigger = yes }
				save_scope_as = laamp_disgruntled_moa
			}
			#Otherwise create a suiting candidate
			if = {
				limit = {
					NOT = { exists = scope:laamp_disgruntled_moa }
				}
				#Create MoA to stuff in pool
				create_character = {
					template = new_warrior_character
					location = scope:visiting_location
					dynasty = none
					trait = disloyal
					gender_female_chance = root_soldier_female_chance
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_disgruntled_moa
				}
			}
			hidden_effect = {
				scope:laamp_disgruntled_moa = {
					if = {
						limit = {
							NOT = { has_trait = overseer }
						}
						random_list = {
							75 = {
								#No trait
							}
							25 = {
								add_trait = overseer
							}
						}
					}
				}
			}
			if = {
				limit = { 1051_can_sparr_trigger = yes }
				scope:visiting_partner ?= { save_scope_as = fighting_child }
			}
		}
		#Save the xp trait as a static number
		if = {
			limit = {
				NOR = {
					1051_maxed_blademaster_trigger = yes
					exists = scope:blademaster_xp
				}
			}
			save_scope_value_as = {
				name = blademaster_xp
				value = {
				    integer_range = {
				        min = small_lifestyle_random_xp_low
				        max = small_lifestyle_random_xp_mid
				    }
				}
			}	
		}
	}
	#RAAAH TRAINING
	option = {
		name = ep3_laamp_decision_event.1051.a
		trigger = {
			gold >= visit_settlement_paid_training_value
		}
		show_as_unavailable = { always = yes }
		#Cue training montage
		1051_actual_training_effect = { TRAINER = scope:laamp_disgruntled_moa }
		ai_chance = {
			base = 100
			modifier = {
				prowess < low_skill_rating
				short_term_gold < tiny_gold_laamps_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				prowess < mediocre_skill_rating
				short_term_gold < minor_gold_laamps_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				prowess < decent_skill_rating
				short_term_gold < medium_gold_laamps_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				prowess < high_skill_rating
				short_term_gold < major_gold_laamps_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				prowess < extremely_high_skill_rating
				short_term_gold < massive_gold_laamps_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Hire the guy as Master of Arms?
	option = {
		name = ep3_laamp_decision_event.1051.b
		trigger = {
			custom_description = {
				text = not_have_master_of_arms_building
				OR = {
					can_employ_court_position_type = master_of_arms_camp_officer
					employs_court_position = master_of_arms_camp_officer
				}
			}
		}
		reason = unlocked_master_of_arms
		show_as_unavailable = { always = yes }
		#Pay up
		pay_short_term_gold = {
			target = scope:laamp_disgruntled_moa
			gold = medium_gold_laamps_value
		}
		hidden_effect = {
			reverse_add_opinion = {
				target = scope:laamp_disgruntled_moa
				modifier = recruited_me_opinion
				opinion = 30
			}
		}
		add_courtier = scope:laamp_disgruntled_moa
		#The actual effect happens in after
		show_as_tooltip = {
			camp_officer_grant_effect = {
				EMPLOYER = root
				POS = master_of_arms
				CANDIDATE = scope:laamp_disgruntled_moa
			}
		}
		#This 'finished' is different since it changes between flag:yes and flag:no
		save_scope_value_as = {
			name = laamp_decision_has_trained
			value = flag:no
		}
		#Go back to castle grounds
		hidden_effect = { 1051_return_to_castle_effect = yes }
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < medium_gold_laamps_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				employs_court_position = master_of_arms_camp_officer
				factor = 0
			}
		}
	}
	#Triggered Option: Sparr with your martial partner
	option = {
		name = ep3_laamp_decision_event.1051.c
		trigger = { 1051_can_sparr_trigger = yes }
		#This erroneously claims that the option is available because of ROOT's martial
		show_unlock_reason = no
		#Training? Hopefully.
		1051_actual_training_effect = { TRAINER = scope:visiting_partner }
		#Do some bonding
		progress_towards_friend_effect = {
			CHARACTER = scope:visiting_partner
			REASON = friend_castle_sparring
			OPINION = 15
		}
		ai_chance = {
			base = 400
		}
	}
	#I want to do something else
	option = {
		name = ep3_laamp_decision_event.1051.d
		#Sets variables and returns us to castle grounds screen
		1031_been_to_effect = { GUILD = training }
		ai_chance = {
			base = 200
			modifier = {
				has_trait = greedy
				factor = 2
			}
		}
	}
	after = {
		if = {
			limit = { scope:laamp_decision_has_trained ?= flag:no }
			#Appoint them
			if = {
				limit = {
					can_appoint_char_to_court_position = {
						CHAR = scope:laamp_disgruntled_moa
						COURT_POS = master_of_arms_camp_officer
					}
				}
				camp_officer_grant_effect = {
					EMPLOYER = root
					POS = master_of_arms
					CANDIDATE = scope:laamp_disgruntled_moa
				}
			}
		}
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:training }
	}
}


#Set the correct variable to block off the Garrison option and remove the desc flavor variable
scripted_effect 1053_finished_garrison_effect = {
	save_scope_as = laamp_decision_has_garrisoned
	#Go back to castle grounds
	hidden_effect = { 1051_return_to_castle_effect = yes }
}

#Add the guard to your camp
scripted_effect 1053_add_guard_effect = {
	hidden_effect = {
		reverse_add_opinion = {
			target = $GUARD$
			modifier = recruited_me_opinion
			opinion = 30
		}
	}
	add_courtier = $GUARD$
	#Go back to castle grounds
	1053_finished_garrison_effect = yes
}

#Find someone who isn't saved, doesn't dislike you and is worse martial
scripted_trigger 1053_random_martial_character_trigger = {
	1010_basic_merchant_checks_trigger = yes
	save_temporary_scope_as = saved_character_check
	#Let's avoid double-dipping
	1010_is_a_saved_merchant_trigger = no
	1010_is_a_saved_peddler_trigger = no
	1010_is_a_saved_crier_trigger = no
	1010_is_a_saved_storyteller_trigger = no
	1010_is_a_saved_thief_trigger = no
	1010_is_a_saved_healer_trigger = no
	1010_is_a_saved_clergy_trigger = no
	1010_is_a_saved_physician_trigger = no
	1010_is_a_saved_bodyguard_trigger = no
	1010_is_a_saved_weaponsmith_trigger = no
	1010_is_a_saved_armorer_trigger = no
	1010_is_a_saved_jeweler_trigger = no
	1010_is_a_saved_quartermaster_trigger = no
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:saved_character_check }
	OR = {
		martial >= average_skill_rating
		prowess >= average_skill_rating
	}
}

#Find someone who isn't saved, doesn't dislike you and is less martial
scripted_trigger 1053_worse_martial_character_trigger = {
	1010_basic_merchant_checks_trigger = yes
	save_temporary_scope_as = saved_character_check
	#Let's avoid double-dipping
	1010_is_a_saved_merchant_trigger = no
	1010_is_a_saved_peddler_trigger = no
	1010_is_a_saved_crier_trigger = no
	1010_is_a_saved_storyteller_trigger = no
	1010_is_a_saved_thief_trigger = no
	1010_is_a_saved_healer_trigger = no
	1010_is_a_saved_clergy_trigger = no
	1010_is_a_saved_physician_trigger = no
	1010_is_a_saved_bodyguard_trigger = no
	1010_is_a_saved_weaponsmith_trigger = no
	1010_is_a_saved_armorer_trigger = no
	1010_is_a_saved_jeweler_trigger = no
	1010_is_a_saved_quartermaster_trigger = no
	can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:saved_character_check }
	1033_has_interesting_skillset_trigger = no
}

#Garrison
ep3_laamp_decision_event.1053 = {
	type = character_event
	title = ep3_laamp_decision_event.1053.t
	window = visit_settlement_window
	desc = {
		#What're they doing?
		first_valid = {
			#We've returned to this scene, now what
			#RETURN:
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_garrison
						scope:garrison_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1053.desc_returned_01 
				}
				triggered_desc = { 
					trigger = { scope:garrison_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1053.desc_returned_02
				}
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_garrison }
				}
				desc = ep3_laamp_decision_event.1053.desc
			}	
		}
	}
	theme = landless_adventurer
	override_icon = { reference = "gfx/interface/icons/event_types/type_duty.dds" }
	override_background = { reference = armory }
	left_portrait = {
		character = scope:1053_first_character
		#PARTNER:
		triggered_animation = {
			trigger = { scope:1053_first_character ?= scope:visiting_partner }
			animation = interested
		}
		#ROOT: Return
		triggered_animation = {
			trigger = {
				scope:1053_first_character = root 
				exists = scope:been_to_garrison 
			}
			animation = chess_cocky
		}
		#ROOT
		animation = admiration
	}
	center_portrait = {
		character = scope:laamp_talented_guard
		#They're counting coins
		triggered_animation = {
			trigger = { scope:garrison_loc_tracker ?= 1 }
			animation = steward
		}
		#They just won a game of cards
		triggered_animation = {
			trigger = { 
				exists = scope:been_to_garrison
				scope:garrison_loc_tracker ?= 0 
			}
			animation = personality_dishonorable
		}
		animation = hero_flex
	}
	right_portrait = {
		character = scope:laamp_plain_guard
		camera = camera_event_scheme_far_right
		#They were just asleep
		triggered_animation = {
			trigger = { scope:garrison_loc_tracker ?= 1 }
			animation = boredom
		}
		#They're tending their wounds
		triggered_animation = {
			trigger = { 
				exists = scope:been_to_garrison
				scope:garrison_loc_tracker ?= 0 
			}
			animation = pain
		}
		animation = disapproval
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = garrison }
		#Find our garrison guards
		if = {
			#Do we already have the guards?
			limit = {
				NOT = { exists = scope:laamp_plain_guard }
			}
			#Don't really care about saving this character in a list
			random_pool_character = {
				province = scope:visiting_location
				limit = { 1053_worse_martial_character_trigger = yes }
				save_scope_as = laamp_plain_guard
			}
			#Otherwise create a suiting plain guard
			if = {
				limit = {
					NOT = { exists = scope:laamp_plain_guard }
				}
				#Create guard character to stuff in pool
				create_character = {
					template = bandit_character
					location = scope:visiting_location
					dynasty = none
					gender_female_chance = root_soldier_female_chance
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_plain_guard
				}
			}
			#Set their cost
			1033_set_cost_effect = { CHARACTER = scope:laamp_plain_guard VALUE_NAME = plain_guard_cost }
			#Don't really care about saving this character in a list
			random_pool_character = {
				province = scope:visiting_location
				limit = { 1053_random_martial_character_trigger = yes }
				save_scope_as = laamp_plain_guard
			}
			#Otherwise create a suiting talented guard
			if = {
				limit = {
					NOT = { exists = scope:laamp_talented_guard }
				}
				#Create guard character to stuff in pool
				create_character = {
					template = new_warrior_character
					location = scope:visiting_location
					dynasty = none
					gender_female_chance = root_soldier_female_chance
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_talented_guard
				}
			}
			#Set their cost
			1033_set_cost_effect = { CHARACTER = scope:laamp_talented_guard VALUE_NAME = talented_guard_cost }
		}
		#Set up the portrait
		if = {
			limit = {
				NOT = { exists = scope:1053_first_character }
			}
			#Partner first
			if = {
				limit = { exists = scope:visiting_partner }
				scope:visiting_partner = { save_scope_as = 1053_first_character }
			}
			#Otherwise ROOT
			else = { save_scope_as = 1053_first_character }
		}
		#For the background
		scope:laamp_plain_guard = {
			if = {
				limit = {
					is_ruler = no
					exists = court_owner
				}
				court_owner = { save_scope_as = bg_override_char }
			}
			else = {
				save_scope_as = bg_override_char
			}
		}
	}
	#Hey, FirstPerson, want to join us?
	option = {
		name = ep3_laamp_decision_event.1053.a
		pay_short_term_gold = {
			target = scope:laamp_plain_guard
			gold = scope:plain_guard_cost
		}
		#The actual adding of the guard and redirecting to castle grounds
		1053_add_guard_effect = { GUARD = scope:laamp_plain_guard }
		ai_chance = {
			base = 200
			modifier = {
				short_term_gold > scope:plain_guard_cost
				factor = 2
			}
		}
	}
	#How about you, more skilled SecondPerson?
	option = {
		name = ep3_laamp_decision_event.1053.b
		pay_short_term_gold = {
			target = scope:laamp_talented_guard
			gold = scope:talented_guard_cost
		}
		#The actual adding of the guard and redirecting to castle grounds
		1053_add_guard_effect = { GUARD = scope:laamp_talented_guard }
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold > scope:talented_guard_cost
				factor = 2
			}
		}
	}
	#I just wanna play some dice.
	option = {
		name = ep3_laamp_decision_event.1053.c
		random_list = {
			35 = {
				desc = ep3_laamp_decision_event.1053.c.plain_wins
				send_interface_toast = {
					title = ep3_laamp_decision_event.1053.c.plain_wins
					left_icon = root
					right_icon = scope:laamp_plain_guard
					pay_short_term_gold = {
						target = scope:laamp_plain_guard
						gold = minor_gold_value
					}
				}
			}
			35 = {
				desc = ep3_laamp_decision_event.1053.c.talented_wins
				send_interface_toast = {
					title = ep3_laamp_decision_event.1053.c.talented_wins
					left_icon = root
					right_icon = scope:laamp_talented_guard
					pay_short_term_gold = {
						target = scope:laamp_talented_guard
						gold = minor_gold_value
					}
				}
			}
			30 = {
				desc = ep3_laamp_decision_event.1053.c.you_win
				send_interface_toast = {
					title = ep3_laamp_decision_event.1053.c.you_win
					left_icon = root
					scope:laamp_plain_guard = {
						pay_short_term_gold = {
							target = root
							gold = minor_gold_value
						}
					}
					scope:laamp_talented_guard = {
						pay_short_term_gold = {
							target = root
							gold = minor_gold_value
						}
					}
				}
			}
		}
		stress_impact = {
			base = minor_stress_impact_loss
			arbitrary = minor_stress_impact_loss
			improvident = minor_stress_impact_loss
		}
		#Go back to castle grounds
		1053_finished_garrison_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < minor_gold_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				has_trait = greedy
				factor = 0
			}
		}
	}
	#I want to do something else
	option = {
		name = ep3_laamp_decision_event.1053.d
		#Sets variables and returns us to castle grounds screen
		1031_been_to_effect = { GUILD = garrison }
		ai_chance = {
			base = 200
			modifier = {
				has_trait = greedy
				factor = 2
			}
		}
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:garrison }
	}
}


#Set the correct scopes, and transfer us back to main
scripted_effect 1055_finished_reinforcers_effect = {
	save_scope_as = laamp_decision_has_reinforced
	add_to_variable_list = {
		name = 1055_reinforced_recently
		target = root.location
		days = visit_settlement_minimum_cooldown_days
	}
	#Go back to castle grounds
	hidden_effect = { 1051_return_to_castle_effect = yes }
}

#Pretty self-explanatory
scripted_effect 1055_calculate_reinforcements_effect = {
	if = {
		limit = { $RESOURCE$_level >= max_$RESOURCE$_level }
		custom_tooltip = {
			text = ep3_laamp_decision_event.1055.$RESOURCE$_full.tt
			every_in_list = {
				list = damaged_maa_regiments
				change_maa_troops_count = replenishable_troops_value
			}
		}
	}
	# 80%
	else_if = {
		limit = { $RESOURCE$_level >= very_high_$RESOURCE$_level }
		custom_tooltip = {
			text = ep3_laamp_decision_event.1055.$RESOURCE$_partial_80.tt
			every_in_list = {
				list = damaged_maa_regiments
				change_maa_troops_count = {
					value = replenishable_troops_value
					multiply = 0.8
				}
			}
		}
	}
	# 60%
	else_if = {
		limit = { $RESOURCE$_level >= high_$RESOURCE$_level }
		custom_tooltip = {
			text = ep3_laamp_decision_event.1055.$RESOURCE$_partial_60.tt
			every_in_list = {
				list = damaged_maa_regiments
				change_maa_troops_count = {
					value = replenishable_troops_value
					multiply = 0.6
				}
			}
		}
	}
	# 40%
	else_if = {
		limit = { $RESOURCE$_level >= medium_$RESOURCE$_level }
		custom_tooltip = {
			text = ep3_laamp_decision_event.1055.$RESOURCE$_partial_40.tt
			every_in_list = {
				list = damaged_maa_regiments
				change_maa_troops_count = {
					value = replenishable_troops_value
					multiply = 0.4
				}
			}
		}
	}
	# 20%
	else = {
		custom_tooltip = {
			text = ep3_laamp_decision_event.1055.$RESOURCE$_partial_20.tt
			every_in_list = {
				list = damaged_maa_regiments
				change_maa_troops_count = {
					value = replenishable_troops_value
					multiply = 0.2
				}
			}
		}
	}
}

#Well, are ya, punk?
scripted_trigger 1055_is_famous_trigger = {
	OR = {
		AND = {
			prestige_level = max_prestige_level
			NOT = { has_variable = 1055_reinforced_with_prestige_recently }
		}
		AND = {
			piety_level = max_piety_level
			NOT = { has_variable = 1055_reinforced_with_piety_recently }
		}
		AND = {
			has_trait = knight_errant
			has_trait_xp = {
				trait = knight_errant
				value = 100 #Max XP
			}
			NOT = { has_variable = 1055_reinforced_with_knight_errant_recently }
		}
	}
}


#Reinforcers
ep3_laamp_decision_event.1055 = {
	type = character_event
	title = ep3_laamp_decision_event.1055.t
	window = visit_settlement_window
	desc = {
		#What're they doing?
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: Maxed prestige or piety
			triggered_desc = {
				trigger = {
					exists = scope:been_to_reinforcers
					1055_is_famous_trigger = yes
				}
				desc = ep3_laamp_decision_event.1055.desc_maxed_out_returned
			}
			#RETURN:
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_reinforcers
						scope:reinforcers_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1055.desc_returned_01 
				}
				triggered_desc = { 
					trigger = { scope:reinforcers_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1055.desc_returned_02
				}
			}
			#FIRST TIME: Maxed prestige or piety
			triggered_desc = {
				trigger = { 1055_is_famous_trigger = yes }
				desc = ep3_laamp_decision_event.1055.desc_maxed_out
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_reinforcers }
				}
				desc = ep3_laamp_decision_event.1055.desc
			}	
		}
	}
	theme = landless_adventurer
	override_sound = { 
		trigger = { 1055_is_famous_trigger = yes }
		reference = "event:/DLC/FP4/MUSIC/Stingers/mx_stinger_legends_lvl_03"
	}
	override_icon = { reference = "gfx/interface/icons/event_types/type_martial.dds" }
	override_background = { reference = ep3_camp }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		triggered_animation = {
			trigger = {
				root = { 1055_is_famous_trigger = yes }
			}
			animation = happiness
		}
		animation = survey
	}
	center_portrait = {
		character = root
		#Defender
		triggered_animation = {
			trigger = {
				has_trait = knight_errant
				has_trait_xp = {
					trait = knight_errant
					value = 100 #Max XP
				}
				NOT = { has_variable = 1055_reinforced_with_knight_errant_recently }
			}
			animation = marshal_shield
		}
		#Zealous
		triggered_animation = {
			trigger = {
				piety_level = max_piety_level
				NOT = { has_variable = 1055_reinforced_with_piety_recently }
			}
			animation = personality_zealous
		}
		#Prestigious
		triggered_animation = {
			trigger = {
				prestige_level = max_prestige_level
				NOT = { has_variable = 1055_reinforced_with_prestige_recently }
			}
			animation = hero_flex
		}
		triggered_animation = {
			trigger = { has_trait = greedy }
			animation = thinking
		}
		animation = betting
	}
	right_portrait = {
		character = scope:laamp_maa_reinforcer
		camera = camera_event_scheme_far_right
		triggered_animation = {
			trigger = {
				root = { 1055_is_famous_trigger = yes }
			}
			animation = personality_coward
		}
		animation = dismissal
	}
	#Am I overusing this?
	override_effect_2d = {
		trigger = { 1055_is_famous_trigger = yes }
		reference = legend_glow
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = reinforcers }
		#Find a spokesperson
		if = {
			#Do we already have a spokesperson?
			limit = {
				NOT = { exists = scope:laamp_maa_reinforcer }
			}
			#Don't really care about saving this character in a list
			random_pool_character = {
				province = scope:visiting_location
				limit = { 1053_random_martial_character_trigger = yes }
				save_scope_as = laamp_maa_reinforcer
			}
			#Otherwise create a spokesperson
			if = {
				limit = {
					NOT = { exists = scope:laamp_plain_guard }
				}
				#Create spokesperson to stuff in pool
				create_character = {
					template = bandit_character
					location = scope:visiting_location
					dynasty = none
					gender_female_chance = root_soldier_female_chance
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_maa_reinforcer
				}
			}
		}
		scope:laamp_maa_reinforcer = {
			add_character_flag = {
				flag = wear_armor
				weeks = 1
			}
		}
		#Run this once
		if = {
			limit = {
				NOT = { exists = scope:least_damaged_maa_missing_soldiers }
			}
			every_maa_regiment = {
				limit = { maa_current_troops_count < maa_max_troops_count }
				add_to_list = damaged_maa_regiments
			}
			ordered_in_list = {
				list = damaged_maa_regiments
				order_by = {
					value = replenishable_troops_value
					multiply = -1
				}
				save_scope_value_as = {
					name = least_damaged_maa_missing_soldiers
					value = this.replenishable_troops_value
				}
			}
			save_scope_value_as = {
				name = num_damaged_maa_regiments
				value = list_size:damaged_maa_regiments
			}
		}
	}
	#Based on Prestige level
	option = {
		name = ep3_laamp_decision_event.1055.a
		trigger = { #This could be upgraded to diminishing returns
			custom_tooltip = {
				text = ep3_laamp_decision_event.1055.a.cooldown.tt
				NOT = { has_variable = 1055_reinforced_with_prestige_recently }
			}
		}
		show_as_unavailable = { always = yes }
		flavor = ep3_laamp_decision_event.1055.a.flavor
		reason = prestige_level
		#Basically the same as piety
		1055_calculate_reinforcements_effect = { RESOURCE = prestige }
		#Le cooldown
		set_variable = {
			name = 1055_reinforced_with_prestige_recently
			days = visit_settlement_minimum_cooldown_days
		}
		#Checkmark and block off the option
		1055_finished_reinforcers_effect = yes
		ai_chance = {
			base = 200
		}
	}
	#Based on Piety level
	option = {
		name = ep3_laamp_decision_event.1055.b
		trigger = { 
			piety_level >= low_piety_level 
		}
		show_as_unavailable = { always = yes }
		flavor = ep3_laamp_decision_event.1055.b.flavor
		reason = piety_level
		#Basically the same as prestige
		1055_calculate_reinforcements_effect = { RESOURCE = piety }
		#Le cooldown
		set_variable = {
			name = 1055_reinforced_with_piety_recently
			days = visit_settlement_minimum_cooldown_days
		}
		#Checkmark and block off the option
		1055_finished_reinforcers_effect = yes
		ai_chance = {
			base = 200
		}
	}
	#Scrounging for desperate soldiers with lower cost Provisions
	option = {
		name = ep3_laamp_decision_event.1055.c
		trigger = {
			domicile ?= { provisions >= scope:least_damaged_maa_missing_soldiers }
		}
		#Pick a random MaA to reinforce, fully
		custom_tooltip = {
			text = ep3_laamp_decision_event.1055.c.tt
			random_in_list = {
				list = damaged_maa_regiments
				change_maa_troops_count = replenishable_troops_value
			}
		}
		#For a cheaper sandwich
		domicile ?= { 
			change_provisions = {
				subtract = scope:least_damaged_maa_missing_soldiers
				divide = visit_settlement_provision_refill_value
			}
		}
		#No cooldown. For now.
		#Checkmark and block off the option
		1055_finished_reinforcers_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				domicile ?= { provisions < sixty_percent_provisions_value }
				factor = 0
			}
		}
	}
	#I am a Knight-Errant, you _fool_! Bask in my righteousness.
	option = {
		name = ep3_laamp_decision_event.1055.d
		trigger = {
			has_trait = knight_errant
			has_trait_xp = {
				trait = knight_errant
				value = 100 #Max XP
			}
			NOT = { has_variable = 1055_reinforced_with_knight_errant_recently }
		}
		show_as_unavailable = { has_variable = 1055_reinforced_with_knight_errant_recently }
		flavor = ep3_laamp_decision_event.1055.d.flavor
		reason = knight_errant
		#You're just that _good_
		custom_tooltip = {
			text = ep3_laamp_decision_event.1055.d.tt
			every_in_list = {
				list = damaged_maa_regiments
				change_maa_troops_count = replenishable_troops_value
			}
		}
		#Le cooldown
		set_variable = {
			name = 1055_reinforced_with_knight_errant_recently
			days = visit_settlement_minimum_cooldown_days
		}
		#Checkmark and block off the option
		1055_finished_reinforcers_effect = yes
		ai_chance = {
			base = 1000 #Just do it 
		}
	}
	#I want to do something else
	option = {
		name = ep3_laamp_decision_event.1055.e
		#Sets variables and returns us to castle grounds screen
		1031_been_to_effect = { GUILD = reinforcers }
		ai_chance = { base = 200 }
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:reinforcers }
	}
}

#Hire the Bodyguard, show/set the effects and variables 
scripted_effect 1057_hire_bodyguard_effect = {
	hidden_effect = {
		reverse_add_opinion = {
			target = scope:laamp_bodyguard_recruit
			modifier = recruited_me_opinion
			opinion = 30
		}
	}
	add_courtier = scope:laamp_bodyguard_recruit
	#The actual effect happens in after
	show_as_tooltip = {
		court_position_grant_effect = {
			EMPLOYER = root
			POS = bodyguard
			CANDIDATE = scope:laamp_bodyguard_recruit
		}
	}
	#This 'finished' is different since it changes between flag:yes and flag:no
	save_scope_value_as = {
		name = laamp_decision_recruited_bodyguard
		value = flag:yes
	}
	#Go back to castle grounds
	hidden_effect = { 1051_return_to_castle_effect = yes }
}


#Visit Bodyguard
ep3_laamp_decision_event.1057 = {
	type = character_event
	title = ep3_laamp_decision_event.1057.t
	window = visit_settlement_window
	desc = {
		#What're they doing?
		first_valid = {
			#We've returned to this scene, now what
			#RETURN:
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_bodyguard
						scope:bodyguard_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1057.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:bodyguard_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1057.desc_returned_02
				}
				triggered_desc = { 
					trigger = { scope:bodyguard_loc_tracker ?= 2 }
					desc = ep3_laamp_decision_event.1057.desc_returned_03
				}
			}
			#FIRST TIME: We've seen this bodyguard before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_bodyguard
					NOT = { exists = scope:been_to_bodyguard }
				}
				desc = ep3_laamp_decision_event.1057.desc_reused_bodyguard
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_bodyguard }
				}
				desc = ep3_laamp_decision_event.1057.desc
			}	
		}
	}
	theme = landless_adventurer
	override_sound = { reference = "event:/MUSIC/Cues/Events/Positive/mx_cue_postive_effect" }
	override_background = { reference = alley_day }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#Slicing up carcasses
		triggered_animation = {
			trigger = { scope:bodyguard_loc_tracker ?= 1 }
			animation = disbelief
		}
		animation = worry
	}
	center_portrait = {
		character = root
		camera = camera_event_scheme_vs_extra_right_look_right
		#Slicing up carcasses
		triggered_animation = {
			trigger = { scope:bodyguard_loc_tracker ?= 1 }
			animation = fear
		}
		#Literal *flex*
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = gallant
					prowess > high_skill_rating
				}
			}
			animation = hero_flex
		}
		animation = flirtation
	}
	right_portrait = {
		character = scope:laamp_bodyguard_recruit
		camera = camera_event_scheme_far_right
		#Still angry
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:been_to_bodyguard }
			}
			animation = rage
		}
		#Had a pleasant conversation prior to interaction
		triggered_animation = {
			trigger = {
				exists = scope:been_to_bodyguard
				scope:bodyguard_loc_tracker ?= 0 
			}
			animation = personality_compassionate
		}
		#Slicing up carcasses
		triggered_animation = {
			trigger = { scope:bodyguard_loc_tracker ?= 1 }
			animation = hunting_knife_start
		}
		#State of life
		animation = disappointed
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Run this once: Re-save the portrait so the Bodyguard is not the 1050_third_character (since they narratively moved to the alley)
		if = {
			limit = { scope:1050_third_character = scope:laamp_bodyguard_recruit }
			#Overwrite with ROOT to block off the portrait
			save_scope_as = 1050_third_character
			#Remember the bodyguard
			1010_remember_vendor_character_effect = { GUILD = bodyguard CHARACTER = scope:laamp_bodyguard_recruit }
		}
		#Can we _not_ repeat the loc?
		1025_set_and_check_hub_loc_tracker_scope_effect = { HUB = bodyguard }
	}
	#Pay gold
	option = {
		name = ep3_laamp_decision_event.1057.a
		pay_short_term_gold = {
			target = scope:laamp_bodyguard_recruit
			gold = minor_gold_value
		}
		#Wrap effect to hire 'em, set scope & return to castle
		1057_hire_bodyguard_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < minor_gold_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				OR = {
					prowess > high_skill_rating
					has_trait = gallant
				}
				factor = 0
			}
		}
	}
	#Flex Prowess
	option = {
		name = ep3_laamp_decision_event.1057.b
		trigger = { 
			prowess > high_skill_rating
			NOT = { has_trait = gallant }
		}
		#Wrap effect to hire 'em, set scope & return to castle
		1057_hire_bodyguard_effect = yes
		ai_chance = {
			base = 1000 #Just do it
		}
	}
	#Diplomacy duel
	option = {
		name = ep3_laamp_decision_event.1057.c
		duel = {
			skill = diplomacy
			value = average_skill_rating
			#Success: Hire 'em up
			50 = {	
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					OR = {
						has_trait = overseer
						has_trait = strategist
					}
					factor = 2
				}
				desc = ep3_laamp_decision_event.1057.c.success
				send_interface_toast = {
					title = ep3_laamp_decision_event.1057.c.success
					left_icon = root
					right_icon = scope:laamp_bodyguard_recruit
					#Yippee!
					1057_hire_bodyguard_effect = yes
				}
			}
			#Failure: Bye, now
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				modifier = {
					has_trait = zealous
					factor = 0.5
				}
				desc = ep3_laamp_decision_event.1057.c.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = ep3_laamp_decision_event.1057.c.failure
					desc = ep3_laamp_decision_event.1057.c.failure.tt
					left_icon = root
					right_icon = scope:laamp_bodyguard_recruit
					#Oh well
					custom_tooltip = ep3_laamp_decision_event.1057.c.failure.tt
					#This 'finished' is different since it changes between flag:yes and flag:no
					save_scope_value_as = {
						name = laamp_decision_recruited_bodyguard
						value = flag:no
					}
					1051_return_to_castle_effect = yes
				}
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					prowess > high_skill_rating
					has_trait = gallant
				}
				factor = 0
			}
		}
	}
	#Triggered Option: Gallant-flex them
	option = {
		name = ep3_laamp_decision_event.1057.d
		trigger = { has_trait = gallant }
		show_as_unavailable = { always = yes }
		reason = gallant
		#Have a cherry on top
		scope:laamp_bodyguard_recruit = {
			hidden_effect = {
				if = {
					limit = { has_trait = disloyal }
					remove_trait = disloyal
				}
			}
			if = {
				limit = {
					NOT = { has_trait = loyal }
				}
				add_trait = loyal
			}
		}
		#Wrap effect to hire 'em, set scope & return to castle
		1057_hire_bodyguard_effect = yes
		ai_chance = {
			base = 1000 #Just do it
		}
	}
	#I want to do something else
	option = {
		name = ep3_laamp_decision_event.1057.e
		#Saves scopes and returns us to castle grounds screen
		1031_been_to_effect = { GUILD = bodyguard }
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = paranoid
				}
				add = 300
			}
		}
	}
	after = {
		if = {
			limit = { scope:laamp_decision_recruited_bodyguard ?= flag:yes }
			#Appoint them
			if = {
				limit = {
					can_appoint_char_to_court_position = {
						CHAR = scope:laamp_bodyguard_recruit
						COURT_POS = bodyguard_court_position
					}
				}
				court_position_grant_effect = {
					EMPLOYER = root
					POS = bodyguard
					CANDIDATE = scope:laamp_bodyguard_recruit
				}
			}
		}
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:bodyguard }
	}
}


######################################################################
# CRAFTSMEN
# ep3_laamp_decision_event.1060
######################################################################

#Set the correct variable to block off the Craftsmen option and remove the desc flavor variable
scripted_effect 1060_finished_craftsmen_effect = {
	remove_list_variable = {
		name = list_of_options
		target = flag:has_craftsman_option
	}
	save_scope_as = laamp_decision_finished_craftsmen_option
}

#Nothing left for us to do
scripted_trigger 1060_done_with_craftsmen_trigger = {
	exists = scope:laamp_decision_bought_weapon
	exists = scope:laamp_decision_bought_armor
	exists = scope:laamp_decision_bought_accessory
	trigger_if = {
		limit = { exists = scope:laamp_quartermaster_recruit }
		exists = scope:laamp_decision_recruited_quartermaster
	}
}

scripted_trigger 1060_is_quartermaster_available_trigger = {
	#They exist
	exists = scope:laamp_quartermaster_recruit
	#We've been there
	exists = scope:been_to_quartermaster
	#But we're not done with 'em
	NOT = { exists = scope:laamp_decision_recruited_quartermaster }
}


#City Holding: Visit the local city craftsmen
ep3_laamp_decision_event.1060 = {
	type = character_event
	title = ep3_laamp_decision_event.1060.t
	window = visit_settlement_window
	desc = {
		#Intro
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: We've returned from Main Square
			random_valid = {
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						exists = scope:been_to_craftsmen
						OR = {
							scope:craftsmen_loc_tracker ?= 0
							scope:craftsmen_loc_tracker ?= 2
						}
					}
					desc = ep3_laamp_decision_event.1060.desc_returned_01
				}
				triggered_desc = { 
					trigger = { 
						var:return_from_location ?= flag:main_square
						scope:craftsmen_loc_tracker ?= 1
					}
					desc = ep3_laamp_decision_event.1060.desc_returned_02
				}
			}
			#RETURN: We've returned from the Weaponsmith
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:weaponsmith }
				desc = ep3_laamp_decision_event.1060.desc_returned_from_weaponsmith
			}
			#RETURN: We've returned from the Armorer
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:armorer }
				desc = ep3_laamp_decision_event.1060.desc_returned_from_armorer
			}
			#RETURN: We've returned from the Jeweler
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:jeweler }
				desc = ep3_laamp_decision_event.1060.desc_returned_from_jeweler
			}
			#RETURN: We've returned from the Quartermaster
			triggered_desc = {
				trigger = { var:return_from_location ?= flag:quartermaster }
				desc = ep3_laamp_decision_event.1060.desc_returned_from_quartermaster
			}
			#FIRST TIME: First time here
			triggered_desc = {
				trigger = { 
					NOT = { exists = scope:been_to_craftsmen }
				}
				desc = ep3_laamp_decision_event.1060.desc
			}
		}
		#Outro
		first_valid = {
			#FIRST TIME: First time here, look at the quartermaster
			triggered_desc = {
				trigger = {
					exists = scope:laamp_quartermaster_recruit
					NOT = { exists = scope:been_to_craftsmen }
				}
				desc = ep3_laamp_decision_event.1060.desc_outro_quartermaster
			}
			#FIRST TIME: First time here, curious partner
			triggered_desc = {
				trigger = {
					exists = scope:visiting_partner
					NOT = { exists = scope:been_to_craftsmen }
				}
				desc = ep3_laamp_decision_event.1060.desc_outro_partner
			}
			#FIRST TIME: First time here
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_craftsmen }
				}
				desc = ep3_laamp_decision_event.1060.desc_outro
			}
			#RETURN: Partner - there is nothing left for us here
			triggered_desc = {
				trigger = { 
					exists = scope:visiting_partner
					1060_done_with_craftsmen_trigger = yes 
				}
				desc = ep3_laamp_decision_event.1060.desc_outro_return_partner_finished
			}
			#RETURN: There is nothing left for us here
			triggered_desc = {
				trigger = { 1060_done_with_craftsmen_trigger = yes }
				desc = ep3_laamp_decision_event.1060.desc_outro_return_finished
			}
			#RETURN: Quartermaster did not move to the tavern, yet
			triggered_desc = {
				trigger = {
					exists = scope:laamp_quartermaster_recruit
					NOR = { 
						exists = scope:been_to_quartermaster
						exists = scope:laamp_decision_recruited_quartermaster
					}
				}
				desc = ep3_laamp_decision_event.1060.desc_outro_quartermaster_return
			}
			#RETURN: We've been here before
			random_valid = {
				#RETURN: Partner flavor
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						exists = scope:been_to_craftsmen
						scope:craftsmen_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1060.desc_outro_return_partner_01
				}
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						scope:craftsmen_loc_tracker ?= 1
					}
					desc = ep3_laamp_decision_event.1060.desc_outro_return_partner_02
				}
				triggered_desc = {
					trigger = {
						exists = scope:visiting_partner
						scope:craftsmen_loc_tracker ?= 2
					}
					desc = ep3_laamp_decision_event.1060.desc_outro_return_partner_03
				}
				#RETURN: Generics
				triggered_desc = {
					trigger = { 
						exists = scope:been_to_craftsmen
						scope:craftsmen_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1060.desc_outro_return_01
				}
				triggered_desc = {
					trigger = { scope:craftsmen_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1060.desc_outro_return_02
				}
				triggered_desc = {
					trigger = { scope:craftsmen_loc_tracker ?= 2 }
					desc = ep3_laamp_decision_event.1060.desc_outro_return_03
				}
			}
		}
	}
	theme = stewardship
	#Get outta here already
	override_effect_2d = {
		trigger = { 
			1060_done_with_craftsmen_trigger = yes
			scope:visiting_location = { is_drylands_or_desert_trigger = no } 
		}
  		reference = rain	
	}
	override_background = { reference = market }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#If it's our (tired) visiting partner
		triggered_animation = {
			trigger = { 1060_done_with_craftsmen_trigger = yes }
			animation = boredom
		}
		#If it's our visiting partner
		animation = survey
	}
	center_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = greedy }
			animation = stress
		}
		animation = personality_forgiving
	}
	#Do we have someone to display?
	right_portrait = {
		trigger = { 
			exists = scope:1060_third_character
			#If this is root, then that means we have talked to the Quartermaster so let's disappear the portrait
			scope:1060_third_character != root
		}
		character = scope:1060_third_character
		#Le Quartermaster
		animation = eyeroll
	}
	#The craftsmen
	lower_left_portrait = {
		#Let's remove them when the option is no longer available
		trigger = {
			scope:1060_fourth_character != root
		}
		character = scope:1060_fourth_character
	}
	lower_center_portrait = {
		#Let's remove them when the option is no longer available
		trigger = {
			scope:1060_fifth_character != root
		}
		character = scope:1060_fifth_character
	}
	lower_right_portrait = {
		#Let's remove them when the option is no longer available
		trigger = {
			scope:1060_sixth_character != root
		}
		character = scope:1060_sixth_character
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Can we _not_ repeat the loc?
		1025_set_and_check_hub_loc_tracker_scope_effect = { HUB = craftsmen }
		#Find our weaponsmith
		if = {
			#Do we already have a weaponsmith?
			limit = {
				NOT = { exists = scope:laamp_weaponsmith_craftsman }
			}
			#Has this person been our weaponsmith in the past 10 years?
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_weaponsmith_trigger = yes
					1010_is_a_saved_merchant_trigger = no
					1010_is_a_saved_peddler_trigger = no
					1010_is_a_saved_crier_trigger = no
					1010_is_a_saved_storyteller_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_healer_trigger = no
					1010_is_a_saved_clergy_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_armorer_trigger = no
					1010_is_a_saved_jeweler_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
				}
				save_scope_as = laamp_weaponsmith_craftsman
				#Some more loc flavor shenanigans for these saved scopes
				save_scope_as = laamp_recurring_weaponsmith_craftsman
			}
			#Otherwise find a weaponsmith in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_weaponsmith_craftsman }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					}
					save_scope_as = laamp_weaponsmith_craftsman
				}
			}
			#Otherwise create a weaponsmith
			if = {
				limit = {
					NOT = { exists = scope:laamp_weaponsmith_craftsman }
				}
				#Create weaponsmith to stuff in pool
				create_character = {
					template = generic_peasant_character
					location = scope:visiting_location
					dynasty = none
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_weaponsmith_craftsman
				}
			}
			scope:laamp_weaponsmith_craftsman = { save_scope_as = 1060_fourth_character }
		}
		#And our armorer
		if = {
			#Do we already have an armorer?
			limit = {
				NOT = { exists = scope:laamp_armorer_craftsman }
			}
			#Has this person been our armorer in the past 10 years?
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_armorer_trigger = yes
					1010_is_a_saved_merchant_trigger = no
					1010_is_a_saved_peddler_trigger = no
					1010_is_a_saved_crier_trigger = no
					1010_is_a_saved_storyteller_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_healer_trigger = no
					1010_is_a_saved_clergy_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_weaponsmith_trigger = no
					1010_is_a_saved_jeweler_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
				}
				save_scope_as = laamp_armorer_craftsman
				#Some more loc flavor shenanigans for these saved scopes
				save_scope_as = laamp_recurring_armorer_craftsman
			}
			#Otherwise find an armorer in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_armorer_craftsman }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					}
					save_scope_as = laamp_armorer_craftsman
				}
			}
			#Otherwise create an armorer
			if = {
				limit = {
					NOT = { exists = scope:laamp_armorer_craftsman }
				}
				#Create armorer to stuff in pool
				create_character = {
					template = generic_peasant_character
					location = scope:visiting_location
					dynasty = none
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_armorer_craftsman
				}
			}
			scope:laamp_armorer_craftsman = { save_scope_as = 1060_fifth_character }
		}
		#And finally, our jeweler
		if = {
			#Do we already have a jeweler?
			limit = {
				NOT = { exists = scope:laamp_jeweler_craftsman }
			}
			#Has this person been our jeweler in the past 10 years?
			random_pool_character = {
				province = scope:visiting_location
				limit = {
					1010_basic_merchant_checks_trigger = yes
					NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					save_temporary_scope_as = saved_character_check
					#Let's avoid double-dipping
					1010_is_a_saved_jeweler_trigger = yes
					1010_is_a_saved_merchant_trigger = no
					1010_is_a_saved_peddler_trigger = no
					1010_is_a_saved_crier_trigger = no
					1010_is_a_saved_storyteller_trigger = no
					1010_is_a_saved_thief_trigger = no
					1010_is_a_saved_healer_trigger = no
					1010_is_a_saved_clergy_trigger = no
					1010_is_a_saved_physician_trigger = no
					1010_is_a_saved_bodyguard_trigger = no
					1010_is_a_saved_weaponsmith_trigger = no
					1010_is_a_saved_armorer_trigger = no
					1010_is_a_saved_quartermaster_trigger = no
				}
				save_scope_as = laamp_jeweler_craftsman
				#Some more loc flavor shenanigans for these saved scopes
				save_scope_as = laamp_recurring_jeweler_craftsman
			}
			#Otherwise find a jeweler in the pool
			if = {
				limit = { 
					NOT = { exists = scope:laamp_jeweler_craftsman }
				}
				random_pool_character = {
					province = scope:visiting_location
					limit = { 
						1010_basic_merchant_checks_trigger = yes
						NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
					}
					save_scope_as = laamp_jeweler_craftsman
				}
			}
			#Otherwise create a jeweler
			if = {
				limit = {
					NOT = { exists = scope:laamp_jeweler_craftsman }
				}
				#Create jeweler to stuff in pool
				create_character = {
					template = generic_peasant_character
					location = scope:visiting_location
					dynasty = none
					culture = scope:visiting_location.culture
					faith = scope:visiting_location.faith
					save_scope_as = laamp_jeweler_craftsman
				}
			}
			scope:laamp_jeweler_craftsman = { save_scope_as = 1060_sixth_character }
		}
		#Rare: Spawn a spectacular Quartermaster
		if = {
			limit = {
				can_employ_court_position_type = quartermaster_camp_officer
				NOT = { has_variable = laamp_decision_1000_checked_for_quartermaster }
			}
			random_list = {
				80 = { 
					#No Quartermaster
				}
				20 = {
					trigger = { can_employ_court_position_type = quartermaster_camp_officer }
					#Has this person been our quartermaster in the past 10 years?
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							1010_basic_merchant_checks_trigger = yes
							NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
							save_temporary_scope_as = saved_character_check
							#Let's avoid double-dipping
							1010_is_a_saved_quartermaster_trigger = yes
							1010_is_a_saved_merchant_trigger = no
							1010_is_a_saved_peddler_trigger = no
							1010_is_a_saved_crier_trigger = no
							1010_is_a_saved_storyteller_trigger = no
							1010_is_a_saved_thief_trigger = no
							1010_is_a_saved_healer_trigger = no
							1010_is_a_saved_clergy_trigger = no
							1010_is_a_saved_physician_trigger = no
							1010_is_a_saved_bodyguard_trigger = no
							1010_is_a_saved_weaponsmith_trigger = no
							1010_is_a_saved_armorer_trigger = no
							1010_is_a_saved_jeweler_trigger = no
						}
						save_scope_as = laamp_quartermaster_recruit
						#Some more loc flavor shenanigans for these saved scopes
						save_scope_as = laamp_recurring_quartermaster
					}
					#Otherwise find a quartermaster in the pool
					if = {
						limit = { 
							NOT = { exists = scope:laamp_quartermaster_recruit }
						}
						random_pool_character = {
							province = scope:visiting_location
							limit = { 
								1010_basic_merchant_checks_trigger = yes
								NOT = { has_trait = devoted } #Look, I like weaponsmith nuns as much as the next person, but it looked _slightly_ off
								stewardship >= 15
								NOR = {
									has_trait = generous
									has_trait = profligate
									has_trait = improvident
								}
							}
							save_scope_as = laamp_quartermaster_recruit
						}
					}
					#Or create a quartermaster
					if = {
						limit = {
							NOT = { exists = scope:laamp_quartermaster_recruit }
						}
						#Create quartermaster to stuff in pool
						create_character = {
							template = bp1_yearly_2021_stewardship_person_template
							location = scope:visiting_location
							trait = arrogant
							dynasty = none
							culture = scope:visiting_location.culture
							faith = scope:visiting_location.faith
							stewardship = { decent_skill_rating high_skill_rating }
							save_scope_as = laamp_quartermaster_recruit
						}
						scope:laamp_quartermaster_recruit ?= {
							#Chance to add a malus trait to this spectatular being
							if = {
								limit = { 
									NOR = { 
										has_trait = possessed_1 
										has_trait = lunatic_1
										has_trait = depressed_1
										has_trait = drunkard
										has_trait = hashishiyah
										has_trait = irritable
									}
								}
								hidden_effect = {
									random = {
										chance = 20
										random_list = {
											10 = { add_trait = possessed_1 }
											10 = { add_trait = lunatic_1 }
											10 = { add_trait = depressed_1 }
											10 = { add_trait = drunkard }
											10 = { add_trait = hashishiyah }
											10 = { add_trait = irritable }
										}
									}
								}
							}
						}
					}
					scope:laamp_quartermaster_recruit = { save_scope_as = 1060_third_character }
				}
			}
			#No decision-scumming
			set_variable = {
				name = laamp_decision_1000_checked_for_quartermaster
				days = visit_settlement_cooldown_days
			}
		}
		#Fourth portrait
		if = {
			limit = {
				OR = {
					#If we've already finished off the Weaponsmith
					AND = {
						scope:1060_fourth_character = scope:laamp_weaponsmith_craftsman
						exists = scope:laamp_decision_bought_weapon
					}
					#And we did that before talking to the Quartermaster
					AND = {
						1060_is_quartermaster_available_trigger = yes
						scope:1060_fourth_character = root
					}
				}
			}
			#Put the Quartermaster in the slot, if they exist
			if = {
				limit = { 1060_is_quartermaster_available_trigger = yes }
				scope:laamp_quartermaster_recruit = { save_scope_as = 1060_fourth_character }
				#Hide the portrait with ROOT if they already are saved somewhere else
				if = {
					limit = { scope:1060_fifth_character ?= scope:laamp_quartermaster_recruit }
					save_scope_as = 1060_fifth_character
				}
				#Hide the portrait with ROOT if they already are saved somewhere else
				if = {
					limit = { scope:1060_sixth_character ?= scope:laamp_quartermaster_recruit }
					save_scope_as = 1060_sixth_character
				}
			}
			#Otherwise hide the portrait with ROOT
			else = { save_scope_as = 1060_fourth_character }
		}
		#Fifth portrait
		if = {
			limit = {
				OR = {
					#If we've already finished off the Armorer
					AND = {
						scope:1060_fifth_character = scope:laamp_armorer_craftsman
						exists = scope:laamp_decision_bought_armor
					}
					#And we did that before talking to the Quartermaster
					AND = {
						1060_is_quartermaster_available_trigger = yes
						scope:1060_fifth_character = root
					}
				}
			}
			#Put the Quartermaster in the slot, if they exist
			if = {
				limit = { 
					1060_is_quartermaster_available_trigger = yes
					NOR = { 
						scope:1060_fourth_character ?= scope:laamp_quartermaster_recruit
						scope:1060_sixth_character ?= scope:laamp_quartermaster_recruit
					}
				}
				scope:laamp_quartermaster_recruit = { save_scope_as = 1060_fifth_character }
			}
			#Otherwise hide the portrait with ROOT
			else = { save_scope_as = 1060_fifth_character }
		}
		#Sixth portrait
		if = {
			limit = {
				OR = {
					#If we've already finished off the Jeweler
					AND = {
						scope:1060_sixth_character = scope:laamp_jeweler_craftsman
						exists = scope:laamp_decision_bought_accessory
					}
					#And we did that before talking to the Quartermaster
					AND = {
						1060_is_quartermaster_available_trigger = yes
						scope:1060_sixth_character = root
					}
				}
			}
			#Put the Quartermaster in the slot, if they exist
			if = {
				limit = { 
					1060_is_quartermaster_available_trigger = yes
					NOR = { 
						scope:1060_fourth_character ?= scope:laamp_quartermaster_recruit
						scope:1060_fifth_character ?= scope:laamp_quartermaster_recruit
					}
				}
				scope:laamp_quartermaster_recruit = { save_scope_as = 1060_sixth_character }
			}
			#Otherwise hide the portrait with ROOT
			else = { save_scope_as = 1060_sixth_character }
		}
	}
	#Visit Weaponsmith
	option = {
		name = {
			text = {
				first_valid = {
					#Return to look at the weapons
					triggered_desc = {
						trigger = { exists = scope:been_to_weaponsmith }
						desc = ep3_laamp_decision_event.1060.a_second
					}
					#First time looking at weapons
					desc = ep3_laamp_decision_event.1060.a
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1060.a.cooldown.tt
				NOT = { exists = scope:laamp_decision_bought_weapon }
			}
		}
		show_as_unavailable = { always = yes }
		reason = visit_weaponsmith
		highlight_portrait = scope:laamp_weaponsmith_craftsman
		custom_tooltip = ep3_laamp_decision_event.1060.a.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = craftsmen }
		#Go to the Weaponsmith screen
		trigger_event = ep3_laamp_decision_event.1061
		ai_chance = { base = 100 }
	}
	#Visit Armorer
	option = {
		name = {
			text = {
				first_valid = {
					#Return to look at the armor
					triggered_desc = {
						trigger = { exists = scope:been_to_armorer }
						desc = ep3_laamp_decision_event.1060.b_second
					}
					#First time looking at armor
					desc = ep3_laamp_decision_event.1060.b
				}
			}
		}
		trigger = {
			#Recruited the armorer
			trigger_if = {
				limit = { scope:laamp_decision_bought_armor ?= flag:no }
				custom_tooltip = {
					text = recruited_armorer.tt
					always = no
				}
			}
			#Been there, done that
			trigger_else_if = {
				limit = { scope:laamp_decision_bought_armor ?= flag:yes }
				custom_tooltip = {
					text = ep3_laamp_decision_event.1060.b.cooldown.tt
					always = no
				}
			}
			trigger_else = { exists = scope:laamp_armorer_craftsman }
		}
		show_as_unavailable = { always = yes }
		reason = visit_armorsmith
		highlight_portrait = scope:laamp_armorer_craftsman
		custom_tooltip = ep3_laamp_decision_event.1060.b.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = craftsmen }
		#Go to the Armorer screen
		trigger_event = ep3_laamp_decision_event.1063
		ai_chance = { base = 100 }
	}
	#Visit Jeweler
	option = {
		name = {
			text = {
				first_valid = {
					#Return to look at the accessories
					triggered_desc = {
						trigger = { exists = scope:been_to_jeweler }
						desc = ep3_laamp_decision_event.1060.c_second
					}
					#First time looking at accessories
					desc = ep3_laamp_decision_event.1060.c
				}
			}
		}
		trigger = {
			custom_tooltip = {
				text = ep3_laamp_decision_event.1060.c.cooldown.tt
				NOT = { exists = scope:laamp_decision_bought_accessory }
			}
		}
		show_as_unavailable = { always = yes }
		reason = visit_jeweler
		highlight_portrait = scope:laamp_jeweler_craftsman
		custom_tooltip = ep3_laamp_decision_event.1060.c.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = craftsmen }
		#Go to the Jeweler screen
		trigger_event = ep3_laamp_decision_event.1065
		ai_chance = { base = 100 }
	}
	#Rare Option: Hire cheaper, skilled, Quartermaster
	option = {
		name = {
			text = {
				first_valid = {
					#Return to talk to the Quartermaster
					triggered_desc = {
						trigger = { exists = scope:been_to_quartermaster }
						desc = ep3_laamp_decision_event.1060.d_second
					}
					#First time talking to the Quartermaster
					desc = ep3_laamp_decision_event.1060.d
				}
			}
		}
		trigger = { 
			exists = scope:laamp_quartermaster_recruit
			NOT = { exists = scope:laamp_decision_recruited_quartermaster }
		}
		reason = unlocked_quartermaster
		highlight_portrait = scope:laamp_quartermaster_recruit
		custom_tooltip = ep3_laamp_decision_event.1060.d.tt
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = craftsmen }
		#For the Quartermaster screen
		trigger_event = ep3_laamp_decision_event.1067
		ai_chance = { base = 500 }
	}
	#I want to do something else
	option = {
		name = {
			text = {
				first_valid = {
					#Nothing left to do
					triggered_desc = {
						trigger = { 1060_done_with_craftsmen_trigger = yes }
						desc = ep3_laamp_decision_event.1060.e_second
					}
					#Back to main square
					desc = ep3_laamp_decision_event.1060.e
				}
			}
		}
		#Have we done everything? Are we closing off the option?
		if = {
			limit = { 1060_done_with_craftsmen_trigger = yes }
			#Clean up unnecessary variables and close off the option
			1060_finished_craftsmen_effect = yes
		}
		#*Withered* - This needs to be done manually because the scope isn't saved before the next event is triggered if it's run in After = { ... }
		1030_save_hub_scope_effect = { HUB = craftsmen }
		#Go back to the main event
		1000_return_to_main_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = paranoid
				}
				add = 300
			}
		}
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:craftsmen }
	}
}


#Identify the weapon artifacts
scripted_effect 1061_set_weapon_variable_effect = {
	set_variable = {
		name = 1061_laamp_decision_weapon
		days = visit_settlement_cooldown_days
	}
}

#Simple enough
scripted_trigger 1061_is_rare_item_trigger = {
	OR = {
		rarity = masterwork
		rarity = famed 
		rarity = illustrious 
	}
}

#Chance to flush the inventory to simulate someone else buying the item or similar. Refresh the stock.
scripted_effect 1061_chance_to_flush_inventory_effect = {
	hidden_effect = {
		random_list = {
			#We didn't buy this one
			50 = {
				trigger = { 
					$FIRST_ITEM$ = { artifact_owner = $VENDOR$ }
				}
				#Less chance to destroy premium stuff
				modifier = {
					$FIRST_ITEM$ = { 1061_is_rare_item_trigger = yes }
					factor = 0.5
				}
				destroy_artifact = $FIRST_ITEM$
			}
			#Or this one
			50 = {
				trigger = { 
					$SECOND_ITEM$ = { artifact_owner = $VENDOR$ }
				}
				#Less chance to destroy premium stuff
				modifier = {
					$SECOND_ITEM$ = { 1061_is_rare_item_trigger = yes }
					factor = 0.5
				}
				destroy_artifact = $SECOND_ITEM$
			}
			#Nor this one?
			50 = {
				trigger = { 
					$THIRD_ITEM$ = { artifact_owner = $VENDOR$ }
				}
				#Less chance to destroy premium stuff
				modifier = {
					$THIRD_ITEM$ = { 1061_is_rare_item_trigger = yes }
					factor = 0.5
				}
				destroy_artifact = $THIRD_ITEM$
			}
		}
	}
}

#Chance for the vendor to have a real gem, once in a while
scripted_effect 1061_buff_item_modifiers_effect = {
	#Masterwork modifiers
	if = {
		limit = { rarity = masterwork }
		if = {
			limit = { has_variable = 1061_laamp_decision_weapon }
			add_scaled_artifact_modifier_prowess_effect = yes
			add_scaled_artifact_modifier_combat_effect = yes
		}
		if = {
			limit = { has_variable = 1063_laamp_decision_armor }
			add_scaled_artifact_modifier_negate_prowess_penalty_effect = yes
			add_scaled_artifact_modifier_terrain_advantage_effect = yes 		
		}
		if = {
			limit = { has_variable = 1065_laamp_decision_accessory }
			add_scaled_artifact_modifier_hire_mercenary_effect = yes
			add_scaled_artifact_modifier_prestige_effect = yes		
		}
	}
}

#We return to the craftsmen event to peruse other options
scripted_effect 1061_return_to_craftsmen_effect = {
	custom_tooltip = ep3_laamp_decision_event.1061.return.tt
	trigger_event = ep3_laamp_decision_event.1060
}

#Set the correct variable to block off the Weaponsmith option and remove the desc flavor variable
scripted_effect 1061_bought_weapon_effect = {
	scope:1061_first_weapon = { remove_variable ?= 1061_weapon_value }
	scope:1061_second_weapon = { remove_variable ?= 1061_weapon_value }
	scope:1061_third_weapon = { remove_variable ?= 1061_weapon_value }
	save_scope_as = laamp_decision_bought_weapon
	#Simulate shifting inventory
	1061_chance_to_flush_inventory_effect = {
		FIRST_ITEM = scope:1061_first_weapon
		SECOND_ITEM = scope:1061_second_weapon
		THIRD_ITEM = scope:1061_third_weapon
		VENDOR = scope:laamp_weaponsmith_craftsman
	}
	#Go back to craftsmen district
	hidden_effect = { 1061_return_to_craftsmen_effect = yes }
}

#The actual transfer
scripted_effect 1061_buy_item_effect = {
	#Weapon
	if = {
		limit = { has_variable = 1061_laamp_decision_weapon }
		root = {
			pay_short_term_gold = {
				target = scope:laamp_weaponsmith_craftsman
				gold = prev.var:1061_weapon_value #Is set via the 1041_set_item_value_effect on the artifact itself
			}
		}
	}
	#Armor
	if = {
		limit = { has_variable = 1063_laamp_decision_armor }
		root = {
			pay_short_term_gold = {
				target = scope:laamp_armorer_craftsman
				gold = prev.var:1063_armor_value
			}
		}
	}
	#Accessory
	if = {
		limit = { has_variable = 1065_laamp_decision_accessory }
		root = {
			pay_short_term_gold = {
				target = scope:laamp_jeweler_craftsman
				gold = prev.var:1065_accessory_value
			}
		}
	}
	set_owner = root
}


#Visit Weaponsmith
ep3_laamp_decision_event.1061 = {
	type = character_event
	title = ep3_laamp_decision_event.1061.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: Generics
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_weaponsmith
						scope:weaponsmith_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1061.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:weaponsmith_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1061.desc_returned_02
				}
			}
			#FIRST TIME: We've seen this weaponsmith before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_weaponsmith_craftsman
					NOT = { exists = scope:been_to_weaponsmith }
				}
				desc = ep3_laamp_decision_event.1061.desc_reused_weaponsmith
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_weaponsmith }
				}
				desc = ep3_laamp_decision_event.1061.desc
			}	
		}
	}
	theme = stewardship
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_martial" }
	override_background = { reference = armory }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		animation = marshal_random_weapon
	}
	center_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:laamp_weaponsmith_craftsman
		camera = camera_event_scheme_far_right
		animation = inspect_weapon
	}
	artifact = {
		target = scope:1061_first_weapon
		position = lower_left_portrait
	}
	artifact = {
		target = scope:1061_second_weapon
		position = lower_center_portrait
	}
	artifact = {
		target = scope:1061_third_weapon
		position = lower_right_portrait
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		location.province_owner = { save_scope_as = bg_override_char }
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = weaponsmith }
		#Find our weapons
		if = {
			limit = {
				NOT = { exists = scope:1061_first_weapon }
			}
			scope:laamp_weaponsmith_craftsman = {
				#Have we created weapons recently, which we can pull?
				if = {
					limit = {
						any_character_artifact ?= { has_variable = 1061_laamp_decision_weapon }
					}
					every_character_artifact = {
						limit = { has_variable = 1061_laamp_decision_weapon }
						add_to_list = list_of_potential_weapons
					}
					random_in_list = {
						list = list_of_potential_weapons
						save_scope_as = 1061_first_weapon
					}
					random_in_list = {
						list = list_of_potential_weapons
						limit = {
							this != scope:1061_first_weapon
						}
						save_scope_as = 1061_second_weapon
					}
					random_in_list = {
						list = list_of_potential_weapons
						limit = {
							NOR = { 
								this = scope:1061_first_weapon
								this = scope:1061_second_weapon
							}
						}
						save_scope_as = 1061_third_weapon
					}
				}
				#If we don't have any old weapons; generate new ones!
				hidden_effect_new_object = { #HAZMAT SUIT OF ERROR SUPRESSION
					if = {
						limit = {
							NOT = { exists = scope:1061_first_weapon }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_weaponsmith_craftsman }
						#Generate weapon
						create_artifact_weapon_effect = {
							OWNER = scope:laamp_weaponsmith_craftsman
							CREATOR = scope:laamp_weaponsmith_craftsman
							SET_WEAPON_TYPE = flag:no
						}
						#Finalization
						scope:newly_created_artifact ?= {
							1061_set_weapon_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1061_first_weapon
						}
					}
					if = {
						limit = {
							NOT = { exists = scope:1061_second_weapon }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_weaponsmith_craftsman }
						#Generate weapon
						create_artifact_weapon_effect = {
							OWNER = scope:laamp_weaponsmith_craftsman
							CREATOR = scope:laamp_weaponsmith_craftsman
							SET_WEAPON_TYPE = flag:no
						}
						#Finalization
						scope:newly_created_artifact ?= {
							1061_set_weapon_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1061_second_weapon
						}
					}
					if = {
						limit = {
							NOT = { exists = scope:1061_third_weapon }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_weaponsmith_craftsman }
						#Generate weapon
						create_artifact_weapon_effect = {
							OWNER = scope:laamp_weaponsmith_craftsman
							CREATOR = scope:laamp_weaponsmith_craftsman
							SET_WEAPON_TYPE = flag:no
						}
						#Finalization
						scope:newly_created_artifact ?= {
							1061_set_weapon_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1061_third_weapon
						}
					}
					#Set the value of the weapons
					scope:1061_first_weapon = { 1041_set_item_value_effect = yes }
					scope:1061_second_weapon = { 1041_set_item_value_effect = yes }
					scope:1061_third_weapon = { 1041_set_item_value_effect = yes }
				}
			}
			#Remember the weaponsmith
			1010_remember_vendor_character_effect = { GUILD = weaponsmith CHARACTER = scope:laamp_weaponsmith_craftsman }
		}
	}
	#Weapon #1
	option = {
		name = ep3_laamp_decision_event.1061.a
		#Pay gold, transfer weapon
		scope:1061_first_weapon = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1061_bought_weapon_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1061_first_weapon.var:1061_weapon_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Weapon #2
	option = {
		name = ep3_laamp_decision_event.1061.b
		#Pay gold, transfer weapon
		scope:1061_second_weapon = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1061_bought_weapon_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1061_second_weapon.var:1061_weapon_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Weapon #3
	option = {
		name = ep3_laamp_decision_event.1061.c
		#Pay gold, transfer weapon
		scope:1061_third_weapon = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1061_bought_weapon_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1061_third_weapon.var:1061_weapon_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#I want to visit another craftsman
	option = {
		name = ep3_laamp_decision_event.1061.d
		#Sets variables and returns us to craftman screen
		1031_been_to_effect = { GUILD = weaponsmith }
		ai_chance = {
			base = 200
			modifier = {
				has_trait = greedy
				factor = 2
			}
		}
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:weaponsmith }
	}
}


#Identify the armor artifacts
scripted_effect 1063_set_armor_variable_effect = {
	set_variable = {
		name = 1063_laamp_decision_armor
		days = visit_settlement_cooldown_days
	}
}

#Set the correct variable to block off the Armorer option and remove the desc flavor variable
scripted_effect 1063_bought_armor_effect = {
	scope:1063_first_armor = { remove_variable ?= 1063_armor_value }
	scope:1063_second_armor = { remove_variable ?= 1063_armor_value }
	scope:1063_third_armor = { remove_variable ?= 1063_armor_value }
	save_scope_value_as = {
		name = laamp_decision_bought_armor
		value = flag:yes
	}
	#Simulate shifting inventory
	1061_chance_to_flush_inventory_effect = {
		FIRST_ITEM = scope:1063_first_armor
		SECOND_ITEM = scope:1063_second_armor
		THIRD_ITEM = scope:1063_third_armor
		VENDOR = scope:laamp_armorer_craftsman
	}
	#Go back to craftsmen district
	hidden_effect = { 1061_return_to_craftsmen_effect = yes }
}


#Visit Armorer
ep3_laamp_decision_event.1063 = {
	type = character_event
	title = ep3_laamp_decision_event.1063.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: Generics
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_armorer
						scope:armorer_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1063.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:armorer_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1063.desc_returned_02
				}
			}
			#FIRST TIME: We've seen this armorer before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_armorer_craftsman
					NOT = { exists = scope:been_to_armorer }
				}
				desc = ep3_laamp_decision_event.1063.desc_reused_armorer
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_armorer }
				}
				desc = ep3_laamp_decision_event.1063.desc
			}	
		}
	}
	theme = stewardship
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { reference = armory }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		animation = personality_content
	}
	center_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:laamp_armorer_craftsman
		camera = camera_event_scheme_far_right
		animation = personality_bold
	}
	artifact = {
		target = scope:1063_first_armor
		position = lower_left_portrait
	}
	artifact = {
		target = scope:1063_second_armor
		position = lower_center_portrait
	}
	artifact = {
		target = scope:1063_third_armor
		position = lower_right_portrait
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		location.province_owner = { save_scope_as = bg_override_char }
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = armorer }
		#Find our armors
		if = {
			limit = {
				NOT = { exists = scope:1063_first_armor }
			}
			scope:laamp_armorer_craftsman = {
				#Have we created armors recently, which we can pull?
				if = {
					limit = {
						any_character_artifact ?= { has_variable = 1063_laamp_decision_armor }
					}
					every_character_artifact = {
						limit = { has_variable = 1063_laamp_decision_armor }
						add_to_list = list_of_potential_armors
					}
					random_in_list = {
						list = list_of_potential_armors
						save_scope_as = 1063_first_armor
					}
					random_in_list = {
						list = list_of_potential_armors
						limit = {
							this != scope:1063_first_armor
						}
						save_scope_as = 1063_second_armor
					}
					random_in_list = {
						list = list_of_potential_armors
						limit = {
							NOR = { 
								this = scope:1063_first_armor
								this = scope:1063_second_armor
							}
						}
						save_scope_as = 1063_third_armor
					}
				}
				#If we don't have any old armors; generate new ones!
				hidden_effect_new_object = { #HAZMAT SUIT OF ERROR SUPRESSION
					if = {
						limit = {
							NOT = { exists = scope:1063_first_armor }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_armorer_craftsman }
						#Generate armor
						create_artifact_armor_effect = {
							OWNER = scope:laamp_armorer_craftsman
							CREATOR = scope:laamp_armorer_craftsman
							SET_ARMOR_TYPE = flag:no
						}
						#Finalization
						scope:newly_created_artifact ?= {
							1063_set_armor_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1063_first_armor
						}
					}
					if = {
						limit = {
							NOT = { exists = scope:1063_second_armor }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_armorer_craftsman }
						#Generate armor
						create_artifact_armor_effect = {
							OWNER = scope:laamp_armorer_craftsman
							CREATOR = scope:laamp_armorer_craftsman
							SET_ARMOR_TYPE = flag:armor_type_lamellar
						}
						#Finalization
						scope:newly_created_artifact ?= {
							1063_set_armor_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1063_second_armor
						}
					}
					if = {
						limit = {
							NOT = { exists = scope:1063_third_armor }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_armorer_craftsman }
						#Generate armor
						create_artifact_armor_effect = {
							OWNER = scope:laamp_armorer_craftsman
							CREATOR = scope:laamp_armorer_craftsman
							SET_ARMOR_TYPE = flag:armor_type_scale
						}
						#Finalization
						scope:newly_created_artifact ?= {
							1063_set_armor_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1063_third_armor
						}
					}
					#Set the value of the armors
					scope:1063_first_armor = { 1041_set_item_value_effect = yes }
					scope:1063_second_armor = { 1041_set_item_value_effect = yes }
					scope:1063_third_armor = { 1041_set_item_value_effect = yes }
				}
			}
			#Remember the armorer
			1010_remember_vendor_character_effect = { GUILD = armorer CHARACTER = scope:laamp_armorer_craftsman }
		}
	}
	#Armor #1
	option = {
		name = ep3_laamp_decision_event.1063.a
		#Pay gold, transfer armor
		scope:1063_first_armor = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1063_bought_armor_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1063_first_armor.var:1063_armor_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Armor #2
	option = {
		name = ep3_laamp_decision_event.1063.b
		#Pay gold, transfer armor
		scope:1063_second_armor = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1063_bought_armor_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1063_second_armor.var:1063_armor_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Armor #3
	option = {
		name = ep3_laamp_decision_event.1063.c
		#Pay gold, transfer armor
		scope:1063_third_armor = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1063_bought_armor_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1063_third_armor.var:1063_armor_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#TRIGGERED OPTION: Attempt to recruit the armorer
	option = {
		name = ep3_laamp_decision_event.1063.d
		trigger = { 
			custom_description = {
				text = not_have_armorer_building
				can_employ_court_position_type = armorer_camp_officer
			}
		}
		reason = unlocked_armorer
		pay_short_term_gold = {
			target = scope:laamp_armorer_craftsman
			gold = minor_gold_value
		}
		hidden_effect = {
			reverse_add_opinion = {
				target = scope:laamp_armorer_craftsman
				modifier = recruited_me_opinion
				opinion = 30
			}
		}
		add_courtier = scope:laamp_armorer_craftsman
		#The actual effect happens in after
		show_as_tooltip = {
			camp_officer_grant_effect = {
				EMPLOYER = root
				POS = armorer
				CANDIDATE = scope:laamp_armorer_craftsman
			}
		}
		#Sets variables and returns us to craftman screen
		save_scope_value_as = {
			name = laamp_decision_bought_armor
			value = flag:no
		}
		#Go back to craftsmen district
		hidden_effect = { 1061_return_to_craftsmen_effect = yes }
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < minor_gold_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
			modifier = {
				employs_court_position = armorer_camp_officer
				factor = 0
			}
		}
	}
	#I want to visit another craftsman
	option = {
		name = ep3_laamp_decision_event.1063.e
		#Sets variables and returns us to craftman screen
		1031_been_to_effect = { GUILD = armorer }
		ai_chance = {
			base = 200
			modifier = {
				has_trait = greedy
				factor = 2
			}
		}
	}
	after = {
		if = {
			limit = { scope:laamp_decision_bought_armor ?= flag:no }
			#Appoint them
			if = {
				limit = {
					can_appoint_char_to_court_position = {
						CHAR = scope:laamp_armorer_craftsman
						COURT_POS = armorer_camp_officer
					}
				}
				camp_officer_grant_effect = {
					EMPLOYER = root
					POS = armorer
					CANDIDATE = scope:laamp_armorer_craftsman
				}
			}
		}
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:armorer }
	}
}


#Identify the accessory artifacts
scripted_effect 1065_set_accessory_variable_effect = {
	set_variable = {
		name = 1065_laamp_decision_accessory
		days = visit_settlement_cooldown_days
	}
}

#Set the correct variable to block off the Jeweler option and remove the desc flavor variable
scripted_effect 1065_bought_accessory_effect = {
	scope:1065_first_accessory = { remove_variable ?= 1065_accessory_value }
	scope:1065_second_accessory = { remove_variable ?= 1065_accessory_value }
	scope:1065_third_accessory = { remove_variable ?= 1065_accessory_value }
	save_scope_as = laamp_decision_bought_accessory
	#Simulate shifting inventory
	1061_chance_to_flush_inventory_effect = {
		FIRST_ITEM = scope:1065_first_accessory
		SECOND_ITEM = scope:1065_second_accessory
		THIRD_ITEM = scope:1065_third_accessory
		VENDOR = scope:laamp_jeweler_craftsman
	}
	#Go back to craftsmen district
	hidden_effect = { 1061_return_to_craftsmen_effect = yes }
}


#Visit Jeweler
ep3_laamp_decision_event.1065 = {
	type = character_event
	title = ep3_laamp_decision_event.1065.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			#We've returned to this scene, now what
			#RETURN: Generics
			random_valid = {
				triggered_desc = { 
					trigger = {
						exists = scope:been_to_jeweler
						scope:jeweler_loc_tracker ?= 0 
					}
					desc = ep3_laamp_decision_event.1065.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:jeweler_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1065.desc_returned_02
				}
			}
			#FIRST TIME: We've seen this jeweler before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_jeweler_craftsman
					NOT = { exists = scope:been_to_jeweler }
				}
				desc = ep3_laamp_decision_event.1065.desc_reused_jeweler
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_jeweler }
				}
				desc = ep3_laamp_decision_event.1065.desc
			}	
		}
	}
	theme = stewardship
	override_background = { reference = physicians_study }
	left_portrait = {
		trigger = { exists = scope:visiting_partner }
		character = scope:visiting_partner
		#It kinda makes sense, doesn't it?
		triggered_animation = {
			trigger = {
				exists = scope:been_to_jeweler
				scope:jeweler_loc_tracker ?= 0
			}
			animation = interested
		}
		animation = war_over_tie
	}
	center_portrait = {
		character = root
		#It kinda makes sense, doesn't it?
		triggered_animation = {
			trigger = {
				exists = scope:been_to_jeweler
				scope:jeweler_loc_tracker ?= 0
			}
			animation = disbelief
		}
		animation = thinking
	}
	right_portrait = {
		character = scope:laamp_jeweler_craftsman
		camera = camera_event_scheme_vs_center_look_left
		#It kinda makes sense, doesn't it?
		triggered_animation = {
			trigger = {
				exists = scope:been_to_jeweler
				scope:jeweler_loc_tracker ?= 0
			}
			animation = paranoia
		}
		triggered_animation = {
			trigger = { scope:jeweler_loc_tracker ?= 1 }
			animation = writing
		}
		animation = chess_cocky
	}
	artifact = {
		target = scope:1065_first_accessory
		position = lower_left_portrait
	}
	artifact = {
		target = scope:1065_second_accessory
		position = lower_center_portrait
	}
	artifact = {
		target = scope:1065_third_accessory
		position = lower_right_portrait
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		location.province_owner = { save_scope_as = bg_override_char }
		#Can we _not_ repeat the loc?
		1025_set_and_check_scene_loc_tracker_scope_effect = { SCENE = jeweler }
		#Find our accessories
		if = {
			limit = {
				NOT = { exists = scope:1065_first_accessory }
			}
			scope:laamp_jeweler_craftsman = {
				#Have we created accessories recently, which we can pull?
				if = {
					limit = {
						any_character_artifact ?= { has_variable = 1065_laamp_decision_accessory }
					}
					every_character_artifact = {
						limit = { has_variable = 1065_laamp_decision_accessory }
						add_to_list = list_of_potential_accessories
					}
					random_in_list = {
						list = list_of_potential_accessories
						save_scope_as = 1065_first_accessory
					}
					random_in_list = {
						list = list_of_potential_accessories
						limit = {
							this != scope:1065_first_accessory
						}
						save_scope_as = 1065_second_accessory
					}
					random_in_list = {
						list = list_of_potential_accessories
						limit = {
							NOR = { 
								this = scope:1065_first_accessory
								this = scope:1065_second_accessory
							}
						}
						save_scope_as = 1065_third_accessory
					}
				}
				#If we don't have any old accessories; generate new ones!
				hidden_effect_new_object = { #HAZMAT SUIT OF ERROR SUPRESSION
					if = {
						limit = {
							NOT = { exists = scope:1065_first_accessory }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_armorer_craftsman }
						#Generate accessory
						random_list = {
							50 = {
								create_artifact_brooch_effect = {
									OWNER = scope:laamp_jeweler_craftsman
									SMITH = scope:laamp_jeweler_craftsman
								}
							}
							50 = {
							 	create_artifact_ring_effect = {
									OWNER = scope:laamp_jeweler_craftsman
									SMITH = scope:laamp_jeweler_craftsman
								}
							}
							50 = {
								create_artifact_necklace_effect = {
									OWNER = scope:laamp_jeweler_craftsman
									SMITH = scope:laamp_jeweler_craftsman
								}
							}
						}
					 	#Finalization
						scope:newly_created_artifact ?= {
							1065_set_accessory_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1065_first_accessory
						}
					}
					if = {
						limit = {
							NOT = { exists = scope:1065_second_accessory }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_armorer_craftsman }
						#Generate accessory
						random_list = {
							50 = {
								create_artifact_crown_effect = {
									OWNER = scope:laamp_jeweler_craftsman
									SMITH = scope:laamp_jeweler_craftsman
								}
							}
							50 = {
								create_artifact_regalia_effect = {
									OWNER = scope:laamp_jeweler_craftsman
									SMITH = scope:laamp_jeweler_craftsman
								}
							}
						}
						#Finalization
						scope:newly_created_artifact ?= {
							1065_set_accessory_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1065_second_accessory
						}
					}
					if = {
						limit = {
							NOT = { exists = scope:1065_third_accessory }
						}
						#Set rarity, maybe
						1041_chance_to_buff_item_rarity_effect = { VENDOR = scope:laamp_armorer_craftsman }
						#Generate accessory
						random_list = {
							#Don't need two rings etc
							50 = {
								trigger = {
									NOT = { 
										scope:1065_first_accessory = { artifact_type = brooch }
									}
								}
								create_artifact_brooch_effect = {
									OWNER = scope:laamp_jeweler_craftsman
									SMITH = scope:laamp_jeweler_craftsman
								}
							}
							50 = {
								trigger = {
									NOT = { 
										scope:1065_first_accessory = { artifact_type = ring }
									}
								}
							 	create_artifact_ring_effect = {
									OWNER = scope:laamp_jeweler_craftsman
									SMITH = scope:laamp_jeweler_craftsman
								}
							}
							50 = {
								trigger = {
									NOT = { 
										scope:1065_first_accessory = { artifact_type = necklace }
									}
								}
								create_artifact_necklace_effect = {
									OWNER = scope:laamp_jeweler_craftsman
									SMITH = scope:laamp_jeweler_craftsman
								}
							}
						}
						#Finalization
						scope:newly_created_artifact ?= {
							1065_set_accessory_variable_effect = yes
							1061_buff_item_modifiers_effect = yes
							#Don't need no notification about this
							1020_suppress_artifact_notifications_effect = yes
							save_scope_as = 1065_third_accessory
						}
					}
					#Set the value of the accessories
					scope:1065_first_accessory = { 1041_set_item_value_effect = yes }
					scope:1065_second_accessory = { 1041_set_item_value_effect = yes }
					scope:1065_third_accessory = { 1041_set_item_value_effect = yes }
				}
				#Remember the jeweler
				1010_remember_vendor_character_effect = { GUILD = jeweler CHARACTER = scope:laamp_jeweler_craftsman }
			}
		}
	}
	#Accessory #1
	option = {
		name = ep3_laamp_decision_event.1065.a
		#Pay gold, transfer Accessory
		scope:1065_first_accessory = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1065_bought_accessory_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1065_first_accessory.var:1065_accessory_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Accessory #2
	option = {
		name = ep3_laamp_decision_event.1065.b
		#Pay gold, transfer Accessory
		scope:1065_second_accessory = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1065_bought_accessory_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1065_second_accessory.var:1065_accessory_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#Accessory #3
	option = {
		name = ep3_laamp_decision_event.1065.c
		#Pay gold, transfer Accessory
		scope:1065_third_accessory = { 1061_buy_item_effect = yes }
		#Then set correct variables and reroute us to the craftsmen
		1065_bought_accessory_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				short_term_gold < scope:1065_third_accessory.var:1065_accessory_value
				short_term_gold < laamp_ai_spending_pants_value
				factor = 0
			}
		}
	}
	#I want to visit another craftsman
	option = {
		name = ep3_laamp_decision_event.1065.d
		#Sets variables and returns us to craftman screen
		1031_been_to_effect = { GUILD = jeweler }
		ai_chance = {
			base = 200
			modifier = {
				has_trait = greedy
				factor = 2
			}
		}
	}
	after = {
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:jeweler }
	}
}


#Hire the Quartermaster, show/set the effects and variables 
scripted_effect 1067_hire_quartermaster_effect = {
	hidden_effect = {
		reverse_add_opinion = {
			target = scope:laamp_quartermaster_recruit
			modifier = recruited_me_opinion
			opinion = 30
		}
	}
	add_courtier = scope:laamp_quartermaster_recruit
	#The actual effect happens in after
	show_as_tooltip = {
		camp_officer_grant_effect = {
			EMPLOYER = root
			POS = quartermaster
			CANDIDATE = scope:laamp_quartermaster_recruit
		}
	}
	#This 'finished' is different since it changes between flag:yes and flag:no
	save_scope_value_as = {
		name = laamp_decision_recruited_quartermaster
		value = flag:yes
	}
	#Go back to craftsmen district
	hidden_effect = { 1061_return_to_craftsmen_effect = yes }
}


#Visit Quartermaster
ep3_laamp_decision_event.1067 = {
	type = character_event
	title = ep3_laamp_decision_event.1067.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			#We've returned to this scene, now what
			#RETURN:
			random_valid = {
				triggered_desc = { 
					trigger = { 
						exists = scope:been_to_quartermaster
						scope:quartermaster_loc_tracker ?= 0
					}
					desc = ep3_laamp_decision_event.1067.desc_returned_01
				}
				triggered_desc = { 
					trigger = { scope:quartermaster_loc_tracker ?= 1 }
					desc = ep3_laamp_decision_event.1067.desc_returned_02
				}
				triggered_desc = { 
					trigger = { scope:quartermaster_loc_tracker ?= 2 }
					desc = ep3_laamp_decision_event.1067.desc_returned_03
				}
			}
			#FIRST TIME: We've seen this quartermaster before
			triggered_desc = {
				trigger = {
					exists = scope:laamp_recurring_quartermaster
					NOT = { exists = scope:been_to_quartermaster }
				}
				desc = ep3_laamp_decision_event.1067.desc_reused_quartermaster
			}
			#FIRST TIME:
			triggered_desc = {
				trigger = {
					NOT = { exists = scope:been_to_quartermaster }
				}
				desc = ep3_laamp_decision_event.1067.desc
			}	
		}
	}
	theme = landless_adventurer
	override_sound = { reference = "event:/MUSIC/Cues/Events/Positive/mx_cue_postive_effect" }
	override_background = { reference = tavern }
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:laamp_quartermaster_recruit
		animation = drink_goblet
	}
	immediate = {
		#To prevent the character, for whatever reason, managing to not have the variable be removed when exiting VS
		temporarily_lock_visit_settlement_effect = yes
		#Run this once: Re-save the portrait so the Quartermaster is not the 1060_third_character (since they narratively moved to the tavern)
		if = {
			limit = { scope:1060_third_character = scope:laamp_quartermaster_recruit }
			#Overwrite the portrait with ROOT to disable it
			save_scope_as = 1060_third_character
			#Remember the Quartermaster
			1010_remember_vendor_character_effect = { GUILD = quartermaster CHARACTER = scope:laamp_quartermaster_recruit }
		}
		#Can we _not_ repeat the loc?
		1025_set_and_check_hub_loc_tracker_scope_effect = { HUB = quartermaster } #This is only a hub because it has 3 random locs
	}
	#Pay up
	option = {
		name = ep3_laamp_decision_event.1067.a
		pay_short_term_gold = {
			target = scope:laamp_quartermaster_recruit
			gold = minor_gold_value
		}
		#Wrap effect to hire 'em and also set up variables
		1067_hire_quartermaster_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				any_courtier = { count >= many_followers_value }
				factor = 0
			}
		}
	}
	#I have a sizeable camp for you to manage
	option = {
		name = ep3_laamp_decision_event.1067.b
		trigger = {
			custom_tooltip = {
				text = not_enough_followers.tt
				any_courtier = { count >= many_followers_value }
			}
		}
		reason = many_followers
		#_Oh noes_
		show_as_unavailable = { always = yes }
		#Wrap effect to hire 'em and also set up variables
		1067_hire_quartermaster_effect = yes
		ai_chance = {
			base = 1000 #Just do it
		}
	}
	#Intrigue duel
	option = {
		name = ep3_laamp_decision_event.1067.c
		duel = {
			skill = intrigue
			value = average_skill_rating
			#Success: Hire 'em up
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = ep3_laamp_decision_event.1067.c.success
				send_interface_toast = {
					title = ep3_laamp_decision_event.1067.c.success
					left_icon = root
					right_icon = scope:laamp_quartermaster_recruit
					#Yippee!
					1067_hire_quartermaster_effect = yes
				}
			}
			#Failure: Bye, now
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}	
				desc = ep3_laamp_decision_event.1067.c.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = ep3_laamp_decision_event.1067.c.failure
					desc = ep3_laamp_decision_event.1067.c.failure.tt
					left_icon = root
					right_icon = scope:laamp_quartermaster_recruit
					#Oh well
					custom_tooltip = ep3_laamp_decision_event.1067.c.failure.tt
					#This 'finished' is different since it changes between flag:yes and flag:no
					save_scope_value_as = {
						name = laamp_decision_recruited_quartermaster
						value = flag:no
					}
					1061_return_to_craftsmen_effect = yes
				}
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				any_courtier = { count >= many_followers_value }
				factor = 0
			}
		}
	}
	#Let's not
	option = {
		name = ep3_laamp_decision_event.1067.d
		#Sets variables and returns us to craftman screen
		1031_been_to_effect = { GUILD = quartermaster }
		ai_chance = {
			base = 100
			modifier = {
				any_courtier = { count >= many_followers_value }
				factor = 0
			}
		}
	}
	after = {
		if = {
			limit = { scope:laamp_decision_recruited_quartermaster ?= flag:yes }
			#Appoint them
			if = {
				limit = {
					can_appoint_char_to_court_position = {
						CHAR = scope:laamp_quartermaster_recruit
						COURT_POS = quartermaster_camp_officer
					}
				}
				camp_officer_grant_effect = {
					EMPLOYER = root
					POS = quartermaster
					CANDIDATE = scope:laamp_quartermaster_recruit
				}
			}
		}
		#What was our last location
		1000_update_last_location_effect = { LOCATION_FLAG = flag:quartermaster }
	}
}


######################################################################
# END
######################################################################


#Seasoned Visitor Decision

scripted_effect 1100_book_creation_effect = {
	if = {
		limit = {
			has_variable = poi_visited
		}
		if = {
			limit = {
				artifacts_use_indian_books_trigger = yes
			}
			create_artifact = {
				name = marco_polo_book_title
				type = journal
				template = marco_polo_book
				creator = root
				description = marco_polo_book_desc 
				visuals = indian_book
				save_scope_as = newly_created_artifact
				modifier = artifact_monthly_prestige_1_modifier
				wealth = 50
				quality = 10
			}
		}
		else = {
			create_artifact = {
				name = marco_polo_book_title
				type = journal
				template = marco_polo_book
				creator = root
				description = marco_polo_book_desc 
				visuals = book
				save_scope_as = newly_created_artifact
				modifier = artifact_monthly_prestige_1_modifier
				wealth = 50
				quality = 10
			}
		}
		hidden_effect = {
			if = {
				limit = {
					var:poi_visited >= 60
				}
				scope:newly_created_artifact = {
					add_artifact_modifier = artifact_monthly_lifestyle_xp_4_modifier
					set_artifact_rarity = illustrious
				}
			}
			else_if = {
				limit = {
					var:poi_visited >= 48
				}
				scope:newly_created_artifact = {
					add_artifact_modifier = artifact_monthly_lifestyle_xp_3_modifier
					set_artifact_rarity = famed
				}
			}
			else_if = {
				limit = {
					var:poi_visited >= 36
				}
				scope:newly_created_artifact = {
					add_artifact_modifier = artifact_monthly_lifestyle_xp_2_modifier
					set_artifact_rarity = masterwork
				}
			}
			else_if = {
				limit = {
					var:poi_visited >= 24
				}
				scope:newly_created_artifact = {
					add_artifact_modifier = artifact_monthly_lifestyle_xp_1_modifier
					set_artifact_rarity = common
				}
			}
	
			scope:newly_created_artifact = {
				remove_artifact_modifier = artifact_monthly_prestige_1_modifier
			}
		}
	}
}

scripted_effect 1100_lifestyle_perk_effect = {
	if = {
		limit = {
			has_variable = poi_visited
		}
		if = {
			limit = {
				var:poi_visited >= 56
			}
			add_relevant_lifestyle_perk_point_effect = { NUMBER = 5 }
		}
		else_if = {
			limit = {
				var:poi_visited >= 48
			}
			add_relevant_lifestyle_perk_point_effect = { NUMBER = 4 }
		}
		else_if = {
			limit = {
				var:poi_visited >= 40
			}
			add_relevant_lifestyle_perk_point_effect = { NUMBER = 3 }
		}
		else_if = {
			limit = {
				var:poi_visited >= 32
			}
			add_relevant_lifestyle_perk_point_effect = { NUMBER = 2 }
		}
		else_if = {
			limit = {
				var:poi_visited >= 24
			}
			add_relevant_lifestyle_perk_point_effect = { NUMBER = 1 }
		}
	}
}

ep3_laamp_decision_event.1100 = {
	type = character_event
	title = ep3_laamp_decision_event.1100.t
	desc = ep3_laamp_decision_event.1100.desc
	window = visit_settlement_window
	theme = travel
	override_background = { reference = relaxing_room }

	left_portrait = {
		character = root
		animation = writing
	}

	immediate = {
		add_character_flag = had_seasoned_visitor_decision
	}

	option = { #I will take it to my grave
		name = ep3_laamp_decision_event.1100.a
		flavor = ep3_laamp_decision_event.1100.a.flavor
		custom_tooltip = ep3_laamp_decision_event.1100.a.desc
		1100_lifestyle_perk_effect = yes

		ai_chance = {
			base = 50
		}
	}

	option = { #I will write it down for future generations
		name = ep3_laamp_decision_event.1100.b
		flavor = ep3_laamp_decision_event.1100.b.flavor
		1100_book_creation_effect = yes
		custom_tooltip = ep3_laamp_decision_event.1100.b.desc

		ai_chance = {
			base = 100
		}
	}

	option = { #Postpone the decision
		name = ep3_laamp_decision_event.1100.c
		flavor = ep3_laamp_decision_event.1100.c.flavor
		custom_tooltip = ep3_laamp_decision_event.1100.c.desc

		remove_character_flag = had_seasoned_visitor_decision

		hidden_effect = {
			add_prestige_no_experience = 1500
			add_gold = 500
		}

		ai_chance = {
			base = 0
		}
	}
}

#Zealous Missionary Decision

ep3_laamp_decision_event.1101 = {
	type = character_event
	title = ep3_laamp_decision_event.1101.t
	desc = ep3_laamp_decision_event.1101.desc
	window = visit_settlement_window
	theme = faith
	override_background = { reference = holy_site_generic }

	left_portrait = {
		character = root
		animation = prayer
	}

	override_effect_2d = {
		reference = legend_glow
	}

	immediate = {
		location = {
			save_scope_as = holy_site_location
		}
		set_variable = {
			name = holy_site_ascension
			value = scope:holy_site_location
		}
	}

	option = {
		name = ep3_laamp_decision_event.1101.a
		custom_tooltip = ep3_laamp_decision_event.1101.a.desc
	}
}

ep3_laamp_decision_event.1102 = {
	type = character_event
	title = ep3_laamp_decision_event.1102.t
	desc = ep3_laamp_decision_event.1102.desc
	window = visit_settlement_window
	theme = faith
	override_background = { reference = terrain }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				learning >= 12
			}
			animation = prayer
		}
		animation = personality_zealous
	}

	immediate = {
		add_character_flag = zealous_missionary_start
	}

	trigger = {
		has_variable = holy_site_ascension
	}

	option = {
		name = ep3_laamp_decision_event.1102.a
		give_nickname = nick_the_missionary
		custom_tooltip = ep3_laamp_decision_event.1102.a.desc
		add_character_flag = {
			flag = zealous_missionary_timer
			years = 10
		}
		trigger_event = ep3_laamp_decision_event.1103
		trigger_event = {
			id = ep3_laamp_decision_event.1104
			months = 122 #2 months after the timer runs out
		}
		set_variable = {
			name = num_counties_converted
			value = 0
		}

		ai_chance = {
			base = 100
		}
	}

	option = {
		name = ep3_laamp_decision_event.1102.b
		custom_tooltip = ep3_laamp_decision_event.1102.b.desc
		remove_character_flag = zealous_missionary_start
		ai_chance = {
			base = 0
		}
	}
	
}
ep3_laamp_decision_event.1103 = {
	type = character_event
	title = ep3_laamp_decision_event.1103.t
	window = visit_settlement_window
	desc = {
		random_valid = {
			triggered_desc = {
				trigger = { scope:current_location.county.faith = scope:current_location.county.holder.faith }
				desc = ep3_laamp_decision_event.1103.desc
			}
			desc = ep3_laamp_decision_event.1103.desc.alternative
		}
	}
	theme = faith
	override_background = { reference = terrain }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				martial >= 12
			}
			animation = inspect_weapon
		}
		triggered_animation = {
			trigger = {
				learning >= 12
			}
			animation = prayer
		}
		triggered_animation = {
			trigger = {
				always = yes
			}
			animation = personality_zealous
		}
	}

	immediate = {
		location = {
			save_scope_as = current_location
		}
	}

	trigger = { #Double safeguard
		has_character_flag = zealous_missionary_timer
		government_has_flag = government_is_landless_adventurer
		location ?= {
			has_holding = yes
		}
		NOT = {
			location.faith = root.faith
			is_ai = yes
			any_player = {
				OR = {
					this = location.county.holder
					this = location.county.holder.top_liege
				}
			}
		}
	}

	option = { #pray very hard
		name = {
			text = {
				random_valid = {
					desc = ep3_laamp_decision_event.1103.a
					desc = ep3_laamp_decision_event.1103.a.alternative
				}
			}
		}
		custom_tooltip = ep3_laamp_decision_event.1103.difficulty.desc
		custom_tooltip = ep3_laamp_decision_event.1103.a.desc

		duel = {
			skills = { diplomacy learning }
			value = very_high_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = {
						subtract = location.county.county_opinion
					}
				}
				modifier = {
					factor = 0.75
					location.county.faith.religion = root.religion
				}
				modifier = {
					factor = 0.75
					knows_language_of_culture = location.county.culture
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ep3_laamp_decision_event.1103.a.success
					left_icon = root
					right_icon = location.county
					location.county = {
						set_county_faith = root.faith
					}
					ep3_hasan_advance_radicalism = yes
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					add = location.county.development_level
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ep3_laamp_decision_event.1103.a.failure
					left_icon = root
					right_icon = location.county
					add_stress = major_stress_gain
				}
			}
		}
		add_stress = miniscule_stress_gain
		add_piety = {
			value = 10
			multiply = location.county.development_level
			min = 20
		}

		reverse_add_opinion = {
			modifier = vengeful_opinion
			opinion = -75
			target = location.county.holder
		}

		ai_chance = {
			base = 25
			modifier = {
				add = root.learning
			}
		}
	}

	option = {
		trigger = {
			root.faith = {
				NOR = {
					has_doctrine = tenet_dharmic_pacifism
					has_doctrine = tenet_pacifism
				}
			}

		}
		name = {
			text = {
				random_valid = {
					desc = ep3_laamp_decision_event.1103.b
					desc = ep3_laamp_decision_event.1103.b.alternative
				}
			}
		}
		flavor = ep3_laamp_decision_event.1103.b.flavor
		custom_tooltip = ep3_laamp_decision_event.1103.difficulty.desc
		custom_tooltip = ep3_laamp_decision_event.1103.b.desc

		duel = {
			skills = { martial intrigue }
			value = high_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					add = {
						value = root.number_of_knights
						multiply = 10
					}
				}
				modifier = {
					add = root.current_military_strength
				}
				modifier = {
					factor = 1.2
					root.faith = {
						has_doctrine = tenet_armed_pilgrimages
					}
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ep3_laamp_decision_event.1103.a.success
					left_icon = root
					right_icon = location.county
					location.county = {
						set_county_faith = root.faith
					}
					ep3_hasan_advance_radicalism = yes
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					add = location.county.development_level
				}
				modifier = {
					add = location.barony.building_max_garrison
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ep3_laamp_decision_event.1103.a.failure
					left_icon = root
					right_icon = location.county
					increase_wounds_effect = { REASON = fight }
					random_courtier ?= {
						increase_wounds_effect = { REASON = fight }
					}
				}
			}
		}

		add_piety = 50
		reverse_add_opinion = {
			modifier = vengeful_opinion
			opinion = -75
			target = location.county.holder
		}


		ai_chance = {
			base = 50
			modifier = {
				add = {
					value = root.current_military_strength
					multiply = 0.1
				}
			}
			modifier = {
				add = {
					value = location.barony.building_max_garrison
					multiply = -0.1
				}
			}
			modifier = {
				add = root.martial
			}
		}
	}

	option = {
		name = {
			text = {
				random_valid = {
					desc = ep3_laamp_decision_event.1103.c
					desc = ep3_laamp_decision_event.1103.c.alternative
				}
			}
		}
		flavor = ep3_laamp_decision_event.1103.c.flavor

		custom_tooltip = ep3_laamp_decision_event.1103.c.desc

		add_stress = minor_stress_gain

		ai_chance = {
			base = 0
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = {
					location.county.faith ?= root.faith
					exists = var:num_counties_converted
				}
				change_variable = {
					name = num_counties_converted
					add = 1
				}
			}
		}
	}
}

ep3_laamp_decision_event.1104 = {
	type = character_event
	title = ep3_laamp_decision_event.1104.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:success
				}
				desc = ep3_laamp_decision_event.1104.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:failure
				}	
				desc = ep3_laamp_decision_event.1104.desc.failure
			}
		}
	}
	theme = faith
	override_background = { reference = terrain }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				exists = scope:success
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				exists = scope:failure
			}
			animation = shame
		}
	}

	override_effect_2d = {
		trigger = {
			exists = scope:success
		}	
		reference = legend_glow
	}

	override_effect_2d = {
		trigger = {
			exists = scope:failure
		}
		reference = rain
	}

	trigger = {
		has_variable = zealous_missionary_start
		NOT = {
			has_variable = zealous_missionary_timer
		}
	}

	immediate = {
		if = {
			limit = {
				has_variable = num_counties_converted
				var:num_counties_converted >= 3
			}
			save_scope_as = success
		}
		else = {
			save_scope_as = failure
		}
	}

	option = {
		trigger = {
			exists = scope:success
		}
		name = ep3_laamp_decision_event.1104.a
		add_piety = omega_piety_gain
		add_trait = saint
	}

	option = {
		trigger = {
			exists = scope:failure
		}
		name = ep3_laamp_decision_event.1104.b

		add_stress = monumental_stress_gain
		add_piety_level = -5
		if = {
			limit = {
				has_nickname = nick_the_missionary
			}
			remove_nickname = yes
			give_nickname = nick_the_unworthy
		}
	}
	
}

ep3_laamp_decision_event.1110 = {
	type = character_event
	title = ep3_laamp_decision_event.1110.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:first_kill }
				desc = ep3_laamp_decision_event.1110.desc.has_kill
			}
			desc = ep3_laamp_decision_event.1110.desc.hasnt_kill
		}
		desc = ep3_laamp_decision_event.1110.desc.outro
	}

	theme = war

	left_portrait = {
		character = root
		animation = celebrate_sword
	}

	override_background = { reference = battlefield }

	override_effect_2d = {	
		reference = legend_glow
	}

	immediate = {
		ordered_killed_character = {
			order_by = days_since_death
			save_scope_as = first_kill
		}
	}

	option = {
		name = ep3_laamp_decision_event.1110.a
		flavor = ep3_laamp_decision_event.1110.a.flavor
		custom_tooltip = ep3_laamp_decision_event.1110.a.desc
		add_character_flag = had_laamp_conq_decision
		trigger_event = {
			id = conqueror.0001
			months = 4
		}
		spawn_army = {
			men_at_arms = {
				type = accolade_maa_vanguards
				stacks = 2
			}
			men_at_arms = {
				type = accolade_maa_lancers
				stacks = 2
			}
			men_at_arms = {
				type = accolade_maa_archers
				stacks = 4
			}
			inheritable = no
			uses_supply = no
			location = root.location
			name = event_troop_default_name
		}
		if = {
			limit = {
				exists = location.kingdom.holder
			}
			add_pressed_claim = location.kingdom
			start_war = {
				cb = ep3_laamp_adventurer_kingdom_invasion
				target = location.kingdom.holder
				claimant = root
				target_title = location.kingdom
				target_title = location.kingdom.title_capital_county
			}
		}
		else_if = {
			limit = {
				exists = location.duchy.holder
			}
			add_pressed_claim = location.duchy
			start_war = {
				cb = claim_cb
				target = location.duchy.holder
				claimant = root
				target_title = location.duchy
				target_title = location.duchy.title_capital_county
			}
		}
		else_if = {
			limit = {
				exists = location.county.holder
			}
			add_pressed_claim = location.county
			start_war = {
				cb = claim_cb
				target = location.county.holder
				claimant = root
				target_title = location.county
			}
		}
		if = {
			limit = { has_dlc_feature = legends }
			create_legend_seed = {
				type = heroic
				quality = famed
				chronicle = conqueror_chronicle
			}
		}
	}
}

ep3_laamp_decision_event.1120 = {
	type = character_event
	title = ep3_laamp_decision_event.1120.t
	window = visit_settlement_window
	desc = ep3_laamp_decision_event.1120.desc

	theme = intrigue

	left_portrait = {
		character = root
		animation = personality_dishonorable
	}

	override_background = { reference = alley_night }

	override_effect_2d = {	
		reference = fog
	}

	
	immediate = {
		become_bandit_king_decision_effect = yes
		set_variable = {
			name = maa_number
			value = 0
		}
	}

	option = {
		name = ep3_laamp_decision_event.1120.a
		flavor = ep3_laamp_decision_event.1120.a.flavor

		set_variable = { #error spam prevention
			name = maa_number
			value = 0
		}

		bandit_king_maa_spawn_effect = yes
	}
}

ep3_laamp_decision_event.1130 = { #begin city construction
	type = character_event
	title = ep3_laamp_decision_event.1130.t
	window = big_event_window
	desc = ep3_laamp_decision_event.1130.desc

	theme = stewardship

	override_background = { reference = terrain }

	left_portrait = {
		character = root
		animation = survey
	}

	immediate = {
		location = {
			set_variable = laamp_city_construction
			save_scope_as = city_location
		}
	}

	option = { #less go
		name = ep3_laamp_decision_event.1130.a
		custom_tooltip = ep3_laamp_decision_event.1130.a.desc
		add_character_flag = laamp_city_builder
		scope:city_location = {
			if = {
				limit = {
					root = { has_variable = city_construction_is_temple_citadel }
				}
				begin_create_holding = { type = temple_citadel_holding }
			}
			else = {
				begin_create_holding = { type = castle_holding }
			}
		}

		trigger_event = {
			id = ep3_laamp_decision_event.1131
			months = 1 # Checked monthly in trigger_fail for event
		}
		trigger_event = {
			id = ep3_laamp_decision_event.1133
			months = { 4 6 }
		}

		ai_chance = {
			base = 10
		}
	}

	option = { #I'm a silly goose, nvm
		name = ep3_laamp_decision_event.1130.b
		add_gold = 400

		ai_chance = {
			base = 0
		}
	}
}

ep3_laamp_decision_event.1131 = { #city is finished, wat do
	type = character_event
	title = ep3_laamp_decision_event.1131.t
	window = big_event_window
	desc = ep3_laamp_decision_event.1131.desc

	theme = stewardship

	override_background = { 
		trigger = {
			location = {
				culture = { has_building_gfx = southeast_asian_building_gfx }
			}
		}
		reference = mpo_rural_village_asian
	}
	override_background = { reference = alley_day }

	left_portrait = {
		character = root
		animation = happiness
	}

	trigger = {
		scope:city_location = {
			OR = {
				has_holding_type = temple_citadel_holding
				has_holding_type = castle_holding
			}
		}
	}

	immediate = { #reward building spawn
		save_scope_value_as = {
			name = year_of_construction
			value = current_year
		}

		if = {
			limit = { 
				scope:city_location = { has_holding_type = temple_citadel_holding }
			}
			laamp_city_builder_construction_effect = {
				FLAG = mill
				BUILDING = watermills
			}
			laamp_city_builder_construction_effect = {
				FLAG = temple_citadel
				BUILDING = temple_citadel
			}
			laamp_city_builder_construction_effect = {
				FLAG = manor
				BUILDING = farm_estates
			}
			laamp_city_builder_construction_effect = {
				FLAG = spice_plantation
				BUILDING = spice_plantation
			}
			laamp_city_builder_construction_effect = {
				FLAG = vihara_halls
				BUILDING = vihara_halls
			}
		}
		else = {
			laamp_city_builder_construction_effect = {
				FLAG = mill
				BUILDING = watermills
			}
			laamp_city_builder_construction_effect = {
				FLAG = castle
				BUILDING = castle
			}
			laamp_city_builder_construction_effect = {
				FLAG = manor
				BUILDING = farm_estates
			}
			laamp_city_builder_construction_effect = {
				FLAG = workshops
				BUILDING = workshops
			}
			laamp_city_builder_construction_effect = {
				FLAG = prayer_hall
				BUILDING = monastic_schools
			}
		}
		
	}

	on_trigger_fail = {
		if = {
			limit = {
				scope:city_location = { #somehow, the city is still being built
					has_ongoing_construction = yes
					has_holding = no
				}
			}
			trigger_event = {
				id = ep3_laamp_decision_event.1131
				months = 1
			}
		}
	}

	option = { #well, actually imma get the whole county
		name = ep3_laamp_decision_event.1131.a

		set_variable = {
			name = holding_barony
			value = scope:city_location.barony
		}
		add_pressed_claim = scope:city_location.county
		add_pressed_claim = scope:city_location.barony
		add_character_flag = temp_no_claim_war_cost
		start_war = {
			cb = claim_cb
			target = scope:city_location.county.holder
			claimant = root
			target_title = scope:city_location.county
			target_title = scope:city_location.barony
		}
		remove_character_flag = temp_no_claim_war_cost

		ai_chance = {
			base = 0
		}
	}

	option = { #the city existence is a reward enough
		name = ep3_laamp_decision_event.1131.b
		add_prestige = 2000
		give_nickname = nick_the_city_builder
		custom_tooltip = ep3_laamp_decision_event.1131.b.desc
		trigger_event = {
			id = ep3_laamp_decision_event.1140
			months = { 1 1 }
		}
		remove_character_flag = laamp_city_builder
		remove_variable = city_construction_is_temple_citadel
		remove_variable = city_construction_is_castle

		ai_chance = {
			base = 10
		}
	}

	after = {
		remove_character_flag = laamp_city_builder_mill
		remove_character_flag = laamp_city_builder_mill_upgrade
		remove_character_flag = laamp_city_builder_temple_citadel
		remove_character_flag = laamp_city_builder_temple_citadel_upgrade
		remove_character_flag = laamp_city_builder_castle
		remove_character_flag = laamp_city_builder_castle_upgrade
		remove_character_flag = laamp_city_builder_manor
		remove_character_flag = laamp_city_builder_manor_upgrade
		remove_character_flag = laamp_city_builder_spice_plantation
		remove_character_flag = laamp_city_builder_spice_plantation_upgrade
		remove_character_flag = laamp_city_builder_workshops
		remove_character_flag = laamp_city_builder_workshops_upgrade
		remove_character_flag = laamp_city_builder_vihara_halls
		remove_character_flag = laamp_city_builder_vihara_halls_upgrade
		remove_character_flag = laamp_city_builder_prayer_hall
		remove_character_flag = laamp_city_builder_prayer_hall_upgrade
	}
	
}

scripted_trigger 1133_holding_still_under_construction_trigger = {
	scope:city_location = {
		has_ongoing_construction = yes
		NOR = {
			has_holding_type = temple_citadel_holding
			has_holding_type = castle_holding
		}
	}
}

ep3_laamp_decision_event.1133 = { #get a mill
	type = character_event
	title = ep3_laamp_decision_event.1133.t
	window = visit_settlement_window
	desc = ep3_laamp_decision_event.1133.desc

	theme = stewardship

	override_background = { reference = terrain }

	left_portrait = {
		character = root
		animation = survey
	}

	trigger = {
		1133_holding_still_under_construction_trigger = yes
		OR = {
			stewardship >= 18
			has_trait = architect
		}
	}

	on_trigger_fail = {
		trigger_event = {
			id = ep3_laamp_decision_event.1134
			months = { 4 6 }
		}
	}

	option = { #cool
		name = ep3_laamp_decision_event.1133.a
		add_character_flag = laamp_city_builder_mill
		show_as_tooltip = {
			scope:city_location = {
				add_building = watermills_01
			}
		}
		remove_short_term_gold = 80

		ai_chance = {
			base = 0
		}

	}

	option = { #go for it!
		name = ep3_laamp_decision_event.1133.b
		add_character_flag = laamp_city_builder_mill_upgrade
		show_as_tooltip = {
			scope:city_location = {
				add_building = watermills_03
			}
		}
		remove_short_term_gold = 200

		ai_chance = {
			base = 10
		}
	}

	option = { #nah
		name = ep3_laamp_decision_event.1133.c

		ai_chance = {
			base = 0
		}
	}

	after = {
		trigger_event = {
			id = ep3_laamp_decision_event.1134
			months = { 4 6 }
		}
	}
	
}

ep3_laamp_decision_event.1134 = { #get more settlers, main building upgrade
	type = character_event
	title = ep3_laamp_decision_event.1134.t
	window = visit_settlement_window
	desc = ep3_laamp_decision_event.1134.desc

	theme = stewardship

	override_background = { reference = terrain }

	left_portrait = {
		character = root
		animation = survey
	}

	trigger = {
		1133_holding_still_under_construction_trigger = yes
		OR = {
			piety_level >= 3
			prestige_level >= 3
		}
	}

	on_trigger_fail = {
		trigger_event = {
			id = ep3_laamp_decision_event.1135
			months = { 4 6 }
		}
	}

	option = { #cool
		name = ep3_laamp_decision_event.1134.a
		if = {
			limit = { has_variable = city_construction_is_temple_citadel }
			add_character_flag = laamp_city_builder_temple_citadel
			scope:city_location = {
				show_as_tooltip = { add_building = temple_citadel_02 }
			}
		}
		else = {
			add_character_flag = laamp_city_builder_castle
			scope:city_location = {
				show_as_tooltip = { add_building = castle_02 }
			}
		}
		remove_short_term_gold = {
			value = {
				add = medium_gold_value
				multiply = 2
			}
		} 
		if = {
			limit = {
				piety_level >= 3
			}
			add_piety = -300
		}
		else = {
			add_prestige = -300
		}

		ai_chance = {
			base = 0
		}

	}

	option = { #go for it!
		name = ep3_laamp_decision_event.1134.b
		if = {
			limit = { has_variable = city_construction_is_temple_citadel }
			add_character_flag = laamp_city_builder_temple_citadel_upgrade
			scope:city_location = {
				show_as_tooltip = { add_building = temple_citadel_03 }
			}
		}
		else = {
			add_character_flag = laamp_city_builder_castle_upgrade
			scope:city_location = {
				show_as_tooltip = { add_building = castle_03 }
			}
		}
		remove_short_term_gold = {
			value = {
				add = major_gold_value
				multiply = 2
			}
		}
		if = {
			limit = {
				piety_level >= 3
			}
			add_piety = -500
		}
		else = {
			add_prestige = -500
		}

		ai_chance = {
			base = 10
		}
	}

	option = { #nah
		name = ep3_laamp_decision_event.1134.c

		ai_chance = {
			base = 0
		}
	}

	after = {
		trigger_event = {
			id = ep3_laamp_decision_event.1135
			months = { 4 6 }
		}
	}
	
}

ep3_laamp_decision_event.1135 = { #argue for more favorable land assigment from county ruler, get manor houses building
	type = character_event
	title = ep3_laamp_decision_event.1135.t
	window = visit_settlement_window
	desc = ep3_laamp_decision_event.1135.desc

	theme = stewardship

	override_background = { reference = terrain }

	left_portrait = {
		character = root
		animation = survey
	}

	right_portrait = {
		character = scope:city_location.county.holder
		animation = thinking
	}

	trigger = {
		1133_holding_still_under_construction_trigger = yes
		scope:city_location.county.holder = {
			reverse_opinion = {
				target = root
				value >= 40
			}
		}
		NOR = {
			scope:city_location = {
				terrain = desert
				terrain = desert_mountains
			}
		}
	}

	option = { #cool
		name = ep3_laamp_decision_event.1135.a
		add_character_flag = laamp_city_builder_manor
		show_as_tooltip = {
			scope:city_location = {
				add_building = farm_estates_01
			}
		}
		pay_short_term_gold = {
			target = scope:city_location.county.holder
			gold = 80
		}
		remove_short_term_gold = 60

		ai_chance = {
			base = 0
		}
	}

	option = { #go for it!
		name = ep3_laamp_decision_event.1135.b
		add_character_flag = laamp_city_builder_manor_upgrade
		show_as_tooltip = {
			scope:city_location = {
				add_building = farm_estates_03
			}
		}
		pay_short_term_gold = {
			target = scope:city_location.county.holder
			gold = 120
		}
		remove_short_term_gold = 220

		ai_chance = {
			base = 10
		}
	}

	option = { #nah
		name = ep3_laamp_decision_event.1135.c

		ai_chance = {
			base = 0
		}
	}
	
}

ep3_laamp_decision_event.1136 = { #utilize connections, get merchant building
	type = character_event
	title = ep3_laamp_decision_event.1136.t
	window = visit_settlement_window
	desc = ep3_laamp_decision_event.1136.desc

	orphan = yes

	theme = stewardship

	override_background = { reference = terrain }

	left_portrait = {
		character = root
		animation = survey
	}

	trigger = {
		1133_holding_still_under_construction_trigger = yes
		prestige_level >= 3
	}

	on_trigger_fail = {
		trigger_event = {
			id = ep3_laamp_decision_event.1137
			months = { 4 6 }
		}
	}

	option = { #cool
		name = ep3_laamp_decision_event.1136.a
		if = {
			limit = { has_variable = city_construction_is_temple_citadel }
			add_character_flag = laamp_city_builder_spice_plantation
			scope:city_location = {
				show_as_tooltip = { add_building = spice_plantation_01 }
			}
		}
		else = {
			add_character_flag = laamp_city_builder_workshops
			scope:city_location = {
				show_as_tooltip = { add_building = workshops_01 }
			}
		}
		add_prestige = -400
		remove_short_term_gold = 120

		ai_chance = {
			base = 0
		}

	}

	option = { #go for it!
		name = ep3_laamp_decision_event.1136.b
		if = {
			limit = { has_variable = city_construction_is_temple_citadel }
			add_character_flag = laamp_city_builder_spice_plantation_upgrade
			scope:city_location = {
				show_as_tooltip = { add_building = spice_plantation_03 }
			}
		}
		else = {
			add_character_flag = laamp_city_builder_workshops_upgrade
			scope:city_location = {
				show_as_tooltip = { add_building = workshops_03 }
			}
		}
		add_prestige = -600
		remove_short_term_gold = 200

		ai_chance = {
			base = 10
		}
	}

	option = { #nah
		name = ep3_laamp_decision_event.1136.c

		ai_chance = {
			base = 0
		}
	}

	after = {
		trigger_event = {
			id = ep3_laamp_decision_event.1137
			months = { 4 6 }
		}
	}
	
}

ep3_laamp_decision_event.1137 = { #utilize connections, get prayer hall
	type = character_event
	title = ep3_laamp_decision_event.1137.t
	window = visit_settlement_window
	desc = ep3_laamp_decision_event.1137.desc

	theme = stewardship

	override_background = { reference = terrain }

	left_portrait = {
		character = root
		animation = survey
	}

	trigger = {
		1133_holding_still_under_construction_trigger = yes
		piety_level >= 3
	}

	option = { #cool
		name = ep3_laamp_decision_event.1137.a
		if = {
			limit = { has_variable = city_construction_is_temple_citadel }
			add_character_flag = laamp_city_builder_vihara_halls
			scope:city_location = {
				show_as_tooltip = { add_building = vihara_halls_01 }
			}
		}
		else = {
			add_character_flag = laamp_city_builder_prayer_hall
			scope:city_location = {
				show_as_tooltip = { add_building = monastic_schools_01 }
			}
		}
		add_piety = -400
		remove_short_term_gold = 120

		ai_chance = {
			base = 0
		}

	}

	option = { #go for it!
		name = ep3_laamp_decision_event.1137.b
		if = {
			limit = { has_variable = city_construction_is_temple_citadel }
			add_character_flag = laamp_city_builder_vihara_halls_upgrade
			scope:city_location = {
				show_as_tooltip = { add_building = vihara_halls_03 }
			}
		}
		else = {
			add_character_flag = laamp_city_builder_prayer_hall_upgrade
			scope:city_location = {
				show_as_tooltip = { add_building = monastic_schools_03 }
			}
		}
		add_piety = -600
		remove_short_term_gold = 200

		ai_chance = {
			base = 10
		}
	}

	option = { #nah
		name = ep3_laamp_decision_event.1137.c

		ai_chance = {
			base = 0
		}
	}
	
}

ep3_laamp_decision_event.1140 = { #city pays dividend
	hidden = yes

	trigger = {
		has_government = landless_adventurer_government
		current_year <= laamp_city_construction_year_value
	}

	immediate = {
		send_interface_toast = {
			type = event_toast_effect_good
			title = ep3_laamp_decision_event.1140.toast
			left_icon = scope:city_location.barony
			add_gold = {
				value = 0
				add = {
					value = 4
					multiply = scope:city_location.combined_building_level
				}
				add = {
					value = 3
					multiply = scope:city_location.county.development_level
				}
				multiply = { # Slowly decrease over time, by 1% every year
					value = {
						value = laamp_city_construction_year_value
						subtract = current_year
						divide = 100
					}
				}
				min = 25
				max = 200
			}
		}
		primary_title.holder ?= {
			trigger_event = {
				id = ep3_laamp_decision_event.1140
				months = { 11 13 }
			}
		}
	}	
}

##################################################
# Butcher Animals
# by Ewan Cowhig Croft
# 1201 - 1210
##################################################

scripted_effect 1201_prune_dog_stories_effect = {
	remove_dog_story_modifiers_effect = yes
	random_owned_story = {
		type = story_cycle_pet_dog
		hidden_effect = { end_story = yes }
	}
}


#	Your camp eats its dogs.
ep3_laamp_decision_event.1201 = {
	type = character_event
	title = ep3_laamp_decision_event.1201.t
	desc = {
		desc = ep3_laamp_decision_event.1201.desc.intro
		first_valid = {
			# There's a whole kennels being eaten, including our dog.
			triggered_desc = {
				trigger = {
					exists = scope:kennels_gone
					has_character_modifier = dog_story_modifier
				}
				desc = ep3_laamp_decision_event.1201.desc.eaten.kennels.have_dog
			}
			# There's a whole kennels being eaten, but we lack a dog.
			triggered_desc = {
				trigger = { exists = scope:kennels_gone }
				desc = ep3_laamp_decision_event.1201.desc.eaten.kennels.no_dog
			}
			# There's one dog being eaten, and it's ours.
			triggered_desc = {
				trigger = {
					scope:dogs_killed = 1
					has_character_modifier = dog_story_modifier
				}
				desc = ep3_laamp_decision_event.1201.desc.eaten.one.have_dog
			}
			# There's one dog being eaten, and it's someone else's.
			triggered_desc = {
				trigger = { scope:dogs_killed = 1 }
				desc = ep3_laamp_decision_event.1201.desc.eaten.one.no_dog
			}
			# There's many dogs being eaten, one of them ours.
			triggered_desc = {
				trigger = {
					scope:dogs_killed >= 4
					has_character_modifier = dog_story_modifier
				}
				desc = ep3_laamp_decision_event.1201.desc.eaten.many.have_dog
			}
			# There's many dogs being eaten, none of them ours.
			triggered_desc = {
				trigger = { scope:dogs_killed >= 4 }
				desc = ep3_laamp_decision_event.1201.desc.eaten.many.no_dog
			}
			# There's a bare handful of dogs being eaten, one of them ours.
			triggered_desc = {
				trigger = {
					scope:dogs_killed <= 3
					has_character_modifier = dog_story_modifier
				}
				desc = ep3_laamp_decision_event.1201.desc.eaten.some.have_dog
			}
			# There's a bare handful of dogs being eaten, none of them ours.
			desc = ep3_laamp_decision_event.1201.desc.eaten.some.no_dog
		}
		desc = ep3_laamp_decision_event.1201.desc.outro
	}
	theme = laamp
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = dismissal
		}
		animation = stress
	}
	right_portrait = {
		character = scope:portrait_char
		animation = fear
	}

	immediate = {
		# Apply cooldown.
		add_character_flag = {
			flag = recently_ate_dogs
			years = butcher_animals_decision_regular_cooldown_value
		}
		# Register how many provisions we'll get.
		domicile = {
			change_provisions = {
				value = {
					value = 0
					root = {
						every_courtier = {
							limit = { has_character_modifier = dog_story_modifier }
							add = butcher_animals_decision_dog_provision_value
						}
						if = {
							limit = { has_character_modifier = dog_story_modifier }
							add = butcher_animals_decision_dog_provision_value
						}
					}
					if = {
						limit = { has_domicile_building = baggage_train_kennel }
						add = butcher_animals_decision_dog_building_provision_value
					}
				}
			}
		}
		# Sort our aesthetics.
		## How many dogs are we losing?
		save_scope_value_as = {
			name = dogs_killed
			value = {
				every_courtier = {
					limit = { has_character_modifier = dog_story_modifier }
					add = 1
				}
				if = {
					limit = { has_character_modifier = dog_story_modifier }
					add = 1
				}
			}
		}
		## Grab a portrait if possible.
		random_courtier = {
			limit = {
				NOT = { has_trait = callous }
				has_character_modifier = dog_story_modifier
			}
			weight = {
				modifier = {
					add = 1000
					OR = {
						is_close_family_of = root
						is_consort_of = root
						has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root }
					}
				}
			}
			save_scope_as = portrait_char
		}
		# Aaaand remove our dogs.
		## We do this separately in various blocks for proper tooltipping & linking.
		every_courtier = {
			custom = ep3_laamp_decision_event.1201.tt.followers_with_dogs
			limit = {
				NOT = { has_trait = callous }
				has_character_modifier = dog_story_modifier
			}
			add_opinion = {
				target = root
				modifier = butcher_opinion
				opinion = -25
			}
		}
		every_courtier = {
			limit = { has_character_modifier = dog_story_modifier }
			custom_tooltip = {
				text = ep3_laamp_decision_event.1201.tt.dog_lost
				subject = this
			}
		}
		hidden_effect = {
			every_courtier = { 1201_prune_dog_stories_effect = yes }
		}
		# Liquidate the kennels.
		domicile = {
			if = {
				limit = { has_domicile_building = baggage_train_kennel }
				remove_domicile_building = baggage_train_kennel
				# Flag that this happened.
				save_scope_value_as = {
					name = kennels_gone
					value = yes
				}
			}
		}
	}

	# Non-callous.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { has_character_modifier = dog_story_modifier }
						desc = ep3_laamp_decision_event.1201.a.own_dog
					}
					desc = ep3_laamp_decision_event.1201.a
				}
			}
		}
		
		# We do stress first because it's more if you eat your own pets.
		if = {
			limit = { has_character_modifier = dog_story_modifier }
			# Goodbye, good boy.
			custom_tooltip = {
				text = ep3_laamp_decision_event.1201.tt.your_dog_lost
				1201_prune_dog_stories_effect = yes
			}
			stress_impact = {
				base = massive_stress_gain
				sadistic = minor_stress_impact_loss
				compassionate = minor_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				base = major_stress_gain
				sadistic = minor_stress_impact_loss
				compassionate = minor_stress_impact_gain
			}
		}

		# The AI only takes this if they have no other option.
		ai_chance = { base = 0 }
	}
	
	# Callous.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { has_character_modifier = dog_story_modifier }
						desc = ep3_laamp_decision_event.1201.b.own_dog
					}
					desc = ep3_laamp_decision_event.1201.b
				}
			}
		}
		trigger = { has_trait = callous }
		trait = callous

		# Eh, I can get another.
		if = {
			limit = { has_character_modifier = dog_story_modifier }
			custom_tooltip = {
				text = ep3_laamp_decision_event.1201.tt.your_dog_lost
				1201_prune_dog_stories_effect = yes
			}
		}

		stress_impact = { callous = massive_stress_impact_loss }
		# If the AI is callous, they should always take this.
		ai_chance = { base = 1000 }
	}
}

scripted_effect 1202_prune_cat_stories_effect = {
	remove_cat_story_modifiers_effect = yes
	random_owned_story = {
		type = story_cycle_pet_cat
		hidden_effect = { end_story = yes }
	}
}

#	Your camp eats its cats.
ep3_laamp_decision_event.1202 = {
	type = character_event
	title = ep3_laamp_decision_event.1202.t
	desc = {
		desc = ep3_laamp_decision_event.1202.desc.intro
		first_valid = {
			# There's one cat being eaten, and it's ours.
			triggered_desc = {
				trigger = {
					scope:cats_killed = 1
					has_character_modifier = cat_story_modifier
				}
				desc = ep3_laamp_decision_event.1202.desc.eaten.one.have_cat
			}
			# There's one cat being eaten, and it's someone else's.
			triggered_desc = {
				trigger = { scope:cats_killed = 1 }
				desc = ep3_laamp_decision_event.1202.desc.eaten.one.no_cat
			}
			# There's many cats being eaten, one of them ours.
			triggered_desc = {
				trigger = {
					scope:cats_killed >= 4
					has_character_modifier = cat_story_modifier
				}
				desc = ep3_laamp_decision_event.1202.desc.eaten.many.have_cat
			}
			# There's many cats being eaten, none of them ours.
			triggered_desc = {
				trigger = { scope:cats_killed >= 4 }
				desc = ep3_laamp_decision_event.1202.desc.eaten.many.no_cat
			}
			# There's a bare handful of cats being eaten, one of them ours.
			triggered_desc = {
				trigger = { has_character_modifier = cat_story_modifier }
				desc = ep3_laamp_decision_event.1202.desc.eaten.some.have_cat
			}
			# There's a bare handful of cats being eaten, none of them ours.
			desc = ep3_laamp_decision_event.1202.desc.eaten.some.no_cat
		}
		desc = ep3_laamp_decision_event.1202.desc.outro
	}
	theme = laamp
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = dismissal
		}
		animation = stress
	}
	right_portrait = {
		character = scope:portrait_char
		animation = fear
	}

	immediate = {
		# Apply cooldown.
		add_character_flag = {
			flag = recently_ate_cats
			years = butcher_animals_decision_regular_cooldown_value
		}
		# Register how many provisions we'll get.
		domicile = {
			change_provisions = {
				value = {
					value = 0
					root = {
						every_courtier = {
							limit = { has_character_modifier = cat_story_modifier }
							add = butcher_animals_decision_cat_provision_value
						}
						if = {
							limit = { has_character_modifier = cat_story_modifier }
							add = butcher_animals_decision_cat_provision_value
						}
					}
				}
			}
		}
		# Sort our aesthetics.
		## How many cats are we losing?
		save_scope_value_as = {
			name = cats_killed
			value = {
				every_courtier = {
					limit = { has_character_modifier = cat_story_modifier }
					add = 1
				}
				if = {
					limit = { has_character_modifier = cat_story_modifier }
					add = 1
				}
			}
		}
		## Grab a portrait if possible.
		random_courtier = {
			limit = {
				NOT = { has_trait = callous }
				has_character_modifier = cat_story_modifier
			}
			weight = {
				modifier = {
					add = 1000
					OR = {
						is_close_family_of = root
						is_consort_of = root
						has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root }
					}
				}
			}
			save_scope_as = portrait_char
		}
		# Aaaand remove our cats.
		## We do this separately in various blocks for proper tooltipping & linking.
		every_courtier = {
			custom = ep3_laamp_decision_event.1201.tt.followers_with_cats
			limit = {
				NOT = { has_trait = callous }
				has_character_modifier = cat_story_modifier
			}
			add_opinion = {
				target = root
				modifier = butcher_opinion
				opinion = -25
			}
		}
		every_courtier = {
			limit = { has_character_modifier = cat_story_modifier }
			custom_tooltip = {
				text = ep3_laamp_decision_event.1202.tt.cat_lost
				subject = this
			}
		}
		hidden_effect = {
			every_courtier = { 1202_prune_cat_stories_effect = yes }
		}
	}

	# Non-callous.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { has_character_modifier = cat_story_modifier }
						desc = ep3_laamp_decision_event.1202.a.own_cat
					}
					desc = ep3_laamp_decision_event.1202.a
				}
			}
		}
		
		# We do stress first because it's more if you eat your own pets.
		if = {
			limit = { has_character_modifier = cat_story_modifier }
			# Our regal companionship is ended.
			custom_tooltip = {
				text = ep3_laamp_decision_event.1202.tt.your_cat_lost
				1202_prune_cat_stories_effect = yes
			}
			stress_impact = {
				base = massive_stress_gain
				sadistic = minor_stress_impact_loss
				compassionate = minor_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				base = major_stress_gain
				sadistic = minor_stress_impact_loss
				compassionate = minor_stress_impact_gain
			}
		}

		# The AI only takes this if they have no other option.
		ai_chance = { base = 0 }
	}
	
	# Callous.
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { has_character_modifier = cat_story_modifier }
						desc = ep3_laamp_decision_event.1202.b.own_cat
					}
					desc = ep3_laamp_decision_event.1202.b
				}
			}
		}
		trigger = { has_trait = callous }
		trait = callous

		# A cat is a cat.
		if = {
			limit = { has_character_modifier = cat_story_modifier }
			# Our regal companionship is ended.
			custom_tooltip = {
				text = ep3_laamp_decision_event.1202.tt.your_cat_lost
				1202_prune_cat_stories_effect = yes
			}
		}

		stress_impact = { callous = massive_stress_impact_loss }
		# If the AI is callous, they should always take this.
		ai_chance = { base = 1000 }
	}
}


scripted_effect 1203_prune_horse_stories_effect = {
	remove_horse_story_modifiers_effect = yes
	random_owned_story = {
		type = story_cycle_martial_lifestyle_warhorse
		end_story = yes
	}
}

#	Your camp eats its horses.
ep3_laamp_decision_event.1203 = {
	type = character_event
	title = ep3_laamp_decision_event.1203.t
	desc = {
		desc = ep3_laamp_decision_event.1203.desc.intro
		first_valid = {
			# Both your horse and your reserve steeds are getting eaten.
			triggered_desc = {
				trigger = {
					has_character_modifier = horse_story_modifier
					exists = scope:horses_gone
				}
				desc = ep3_laamp_decision_event.1203.desc.eaten.both
			}
			# Just your horse is getting eaten.
			triggered_desc = {
				trigger = { has_character_modifier = horse_story_modifier }
				desc = ep3_laamp_decision_event.1203.desc.eaten.own_horse
			}
			# Just the reserve steeds are getting eaten.
			triggered_desc = {
				trigger = { exists = scope:horses_gone }
				desc = ep3_laamp_decision_event.1203.desc.eaten.reserve_steeds
			}
		}
		desc = ep3_laamp_decision_event.1203.desc.outro
	}
	theme = laamp
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = dismissal
		}
		animation = stress
	}

	immediate = {
		# Apply cooldown.
		add_character_flag = {
			flag = recently_ate_horses
			years = butcher_animals_decision_regular_cooldown_value
		}
		# Make it look like we've killed our horse, but hold them till after for loc.
		show_as_tooltip = { 1203_prune_horse_stories_effect = yes }
		# Register how many provisions we'll get.
		domicile = {
			change_provisions = {
				root = {
					if = {
						limit = { has_character_modifier = horse_story_modifier }
						add = butcher_animals_decision_horse_provision_value
					}
				}
				if = {
					limit = { has_domicile_building = baggage_train_ample_steeds }
					add = butcher_animals_decision_horse_building_provision_value
				}
			}
			# Liquidate the horses.
			if = {
				limit = { has_domicile_building = baggage_train_ample_steeds }
				remove_domicile_building = baggage_train_ample_steeds
				# Flag that this happened.
				save_scope_value_as = {
					name = horses_gone
					value = yes
				}
			}
		}
	}

	# Non-callous: even in death, they carry us forward..
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:horses_gone }
						desc = ep3_laamp_decision_event.1203.a.many_steeds
					}
					desc = ep3_laamp_decision_event.1203.a.single_steed
				}
			}
		}

		stress_impact = {
			base = major_stress_gain
			sadistic = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		# The AI only takes this if they have no other option.
		ai_chance = { base = 0 }
	}
	
	# Callous: you know, this isn't that bad actually...
	option = {
		name = ep3_laamp_decision_event.1203.b
		trigger = { has_trait = callous }
		trait = callous

		stress_impact = { callous = massive_stress_impact_loss }
		# If the AI is callous, they should always take this.
		ai_chance = { base = 1000 }
	}

	after = {
		hidden_effect = { 1203_prune_horse_stories_effect = yes }
	}
}

#	Your camp eats its elephants.
ep3_laamp_decision_event.1204 = {
	type = character_event
	title = ep3_laamp_decision_event.1204.t
	desc = ep3_laamp_decision_event.1204.desc
	theme = laamp
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { has_trait = callous }
			animation = dismissal
		}
		animation = stress
	}

	immediate = {
		# Apply cooldown.
		add_character_flag = {
			flag = recently_ate_elephants
			years = butcher_animals_decision_elephant_cooldown_value
		}
		# Register how many provisions we'll get.
		domicile = {
			change_provisions = butcher_animals_decision_elephant_building_provision
			# Liquidate the elephants.
			if = {
				limit = { has_domicile_building = proving_grounds_elephantry_reserve }
				remove_domicile_building = proving_grounds_elephantry_reserve
			}
		}
	}

	# Non-callous.
	option = {
		name = ep3_laamp_decision_event.1204.a
		
		stress_impact = {
			base = major_stress_gain
			sadistic = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
		}
		# The AI only takes this if they have no other option.
		ai_chance = { base = 0 }
	}
	
	# Callous.
	option = {
		name = ep3_laamp_decision_event.1204.b
		trigger = { has_trait = callous }
		trait = callous

		stress_impact = { callous = massive_stress_impact_loss }
		# If the AI is callous, they should always take this.
		ai_chance = { base = 1000 }
	}

	# Will there be additional consequences?
	after = {
		if = {
			limit = {
				any_maa_regiment = { is_unit_type = elephant_cavalry }
			}
			trigger_event = {
				id = ep3_laamp_decision_event.1205
				years = 1
			}
		}
	}
}

#	Elephant survivors never forget.
ep3_laamp_decision_event.1205 = {
	type = character_event
	title = ep3_laamp_decision_event.1205.t
	desc = ep3_laamp_decision_event.1205.desc
	theme = laamp
	left_portrait = {
		character = root
		animation = shock
	}

	immediate = { add_character_modifier = ep3_laamp_decision_event_1205_modifier }

	# Damn and blast these recalcitrant beasts!
	option = {
		name = ep3_laamp_decision_event.1205.a

		custom_tooltip = ep3_laamp_decision_event.1205.a.tt

		# No stress, no AI.
	}
}

scripted_trigger ep3_laamp_decision_event_1300_age_diff_trigger = {
	OR = {
		age <= {
			value = scope:char_current.age
			add = 5
		}
		scope:char_current.age >= {
			value = age
			add = 5
		}
	}
}

#Youths of LAAMP-prone cultures consider becoming LAAMPs
ep3_laamp_decision_event.1300 = {
	hidden = yes
	trigger = {
		laamp_youth_cultural_tradition_trigger = yes
		#Looser skill reqs for eager-ass Normans
		trigger_if = {
			limit = {
				culture = {
					has_cultural_parameter = much_more_likely_to_be_laamps
				}
			}
			OR = {
				prowess >= 8
				martial >= 8
			}
		}
		trigger_else = {
			OR = {
				prowess >= 10
				martial >= 10
			}
		}
		ai_boldness > 0
		ai_energy > 0
	}
	immediate = {
		random = {
			chance = 0
			modifier = { add = ep3_laamp_chance_score_value }
			#Counteract bonus in above value somewhat
			modifier = {
				always = yes
				add = -50
			}
			create_landless_adventurer_title_effect = {
				REASON = flag:runaway_allowed
				FLAVOR_CHAR = liege
			}
			# Create a bunch of secondary chars to go on their adventure with them (so that Norman/Turkish bands don't immediately de-Normanify/Turkify).
			while = {
				count = 3
				create_character = {
					template = soldier_friend_character
					employer = root
					culture = root.culture
					faith = root.faith
					age = root.age
					gender_female_chance = root_soldier_female_chance
					after_creation = { add_to_list = created_chars_list }
				}
			}
			while = {
				count = 3
				create_character = {
					template = mercenary
					employer = root
					culture = root.culture
					faith = root.faith
					gender_female_chance = root_soldier_female_chance
					after_creation = { add_to_list = created_chars_list }
				}
			}
			## Plus add starting drama.
			every_in_list = {
				list = created_chars_list
				save_scope_as = char_current
				random_list = {
					100 = {
						trigger = {
							any_in_list = {
								list = created_chars_list
								can_set_relation_friend_trigger = { CHARACTER = scope:char_current }
							}
						}
						random_in_list = {
							list = created_chars_list
							limit = {
								can_set_relation_friend_trigger = { CHARACTER = scope:char_current }
							}
							set_random_friendship_reason = { TARGET = scope:char_current }
						}
					}
					100 = {
						trigger = {
							any_in_list = {
								list = created_chars_list
								can_set_relation_rival_trigger = { CHARACTER = scope:char_current }
							}
						}
						random_in_list = {
							list = created_chars_list
							limit = {
								can_set_relation_rival_trigger = { CHARACTER = scope:char_current }
							}
							set_random_rivalry_reason = {
								TARGET = scope:char_current
								RELATION = rival
							}
						}
					}
					100 = {
						trigger = {
							any_in_list = {
								list = created_chars_list
								ep3_laamp_decision_event_1300_age_diff_trigger = yes
								can_set_relation_lover_trigger = { CHARACTER = scope:char_current }
							}
						}
						random_in_list = {
							list = created_chars_list
							limit = {
								ep3_laamp_decision_event_1300_age_diff_trigger = yes
								can_set_relation_lover_trigger = { CHARACTER = scope:char_current }
							}
							set_random_lover_reason = { TARGET = scope:char_current }
						}
					}
				}
			}
			trigger_event = ep3_laamps.0003
			if = { # Debug AI tracking
				limit = { debug_only = yes }
				if = {
					limit = { exists = global_var:ai_birthday_cultrad_laamp_count }
					change_global_variable = {
						name = ai_birthday_cultrad_laamp_count
						add = 1
					}
				}
				else = {
					set_global_variable = {
						name = ai_birthday_cultrad_laamp_count
						value = 1
					}
				}
				debug_log = "AI became adventurer due to cultural tradition"
				debug_log_scopes = yes
			}
		}
	}
}
