﻿namespace = gdp_visit_holding_decision_event

######################################################################
# MAIN 
# gdp_visit_holding_decision_event.1000
######################################################################
# > Visit Market/Docks
# > Visit Guild
# > Holding Option (Visit Church / Visit Patron)

#Enter Holding Main Hub
gdp_visit_holding_decision_event.1000 = {
	type = character_event 
	title = gdp_visit_holding_decision_event.1000.t 
	window = visit_settlement_window
	desc = gdp_visit_holding_decision_event.1000.desc

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { reference = courtyard }

	center_portrait = {
		character = root 
		animation = deliberation
	}
	immediate = {
		suzerain = { save_scope_as = patron }
		#For loc purposes
		if = {
			limit = {
				NOT = { exists = scope:visiting_location }
			}
			location = { save_scope_as = visiting_location }
		}
		visit_holding_ensure_visiting_associate_effect = yes
		gdp_merchant_legacy_4_visit_entrepot_effect = yes
	}
	#Visit Craftsmen Guilds
	option = {
		name = gdp_visit_holding_decision_event.1000.a
		reason = craftsmen_guild
		trigger = {
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1000.guilds.inaccessible.tt
				visit_holding_guilds_blocked_trigger = no
			}
		}
		show_as_unavailable = { always = yes }
		custom_tooltip = gdp_visit_holding_decision_event.1000.a.tt
		visit_holding_mark_hub_area_visited_effect = yes
		trigger_event = gdp_visit_holding_decision_event.1110
	}
	#Visit Holder: Patron
	option = {
		name = gdp_visit_holding_decision_event.1000.b
		reason = patron
		trigger = {
			NOT = {
				location = {
					holding_is_church = yes
				}
			}
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1000.patron.no_patron.tt
				is_landless_merchant = yes
				suzerain = {
					NOT = { this = root }
					is_ai = yes
				}
			}
			custom_tooltip = {
				text = gdp_guards_were_summoned.tt
				NOT = { has_variable = 1200_guards_summoned }
			}
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1000.patron.inaccessible.tt
				visit_holding_patron_blocked_trigger = no
			}
		}
		custom_tooltip =  gdp_visit_holding_decision_event.1000.b.tt
		visit_holding_mark_hub_area_visited_effect = yes
		trigger_event = gdp_visit_holding_decision_event.1200 
	}
	#Visit Market 
	option = {
		name = gdp_visit_holding_decision_event.1000.c
	    trigger = {
			location = { is_coastal = no }
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1000.market.inaccessible.tt
				visit_holding_market_dock_blocked_trigger = no
			}
		}
		show_as_unavailable = {
			location = { is_coastal = no }
		}
		reason = marketplace
		custom_tooltip = gdp_visit_holding_decision_event.1000.c.tt
		visit_holding_mark_hub_area_visited_effect = yes
		trigger_event = gdp_visit_holding_decision_event.1300 
	}
	#Visit Holy Site: Visit the local Holy Site
	option = {
		name = gdp_visit_holding_decision_event.1000.f
		trigger = {
			location = {
				OR = {
					has_holding_type = church_holding
					has_holding_type = temple_citadel_holding
				}
			}

			# What about critically failing?
			custom_tooltip = {
				text = gdp_visit_holding_caught_stealing.tt
				NOT = { has_variable = 1500_caught_stealing }
			}
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1000.worship.inaccessible.tt
				visit_holding_worship_blocked_trigger = no
			}
		}
		show_as_unavailable = {
			location = {
				OR = {
					has_holding_type = church_holding
					has_holding_type = temple_citadel_holding
				}
			}
		}
		reason = church_holding
		#Actual transition event
		custom_tooltip = gdp_visit_holding_decision_event.1000.f.tt
		visit_holding_mark_hub_area_visited_effect = yes
		trigger_event = gdp_visit_holding_decision_event.1500
	}
	#Visit Docks 
	option = {
		name = gdp_visit_holding_decision_event.1000.e
		trigger = {
			location = { is_coastal = yes }
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1000.docks.inaccessible.tt
				visit_holding_market_dock_blocked_trigger = no
			}
		}
		show_as_unavailable = {
			location = { is_coastal = yes }
		}
		reason = docks
		custom_tooltip = gdp_visit_holding_decision_event.1000.e.tt
		visit_holding_mark_hub_area_visited_effect = yes
		trigger_event = gdp_visit_holding_decision_event.1400
	}
	#Leave/Opt out
	option = {
		name = {
			text = {
				first_valid = {
					# Been everywhere, done everything
					triggered_desc = {
						trigger = { visit_holding_decision_all_options_exhausted_trigger = yes }
						desc = gdp_visit_holding_decision_event.1000.d.exhausted
					}
					# Been nowhere at all, turning on the spot
					triggered_desc = {
						trigger = {
							NOT = { has_variable = gdp_visit_holding_been_to_area }
						}
						desc = gdp_visit_holding_decision_event.1000.d.changed_mind
					}
					# Fallback
					desc = gdp_visit_holding_decision_event.1000.d
				}
			}
		}
		flavor = {
			# Not been anywhere
			triggered_desc = {
				trigger = {
					NOT = { has_variable = gdp_visit_holding_been_to_area }
				}
				desc = gdp_visit_holding_decision_event.1000.d.changed_mind.tt
			}
			# Fallback
			desc = gdp_visit_holding_decision_event.1000.d.tt
		}
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit ?= { visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit ?= {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit ?= {visit_holding_clean_up_variables_effect = yes }
		if = {
			limit = { scope:negotiator ?= { has_character_flag = gdp_1200_temp_negotiator } }
			scope:negotiator = { silent_disappearance_effect = yes }
		}
	}
}

######################################################################
# CRAFTSMEN GUILD
# gdp_visit_holding_decision_event.1110
######################################################################
# > Improve Artifacts
# > Arms and Armor
# > The Guild Master

#Visit Craftsmen Guild
gdp_visit_holding_decision_event.1110 = {
	type = character_event 
	title = gdp_visit_holding_decision_event.1110.t
	window = visit_settlement_window
	desc = gdp_visit_holding_decision_event.1110.desc

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { reference = gdp_artisan_street_crowd }

	left_portrait = {
		character = root
		animation = steward
		camera = camera_event_scheme_center
	}
	#Visit Curator
	option = {
		name = gdp_visit_holding_decision_event.1110.a
		trigger = {
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1110.a.no.arfitfacts.tt
				any_character_artifact = {
					OR = {
						rarity = common
						rarity = masterwork
					}
					NOT = { artifact_type = creature }
				} 
			}
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1110.a.cooldown.tt
				NOT = { has_variable = 1111_has_improved_artifact_recently }
			}
		}
		show_as_unavailable = { always = yes }
		reason = curator 
		custom_tooltip = gdp_visit_holding_decision_event.1110.a.tt	
		trigger_event = gdp_visit_holding_decision_event.1111 
	}
	#Visit Blacksmith
	option = {
		name = gdp_visit_holding_decision_event.1110.b
		trigger = {
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1110.b.cooldown.tt
				NOT = { has_variable = 1111_has_bought_artifact_recently }
			}
		}
		show_as_unavailable = { always = yes }
		reason = blacksmith
		custom_tooltip = gdp_visit_holding_decision_event.1110.b.tt
		trigger_event = gdp_visit_holding_decision_event.1112  
	}
	#Visit Guild Master
	option = {
		name = gdp_visit_holding_decision_event.1110.c
		trigger = { 
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1110.c.cooldown.tt
				NOT = { has_variable = 1110_visited_guild_master_recently }
			}
		}
		show_as_unavailable = { always = yes }
		reason = guild_master
		custom_tooltip = gdp_visit_holding_decision_event.1110.c.tt
		trigger_event = gdp_visit_holding_decision_event.1113  
	}
	#Leave
	option = {
		name = gdp_visit_holding_decision_event.1110.d
		custom_tooltip =  gdp_visit_holding_decision_event.1110.d.tt
		trigger_event = gdp_visit_holding_decision_event.1000 
	}
}

#Find common and masterwork artifacts to improve
scripted_effect 1111_set_artifact_effect = {
	every_character_artifact = {
		limit = {
			OR = {
				rarity = common
				rarity = masterwork
			}
			# Animals are living creatures and cannot be improved by the Curator
			NOT = { artifact_type = creature }
		}
		add_to_list = owned_artifacts
	}
	random_in_list = {
		list = owned_artifacts
		weight = {
			base = 1
			modifier = {
				add = 9
				rarity = common
			}
			modifier = {
				add = 5
				rarity = masterwork
			}
		}
		save_scope_as = artifact_target_1
	}
	random_in_list = {
		list = owned_artifacts
		limit = { this != scope:artifact_target_1 }
		weight = {
			base = 1
			modifier = {
				add = 9
				rarity = common
			}
			modifier = {
				add = 5
				rarity = masterwork
			}
		}
		save_scope_as = artifact_target_2
	}
	random_in_list = {
		list = owned_artifacts
		limit = {
			AND = {
				this != scope:artifact_target_1
				this != scope:artifact_target_2		 
			}
		}
		weight = {
			base = 1
			modifier = {
				add = 9
				rarity = common
			}
			modifier = {
				add = 5
				rarity = masterwork
			}
		}
		save_scope_as = artifact_target_3
	}			
}
#Discount if you are good at stewardship or learning
scripted_effect 1111_artifact_cost_effect = {
	save_scope_value_as = {
		name = $COST_NAME$
		value = {
			value = $GOLD_VALUE$
			if = {
				limit = {
					scope:liege = { stewardship >= average_skill_level }
				}
				subtract = {
					value = $GOLD_VALUE$
					multiply = 0.1
				}	
			}
			if = {
				limit = {
					scope:liege = { learning >= average_skill_level }
				}
				subtract = {
					value = $GOLD_VALUE$
					multiply = 0.1
				}	
			}
			if = {
				limit = {
					scope:liege = { learning >= good_skill_level }
				}
				subtract = {
					value = $GOLD_VALUE$
					multiply = 0.1
				}	
			}
		}
	}
}
scripted_effect 1111_artifact_value_effect = {
	#Expensive
	if = {
		limit = { rarity = masterwork }
		1111_artifact_cost_effect = { GOLD_VALUE = root.major_gold_value COST_NAME = $COST_NAME$ }
	}
	#OK price
	else_if = {
		limit = { rarity = common }
		1111_artifact_cost_effect = { GOLD_VALUE = root.medium_gold_value COST_NAME = $COST_NAME$ }
	}	
}
scripted_effect 1111_artifact_increase_rarity_effect = {
	switch = {
		trigger = rarity
		common = { set_artifact_rarity = masterwork }
		masterwork = { set_artifact_rarity = famed }
	}
}

#Visit Curator: Improve Artifacts
gdp_visit_holding_decision_event.1111 = {
	type = character_event 
	title = gdp_visit_holding_decision_event.1111.t
	window = visit_settlement_window
	desc = gdp_visit_holding_decision_event.1111.desc
	
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { reference = study }

	artifact = {
		target = scope:artifact_target_1
		position = lower_left_portrait
	}
	artifact = {
		target = scope:artifact_target_2
		position = lower_center_portrait
	}
	artifact = {
		target = scope:artifact_target_3
		position = lower_right_portrait
	}
	left_portrait = {
		character = root
		animation = chess_certain_win
		camera = camera_event_scheme_center_look_right
	}
	right_portrait = {
		character = scope:curator
		animation = eccentric
	}

	immediate = {
		1111_set_artifact_effect = yes
		root = { save_scope_as = liege }
		suzerain = { save_scope_as = patron }
		if = {
			limit = {
				NOT = { exists = scope:curator } 
		  	}
		 	create_character = {
		 		template = curator_template
		 		location = root.location
		        culture = root.location.culture
		        faith = root.location.faith
				save_scope_as = curator
		 	}
		}
		scope:curator = { save_scope_as = antiquarian_from_task }
		#Pre-compute each offered artifact's cost so options can be gated on available gold
		if = {
			limit = { exists = scope:artifact_target_1 }
			scope:artifact_target_1 = { 1111_artifact_value_effect = { COST_NAME = 1111_artifact_cost_1 } }
		}
		else = { save_scope_value_as = { name = 1111_artifact_cost_1 value = 0 } }
		if = {
			limit = { exists = scope:artifact_target_2 }
			scope:artifact_target_2 = { 1111_artifact_value_effect = { COST_NAME = 1111_artifact_cost_2 } }
		}
		else = { save_scope_value_as = { name = 1111_artifact_cost_2 value = 0 } }
		if = {
			limit = { exists = scope:artifact_target_3 }
			scope:artifact_target_3 = { 1111_artifact_value_effect = { COST_NAME = 1111_artifact_cost_3 } }
		}
		else = { save_scope_value_as = { name = 1111_artifact_cost_3 value = 0 } }
	}

	option = { 
		name = gdp_visit_holding_decision_event.1111.a
		trigger = {
			short_term_gold >= scope:1111_artifact_cost_1
		}
		show_as_unavailable = { short_term_gold < scope:1111_artifact_cost_1 }
		scope:artifact_target_1 = {
			save_scope_as = artifact_target
			1111_artifact_increase_rarity_effect = yes
			hidden_effect = { antiquarian_improve_artifact_effect = yes }
		}
		custom_tooltip = gdp_visit_holding_decision_event.1111.a.tt
		pay_short_term_gold = {
			target = scope:patron
			gold = scope:1111_artifact_cost_1
		}
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1111_has_improved_artifact_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}

	option = { 
		name = gdp_visit_holding_decision_event.1111.b
		trigger = {
			exists = scope:artifact_target_2
			short_term_gold >= scope:1111_artifact_cost_2
		}
		show_as_unavailable = { exists = scope:artifact_target_2 short_term_gold < scope:1111_artifact_cost_2 }
		scope:artifact_target_2 = {
			save_scope_as = artifact_target
			1111_artifact_increase_rarity_effect = yes
			hidden_effect = { antiquarian_improve_artifact_effect = yes }
		}
		custom_tooltip = gdp_visit_holding_decision_event.1111.b.tt
		pay_short_term_gold = {
			target = scope:patron
			gold = scope:1111_artifact_cost_2
		}
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1111_has_improved_artifact_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}

	option = { 
		name = gdp_visit_holding_decision_event.1111.c
		trigger = {
			exists = scope:artifact_target_3
			short_term_gold >= scope:1111_artifact_cost_3
		}
		show_as_unavailable = { exists = scope:artifact_target_3 short_term_gold < scope:1111_artifact_cost_3 }
		scope:artifact_target_3 = {
			save_scope_as = artifact_target
			1111_artifact_increase_rarity_effect = yes
			hidden_effect = { antiquarian_improve_artifact_effect = yes }
		}
		custom_tooltip = gdp_visit_holding_decision_event.1111.c.tt
		pay_short_term_gold = {
			target = scope:patron
			gold = scope:1111_artifact_cost_3
		}
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1111_has_improved_artifact_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}
	#Go Back To Previous
	option = { 
		name = gdp_visit_holding_decision_event.1111.d
		custom_tooltip = gdp_visit_holding_decision_event.1111.d.tt
		trigger_event = gdp_visit_holding_decision_event.1110
	}	
}
scripted_effect 1112_artifact_arms_armor_creation_effect = {
	if = {
		limit = {
			NOT = { exists = scope:arms_armor_artifact_1 }
		}
		1112_artifact_arms_armor_rarity_effect = yes
		#Generate weapon 
		create_artifact_weapon_effect = {
			OWNER = scope:blacksmith
			CREATOR = scope:blacksmith
			SET_WEAPON_TYPE = flag:no
		}
		#Finalization
		scope:newly_created_artifact ?= { save_scope_as = arms_armor_artifact_1 }
	}
	if = {
		limit = {
			NOT = { exists = scope:arms_armor_artifact_2 }
		}
		1112_artifact_arms_armor_rarity_effect = yes
		#Generate armor
		create_artifact_armor_effect = {
			OWNER = scope:blacksmith
			CREATOR = scope:blacksmith
			SET_ARMOR_TYPE = flag:no
		}
		#Finalization
		scope:newly_created_artifact ?= { save_scope_as = arms_armor_artifact_2 }
	}
	if = {
		limit = {
			NOT = { exists = scope:arms_armor_artifact_3 }
		}
		1112_artifact_arms_armor_rarity_effect = yes
		random_list = {
		#Generate weapon OR armor
			50 = { 
				create_artifact_weapon_effect = {
					OWNER = scope:blacksmith
					CREATOR = scope:blacksmith
					SET_WEAPON_TYPE = flag:no
				}
			}
			50 = { 
				create_artifact_armor_effect = {
					OWNER = scope:blacksmith
					CREATOR = scope:blacksmith
					SET_ARMOR_TYPE = flag:no
				}
			}
		}
		#Finalization
		scope:newly_created_artifact ?= { save_scope_as = arms_armor_artifact_3 }
	}
	scope:arms_armor_artifact_1 = { 1112_artifact_arms_armor_value_effect = yes }
	scope:arms_armor_artifact_2 = { 1112_artifact_arms_armor_value_effect = yes }
	scope:arms_armor_artifact_3 = { 1112_artifact_arms_armor_value_effect = yes }
}
scripted_effect 1112_artifact_arms_armor_rarity_effect = {
	random_list = {
		20 = { set_artifact_rarity_famed = yes }
		40 = { set_artifact_rarity_masterwork = yes }
		80 = { set_artifact_rarity_common = yes }
	}
}
scripted_effect 1112_artifact_arms_armor_value_effect = {
	set_variable = {
		name = 1112_artifact_value
		value = {
			value = artifact_wealth_quality_average_value
			multiply = 4
			multiply = { 0.9 1.1 }
		}
	}
}

#Visit Blacksmith : Arms and Armor
gdp_visit_holding_decision_event.1112 = {
	type = character_event 
	title = gdp_visit_holding_decision_event.1112.t
	window = visit_settlement_window
	desc = gdp_visit_holding_decision_event.1112.desc
	
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { reference = gdp_smithy_workshop }

	artifact = {
		target = scope:arms_armor_artifact_1
		position = lower_left_portrait
	}
	artifact = {
		target = scope:arms_armor_artifact_2
		position = lower_center_portrait
	}
	artifact = {
		target = scope:arms_armor_artifact_3
		position = lower_right_portrait
	}
	left_portrait = {
		character = root
		animation = inspect_weapon
		camera = camera_event_group_talking_left_left
	}
	right_portrait = {
		character = scope:blacksmith
		animation = menacing
		camera = camera_event_center_away_pointing_left_fov25
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:blacksmith }
			}
			create_character = {
				template = generic_peasant_character
		        location = root.location
		        dynasty = none 
		        culture = root.location.culture
		        faith = root.location.faith
				save_scope_as = blacksmith
				after_creation = { remove_character_flag = peasant_outfit }
			}
		}
		scope:blacksmith = {
			#Create New Artifact
			hidden_effect_new_object = { 1112_artifact_arms_armor_creation_effect = yes }
		}
	}
	option = {
		name = gdp_visit_holding_decision_event.1112.a
		trigger = {
			short_term_gold >= scope:arms_armor_artifact_1.var:1112_artifact_value
		}
		show_as_unavailable = { short_term_gold < scope:arms_armor_artifact_1.var:1112_artifact_value }
		pay_short_term_gold = {
			target = scope:blacksmith
			gold = scope:arms_armor_artifact_1.var:1112_artifact_value
		}
		scope:arms_armor_artifact_1 = { set_owner = root }
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1111_has_bought_artifact_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}
	option = {
		name = gdp_visit_holding_decision_event.1112.b
		trigger = {
			short_term_gold >= scope:arms_armor_artifact_2.var:1112_artifact_value
		}
		show_as_unavailable = { short_term_gold < scope:arms_armor_artifact_2.var:1112_artifact_value }
		pay_short_term_gold = {
			target = scope:blacksmith
			gold = scope:arms_armor_artifact_2.var:1112_artifact_value
		}
		scope:arms_armor_artifact_2 = { set_owner = root }
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1111_has_bought_artifact_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}
	option = {
		name = gdp_visit_holding_decision_event.1112.c
		trigger = {
			short_term_gold >= scope:arms_armor_artifact_3.var:1112_artifact_value
		}
		show_as_unavailable = { short_term_gold < scope:arms_armor_artifact_3.var:1112_artifact_value }
		pay_short_term_gold = {
			target = scope:blacksmith
			gold = scope:arms_armor_artifact_3.var:1112_artifact_value
		}
		scope:arms_armor_artifact_3 = { set_owner = root }
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1111_has_bought_artifact_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}
	option = {
		name = gdp_visit_holding_decision_event.1112.d
		custom_tooltip = gdp_visit_holding_decision_event.1112.d.tt
		trigger_event = gdp_visit_holding_decision_event.1110
	}
}

scripted_effect 1113_guild_master_duel_skill_effect = {
	if = {
		limit = { 
			scope:guild_master = { has_trait = education_stewardship_4 } 
		}
		1113_duel_effect = { SKILL = stewardship }
	}
	else_if = {
		limit = { 
			scope:guild_master = { has_trait = education_learning_4 } 
		}
		1113_duel_effect = { SKILL = learning }
	}
	else_if = {
		limit = { 
			scope:guild_master = { has_trait = education_diplomacy_4 } 
		}
		1113_duel_effect = { SKILL = diplomacy }
	}
}
scripted_effect 1113_lifestyle_xp_gain_per_type_effect = {
	if = {
		limit = { has_trait = education_diplomacy }
		add_diplomacy_lifestyle_xp =  minor_lifestyle_xp
	}
	else_if = {
		limit = { has_trait = education_martial }
		add_martial_lifestyle_xp =  minor_lifestyle_xp
	}
	else_if = {
		limit = { has_trait = education_stewardship }
		add_stewardship_lifestyle_xp =  minor_lifestyle_xp
	}
	else_if = {
		limit = { has_trait = education_intrigue }
		add_intrigue_lifestyle_xp =  minor_lifestyle_xp
	}
	else_if = {
		limit = { has_trait = education_learning }
		add_learning_lifestyle_xp =  minor_lifestyle_xp
	}
	else = {
		custom_tooltip = gdp_visit_holding_decision_event.1113.a.child
		education_point_acquisition_additional_points_effect = { LEVEL = low }	
	}
}
scripted_effect 1113_duel_effect = {
	duel = {
		skill = $SKILL$
		target = scope:guild_master
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
				min = -35
			}
			desc = gdp_visit_holding_decision_event.1113.a.success
			send_interface_toast = {
				title = gdp_visit_holding_decision_event.1113.a.success
				left_icon = root
				right_icon = scope:guild_master
				add_character_modifier = {
					modifier = gdp_guild_master_inpiration_$SKILL$_modifier
					years = 5
				}
				scope:visiting_associate = {
					1113_lifestyle_xp_gain_per_type_effect = yes			
				}
			}

		}
		#Failure: Increased price for supplies
		50 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
				min = -20
			}	
			desc = gdp_visit_holding_decision_event.1113.a_$SKILL$.failure
			send_interface_toast = {
				title = gdp_visit_holding_decision_event.1113.a_$SKILL$.failure
				left_icon = root
				right_icon = scope:guild_master
				custom_tooltip = gdp_visit_holding_decision_event.1113.a.failure.tt
			}
		}
	}	
}

#Visit Guild Master
gdp_visit_holding_decision_event.1113 = {
	type = character_event 
	title = gdp_visit_holding_decision_event.1113.t
	window = visit_settlement_window
	desc = gdp_visit_holding_decision_event.1113.desc
	
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { reference = study }

	left_portrait = {
		character = scope:visiting_associate
		animation = stressed_teacher
		camera = camera_event_donkey_left_forward_centered
	}
	center_portrait = {
		character = root
		animation = throne_room_writer
		camera = camera_event_horse_right_facing_left_close
	}

	right_portrait = {
		character = scope:guild_master
		animation = debating
		camera = camera_event_scheme_vs_extra_right_look_left
	}

	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:guild_master } 
		  	}
		 	create_character = {
		 		template = guild_master_template
		 		location = root.location
		        dynasty = none 
		        culture = root.location.culture
		        faith = root.location.faith
				save_scope_as = guild_master
		 	}
		}
		visit_holding_ensure_visiting_associate_effect = yes
	}
	option = {
		name = gdp_visit_holding_decision_event.1113.a
		1113_guild_master_duel_skill_effect = yes
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1110_visited_guild_master_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}
	option = {
		name = gdp_visit_holding_decision_event.1113.b
		custom_tooltip = gdp_visit_holding_decision_event.1113.b.tt
		scope:visiting_associate = { 1113_lifestyle_xp_gain_per_type_effect = yes }
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1110_visited_guild_master_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}
	option = {
		name = gdp_visit_holding_decision_event.1113.c
		custom_tooltip = gdp_visit_holding_decision_event.1113.c.tt
		1113_lifestyle_xp_gain_per_type_effect = yes
		if = {
			limit = { has_trait = lifestyle_merchant }
			if = {
				limit = { has_realm_law = company_purpose_creditor }
				add_trait_xp = {
					trait = lifestyle_merchant
					track = creditor
					value = lifestyle_merchant_xp_gain_minor_value
				}
			}
			else_if = {
				limit = { has_realm_law = company_purpose_artisan }
				add_trait_xp = {
					trait = lifestyle_merchant
					track = artisan
					value = lifestyle_merchant_xp_gain_minor_value
				}
			}
			else_if = {
				limit = { has_realm_law = company_purpose_caravaneer }
				add_trait_xp = {
					trait = lifestyle_merchant
					track = caravaneer
					value = lifestyle_merchant_xp_gain_minor_value
				}
			}
		}
		visit_holding_set_option_cooldown_guilds_effect = { VAR = 1110_visited_guild_master_recently }
		trigger_event = gdp_visit_holding_decision_event.1110
	}
	option = {
		name = gdp_visit_holding_decision_event.1113.d
		custom_tooltip = gdp_visit_holding_decision_event.1113.d.tt
		trigger_event = gdp_visit_holding_decision_event.1110
	}	
}

######################################################################
# VISIT MARKET (Inland Location)
# gdp_visit_holding_decision_event.1300
# VISIT DOCKS (Coastal Location)
# gdp_visit_holding_decision_event.1400
######################################################################
# > Recruit Interesting People
# > Visit Foreign Traders

scripted_effect set_foreign_caravaneer_culture = {
	random_empire = {
		limit = {
			any_de_jure_county = {
				culture != root.culture
				culture = { has_cultural_tradition = tradition_saharan_traders }
			}
		}
		random_de_jure_county = {
			limit = {
				culture != root.culture
				culture = { has_cultural_tradition = tradition_saharan_traders }
			}
			save_scope_as = carvaneer_origin
		}
	}
}

#Rare: Spawn Monk
scripted_effect visit_holding_try_spawn_monk_effect = {
	if = {
		limit = {
			NOT = { has_variable = visit_holding_checked_for_monk }
			NOT = { exists = scope:monk }
			NOT = { visit_holding_rare_spawn_already_seen_trigger = { SCENE = monk } }
		}
		random_list = {
			100 = {
				#Search for monk in pool
				if = {
					limit = {
						NOT = { exists = scope:monk }
					}
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							is_available_healthy_adult = yes
							has_trait = devoted
							faith = scope:visiting_location.faith
							learning >= high_skill_rating
						}
						save_scope_as = monk
					}
				}
				#Otherwise create them
				if = {
					limit = {
						NOT = { exists = scope:monk }
					}
					create_character = {
						template = monk_character_template
						location = scope:visiting_location
						dynasty = none
						culture = scope:visiting_location.culture
						faith = scope:visiting_location.faith
						learning = { high_skill_rating very_high_skill_rating }
						save_scope_as = monk
						after_creation = {
							add_character_flag = created
						}
					}
				}
				if = {
					limit = { exists = scope:monk }
					visit_holding_mark_rare_spawn_seen_effect = { SCENE = monk }
				}
			}
		}
		set_variable = visit_holding_checked_for_monk
	}
}
#Rare: Spawn seasoned Caravaneer
scripted_effect visit_holding_try_spawn_caravaneer_effect = {
	if = {
		limit = {
			NOT = { has_variable = visit_holding_checked_for_caravaneer }
			NOT = { exists = scope:caravaneer }
			NOT = { visit_holding_rare_spawn_already_seen_trigger = { SCENE = caravaneer } }
		}
		random_list = {
			100 = {
				#Search for caravaneer in pool
				if = {
					limit = {
						NOT = { exists = scope:caravaneer }
					}
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							is_available_healthy_adult = yes
							culture = { has_cultural_tradition = tradition_saharan_traders }
							has_education_stewardship_trigger = yes
							stewardship >= high_skill_rating
						}
						save_scope_as = caravaneer
					}
				}
				#Otherwise create them
				if = {
					limit = {
						NOT = { exists = scope:caravaneer }
					}
					set_foreign_caravaneer_culture = yes
					if = {
						limit = {
							NOT = { exists = scope:carvaneer_origin }
						}
						scope:visiting_location = { save_scope_as = carvaneer_origin }
					}
					create_character = {
						template = gdp_seasoned_caravaneer_template
						location = scope:visiting_location
						dynasty = none
						culture = scope:carvaneer_origin.culture
						faith = scope:carvaneer_origin.faith
						gender_female_chance = 50
						save_scope_as = caravaneer
						after_creation = {
							add_character_flag = created
							set_location = root.location
							random_list = {
								50 = {
									add_random_tiered_trait_track_xp_effect = {
										TRAIT = lifestyle_traveler
										TRACK = travel
										LEVEL_1 = yes
										LEVEL_3 = no
									}
								}
								50 = {
									add_random_tiered_trait_track_xp_effect = {
										TRAIT = lifestyle_traveler
										TRACK = danger
										LEVEL_1 = yes
										LEVEL_3 = no
									}
								}
							}
						}
					}
				}
				if = {
					limit = { exists = scope:caravaneer }
					visit_holding_mark_rare_spawn_seen_effect = { SCENE = caravaneer }
				}
			}
		}
		set_variable = visit_holding_checked_for_caravaneer
	}
}
#Rare: Spawn Seasoned Sea Captain
scripted_effect visit_holding_try_spawn_sea_captain_effect = {
	if = {
		limit = {
			NOT = { has_variable = visit_holding_checked_for_sea_captain }
			NOT = { exists = scope:sea_captain }
			location ?= { is_coastal = yes }
			NOT = { visit_holding_rare_spawn_already_seen_trigger = { SCENE = sea_captain } }
		}
		random_list = {
			100 = {
				#Search for sea captain in pool
				if = {
					limit = {
						NOT = { exists = scope:sea_captain }
					}
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							is_available_healthy_adult = yes
							has_trait = forder
							visit_holding_stewardship_education_min_2_trigger = yes
							stewardship >= high_skill_rating
						}
						save_scope_as = sea_captain
						if = {
							limit = {
								NOT = { has_trait = one_legged }
							}
							add_trait = one_legged
						}
					}
				}
				#Otherwise create them
				if = {
					limit = {
						NOT = { exists = scope:sea_captain }
					}
					create_character = {
						template = weird_sailor_template
						location = scope:visiting_location
						dynasty = none
						culture = scope:visiting_location.culture
						faith = scope:visiting_location.faith
						trait = education_stewardship_2
						stewardship = { high_skill_rating very_high_skill_rating }
						save_scope_as = sea_captain
						after_creation = {
							add_character_flag = created
						}
					}
				}
				if = {
					limit = { exists = scope:sea_captain }
					visit_holding_ensure_stewardship_education_min_2_effect = { CHARACTER = scope:sea_captain }
					visit_holding_mark_rare_spawn_seen_effect = { SCENE = sea_captain }
				}
			}
		}
		set_variable = visit_holding_checked_for_sea_captain
	}
}
#Rare: Spawn Carnival Character
scripted_effect visit_holding_try_spawn_carnival_jester_effect = {
	if = {
		limit = {
			NOT = { has_variable = visit_holding_checked_for_carnival_jester }
			NOT = { exists = scope:carnival_jester }
			location ?= { is_coastal = no }
			NOT = { visit_holding_rare_spawn_already_seen_trigger = { SCENE = carnival_jester } }
		}
		random_list = {
			100 = {
				#Search for carnival jester in pool
				if = {
					limit = {
						NOT = { exists = scope:carnival_jester }
					}
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							is_available_healthy_adult = yes
							has_trait = gregarious
							intrigue >= high_skill_rating
						}
						save_scope_as = carnival_jester
						add_character_flag = jester_outfit
					}
				}
				#Otherwise create them
				if = {
					limit = {
						NOT = { exists = scope:carnival_jester }
					}
					create_character = {
						template = jester_template
						location = scope:visiting_location
						dynasty = none
						culture = scope:visiting_location.culture
						faith = scope:visiting_location.faith
						gender_female_chance = 50
						intrigue = { high_skill_rating very_high_skill_rating }
						save_scope_as = carnival_jester
						after_creation = {
							add_character_flag = jester_outfit
							add_character_flag = created
						}
					}
				}
				if = {
					limit = { exists = scope:carnival_jester }
					visit_holding_mark_rare_spawn_seen_effect = { SCENE = carnival_jester }
				}
			}
		}
		set_variable = visit_holding_checked_for_carnival_jester
	}
}
#Fallback: Spawn a former palace cook if no other rare character appeared
scripted_effect visit_holding_try_spawn_cook_effect = {
	if = {
		limit = {
			NOT = { has_variable = visit_holding_checked_for_cook }
			NOT = { visit_holding_rare_spawn_already_seen_trigger = { SCENE = cook } }
		}
		random_list = {
			100 = {
				#Search for a cook in pool
				if = {
					limit = {
						NOT = { exists = scope:cook }
					}
					random_pool_character = {
						province = scope:visiting_location
						limit = {
							is_available_healthy_adult = yes
							NOT = { has_trait = devoted }
							stewardship >= high_skill_rating
							NOR = {
								has_trait = generous
								has_trait = profligate
								has_trait = improvident
							}
						}
						save_scope_as = cook
					}
				}
				#Otherwise create them
				if = {
					limit = {
						NOT = { exists = scope:cook }
					}
					create_character = {
						template = bp1_yearly_2021_stewardship_person_template
						location = scope:visiting_location
						trait = arrogant
						trait = gluttonous
						dynasty = none
						culture = scope:visiting_location.culture
						faith = scope:visiting_location.faith
						stewardship = { high_skill_rating very_high_skill_rating }
						gender_female_chance = 50
						save_scope_as = cook
						after_creation = {
							add_character_flag = created
						}
					}
					scope:cook ?= {
						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 = { exists = scope:cook }
					visit_holding_mark_rare_spawn_seen_effect = { SCENE = cook }
				}
			}
		}
		set_variable = visit_holding_checked_for_cook
	}
}

scripted_trigger visit_holding_relax_tea_trigger = {
	location = {
		OR = {
			culture = {
				OR = {
					has_cultural_pillar = heritage_chinese
					has_cultural_pillar = heritage_japonic
					has_cultural_pillar = heritage_korean
					has_cultural_pillar = heritage_buyeo
				}
			}
			geographical_region = world_asia
		}
	}
}

#Visit Market 
gdp_visit_holding_decision_event.1300 = { 
	type = character_event 
	title = gdp_visit_holding_decision_event.1300.t 
	window = visit_settlement_window 
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					location ?= {
						OR = {
							culture ?= { has_graphical_east_asia_culture_group_trigger = yes }
							steppe_building_gfx_use_east_asian_trigger = yes
							steppe_building_gfx_use_southeast_asian_trigger = yes
							culture ?= { has_building_gfx = southeast_asian_building_gfx }
						}
					}
					location.county ?= {
						NOR = {
							title_province ?= {
								OR = {
									has_holding_type = tribal_holding
									has_holding_type = nomad_holding
									has_holding_type = herder_holding
								}
							}
							prosperity_level < 5
						}
					}
				}
				desc = gdp_visit_holding_decision_event.1300.asia
			}
			triggered_desc = {
				trigger = {
					location ?= {
						OR = {
							geographical_region = graphical_mena
							geographical_region = graphical_india
							culture ?= { has_building_gfx = iranian_building_gfx }
							culture ?= { has_building_gfx = indian_building_gfx }
							AND = {
					 			geographical_region = world_europe_west_iberia
					 			faith ?= { religion = religion:islam_religion }
					 		}
					 		steppe_building_gfx_use_indian_trigger = yes
					 		AND = {
						 		steppe_building_gfx_use_mena_trigger = yes
								NOT = {
									root = { government_has_flag = government_is_tribal }
									geographical_region = world_steppe
								}
							}
						}
					}
				}
				desc = gdp_visit_holding_decision_event.1300.mena_india
			}
			desc = gdp_visit_holding_decision_event.1300.default
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:monk
					exists = scope:been_to_monk
				}
				desc = gdp_visit_holding_decision_event.monk_hint_return
			}
			triggered_desc = {
				trigger = { exists = scope:monk }
				desc = gdp_visit_holding_decision_event.monk_hint
			}
			triggered_desc = {
				trigger = {
					exists = scope:caravaneer
					exists = scope:been_to_caravaneer
				}
				desc = gdp_visit_holding_decision_event.caravaneer_hint_return
			}
			triggered_desc = {
				trigger = { exists = scope:caravaneer }
				desc = gdp_visit_holding_decision_event.caravaneer_hint
			}
			triggered_desc = {
				trigger = {
					exists = scope:carnival_jester
					exists = scope:been_to_carnival_jester
				}
				desc = gdp_visit_holding_decision_event.carnival_jester_hint_return
			}
			triggered_desc = {
				trigger = { exists = scope:carnival_jester }
				desc = gdp_visit_holding_decision_event.carnival_jester_hint
			}
			triggered_desc = {
				trigger = {
					exists = scope:cook
					exists = scope:been_to_cook
				}
				desc = gdp_visit_holding_decision_event.cook_hint_return
			}
			triggered_desc = {
				trigger = { exists = scope:cook }
				desc = gdp_visit_holding_decision_event.cook_hint
			}
			desc = gdp_visit_holding_decision_event.1300.desc.fallback
		}
	}

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { reference = market }

	left_portrait = {
		character = root
		animation = steward
	}
	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:visiting_location }
			}
			location = { save_scope_as = visiting_location }
		}
		random = {
			chance = 20			
			location = {
				# Rare Spawn: Monk		
				if = {
					limit = {
						OR = {
							geographical_region = world_asia_japan
							geographical_region = world_asia_china
							geographical_region = world_asia_korea
						}
					}
					root = { visit_holding_try_spawn_monk_effect = yes }
				}
				# Rare Spawn: Caravaneer
				else_if = {
					limit = {
						OR = {
							# Check for cultures
							culture ?= { has_cultural_tradition = tradition_caravaneers }
							# Check for terrain
							geographical_region = world_africa_sahara
							geographical_region = world_africa_north
							geographical_region = sahel_sub_saharan_africa_nomad_area
						}
					}
					root = { visit_holding_try_spawn_caravaneer_effect = yes }
				}
				# Rare Spawn: Carnival Entertainer
				else_if = {
					limit = {
						is_coastal = no
						county.holder ?= { government_has_flag = government_is_republic }
					}
					root = { visit_holding_try_spawn_carnival_jester_effect = yes }
				}
				# Fallback: Cook
				else = {
					root = { visit_holding_try_spawn_cook_effect = yes }
				}
			}
		}
	}
	#Eavesdrop on traders
	option = {
		name = gdp_visit_holding_decision_event.1300.a
		trigger = { 
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1300.a.cooldown.tt
				NOT = { has_variable = 1310_has_created_contract_recently }
			}
		}
		show_as_unavailable = { always = yes }
		reason = traders 
		custom_tooltip =  gdp_visit_holding_decision_event.1300.a.tt
		trigger_event = gdp_visit_holding_decision_event.1310
	}
	#Look for recruits
	option = {
		name = gdp_visit_holding_decision_event.1300.b
		trigger = { 
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1300.b.cooldown.tt
				NOT = { has_variable = 1320_has_recruited_recently }
			}
		}
		show_as_unavailable = { always = yes }
		reason = market_recruitment
		custom_tooltip =  gdp_visit_holding_decision_event.1300.b.tt
		trigger_event = gdp_visit_holding_decision_event.1320
	}
	#Visit potential interesting character(s)
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:been_to_monk }
						desc = gdp_visit_holding_decision_event.1300.d_second
					}
					desc = gdp_visit_holding_decision_event.1300.d
				}
			}
		}
		trigger = {
			exists = scope:monk
			NOT = { exists = scope:recruited_interesting_character }
			is_ai = no
		}
		reason = market_recruitment
		custom_tooltip = gdp_visit_holding_decision_event.1300.d.tt
		trigger_event = gdp_visit_holding_decision_event.1330
	}
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:been_to_caravaneer }
						desc = gdp_visit_holding_decision_event.1300.g_second
					}
					desc = gdp_visit_holding_decision_event.1300.g
				}
			}
		}
		trigger = {
			exists = scope:caravaneer
			NOT = { exists = scope:recruited_interesting_character }
			is_ai = no
		}
		reason = market_recruitment
		custom_tooltip = gdp_visit_holding_decision_event.1300.g.tt
		trigger_event = gdp_visit_holding_decision_event.1333
	}
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:been_to_carnival_jester }
						desc = gdp_visit_holding_decision_event.1300.h_second
					}
					desc = gdp_visit_holding_decision_event.1300.h
				}
			}
		}
		trigger = {
			exists = scope:carnival_jester
			NOT = { exists = scope:recruited_interesting_character }
			is_ai = no
		}
		reason = market_recruitment
		custom_tooltip = gdp_visit_holding_decision_event.1300.h.tt
		trigger_event = gdp_visit_holding_decision_event.1335
	}
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:been_to_cook }
						desc = gdp_visit_holding_decision_event.1300.i_second
					}
					desc = gdp_visit_holding_decision_event.1300.i
				}
			}
		}
		trigger = {
			exists = scope:cook
			NOT = { exists = scope:recruited_interesting_character }
			is_ai = no
		}
		reason = market_recruitment
		custom_tooltip = gdp_visit_holding_decision_event.1300.i.tt
		trigger_event = gdp_visit_holding_decision_event.1336
	}
	# Just relax
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							visit_holding_relax_tea_trigger = yes
							NOR = {
								AND = {
									has_trait = drunkard
									location = {
										NOR = {
											geographical_region = world_europe
											geographical_region = world_asia
										}
									}
								}
								has_trait = comfort_eater
							}
						}
						desc = gdp_visit_holding_decision_event.1300.j_tea
					}
					triggered_desc = {
						trigger = {
							trigger_if = {
								limit = { has_trait = temperate }
								has_trait = hashishiyah
							}
							trigger_if = {
								limit = {
									NOT = { has_trait = hashishiyah }
								}
								NOT = { has_trait = comfort_eater }
							}
							can_be_hashishiyah = yes
							location = {
								NOR = {
									geographical_region = world_europe
									geographical_region = world_asia
								}
							}
						}
						desc = gdp_visit_holding_decision_event.1300.j_hashish
					}
					triggered_desc = {
						trigger = {
							trigger_if = {
								limit = { has_trait = temperate }
								has_trait = drunkard
							}
							trigger_if = {
								limit = {
									NOT = { has_trait = drunkard }
								}
								NOT = { has_trait = comfort_eater }
							}
							location = { # Not offering booze
								NOR = {
									religion = religion:islam_religion
									religion = religion:jainism_religion
									faith = faith:mandaean_faith
								}
							}
						}
						desc = gdp_visit_holding_decision_event.1300.j_drink
					}
					triggered_desc = {
						trigger = {
							trigger_if = {
								limit = { has_trait = temperate }
								has_trait = comfort_eater
							}
							NOR = {
								has_trait = inappetetic
								has_trait = temperate
							}
						}
						desc = gdp_visit_holding_decision_event.1300.j_food
					}
					desc = gdp_visit_holding_decision_event.1300.j_bath
				}
			}
		}
		trigger = {
			trigger_if = { # stop too many simultaneous options
				limit = {
					OR = {
						exists = scope:monk
						exists = scope:caravaneer
						exists = scope:carnival_jester
						exists = scope:cook
					}
				}
				exists = scope:recruited_interesting_character
			}
			stress > 0
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1300.j.cooldown.tt
				NOT = { has_variable = 1320_has_relaxed_recently }
			}
		}
		show_as_unavailable = { has_variable = 1320_has_relaxed_recently }
		reason = stress_loss
		custom_tooltip = gdp_visit_holding_decision_event.1300.j.tt
		if = {
			limit = { exists = scope:visiting_associate }
			custom_tooltip = gdp_visit_holding_decision_event.1300.j.associate.tt
		}
		trigger_event = gdp_visit_holding_decision_event.1340
	}
	#Go Back To Main Hub
	option = {
		name = gdp_visit_holding_decision_event.1300.c
		custom_tooltip =  gdp_visit_holding_decision_event.1300.c.tt
		trigger_event = gdp_visit_holding_decision_event.1000
	}
}
#Visit Docks
gdp_visit_holding_decision_event.1400 = { 
	type = character_event 
	title = gdp_visit_holding_decision_event.1400.t 
	window = visit_settlement_window 
	desc = {
		desc = gdp_visit_holding_decision_event.1400.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					location ?= {
						OR = {
							culture ?= {
								has_graphical_east_asia_culture_group_trigger = yes
							}
							steppe_building_gfx_use_east_asian_trigger = yes
							steppe_building_gfx_use_southeast_asian_trigger = yes
							culture ?= {
								has_building_gfx = southeast_asian_building_gfx
							}
						}
					}
					location.county ?= {
						NOR = {
							title_province ?= {
								OR = {
									has_holding_type = tribal_holding
									has_holding_type = nomad_holding
									has_holding_type = herder_holding
								}
							}
							prosperity_level < 5
						}
					}
				}
				desc = gdp_visit_holding_decision_event.1400.asia
			}
			triggered_desc = {
				trigger = {
					location ?= {
						OR = {
							geographical_region = graphical_mena
							geographical_region = graphical_india
							culture ?= { has_building_gfx = iranian_building_gfx }
							culture ?= { has_building_gfx = indian_building_gfx }
							AND = {
					 			geographical_region = world_europe_west_iberia
					 			faith ?= { religion = religion:islam_religion }
					 		}
					 		steppe_building_gfx_use_indian_trigger = yes
					 		AND = {
						 		steppe_building_gfx_use_mena_trigger = yes
								NOT = {
									root = { government_has_flag = government_is_tribal }
									geographical_region = world_steppe
								}
							}
						}
					}
				}
				desc = gdp_visit_holding_decision_event.1400.mena_india
			}
		desc = gdp_visit_holding_decision_event.1400.default
		}
		first_valid = {			
			triggered_desc = {
				trigger = {
					exists = scope:sea_captain
					exists = scope:been_to_sea_captain
				}
				desc = gdp_visit_holding_decision_event.sea_captain_hint_return
			}
			triggered_desc = {
				trigger = {
					exists = scope:sea_captain
					NOT = { exists = scope:been_to_sea_captain }
				}
				desc = gdp_visit_holding_decision_event.sea_captain_hint
			}
			desc = gdp_visit_holding_decision_event.1400.outro
		}	
	}

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { reference = docks }

	center_portrait = {
		character = root
		animation = steward
	}
	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:visiting_location }
			}
			location = { save_scope_as = visiting_location }
		}
		visit_holding_try_spawn_sea_captain_effect = yes
	}
	#Eavesdrop on traders
	option = {
		name = gdp_visit_holding_decision_event.1300.a
		trigger = { 
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1300.a.cooldown.tt
				NOT = { has_variable = 1310_has_created_contract_recently }
			}
		}
		show_as_unavailable = { always = yes }
		reason = traders 
		custom_tooltip =  gdp_visit_holding_decision_event.1300.a.tt
		trigger_event = gdp_visit_holding_decision_event.1310
	}
	#Look for recruits
	option = {
		name = gdp_visit_holding_decision_event.1400.b
		trigger = { 
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1300.b.cooldown.tt
				NOT = { has_variable = 1320_has_recruited_recently }
			}
		}
		show_as_unavailable = { always = yes }
		reason = market_recruitment
		custom_tooltip =  gdp_visit_holding_decision_event.1400.b.tt
		trigger_event = gdp_visit_holding_decision_event.1320
	}
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:been_to_sea_captain }
						desc = gdp_visit_holding_decision_event.1400.d_second
					}
					desc = gdp_visit_holding_decision_event.1400.d
				}
			}
		}
		trigger = {
			exists = scope:sea_captain
			NOR = {
				exists = scope:recruited_interesting_character
				has_character_flag = captain_shoved_off
			}
			is_ai = no
		}
		reason = market_recruitment
		custom_tooltip = gdp_visit_holding_decision_event.1400.d.tt
		trigger_event = gdp_visit_holding_decision_event.1334
	}
	# Just relax
	option = {
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = {
							visit_holding_relax_tea_trigger = yes
							NOR = {
								AND = {
									has_trait = drunkard
									location = {
										NOR = {
											geographical_region = world_europe
											geographical_region = world_asia
										}
									}
								}
								has_trait = comfort_eater
							}
						}
						desc = gdp_visit_holding_decision_event.1300.j_tea
					}
					triggered_desc = {
						trigger = {
							trigger_if = {
								limit = { has_trait = temperate }
								has_trait = hashishiyah
							}
							trigger_if = {
								limit = {
									NOT = { has_trait = hashishiyah }
								}
								NOT = { has_trait = comfort_eater }
							}
							can_be_hashishiyah = yes
							location = {
								NOR = {
									geographical_region = world_europe
									geographical_region = world_asia
								}
							}
						}
						desc = gdp_visit_holding_decision_event.1300.j_hashish
					}
					triggered_desc = {
						trigger = {
							trigger_if = {
								limit = { has_trait = temperate }
								has_trait = drunkard
							}
							trigger_if = {
								limit = {
									NOT = { has_trait = drunkard }
								}
								NOT = { has_trait = comfort_eater }
							}
							location = { # Not offering booze
								NOR = {
									religion = religion:islam_religion
									religion = religion:jainism_religion
									faith = faith:mandaean_faith
								}
							}
						}
						desc = gdp_visit_holding_decision_event.1300.j_drink
					}
					triggered_desc = {
						trigger = {
							trigger_if = {
								limit = { has_trait = temperate }
								has_trait = comfort_eater
							}
							NOR = {
								has_trait = inappetetic
								has_trait = temperate
							}
						}
						desc = gdp_visit_holding_decision_event.1300.j_food
					}
					desc = gdp_visit_holding_decision_event.1300.j_bath
				}
			}
		}
		trigger = {
			trigger_if = { # stop too many simultaneous options
				limit = {
					exists = scope:sea_captain
				}
				exists = scope:recruited_interesting_character
			}
			stress > 0
			#You're on cooldown
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1300.j.cooldown.tt
				NOT = { has_variable = 1320_has_relaxed_recently }
			}
		}
		show_as_unavailable = { has_variable = 1320_has_relaxed_recently }
		reason = stress_loss
		custom_tooltip = gdp_visit_holding_decision_event.1300.j.tt
		if = {
			limit = { exists = scope:visiting_associate }
			custom_tooltip = gdp_visit_holding_decision_event.1300.j.associate.tt
		}
		trigger_event = gdp_visit_holding_decision_event.1340
	}
	#Go Back To Main Hub
	option = {
		name = gdp_visit_holding_decision_event.1300.c
		custom_tooltip =  gdp_visit_holding_decision_event.1400.c.tt
		trigger_event = gdp_visit_holding_decision_event.1000
	}
}

#Visit Foreign Traders
gdp_visit_holding_decision_event.1310 = {
	type = character_event 
	title = gdp_visit_holding_decision_event.1310.t
	window = visit_settlement_window
	desc = gdp_visit_holding_decision_event.1310.desc
	
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { 
		trigger = { 
			location = { is_coastal = yes } 
		}
		reference = docks
	}
	override_background = { reference = market }

	left_portrait = {
		character = scope:foreigner
		animation = debating
		camera = camera_event_center_pointing_forward
	}
	center_portrait = {
		character = scope:local_trader
		animation = eyeroll
		hide_info = yes
		camera = camera_event_standing_with_horse_left
	}
	right_portrait = {
		character = root
		animation = eavesdrop
		camera = camera_event_left_forward
	}
	immediate = {
		random_empire = {
			limit = {
				any_de_jure_county = {
					culture != root.culture
					"squared_distance(root.location)" <= squared_distance_medium
				}
			}
			random_de_jure_county = {
				limit = {
					culture != root.culture
					"squared_distance(root.location)" <= squared_distance_medium
				}
				save_scope_as = foreign_trader_home
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:foreigner }
			}
			create_character = {
				template = generic_peasant_character
		        location = root.location
		        dynasty = none 
		        culture = scope:foreign_trader_home.culture
		        faith = scope:foreign_trader_home.faith
				save_scope_as = foreigner
				after_creation = {
					remove_character_flag = peasant_outfit
					set_location = root.location
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:local_trader }
			}
			create_character = {
				template = generic_peasant_character
		        location = root.location
		        dynasty = none 
		        culture = root.location.culture
		        faith = root.location.faith
				save_scope_as = local_trader
				after_creation = {
					remove_character_flag = peasant_outfit
				}
			}
		}
	}
	#Menagerie Acquisition Contract
	option = {
	 	name = gdp_visit_holding_decision_event.1310.a
	 	custom_tooltip =  gdp_visit_holding_decision_event.1310.a.tt
	 	trigger = {
 			can_create_task_contract = { type_name = menagerie_acquisition }
			custom_tooltip = {
				text = spawn_merchant_contract_interaction_duplicate_tt
				NOT = { any_character_task_contract = { has_task_contract_type = menagerie_acquisition } }
			}
			short_term_gold >= root.medium_gold_value
	 	}
	 	show_as_unavailable = { always = yes }
	 	trigger_event = { on_action = gdp_menagerie_acquisition }
	 	pay_short_term_gold = {
	 		target = scope:foreigner
	 		gold = root.medium_gold_value
	 	}
	 	#Dock Or Market-Hub
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
	 	visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1310_has_created_contract_recently }
	}
	#Procuring Curio Contract
	option = {
		name = gdp_visit_holding_decision_event.1310.b
	 	custom_tooltip =  gdp_visit_holding_decision_event.1310.b.tt
		trigger = {
			can_create_task_contract = { type_name = find_curio }
			custom_tooltip = {
				text = spawn_merchant_contract_interaction_duplicate_tt
				NOT = {
					any_character_task_contract = { has_task_contract_type = find_curio }
				}
			}
			short_term_gold >= root.medium_gold_value
		}
		show_as_unavailable = { always = yes }

	 	trigger_event = { on_action = gdp_find_curio }
	 	pay_short_term_gold = {
	 		target = scope:foreigner
	 		gold = root.medium_gold_value
	 	}
	 	#Dock Or Market-Hub
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
	 	visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1310_has_created_contract_recently }
	}
	#Company Purpose Contracts
	#Artisan Purpose
	option = {
		name = gdp_visit_holding_decision_event.1310.c
	 	custom_tooltip = gdp_visit_holding_decision_event.1310.c.tt
		trigger = {
 			can_create_task_contract = { type_name = support_guilds }
 			custom_tooltip = {
				text = spawn_merchant_contract_interaction_duplicate_tt
				NOT = {
					any_character_task_contract = { has_task_contract_type = support_guilds }
				}
			}
			custom_tooltip = {
				text = spawn_merchant_contract_interaction_cooldown_tt
				NOT = { has_character_flag = trade_opportunity_cooldown_support_guilds }
			}
			custom_tooltip = {
				text = spawn_merchant_contract_interaction_route_tt
				any_trade_route = {
					has_trader = yes
					any_trade_market_on_route = {}
				}
			}
			short_term_gold >= root.medium_gold_value
		}
		show_as_unavailable = { 
			has_realm_law = company_purpose_artisan
			can_create_task_contract = { type_name = support_guilds }
		}
	 	trigger_event = { on_action = gdp_support_guilds }
	 	pay_short_term_gold = {
	 		target = scope:foreigner
	 		gold = root.medium_gold_value
	 	}
	 	#Dock Or Market-Hub
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
	 	visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1310_has_created_contract_recently }
 	}
 	#Creditor Purpose
 	option = {
		name = gdp_visit_holding_decision_event.1310.c
	 	custom_tooltip = gdp_visit_holding_decision_event.1310.c.tt
		trigger = {
			can_create_task_contract = { type_name = seek_debtors }
			custom_tooltip = {
				text = spawn_merchant_contract_interaction_duplicate_tt
				NOT = {
					any_character_task_contract = { has_task_contract_type = seek_debtors }
				}
			}
			custom_tooltip = {
				text = spawn_merchant_contract_interaction_cooldown_tt
				NOT = { has_character_flag = trade_opportunity_cooldown_seek_debtors }
			}
			custom_tooltip = {
				text = spawn_merchant_contract_interaction_route_tt
				any_trade_route = {
					has_trader = yes
					any_trade_market_on_route = {}
				}
			}
		}
		show_as_unavailable = { 
			has_realm_law = company_purpose_creditor
			can_create_task_contract = { type_name = seek_debtors }
		}
	 	trigger_event = { on_action = gdp_seek_debtors }
	 	#Dock Or Market-Hub
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
 		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1310_has_created_contract_recently }
 	}
	#Dock Or Market-Hub Leave
	option = {
	 	name = gdp_visit_holding_decision_event.1310.d
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.d.tt	
		trigger = {
			location = { is_coastal = no }
		}
	 	trigger_event = gdp_visit_holding_decision_event.1300
	}
	option = {
	 	name = gdp_visit_holding_decision_event.1310.d
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.e.tt		
		trigger = {
			location = { is_coastal = yes }
		}
	 	trigger_event = gdp_visit_holding_decision_event.1400
	}
}

#Used to generate random recruits from templates
scripted_trigger 1320_generate_character_trigger = {
	NOR = {
        AND = {
            exists = scope:market_first_recruit
            scope:market_first_recruit = { has_character_flag = is_$ARCHETYPE$_recruit }
        }
        AND = {
            exists = scope:market_second_recruit
            scope:market_second_recruit = { has_character_flag = is_$ARCHETYPE$_recruit }
        }
        AND = {
            exists = scope:market_third_recruit
            scope:market_third_recruit = { has_character_flag = is_$ARCHETYPE$_recruit }
        }
    }
}
#Scripted effect to create a new character based on archetype
scripted_effect 1320_character_creation_type_effect = {
	create_character = {
        template = $ARCHETYPE$_recruit_template
        gender_female_chance = 50
        location = root.location
        dynasty = none 
        culture = $CULTURE$
        faith = $FAITH$
        save_scope_as = 1320_new_character
        after_creation = { add_character_flag = is_$ARCHETYPE$_recruit }
    }
    scope:1320_new_character ?= {
    	if = {
    		limit = { location != root.location }
    		set_location = root.location
    	}
    }
}
scripted_effect 1320_generate_character_effect = {
    random_list = {
        #Charlatan 
        10 = {
            trigger = {
                1320_generate_character_trigger = { ARCHETYPE = charlatan }
            }
            1320_character_creation_type_effect = { 
	            ARCHETYPE = charlatan 
	            CULTURE = root.location.culture
	            FAITH = root.location.faith
            }
        }
        #Hired Muscle
        10 = {
            trigger = {
                1320_generate_character_trigger = { ARCHETYPE = hired_muscle }
            }       
            1320_character_creation_type_effect = { 
            	ARCHETYPE = hired_muscle
            	CULTURE = root.location.culture
	            FAITH = root.location.faith
            }
        }
        #Numerate
        10 = {
            trigger = {
                1320_generate_character_trigger = { ARCHETYPE = numerate }
            }
            1320_character_creation_type_effect = { 
            	ARCHETYPE = numerate
            	CULTURE = root.location.culture
	            FAITH = root.location.faith            	
            }
        }
        #Traveler
        10 = {
            trigger = {
                1320_generate_character_trigger = { ARCHETYPE = traveler }
                exists = scope:foreign_traveler_origin
            }
            1320_character_creation_type_effect = {
            	ARCHETYPE = traveler
            	CULTURE = scope:foreign_traveler_origin.culture
	            FAITH = scope:foreign_traveler_origin.faith
            }
        }
        #Urchin
        10 = {
            trigger = {
                1320_generate_character_trigger = { ARCHETYPE = urchin }
            }
            1320_character_creation_type_effect = {
            	ARCHETYPE = urchin
            	CULTURE = root.location.culture
	            FAITH = root.location.faith
            }
        }
        #Herbalist
        10 = {
            trigger = {
                1320_generate_character_trigger = { ARCHETYPE = herbalist }
            }
            1320_character_creation_type_effect = {
            	ARCHETYPE = herbalist
            	CULTURE = root.location.culture
	            FAITH = root.location.faith
            }
        }
    }
    if = {
        limit = { NOT = { exists = scope:market_first_recruit } }
        scope:1320_new_character = { save_scope_as = market_first_recruit }
    }
    else_if = {
        limit = { NOT = { exists = scope:market_second_recruit } }
        scope:1320_new_character = { save_scope_as = market_second_recruit }
    }
    else_if = {
        limit = { NOT = { exists = scope:market_third_recruit } }
        scope:1320_new_character = { save_scope_as = market_third_recruit }
    }
}
scripted_effect 1320_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 = visit_holding_associate_recruit_gold_min
                max = visit_holding_associate_recruit_gold_max
            }
            multiply = {
            	value = scope:$VALUE_NAME$_sum_skills
            	divide = 15
            }
        }
    }
}
scripted_effect 1320_archetype_save_effect = {
	switch = {
		trigger = has_character_flag
		is_charlatan_recruit = { save_scope_as = charlatan_recruit }
		is_hired_muscle_recruit = { save_scope_as = hired_muscle_recruit }
		is_numerate_recruit = { save_scope_as = numerate_recruit }
		is_traveler_recruit = { save_scope_as = traveler_recruit }
		is_urchin_recruit = { save_scope_as = urchin_recruit }
		is_herbalist_recruit = { save_scope_as = herbalist_recruit }
	}
}
scripted_effect 1320_archetype_option_effect = {
	$SCOPE$ = {
		switch = {
			trigger = has_character_flag
			is_charlatan_recruit = {
				custom_tooltip = gdp_visit_holding_decision_event.1320.charlatan.tt
				root = {
					trigger_event = gdp_visit_holding_decision_event.1321
				}
			}
			is_hired_muscle_recruit = {
				custom_tooltip = gdp_visit_holding_decision_event.1320.hired_muscle.tt
				root = {
					trigger_event = gdp_visit_holding_decision_event.1322
				}
			}
			is_numerate_recruit = {
				custom_tooltip = gdp_visit_holding_decision_event.1320.numerate.tt
				root = {
					trigger_event = gdp_visit_holding_decision_event.1323
				}
			}
			is_traveler_recruit = {
				custom_tooltip = gdp_visit_holding_decision_event.1320.traveler.tt
				root = {
					trigger_event = gdp_visit_holding_decision_event.1324
				}
			}
			is_urchin_recruit = {
				custom_tooltip = gdp_visit_holding_decision_event.1320.urchin.tt
				root = {
					trigger_event = gdp_visit_holding_decision_event.1325
				}
			}
			is_herbalist_recruit = {
				custom_tooltip = gdp_visit_holding_decision_event.1320.herbalist.tt
				root = {
					trigger_event = gdp_visit_holding_decision_event.1326
				}
			}
		}
	}
}

scripted_effect set_foreign_traveler_origin_effect = {
	random_empire = {
		limit = {
			any_de_jure_county = {
				culture != root.culture
				"squared_distance(root.location)" <= squared_distance_medium
			}
		}
		random_de_jure_county = {
			limit = {
				culture != root.culture
				"squared_distance(root.location)" <= squared_distance_medium
			}
			save_scope_as = foreign_traveler_origin
		}
	}
}

#Recruit Interesting People
gdp_visit_holding_decision_event.1320 = {
	type = character_event 
	window = visit_settlement_window
	title = {
	    first_valid = {
    		triggered_desc = {
    		    trigger = {
    		    	location = { is_coastal = yes }
    		    }
    		    desc = gdp_visit_holding_decision_event.1320.t_docks
    		}
    		desc = gdp_visit_holding_decision_event.1320.t_market
    	}
    }	
	desc = {
		desc = gdp_visit_holding_decision_event.1320.desc
		#Check first recruit type
		desc = gdp_visit_holding_decision_event.1320.first_character_desc
		desc = gdp_visit_holding_decision_event.1320.mid.desc
		#Check Second Recruit type
		desc = gdp_visit_holding_decision_event.1320.second_character_desc
		desc = gdp_visit_holding_decision_event.1320.mid.desc
		#Check Third Recruit type
		desc = gdp_visit_holding_decision_event.1320.third_character_desc
	}

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { 
		trigger = { 
			location = { is_coastal = yes } 
		}
		reference = docks
	}
	override_background = { reference = market }

	left_portrait = {
		character = scope:market_first_recruit
		outfit_tags = { no_cloak }
		scripted_animation = gdp_visit_holding_animation_1320
		camera = camera_event_left
	}

	center_portrait = {
		character =  scope:market_second_recruit
		outfit_tags = { no_cloak }
		scripted_animation = gdp_visit_holding_animation_1320
		camera = camera_event_scheme_center
	}

	right_portrait = {
		character =  scope:market_third_recruit
		outfit_tags = { no_cloak }
		scripted_animation = gdp_visit_holding_animation_1320
		camera = camera_event_right_pointing_right
	}

	immediate = {
		hidden_effect = {
			set_foreign_traveler_origin_effect = yes
			while = {
				count = 3
				1320_generate_character_effect = yes
			}
		}

		#What recruit are they
		scope:market_first_recruit ?= {
			1320_archetype_save_effect = yes
		}
		scope:market_second_recruit ?= {
			1320_archetype_save_effect = yes
		}
		scope:market_third_recruit ?= {
			1320_archetype_save_effect = yes
		}
	}
	#What type of recruit are they? Set event based on type
	option = {
	 	name = gdp_visit_holding_decision_event.1320.a
	 	1320_archetype_option_effect = { SCOPE = scope:market_first_recruit }
	}
	option = {
	 	name = gdp_visit_holding_decision_event.1320.b
	 	1320_archetype_option_effect = { SCOPE = scope:market_second_recruit }
	}
	option = {
	 	name = gdp_visit_holding_decision_event.1320.c
	 	1320_archetype_option_effect = { SCOPE = scope:market_third_recruit }	
	}
	#Dock Or Market-Hub
	option = {
	 	name = gdp_visit_holding_decision_event.1320.d
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.d.tt		
		trigger = {
			location = { is_coastal = no }
		}
	 	trigger_event = gdp_visit_holding_decision_event.1300
	}
	option = {
	 	name = gdp_visit_holding_decision_event.1320.e
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.e.tt		
		trigger = {
			location = { is_coastal = yes }
		}
	 	trigger_event = gdp_visit_holding_decision_event.1400
	}
}

# Standard Recruitment Options
#The Charlatan
gdp_visit_holding_decision_event.1321 = {
	type = character_event 
	title = {
	    first_valid = {
    		triggered_desc = {
    		    trigger = {
    		    	location = { is_coastal = yes }
    		    }
    		    desc = gdp_visit_holding_decision_event.1321.t_docks
    		}
    		desc = gdp_visit_holding_decision_event.1321.t_market
    	}
    	desc = gdp_visit_holding_decision_event.1321.t
    }
	window = visit_settlement_window	
	desc = gdp_visit_holding_decision_event.1321.desc
 
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { 
		trigger = { 
			location = { is_coastal = yes } 
		}
		reference = docks
	}
	override_background = { reference = market }

	left_portrait = {
		character = root
		animation = interested
	}

	right_portrait = {
		character =  scope:charlatan_recruit
		animation = betting
		camera = camera_event_right_crowner_crowning
	}

	immediate = {
		#Set recruitment cost
		if = {
		 	limit = { 
		 		NOT = { exists = scope:charlatan_recruit_cost }
		 	}
		 	1320_set_cost_effect = { CHARACTER = scope:charlatan_recruit VALUE_NAME = charlatan_recruit_cost }
		}
	}

	#Beat Them at their own game (Skill Duel)
	option = {
		name = gdp_visit_holding_decision_event.1321.a

		duel = {
			skill = intrigue 
			value = average_skill_rating 
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1321.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1321.a.success
					left_icon = root 
					right_icon = scope:charlatan_recruit
					add_courtier = scope:charlatan_recruit
					hidden_effect = {
						scope:charlatan_recruit = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
						}
					}					
				}
				if = {
					limit = { has_lifestyle = intrigue_lifestyle }
					add_intrigue_lifestyle_xp = medium_lifestyle_xp
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1321.a.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1321.a.failure
					desc = gdp_visit_holding_decision_event.1321.a.failure
						left_icon = root 
						right_icon = scope:charlatan_recruit
				}
			}
		}
		#Dock Or Market-Hub
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			humble = minor_stress_impact_gain
			shy = medium_stress_impact_gain
			gregarious = minor_stress_impact_loss
			stubborn = minor_stress_impact_loss
			arrogant = medium_stress_impact_loss
		} 
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes } 
	}
	#Pay Them
	option = {
		name = gdp_visit_holding_decision_event.1321.b
		trigger = { 
			#You're broke
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1321.b.tt
				short_term_gold >= scope:charlatan_recruit_cost
			}
		}
		show_as_unavailable = { always = yes }

		pay_short_term_gold = {
			target = scope:charlatan_recruit
			gold = scope:charlatan_recruit_cost
		}

		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:charlatan_recruit 
			add_courtier = scope:charlatan_recruit
			hidden_effect = {
				scope:charlatan_recruit = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
				}
			}			
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
			generous = medium_stress_impact_loss
			ambitious = minor_stress_impact_loss
		} 
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes }
	}
	#Go Back
	option = {
	 	name = gdp_visit_holding_decision_event.1321.c
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.tt
	 	trigger_event = gdp_visit_holding_decision_event.1320
	}
}
#The Hired Muscle
gdp_visit_holding_decision_event.1322 = {
	type = character_event 
	title = {
	    first_valid = {
    		triggered_desc = {
    		    trigger = {
    		    	location = { is_coastal = yes }
    		    }
    		    desc = gdp_visit_holding_decision_event.1322.t_docks
    		}
    		desc = gdp_visit_holding_decision_event.1322.t_market
    	}
    	desc = gdp_visit_holding_decision_event.1322.t
    }
	window = visit_settlement_window
	desc = gdp_visit_holding_decision_event.1322.desc
 
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { 
		trigger = { 
			location = { is_coastal = yes } 
		}
		reference = docks
	}
	override_background = { reference = market }

	left_portrait = {
		character = root
		animation = dismissal
	}

	right_portrait = {
		character = scope:hired_muscle_recruit
		animation = rage
		camera = camera_event_scheme_vs_center_look_left
	}

	immediate = {
		#Set recruitment cost
		if = {
		 	limit = { 
		 		NOT = { exists = scope:hired_muscle_recruit_cost }
		 	}
		 	1320_set_cost_effect = { CHARACTER = scope:hired_muscle_recruit VALUE_NAME = hired_muscle_recruit_cost }
		}
	}

	#Beat Them at their own game (Skill Duel)
	option = {
		name = gdp_visit_holding_decision_event.1322.a
		duel = {
			skills = { martial prowess } 
			value = high_skill_rating 
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1322.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1322.a.success
					left_icon = root 
					right_icon = scope:hired_muscle_recruit
					add_courtier = scope:hired_muscle_recruit
					scope:hired_muscle_recruit = { increase_wounds_effect = { REASON = fight }
					}
					hidden_effect = {
						scope:hired_muscle_recruit = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
						}
					}
				}
				if = {
					limit = { has_lifestyle = martial_lifestyle }
					add_martial_lifestyle_xp = medium_lifestyle_xp
				}
			}
			#Fail: chance of injury 
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1322.a.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1322.a.failure
					desc = gdp_visit_holding_decision_event.1322.a.failure
					left_icon = root 
					right_icon = scope:hired_muscle_recruit
					add_stress = minor_stress_gain 
					root = { increase_wounds_effect = { REASON = fight }
					}
				}
			}
		}
		#Dock Or Market-Hub
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_gain
			craven = medium_stress_impact_gain
			just = minor_stress_impact_gain
			content = minor_stress_impact_gain
			brave = medium_stress_impact_loss
			arrogant = medium_stress_impact_loss
			stubborn = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			ambitious = minor_stress_impact_loss
		} 
		#Cooldown modifier
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes } 		
	}
	#Pay Them
	option = {
		name = gdp_visit_holding_decision_event.1322.b
		trigger = { 
			#You're broke
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1322.b.tt
				short_term_gold >= scope:hired_muscle_recruit_cost
			}
		}
		show_as_unavailable = { always = yes }
		pay_short_term_gold = {
			target = scope:hired_muscle_recruit
			gold = scope:hired_muscle_recruit_cost
		}

		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:hired_muscle_recruit 
			add_courtier = scope:hired_muscle_recruit
			hidden_effect = {
				scope:hired_muscle_recruit = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
				}
			}
		}
		#Stress modifiers
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
			generous = medium_stress_impact_loss
			ambitious = minor_stress_impact_loss
		} 
		#Set cooldown
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Dock Or Market-Hub
		if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes }
	}
	#Go Back
	option = {
	 	name = gdp_visit_holding_decision_event.1322.c
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.tt
	 	trigger_event = gdp_visit_holding_decision_event.1320
	 }
}
#The Numerate
gdp_visit_holding_decision_event.1323 = {
	type = character_event 
	title = {
	    first_valid = {
    		triggered_desc = {
    		    trigger = { location = { is_coastal = yes } }
    		    desc = gdp_visit_holding_decision_event.1323.t_docks
    		}
    		desc = gdp_visit_holding_decision_event.1323.t_market
    	}
    	desc = gdp_visit_holding_decision_event.1323.t
    }
	window = visit_settlement_window 	
	desc = gdp_visit_holding_decision_event.1323.desc
 
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { 
		trigger = { 
			location = { is_coastal = yes } 
		}
		reference = docks
	}
	override_background = { reference = market }

	left_portrait = {
		character = root
		animation = thinking_all
	}

	right_portrait = {
		character =  scope:numerate_recruit
		animation = writing
		camera = camera_event_scheme_vs_center_look_left
	}

	immediate = {
		#Set recruitment cost
		if = {
		 	limit = { 
		 		NOT = { exists = scope:numerate_recruit_cost }
		 	}
		 	1320_set_cost_effect = { CHARACTER = scope:numerate_recruit VALUE_NAME = numerate_recruit_cost }
		}
	}

	#Beat Them at their own game (Skill Duel)
	option = {
		name = gdp_visit_holding_decision_event.1323.a
		duel = {
			skill = stewardship
			value = average_skill_rating 
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1323.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1323.a.success
					left_icon = root 
					right_icon = scope:numerate_recruit
					add_courtier = scope:numerate_recruit
					hidden_effect = {
						scope:numerate_recruit = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
						}
					}
				}
				if = {
					limit = { has_lifestyle = stewardship_lifestyle }
					add_stewardship_lifestyle_xp = medium_lifestyle_xp
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1323.a.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1323.a.failure
					desc = gdp_visit_holding_decision_event.1323.a.failure
						left_icon = root 
						right_icon = scope:numerate_recruit
				}
			}
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			deceitful = medium_stress_impact_gain
			impatient = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			eccentric = medium_stress_impact_loss
			patient = minor_stress_impact_loss
			honest = minor_stress_impact_loss
			diligent = minor_stress_impact_loss
		} 
		#Set Cooldown 
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes } 
	}
	#Pay Them
	option = {
		name = gdp_visit_holding_decision_event.1323.b
		trigger = { 
			#You're broke
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1323.b.tt
				short_term_gold >= scope:numerate_recruit_cost
			}
		}
		show_as_unavailable = { always = yes }

		pay_short_term_gold = {
			target = scope:numerate_recruit
			gold = scope:numerate_recruit_cost
		}

		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:numerate_recruit 
			add_courtier = scope:numerate_recruit
			hidden_effect = {
				scope:numerate_recruit = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
				}
			}			
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
			generous = medium_stress_impact_loss
			ambitious = minor_stress_impact_loss
		}		
		#Set cooldown
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes }
	}
	#Go Back
	option = {
	 	name = gdp_visit_holding_decision_event.1323.c
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.tt
	 	trigger_event = gdp_visit_holding_decision_event.1320
	 }
}
#The Traveler
gdp_visit_holding_decision_event.1324 = {
	type = character_event 
	title = {
	    first_valid = {
    		triggered_desc = {
    		    trigger = { location = { is_coastal = yes } }
    		    desc = gdp_visit_holding_decision_event.1324.t_docks
    		}
    		desc = gdp_visit_holding_decision_event.1324.t_market
    	}
    	desc = gdp_visit_holding_decision_event.1324.t
    }
	window = visit_settlement_window 	
	desc = gdp_visit_holding_decision_event.1324.desc
 
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { 
		trigger = { 
			location = { is_coastal = yes } 
		}
		reference = docks
	}
	override_background = { reference = market }

	left_portrait = {
		character = root
		animation = flirtation
	}

	center_portrait = {
		character =  scope:traveler_recruit
		animation = admiration
		camera = camera_event_scheme_vs_center_look_left
	}

	right_portrait = {
		character = scope:local
		animation = holding_scales
		camera = camera_event_center_away_pointing_left_fov25
	}	

	immediate = {
		#Set recruitment cost
		if = {
		 	limit = { 
		 		NOT = { exists = scope:traveler_recruit_cost }
		 	}
		 	1320_set_cost_effect = { CHARACTER = scope:traveler_recruit VALUE_NAME = traveler_recruit_cost }
		}

		if = {
			limit = {
				NOT = { exists = scope:local }
			}
			create_character = {
				template = generic_peasant_character
		        location = root.location
		        dynasty = none 
		        culture = root.location.culture
		        faith = root.location.faith
				save_scope_as = local
				after_creation = { remove_character_flag = peasant_outfit }
			}
		}
	}

	#Beat Them at their own game (Skill Duel)
	option = {
		name = gdp_visit_holding_decision_event.1324.a
		duel = {
			skill = diplomacy
			value = average_skill_rating 
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1324.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1324.a.success
					left_icon = root 
					right_icon = scope:traveler_recruit
					add_courtier = scope:traveler_recruit
					hidden_effect = {
						scope:traveler_recruit = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
						}
					}
				}
				if = {
					limit = { has_lifestyle = diplomacy_lifestyle }
					add_diplomacy_lifestyle_xp = medium_lifestyle_xp
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1324.a.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1324.a.failure
					desc = gdp_visit_holding_decision_event.1324.a.failure
						left_icon = root 
						right_icon = scope:traveler_recruit
				}
			}
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			impatient = medium_stress_impact_gain
			lazy = minor_stress_impact_gain
			shy = medium_stress_impact_gain
			patient = minor_stress_impact_loss
			honest = minor_stress_impact_loss
			diligent = minor_stress_impact_loss
			gregarious = medium_stress_impact_loss
		}
		#Set Cooldown 
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes } 
	}
	#Pay Them
	option = {
		name = gdp_visit_holding_decision_event.1324.b
		trigger = { 
			#You're broke
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1324.b.tt
				short_term_gold >= scope:traveler_recruit_cost
			}
		}
		show_as_unavailable = { always = yes }

		pay_short_term_gold = {
			target = scope:traveler_recruit
			gold = scope:traveler_recruit_cost
		}

		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:traveler_recruit
			add_courtier = scope:traveler_recruit
			hidden_effect = {
				scope:traveler_recruit = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
				}
			}			
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
			generous = medium_stress_impact_loss
			ambitious = minor_stress_impact_loss
		}		
		#Set cooldown
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes }
	}
	#Go Back
	option = {
	 	name = gdp_visit_holding_decision_event.1324.c
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.tt
	 	trigger_event = gdp_visit_holding_decision_event.1320
	 }
}
#The Urchin
gdp_visit_holding_decision_event.1325 = {
	type = character_event 
	title = {
	    first_valid = {
    		triggered_desc = {
    		    trigger = { location = { is_coastal = yes } }
    		    desc = gdp_visit_holding_decision_event.1325.t_docks
    		}
    		desc = gdp_visit_holding_decision_event.1325.t_market
    	}
    	desc = gdp_visit_holding_decision_event.1325.t
    }
	window = visit_settlement_window 	
	desc = gdp_visit_holding_decision_event.1325.desc
 
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { 
		trigger = { 
			location = { is_coastal = yes } 
		}
		reference = docks
	}
	override_background = { reference = market }

	center_portrait = {
		character = root
		animation = disbelief
		camera = camera_body_right
	}

	right_portrait = {
		character =  scope:urchin_recruit
		animation = beg
		camera = camera_event_center_pointing_left
	}	

	immediate = {
		#Set recruitment cost
		if = {
		 	limit = { 
		 		NOT = { exists = scope:urchin_recruit_cost }
		 	}
		 	1320_set_cost_effect = { CHARACTER = scope:urchin_recruit VALUE_NAME = urchin_recruit_cost }
		}
	}

	#Beat Them at their own game (Skill Duel)
	option = {
		name = gdp_visit_holding_decision_event.1325.a
		duel = {
			skill = intrigue 
			value = average_skill_rating 
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1325.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1325.a.success
					left_icon = root 
					right_icon = scope:urchin_recruit
					add_courtier = scope:urchin_recruit
					hidden_effect = {
						scope:urchin_recruit = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
						}
					}					
				}
				if = {
					limit = { has_lifestyle = intrigue_lifestyle }
					add_intrigue_lifestyle_xp = medium_lifestyle_xp
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1325.a.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1325.a.failure
					desc = gdp_visit_holding_decision_event.1325.a.failure
					left_icon = root 
					right_icon = scope:urchin_recruit
				}
			}
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			deceitful = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			honest = minor_stress_impact_gain
			trusting = medium_stress_impact_gain
			just = medium_stress_impact_gain
		} 
		#Set Cooldown 
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes } 
	}
	#Pay Them
	option = {
		name = gdp_visit_holding_decision_event.1325.b
		trigger = { 
			#You're broke
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1325.b.tt
				short_term_gold >= scope:urchin_recruit_cost
			}
		}
		show_as_unavailable = { always = yes }

		pay_short_term_gold = {
			target = scope:urchin_recruit
			gold = scope:urchin_recruit_cost
		}
		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:urchin_recruit
			add_courtier = scope:urchin_recruit	
			hidden_effect = {
				scope:urchin_recruit = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
				}
			}
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
			generous = medium_stress_impact_loss
			ambitious = minor_stress_impact_loss
		}		
		#Set cooldown
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes }
	}
	#Go Back
	option = {
	 	name = gdp_visit_holding_decision_event.1325.c
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.tt
	 	trigger_event = gdp_visit_holding_decision_event.1320
	 }
}
#The Herbalist
gdp_visit_holding_decision_event.1326 = {
	type = character_event 
	title = {
	    first_valid = {
    		triggered_desc = {
    		    trigger = {
    		    	location = { is_coastal = yes }
    		    }
    		    desc = gdp_visit_holding_decision_event.1326.t_docks
    		}
    		desc = gdp_visit_holding_decision_event.1326.t_market
    	}
    	desc = gdp_visit_holding_decision_event.1326.t
    }
	window = visit_settlement_window 	
	desc = gdp_visit_holding_decision_event.1326.desc
 
	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_generic" }
	override_background = { 
		trigger = { 
			location = { is_coastal = yes } 
		}
		reference = docks
	}
	override_background = { reference = market }

	center_portrait = {
		character = root
		animation = delirium
		camera = camera_body_right
	}

	right_portrait = {
		character = scope:herbalist_recruit
		animation = physician
		camera = camera_body_left
	}	

	immediate = {
		#Set recruitment cost
		if = {
		 	limit = { 
		 		NOT = { exists = scope:herbalist_recruit_cost }
		 	}
		 	1320_set_cost_effect = { CHARACTER = scope:herbalist_recruit VALUE_NAME = herbalist_recruit_cost }
		}
	}

	#Beat Them at their own game (Skill Duel)
	option = {
		name = gdp_visit_holding_decision_event.1326.a
		duel = {
			skill = learning
			value = average_skill_rating 
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1326.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1326.a.success
					left_icon = root 
					right_icon = scope:herbalist_recruit
					add_courtier = scope:herbalist_recruit
					hidden_effect = {
						scope:herbalist_recruit = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
						}
					}					
				}
				if = {
					limit = { has_lifestyle = learning_lifestyle }
					add_learning_lifestyle_xp = medium_lifestyle_xp
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1326.a.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1326.a.failure
					desc = gdp_visit_holding_decision_event.1326.a.failure
						left_icon = root 
						right_icon = scope:herbalist_recruit
				}
			}
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = { trigger_event = gdp_visit_holding_decision_event.1300 }
		#Stress modifiers
		stress_and_fulfillment_impact = {
			deceitful = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			eccentric = minor_stress_impact_loss
			patient = minor_stress_impact_loss
			honest = medium_stress_impact_loss
			stubborn = medium_stress_impact_loss
		} 
		#Set Cooldown 
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes } 
	}
	#Pay Them
	option = {
		name = gdp_visit_holding_decision_event.1326.b
		trigger = { 
			#You're broke
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1326.b.tt
				short_term_gold >= scope:herbalist_recruit_cost
			}
		}
		show_as_unavailable = { always = yes }

		pay_short_term_gold = {
			target = scope:herbalist_recruit
			gold = scope:herbalist_recruit_cost
		}

		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:herbalist_recruit
			add_courtier = scope:herbalist_recruit	
			hidden_effect = {
				scope:herbalist_recruit = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
				}
			}
		}
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = {
	 		trigger_event = gdp_visit_holding_decision_event.1300
	 	}
		#Stress modifiers
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
			generous = medium_stress_impact_loss
			ambitious = minor_stress_impact_loss
		}		
		#Set cooldown
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		#Clean up variables
		visit_holding_clean_up_variables_effect = yes
		scope:market_first_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_second_recruit = {visit_holding_clean_up_variables_effect = yes }
		scope:market_third_recruit = {visit_holding_clean_up_variables_effect = yes }
	}
	#Go Back
	option = {
	 	name = gdp_visit_holding_decision_event.1326.c
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.tt
	 	trigger_event = gdp_visit_holding_decision_event.1320
	}
}

# Rare Spawn Characters
# The Monk
gdp_visit_holding_decision_event.1330 = {
	type = character_event
	title = gdp_visit_holding_decision_event.1330.t
	window = visit_settlement_window
	desc = {
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:been_to_monk
						scope:monk_loc_tracker ?= 1
					}
					desc = gdp_visit_holding_decision_event.1330.desc_returned_01
				}
				triggered_desc = {
					trigger = { scope:monk_loc_tracker ?= 2 }
					desc = gdp_visit_holding_decision_event.1330.desc_returned_02
				}
			}
			desc = gdp_visit_holding_decision_event.1330.desc
		}
	}

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_social" }
	override_background = tavern

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:monk }
			animation = interested
		}
		animation = pondering
	}
	right_portrait = {
		character = scope:monk
		trigger = { exists = scope:monk }
		animation = prayer
	}
	immediate = {
		#Set recruitment cost
		if = {
		 	limit = { 
		 		NOT = { exists = scope:monk_recruit_cost }
		 	}
		 	1320_set_cost_effect = { CHARACTER = scope:monk VALUE_NAME = monk_recruit_cost }
		}
		visit_holding_set_rare_recruit_loc_tracker_effect = { SCENE = monk }
		visit_holding_pick_merchant_court_position_effect = {
			CHARACTER = scope:monk
			EMPLOYER = root
		}
	}
	#Recruit them
	option = {
		name = gdp_visit_holding_decision_event.1330.a
		trigger = {
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1330.a.tt
				short_term_gold >= scope:monk_recruit_cost
			}
		}
		scope:monk = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1330.recruit_benefits.tt
					object = scope:monk
				}
			}
		}
		show_as_unavailable = { always = yes }
		pay_short_term_gold = {
			target = scope:monk
			gold = scope:monk_recruit_cost
		}
		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:monk
			add_courtier = scope:monk	
			hidden_effect = {
				scope:monk = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
					save_scope_as = recruited_interesting_character
				}
			}
		}
		visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:monk }
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Duel them
	option = {
		name = gdp_visit_holding_decision_event.1330.c
		scope:monk = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1330.recruit_benefits.tt
					object = scope:monk
				}
			}
		}
		duel = {
			skill = diplomacy 
			value = average_skill_rating 
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1330.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1330.c.success
					left_icon = root
					right_icon = scope:monk
					add_courtier = scope:monk
					hidden_effect = {
						scope:monk = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
							remove_character_flag ?= created
							save_scope_as = recruited_interesting_character
						}
					}
				}
				visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:monk }
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1330.c.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1330.c.failure
					desc = gdp_visit_holding_decision_event.1330.c.failure
					left_icon = root 
					right_icon = scope:monk
				}
				visit_holding_rare_recruit_duel_loss_effect = {
					CHARACTER = scope:monk
					SCENE = monk
				}
			}
		}
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Go Back
	option = {
	 	name = gdp_visit_holding_decision_event.1330.d
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.d.tt
		visit_holding_been_to_rare_recruit_effect = { SCENE = monk }
	 	visit_holding_return_to_market_dock_hub_effect = yes
	}
}
# The Seasoned Caravaneer
gdp_visit_holding_decision_event.1333 = {
	type = character_event
	title = {
		desc = gdp_visit_holding_decision_event.1333.t_market
		desc = gdp_visit_holding_decision_event.1333.t
	}
	window = visit_settlement_window
	desc = {
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:been_to_caravaneer
						scope:caravaneer_loc_tracker ?= 1
					}
					desc = gdp_visit_holding_decision_event.1333.desc_returned_01
				}
				triggered_desc = {
					trigger = { scope:caravaneer_loc_tracker ?= 2 }
					desc = gdp_visit_holding_decision_event.1333.desc_returned_02
				}
			}
			desc = gdp_visit_holding_decision_event.1333.desc
		}
	}

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_social" }
	override_background = { reference = market }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:caravaneer }
			animation = interested
		}
		animation = pondering
	}
	right_portrait = {
		character = scope:caravaneer
		trigger = { exists = scope:caravaneer }
		animation = dromedary_holding
		camera = camera_event_center_pointing_forward_fov35
	}
	immediate = {
		#Set recruitment cost
		if = {
			limit = {
				NOT = { exists = scope:caravaneer_recruit_cost }
			}
			1320_set_cost_effect = { CHARACTER = scope:caravaneer VALUE_NAME = caravaneer_recruit_cost }
		}
		visit_holding_set_rare_recruit_loc_tracker_effect = { SCENE = caravaneer }
		visit_holding_pick_merchant_court_position_effect = {
			CHARACTER = scope:caravaneer
			EMPLOYER = root
		}
	}
	#Recruit them
	option = {
		name = gdp_visit_holding_decision_event.1333.a
		trigger = {
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1333.a.tt
				short_term_gold >= scope:caravaneer_recruit_cost
			}
		}
		scope:caravaneer = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1333.recruit_benefits.tt
					object = scope:caravaneer
				}
			}
		}
		show_as_unavailable = { always = yes }
		pay_short_term_gold = {
			target = scope:caravaneer
			gold = scope:caravaneer_recruit_cost
		}
		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:caravaneer
			add_courtier = scope:caravaneer
			hidden_effect = {
				scope:caravaneer = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
					save_scope_as = recruited_interesting_character
				}
			}
		}
		visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:caravaneer }
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Caravaneer: talk shop
	option = {
		name = gdp_visit_holding_decision_event.1333.b
		trigger = {
			has_realm_law = company_purpose_caravaneer
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1333.b.cooldown.tt
				NOT = { has_variable = 1333_gained_caravaneer_xp_recently }
			}
		}
		show_as_unavailable = { has_realm_law = company_purpose_caravaneer }
		reason = purpose_caravaneer
		add_trait_xp = {
			trait = lifestyle_merchant
			track = caravaneer
			value = lifestyle_merchant_xp_gain_minor_value
		}
		random = {
			chance = 10
			if = {
				limit = {
					NOT = { has_trait = lifestyle_traveler }
				}
				add_trait = lifestyle_traveler
			}
		}
		visit_holding_set_option_cooldown_effect = { VAR = 1333_gained_caravaneer_xp_recently }
		visit_holding_return_to_market_dock_hub_effect = yes
	}

	#Duel them
	option = {
		name = gdp_visit_holding_decision_event.1333.c
		scope:caravaneer = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1333.recruit_benefits.tt
					object = scope:caravaneer
				}
			}
		}
		duel = {
			skill = stewardship
			value = average_skill_rating
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1333.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1333.c.success
					left_icon = root
					right_icon = scope:caravaneer
					add_courtier = scope:caravaneer
					hidden_effect = {
						scope:caravaneer = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
							remove_character_flag ?= created
							save_scope_as = recruited_interesting_character
						}
					}
				}
				visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:caravaneer }
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1333.c.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1333.c.failure
					desc = gdp_visit_holding_decision_event.1333.c.failure
					left_icon = root
					right_icon = scope:caravaneer
				}
				visit_holding_rare_recruit_duel_loss_effect = {
					CHARACTER = scope:caravaneer
					SCENE = caravaneer
				}
			}
		}
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Go Back
	option = {
		name = gdp_visit_holding_decision_event.1333.d
		custom_tooltip = gdp_visit_holding_decision_event.1320.d.tt
		visit_holding_been_to_rare_recruit_effect = { SCENE = caravaneer }
		visit_holding_return_to_market_dock_hub_effect = yes
	}
}
# The Sea Captain
gdp_visit_holding_decision_event.1334 = {
	type = character_event
	title = {
		desc = gdp_visit_holding_decision_event.1334.t_docks
		desc = gdp_visit_holding_decision_event.1334.t
	}
	window = visit_settlement_window
	desc = {
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:been_to_sea_captain
						scope:sea_captain_loc_tracker ?= 1
					}
					desc = gdp_visit_holding_decision_event.1334.desc_returned_01
				}
				triggered_desc = {
					trigger = { scope:sea_captain_loc_tracker ?= 2 }
					desc = gdp_visit_holding_decision_event.1334.desc_returned_02
				}
			}
			desc = gdp_visit_holding_decision_event.1334.desc
		}
	}

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_social" }
	override_background = { reference = docks }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:sea_captain }
			animation = interested
		}
		animation = pondering
	}
	center_portrait = {
		character = scope:sea_captain
		trigger = { exists = scope:sea_captain }
		animation = biting_coin
	}
	right_portrait = {
		character = scope:traveler
		trigger = { 
			exists = scope:sea_captain
			NOT = { exists = scope:been_to_sea_captain }
		}
		animation = beg
		hide_info = yes
		camera = camera_event_right
	}
	immediate = {
		#Set recruitment cost
		if = {
			limit = {
				NOT = { exists = scope:sea_captain_recruit_cost }
			}
			1320_set_cost_effect = { CHARACTER = scope:sea_captain VALUE_NAME = sea_captain_recruit_cost }
		}
		visit_holding_set_rare_recruit_loc_tracker_effect = { SCENE = sea_captain }
		visit_holding_pick_merchant_court_position_effect = {
			CHARACTER = scope:sea_captain
			EMPLOYER = root
		}
		#Set up crowd
		if = {
			limit = { is_ai = no }
			create_character = {
				template = peasant_character
				location = root.location
				culture = root.culture
				gender_female_chance = 50
				save_scope_as = traveler
			}
		}
	}

	#Traveler: talk shop
	option = {
		name = gdp_visit_holding_decision_event.1334.b
		trigger = {
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1334.b.cooldown.tt
				NOT = { has_variable = 1334_gained_traveler_xp_recently }
			}
		}
		show_as_unavailable = { always = yes }
		if = {
			limit = {
				NOT = { has_trait = lifestyle_traveler }
			}
			add_trait = lifestyle_traveler
		}
		add_trait_xp = {
			trait = lifestyle_traveler
			track = travel
			value = { 3 5 }
		}
		visit_holding_set_option_cooldown_effect = { VAR = 1334_gained_traveler_xp_recently }
		visit_holding_return_to_market_dock_hub_effect = yes
	}

	#Recruit them
	option = {
		name = gdp_visit_holding_decision_event.1334.a
		trigger = {
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1334.a.tt
				short_term_gold >= scope:sea_captain_recruit_cost
			}
		}
		scope:sea_captain = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1334.recruit_benefits.tt
					object = scope:sea_captain
				}
			}
		}
		show_as_unavailable = { always = yes }
		pay_short_term_gold = {
			target = scope:sea_captain
			gold = scope:sea_captain_recruit_cost
		}
		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:sea_captain
			add_courtier = scope:sea_captain
			hidden_effect = {
				scope:sea_captain = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
					save_scope_as = recruited_interesting_character
				}
			}
		}
		visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:sea_captain }
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Duel them
	option = {
		name = gdp_visit_holding_decision_event.1334.c
		scope:sea_captain = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1334.recruit_benefits.tt
					object = scope:sea_captain
				}
			}
		}
		duel = {
			skill = stewardship
			value = average_skill_rating
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1334.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1334.c.success
					left_icon = root
					right_icon = scope:sea_captain
					add_courtier = scope:sea_captain
					hidden_effect = {
						scope:sea_captain = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
							remove_character_flag ?= created
							save_scope_as = recruited_interesting_character
						}
					}
				}
				visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:sea_captain }
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1334.c.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1334.c.failure
					desc = gdp_visit_holding_decision_event.1334.c.failure
					left_icon = root
					right_icon = scope:sea_captain
				}
				visit_holding_rare_recruit_duel_loss_effect = {
					CHARACTER = scope:sea_captain
					SCENE = sea_captain
				}
				add_character_flag = captain_shoved_off
			}
		}
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Go Back
	option = {
		name = gdp_visit_holding_decision_event.1334.d
		custom_tooltip = gdp_visit_holding_decision_event.1320.e.tt
		visit_holding_been_to_rare_recruit_effect = { SCENE = sea_captain }
		visit_holding_return_to_market_dock_hub_effect = yes
	}
	after = {
		scope:traveler ?= { silent_disappearance_effect = yes }
	}
}
# The Carnival Jester
gdp_visit_holding_decision_event.1335 = {
	type = character_event
	title = {
		desc = gdp_visit_holding_decision_event.1335.t_market
		desc = gdp_visit_holding_decision_event.1335.t
	}
	window = visit_settlement_window
	desc = {
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:been_to_carnival_jester
						scope:carnival_jester_loc_tracker ?= 1
					}
					desc = gdp_visit_holding_decision_event.1335.desc_returned_01
				}
				triggered_desc = {
					trigger = { scope:carnival_jester_loc_tracker ?= 2 }
					desc = gdp_visit_holding_decision_event.1335.desc_returned_02
				}
			}
			desc = gdp_visit_holding_decision_event.1335.desc
		}
	}

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_social" }
	override_background = { reference = market }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:carnival_jester }
			animation = interested
		}
		animation = pondering
	}
	center_portrait = {
		character = scope:carnival_jester
		trigger = { exists = scope:carnival_jester }
		animation = juggling
	}
	right_portrait = {
		character = scope:carnival_spectator
		animation = happiness
		hide_info = yes
		camera = camera_event_right
	}
	immediate = {
		#Set recruitment cost
		if = {
			limit = {
				NOT = { exists = scope:carnival_jester_recruit_cost }
			}
			1320_set_cost_effect = { CHARACTER = scope:carnival_jester VALUE_NAME = carnival_jester_recruit_cost }
		}
		visit_holding_set_rare_recruit_loc_tracker_effect = { SCENE = carnival_jester }
		visit_holding_pick_merchant_court_position_effect = {
			CHARACTER = scope:carnival_jester
			EMPLOYER = root
		}
		#Set up crowd
		if = {
			limit = { is_ai = no }
			create_character = {
				template = peasant_character
				location = root.location
				culture = root.location.culture
				faith = root.location.faith
				gender_female_chance = 50
				save_scope_as = carnival_spectator
			}
		}
	}

	#Creditor: talk shop
	option = {
		name = gdp_visit_holding_decision_event.1335.b
		trigger = {
			has_realm_law = company_purpose_creditor
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1335.b.cooldown.tt
				NOT = { has_variable = 1335_gained_creditor_xp_recently }
			}
		}
		show_as_unavailable = { has_realm_law = company_purpose_creditor }
		reason = purpose_creditor
		add_trait_xp = {
			trait = lifestyle_merchant
			track = creditor
			value = lifestyle_merchant_xp_gain_minor_value
		}
		visit_holding_set_option_cooldown_effect = { VAR = 1335_gained_creditor_xp_recently }
		visit_holding_return_to_market_dock_hub_effect = yes
	}
	
	#Recruit them
	option = {
		name = gdp_visit_holding_decision_event.1335.a
		trigger = {
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1335.a.tt
				short_term_gold >= scope:carnival_jester_recruit_cost
			}
		}
		scope:carnival_jester = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1335.recruit_benefits.tt
					object = scope:carnival_jester
				}
			}
		}
		show_as_unavailable = { always = yes }
		pay_short_term_gold = {
			target = scope:carnival_jester
			gold = scope:carnival_jester_recruit_cost
		}
		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:carnival_jester
			add_courtier = scope:carnival_jester
			hidden_effect = {
				scope:carnival_jester = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
					save_scope_as = recruited_interesting_character
				}
			}
		}
		visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:carnival_jester }
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Duel them
	option = {
		name = gdp_visit_holding_decision_event.1335.c
		scope:carnival_jester = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1335.recruit_benefits.tt
					object = scope:carnival_jester
				}
			}
		}
		duel = {
			skill = diplomacy
			value = average_skill_rating
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1335.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1335.c.success
					left_icon = root
					right_icon = scope:carnival_jester
					add_courtier = scope:carnival_jester
					hidden_effect = {
						scope:carnival_jester = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
							remove_character_flag ?= created
							save_scope_as = recruited_interesting_character
						}
					}
				}
				visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:carnival_jester }
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1335.c.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1335.c.failure
					desc = gdp_visit_holding_decision_event.1335.c.failure
					left_icon = root
					right_icon = scope:carnival_jester
				}
				visit_holding_rare_recruit_duel_loss_effect = {
					CHARACTER = scope:carnival_jester
					SCENE = carnival_jester
				}
			}
		}
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Go Back
	option = {
		name = gdp_visit_holding_decision_event.1335.d
		custom_tooltip = gdp_visit_holding_decision_event.1320.d.tt
		visit_holding_been_to_rare_recruit_effect = { SCENE = carnival_jester }
		visit_holding_return_to_market_dock_hub_effect = yes
	}
	after = {
		scope:carnival_spectator ?= { silent_disappearance_effect = yes }
	}
}
# The Cook
gdp_visit_holding_decision_event.1336 = {
	type = character_event
	title = {
		desc = gdp_visit_holding_decision_event.1336.t_market
		desc = gdp_visit_holding_decision_event.1336.t
	}
	window = visit_settlement_window
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:been_to_cook
					scope:cook_loc_tracker ?= 1
				}
				desc = gdp_visit_holding_decision_event.1336.desc_returned_01
			}
			triggered_desc = {
				trigger = { scope:cook_loc_tracker ?= 2 }
				desc = gdp_visit_holding_decision_event.1336.desc_returned_02
			}
			desc = {
				desc = gdp_visit_holding_decision_event.1336.desc_intro
				first_valid = {
					triggered_desc = {
						trigger = { exists = scope:local_noble }
						desc = gdp_visit_holding_decision_event.1336.desc_named_noble
					}
					desc = gdp_visit_holding_decision_event.1336.desc_unknown_noble
				}
			}
		}
	}

	theme = merchant
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_social" }
	override_background = { reference = market }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:cook }
			animation = interested
		}
		animation = pondering
	}
	right_portrait = {
		character = scope:cook
		trigger = { exists = scope:cook }
		animation = disappointed
	}
	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:visiting_location }
			}
			location = { save_scope_as = visiting_location }
		}
		if = {
			limit = { NOT = { exists = scope:local_noble } }
			scope:visiting_location.county.holder ?= {
				if = {
					limit = { this != root }
					save_scope_as = local_noble
				}
				else = {
					liege ?= {
						if = {
							limit = {
								this != root
								is_landed = yes
							}
							save_scope_as = local_noble
						}
					}
				}
			}
		}
		#Set recruitment cost
		if = {
			limit = {
				NOT = { exists = scope:cook_recruit_cost }
			}
			1320_set_cost_effect = { CHARACTER = scope:cook VALUE_NAME = cook_recruit_cost }
		}
		visit_holding_set_rare_recruit_loc_tracker_effect = { SCENE = cook }
		visit_holding_pick_merchant_court_position_effect = {
			CHARACTER = scope:cook
			EMPLOYER = root
		}
	}
	#Recruit them
	option = {
		name = gdp_visit_holding_decision_event.1336.a
		trigger = {
			custom_tooltip = {
				text = gdp_visit_holding_decision_event.1336.a.tt
				short_term_gold >= scope:cook_recruit_cost
			}
		}
		scope:cook = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1336.recruit_benefits.tt
					object = scope:cook
				}
			}
		}
		show_as_unavailable = { always = yes }
		pay_short_term_gold = {
			target = scope:cook
			gold = scope:cook_recruit_cost
		}
		send_interface_toast = {
			type = event_toast_effect_good
			title = market_recruitment_success.t
			left_icon = scope:cook
			add_courtier = scope:cook
			hidden_effect = {
				scope:cook = {
					add_opinion = {
						modifier = recruited_me_opinion
						target = root
						opinion = 50
					}
					save_scope_as = recruited_interesting_character
				}
			}
		}
		visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:cook }
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Duel them
	option = {
		name = gdp_visit_holding_decision_event.1336.c
		scope:cook = {
			if = {
				limit = { NOT = { exists = var:visit_holding_recruit_court_position } }
				custom_description_no_bullet = {
					text = gdp_visit_holding_decision_event.1336.recruit_benefits.tt
					object = scope:cook
				}
			}
		}
		duel = {
			skill = stewardship
			value = average_skill_rating
			#Success : recruit them
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = gdp_visit_holding_decision_event.1336.c.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_visit_holding_decision_event.1336.c.success
					left_icon = root
					right_icon = scope:cook
					add_courtier = scope:cook
					hidden_effect = {
						scope:cook = {
							add_opinion = {
								modifier = recruited_me_opinion
								target = root
								opinion = 50
							}
							remove_character_flag ?= created
							save_scope_as = recruited_interesting_character
						}
					}
				}
				visit_holding_appoint_rare_recruit_court_position_effect = { CHARACTER = scope:cook }
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -20
				}
				desc = gdp_visit_holding_decision_event.1336.c.failure
				send_interface_toast = {
					type = event_toast_text_bad
					title = gdp_visit_holding_decision_event.1336.c.failure
					desc = gdp_visit_holding_decision_event.1336.c.failure
					left_icon = root
					right_icon = scope:cook
				}
				visit_holding_rare_recruit_duel_loss_effect = {
					CHARACTER = scope:cook
					SCENE = cook
				}
			}
		}
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_recruited_recently }
		visit_holding_rare_recruit_return_to_hub_after_recruit_effect = yes
	}

	#Go Back
	option = {
		name = gdp_visit_holding_decision_event.1336.d
		custom_tooltip = gdp_visit_holding_decision_event.1320.d.tt
		visit_holding_been_to_rare_recruit_effect = { SCENE = cook }
		visit_holding_return_to_market_dock_hub_effect = yes
	}
}

# Relax
gdp_visit_holding_decision_event.1340 = {
	type = character_event
	title = gdp_visit_holding_decision_event.1340.t
	window = visit_settlement_window
	desc = {
		desc = gdp_visit_holding_decision_event.1340.desc
		triggered_desc = { # Tea
			trigger = { scope:relax_type = flag:tea }
			desc = gdp_visit_holding_decision_event.1340.tea
		}
		triggered_desc = { # Hashish
			trigger = { scope:relax_type = flag:hashish }
			desc = gdp_visit_holding_decision_event.1340.hashish
		}
		triggered_desc = { # Drink
			trigger = { scope:relax_type = flag:drink }
			desc = gdp_visit_holding_decision_event.1340.drink
		}
		triggered_desc = { # Food
			trigger = { scope:relax_type = flag:food }
			desc = gdp_visit_holding_decision_event.1340.food
		}
		triggered_desc = { # Bath
			trigger = { scope:relax_type = flag:bath }
			desc = gdp_visit_holding_decision_event.1340.bath
		}
	}
	theme = merchant
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:relax_type = flag:tea }
			animation = interested
		}
		triggered_animation = {
			trigger = { scope:relax_type = flag:hashish }
			animation = delirium
		}
		triggered_animation = {
			trigger = {
				scope:relax_type = flag:food
				is_vegetarian_trigger = no
				faith = {
					NOR = {
						religion_tag = islam_religion
						religion_tag = judaism_religion
					}
				}
			}
			animation = eating_salami
		}
		triggered_animation = {
			trigger = {
				scope:relax_type = flag:food
				is_vegetarian_trigger = no
			}
			animation = eating
		}
		triggered_animation = {
			trigger = {
				scope:relax_type = flag:food
				is_vegetarian_trigger = yes
			}
			animation = interested
		}
		triggered_animation = {
			trigger = { scope:relax_type = flag:drink }
			animation = drink
		}
		animation = happiness
	}
	right_portrait = {
		trigger = { exists = scope:visiting_associate }
		character = scope:visiting_associate
		animation = happiness
	}
	override_sound = { reference = "event:/SFX/Events/Themes/sfx_event_theme_type_social" }
	override_background = {
		trigger = {
			OR = {
				scope:relax_type = flag:tea
				scope:relax_type = flag:drink
			}
		}
		reference = tavern
	}
	override_background = {
		trigger = { scope:relax_type = flag:hashish }
		reference = relaxing_room
	}
	override_background = {
		trigger = { scope:relax_type = flag:food }
		reference = feast
	}
	override_background = {
		trigger = { scope:relax_type = flag:bath }
		reference = bath_house
	}
	override_effect_2d = {
		trigger = { scope:relax_type = flag:bath }
		reference = smoke
	}

	immediate = {
		location.county.holder = { save_scope_as = bg_scope }
		visit_holding_ensure_visiting_associate_effect = yes
		if = { # Tea
		 	limit = {
		 		visit_holding_relax_tea_trigger = yes
		 		NOR = {
					AND = {
						has_trait = drunkard
						location = {
							NOR = {
								geographical_region = world_europe
								geographical_region = world_asia
							}
						}
					}
					has_trait = comfort_eater
				}
			}
		 	save_scope_value_as = {
		 		name = relax_type
		 		value = flag:tea
		 	}
			stress_and_fulfillment_impact = {
				base = minor_stress_impact_loss
				gregarious = minor_stress_impact_loss
			}
			scope:visiting_associate ?= {
				if = {
					limit = { is_alive = yes }
					stress_and_fulfillment_impact = {
						base = minor_stress_impact_loss
						gregarious = minor_stress_impact_loss
					}
				}
			}
	 	}
		else_if = { # Hashish
			limit = {
				trigger_if = {
					limit = { has_trait = temperate }
					has_trait = hashishiyah
				}
				trigger_if = {
					limit = {
						NOT = { has_trait = hashishiyah }
					}
					NOT = { has_trait = comfort_eater }
				}
				can_be_hashishiyah = yes
				location = {
					NOR = {
						geographical_region = world_europe
						geographical_region = world_asia
					}
				}
			}
		 	save_scope_value_as = {
		 		name = relax_type
		 		value = flag:hashish
		 	}
			stress_and_fulfillment_impact = {
				base = minor_stress_impact_loss
				hashishiyah = minor_stress_impact_loss
			}
			scope:visiting_associate ?= {
				if = {
					limit = { is_alive = yes }
					stress_and_fulfillment_impact = {
						base = minor_stress_impact_loss
						hashishiyah = minor_stress_impact_loss
					}
				}
			}
		}
		else_if = { # Drink
			limit = {
				trigger_if = {
					limit = { has_trait = temperate }
					has_trait = drunkard
				}
				trigger_if = {
					limit = {
						NOT = { has_trait = drunkard }
					}
					NOT = { has_trait = comfort_eater }
				}
				location = { # Not offering booze
					NOR = {
						religion = religion:islam_religion
						religion = religion:jainism_religion
						faith = faith:mandaean_faith
					}
				}
			}
		 	save_scope_value_as = {
		 		name = relax_type
		 		value = flag:drink
		 	}
			stress_and_fulfillment_impact = {
				base = minor_stress_impact_loss
				lifestyle_reveler = minor_stress_impact_loss
				drunkard = minor_stress_impact_loss
				gregarious = minor_stress_impact_loss
			}
			scope:visiting_associate ?= {
				if = {
					limit = { is_alive = yes }
					stress_and_fulfillment_impact = {
						base = minor_stress_impact_loss
						lifestyle_reveler = minor_stress_impact_loss
						drunkard = minor_stress_impact_loss
						gregarious = minor_stress_impact_loss
					}
				}
			}
		}
		else_if = { # Food
			limit = {
				trigger_if = {
					limit = { has_trait = temperate }
					has_trait = comfort_eater
				}
				NOR = {
					has_trait = inappetetic
					has_trait = temperate
				}
			}
			save_scope_value_as = {
				name = relax_type
				value = flag:food
			}
			stress_and_fulfillment_impact = {
				base = minor_stress_impact_loss
				gluttonous = minor_stress_impact_loss
				comfort_eater = minor_stress_impact_loss
				gregarious = minor_stress_impact_loss
			}
			scope:visiting_associate ?= {
				if = {
					limit = { is_alive = yes }
					stress_and_fulfillment_impact = {
						base = minor_stress_impact_loss
						gluttonous = minor_stress_impact_loss
						comfort_eater = minor_stress_impact_loss
						gregarious = minor_stress_impact_loss
					}
				}
			}
		}
		else = { # Bath
			save_scope_value_as = {
				name = relax_type
				value = flag:bath
			}
			stress_and_fulfillment_impact = {
				base = minor_stress_impact_loss
				gregarious = minor_stress_impact_loss
			}
			scope:visiting_associate ?= {
				if = {
					limit = { is_alive = yes }
					stress_and_fulfillment_impact = {
						base = minor_stress_impact_loss
						gregarious = minor_stress_impact_loss
					}
				}
			}
		}
		visit_holding_set_option_cooldown_market_dock_effect = { VAR = 1320_has_relaxed_recently }
	}

	#Go Back
	option = {
	 	name = gdp_visit_holding_decision_event.1340.a
	 	custom_tooltip = gdp_visit_holding_decision_event.1320.d.tt	
	 	if = {
	 		limit = {
	 			location = { is_coastal = yes }
	 		}
	 		trigger_event = gdp_visit_holding_decision_event.1400
	 	}
	 	else = {
	 		trigger_event = gdp_visit_holding_decision_event.1300
	 	}
	}

	after = {
		remove_character_flag = is_naked
	}
}
