﻿namespace = gdp_merchant_luxury_contract

scripted_effect luxury_contract_save_spawn_culture_and_faith_effect = {
	if = {
		limit = {
			exists = location.culture
			exists = location.faith
		}
		location.culture = { save_temporary_scope_as = lc_spawn_culture }
		location.faith = { save_temporary_scope_as = lc_spawn_faith }
	}
	else = {
		culture = { save_temporary_scope_as = lc_spawn_culture }
		faith = { save_temporary_scope_as = lc_spawn_faith }
	}
}

scripted_effect luxury_contract_cleanup_unused_character_effect = {
	#if = {
	#	limit = { scope:artifact.artifact_owner ?= this }
	#	hidden_effect = { destroy_artifact = scope:artifact }
	#}
	if = {
		limit = { scope:urchin ?= this }
		remove_character_flag = peasant_outfit
	}
	if = {
		limit = { has_character_flag = destroy_me }
		silent_disappearance_effect = yes
	}
}

scripted_effect luxury_contract_reward_quality_effect = {
	switch = {
		trigger = scope:task_contract.task_contract_tier
		tier_county = {
			save_scope_value_as = {
				name = quality
				value = { 45 70 }
			}
			save_scope_value_as = {
				name = wealth
				value = { 20 30 }
			}
		}
		tier_duchy = {
			save_scope_value_as = {
				name = quality
				value = { 55 80 }
			}
			save_scope_value_as = {
				name = wealth
				value = { 35 45 }
			}
		}
		tier_kingdom = {
			save_scope_value_as = {
				name = quality
				value = { 65 90 }
			}
			save_scope_value_as = {
				name = wealth
				value = { 45 60 }
			}
		}
	}
}

scripted_effect luxury_contract_fallback_reward_quality_effect = {
	switch = {
		trigger = scope:task_contract.task_contract_tier
		tier_county = {
			save_scope_value_as = {
				name = quality
				value = { 10 25 }
			}
			save_scope_value_as = {
				name = wealth
				value = { 5 10 }
			}
		}
		tier_duchy = {
			save_scope_value_as = {
				name = quality
				value = { 20 35 }
			}
			save_scope_value_as = {
				name = wealth
				value = { 15 20 }
			}
		}
		tier_kingdom = {
			save_scope_value_as = {
				name = quality
				value = { 30 45 }
			}
			save_scope_value_as = {
				name = wealth
				value = { 25 30 }
			}
		}
	}
}

####
# gdp_merchant_luxury_contract.0001-1000 - Menagerie Acquisition
###

gdp_merchant_luxury_contract.0001 = { # Intro
	type = character_event
	title = gdp_merchant_luxury_contract.0001.t
	desc = {
		desc = gdp_merchant_luxury_contract.0001.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					location = {
						OR = {
							terrain = desert
							terrain = desert_mountains
						}
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.desert
			}
			triggered_desc = {
				trigger = { 
					location = {
						terrain = mountains
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.mountain
			}
			triggered_desc = {
				trigger = { 
					location = {
						terrain = jungle
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.jungle
			}
			desc = gdp_merchant_luxury_contract.0001.desc.plains
		}
		desc = double_line_break
		first_valid = {
			triggered_desc = {
				trigger = {	knows_language_of_culture = location.county.culture }
				desc = gdp_merchant_luxury_contract.0001.desc.locals_language
			}
			desc = gdp_merchant_luxury_contract.0001.desc.locals
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:big_cat_flag
					calc_true_if = {
						amount = 0
						exists = scope:small_cat_flag
						exists = scope:elephant_flag
						exists = scope:bear_flag
						exists = scope:monkey_flag
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.big_cat
			}
			triggered_desc = {
				trigger = {
					exists = scope:small_cat_flag
					calc_true_if = {
						amount = 0
						exists = scope:big_cat_flag
						exists = scope:elephant_flag
						exists = scope:bear_flag
						exists = scope:monkey_flag
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.small_cat
			}
			triggered_desc = {
				trigger = {
					exists = scope:bear_flag
					calc_true_if = {
						amount = 0
						exists = scope:big_cat_flag
						exists = scope:small_cat_flag
						exists = scope:monkey_flag
						exists = scope:elephant_flag
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.bear
			}
			triggered_desc = {
				trigger = {
					exists = scope:monkey_flag
					calc_true_if = {
						amount = 0
						exists = scope:big_cat_flag
						exists = scope:small_cat_flag
						exists = scope:bear_flag
						exists = scope:elephant_flag
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.monkey
			}
			triggered_desc = {
				trigger = {
					exists = scope:elephant_flag
					calc_true_if = {
						amount = 0
						exists = scope:big_cat_flag
						exists = scope:small_cat_flag
						exists = scope:bear_flag
						exists = scope:monkey_flag
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.elephant
			}
			triggered_desc = {
				trigger = {
					exists = scope:elephant_flag
					calc_true_if = {
						amount >= 1
						exists = scope:big_cat_flag
						exists = scope:small_cat_flag
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.elephant_cat
			}
			triggered_desc = {
				trigger = {
					exists = scope:monkey_flag
					calc_true_if = {
						amount >= 1
						exists = scope:big_cat_flag
						exists = scope:small_cat_flag
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.monkey_cat
			}
			triggered_desc = {
				trigger = {
					exists = scope:bear_flag
					calc_true_if = {
						amount >= 1
						exists = scope:big_cat_flag
						exists = scope:small_cat_flag
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.bear_cat
			}
			triggered_desc = {
				trigger = {
					exists = scope:bear_flag
					exists = scope:elephant_flag
				}
				desc = gdp_merchant_luxury_contract.0001.desc.monkey_elephant
			}
			desc = gdp_merchant_luxury_contract.0001.desc.bird
		}
		desc = double_line_break
		desc = gdp_merchant_luxury_contract.0001.desc.close
	}
	theme = trade
	left_portrait = {
		character = root
		animation = survey
	}
	override_background = { reference = terrain }

	immediate = {
		remove_variable = target_animal_type
		save_scope_as = merchant
		hidden_effect = {
			location = {
				save_scope_as = local_province
				barony = { save_scope_as = local_barony }
				county = { save_scope_as = local_county }
				duchy = {
					while = {
						count = 3
						random_list = {
							10 = {
								trigger = {
									NOT = { exists = scope:big_cat_flag }
									any_de_jure_county = {
										any_county_province = {
											OR = {
												hunt_animal_lion_trigger = yes
												hunt_animal_tiger_trigger = yes
												hunt_animal_leopard_trigger = yes
											}
										}
									}
								}
								save_scope_as = big_cat_flag
							}
							10 = {
								trigger = {
									NOT = { exists = scope:small_cat_flag }
									any_de_jure_county = {
										any_county_province = {
											OR = {
												hunt_animal_caracal_trigger = yes
												hunt_animal_lynx_trigger = yes
											}
										}
									}
								}
								save_scope_as = small_cat_flag
							}
							10 = {
								trigger = {
									NOT = { exists = scope:bear_flag }
									any_de_jure_county = {
										any_county_province = { hunt_animal_bear_trigger = yes }
									}
								}
								save_scope_as = bear_flag
							}
							10 = {
								trigger = {
									NOT = { exists = scope:elephant_flag }
									any_de_jure_county = {
										any_county_province = { luxury_contract_creature_elephant_trigger = yes }
									}
								}
								save_scope_as = elephant_flag
							}
							10 = {
								trigger = {
									NOT = { exists = scope:monkey_flag }
									any_de_jure_county = {
										any_county_province = { luxury_contract_creature_monkey_trigger = yes }
									}
								}
								save_scope_as = monkey_flag
							}
						}
					}
				}
			}
		}
	}

	option = { # Wilds
		name = gdp_merchant_luxury_contract.0001.a
		flavor = gdp_merchant_luxury_contract.0001.a.flavor
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_wilds_flag
		}
		add_internal_flag = dangerous
		custom_tooltip = gdp_merchant_luxury_contract.0001.a.tt
		stress_and_fulfillment_impact = {
			craven = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}

	option = { # City
		name = gdp_merchant_luxury_contract.0001.b
		flavor = gdp_merchant_luxury_contract.0001.b.flavor
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_urban_flag
		}
		custom_tooltip = gdp_merchant_luxury_contract.0001.b.tt
		stress_and_fulfillment_impact = {
			brave = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_sociability = 0.25
				ai_boldness = -0.25
			}
		}
	}

	after = {
		trigger_event = {
			on_action = gdp_menagerie_acquisition_random_pool_start
			days = 3
		}
	}
}

scripted_trigger luxury_contract_potential_rich_trigger = {
	exists = house
	is_available_quick = {
		ai = yes
		adult = yes
		imprisoned = no
		incapable = no
		in_army = no
	}
}

scripted_trigger luxury_contract_any_rich_local_trigger = {
	location.county ?= {
		OR = {
			holder = {
				OR = {
					luxury_contract_potential_rich_trigger = yes
					any_courtier = { luxury_contract_potential_rich_trigger = yes }
					any_vassal = {
						capital_province.duchy = root.location.duchy
						OR = {
							luxury_contract_potential_rich_trigger = yes
							any_courtier = { luxury_contract_potential_rich_trigger = yes }
						}
					}
				}
			}
			title_province = {
				any_province_domicile = {
					OR = {
						is_domicile_type = merchant_company
						is_domicile_type = east_asian_estate
						is_domicile_type = japanese_manor
					}
					owner = {
						OR = {
							luxury_contract_potential_rich_trigger = yes
							any_courtier = { luxury_contract_potential_rich_trigger = yes }
						}
					}
				}
			}
		}
	}
}

scripted_effect luxury_contract_find_rich_local_effect = {
	if = {
		limit = { luxury_contract_potential_rich_trigger = yes }
		add_to_list = potential_rich_local
	}
	every_courtier = {
		limit = { luxury_contract_potential_rich_trigger = yes }
		add_to_list = potential_rich_local
	}
}

scripted_effect luxury_contract_select_rich_local_effect = {
	location = {
		county.holder = {
			luxury_contract_find_rich_local_effect = yes
			every_vassal = {
				limit = { capital_province.duchy = root.location.duchy }
				luxury_contract_find_rich_local_effect = yes
			}
		}
		duchy = {
			every_de_jure_county = {
				title_province = {
					every_province_domicile = {
						limit = {
							OR = {
								is_domicile_type = merchant_company
								is_domicile_type = east_asian_estate
								is_domicile_type = japanese_manor
							}
						}
						owner = { luxury_contract_find_rich_local_effect = yes }
					}
				}
				every_pool_character = {
					province = title_province
					limit = { luxury_contract_potential_rich_trigger = yes }
					add_to_list = potential_rich_local
				}
			}
		}
	}
	# SELECT
	random_in_list = {
		list = potential_rich_local
		weight = {
			base = 1
			modifier = { add = gold }
			modifier = {
				government_has_flag = government_has_influence
				add = influence
			}
			modifier = {
				add = {
					value = prestige_level
					multiply = 10
				}
			}
			modifier = {
				add = {
					value = dynasty.dynasty_prestige_level
					multiply = 10
				}
			}
			modifier = {
				is_ruler = yes
				factor = 10
			}
			modifier = {
				primary_spouse ?= { is_ruler = yes }
				factor = 5
			}
			modifier = {
				any_parent = { is_ruler = yes }
				factor = 5
			}
			modifier = {
				is_landed = yes
				factor = 10
			}
			modifier = {
				primary_spouse ?= { is_landed = yes }
				factor = 5
			}
			modifier = {
				any_parent = { is_landed = yes }
				factor = 5
			}
			modifier = {
				is_ai = no
				factor = 0.01
			}
		}
		save_scope_as = rich_local
	}
}

### Rich Local sub-chain
gdp_merchant_luxury_contract.0011 = { # Start
	type = character_event
	title = gdp_merchant_luxury_contract.0011.t
	desc = {
		desc = gdp_merchant_luxury_contract.0011.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:rich_local = {
						OR = {
							var:animal_type ?= flag:peacock
							var:animal_type ?= flag:caracal
						}
					}
				}
				desc = gdp_merchant_luxury_contract.0011.leashed
			}
			triggered_desc = {
				trigger = {
					scope:rich_local = {
						OR = {
							var:animal_type ?= flag:cockatoo
							var:animal_type ?= flag:parrot
						}
					}
				}
				desc = gdp_merchant_luxury_contract.0011.shoulder
			}
			desc = gdp_merchant_luxury_contract.0011.cage
		}
		desc = gdp_merchant_luxury_contract.0011.close
	}
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:rich_local
		animation = dismissal
		camera = camera_event_right_pointing_left
	}
	artifact = {
		target = scope:rich_local_creature
		position = lower_center_portrait
	}
	override_background = { reference = market }

	trigger = {
		scope:lc_active_path_flag ?= flag:lc_0001_urban_flag
		luxury_contract_any_rich_local_trigger = yes
	}

	immediate = {
		save_scope_as = lc_0001_rich_local_flag
		luxury_contract_select_rich_local_effect = yes
		scope:rich_local = {
			select_dealer_creature_effect = { TYPE = rich_local }
			assign_quirk_effect = yes
		}
		luxury_contract_reward_quality_effect = yes
		hidden_effect_new_object = {
			create_creature_artifact_effect = {
				OWNER = scope:rich_local
				CREATOR = scope:rich_local
			}
		}
		scope:newly_created_artifact ?= { save_scope_as = rich_local_creature }
		scope:task_contract = {
			set_variable = {
				name = artifact
				value = scope:rich_local_creature
			}
		}
	}

	option = { # Offer to buy it
		name = gdp_merchant_luxury_contract.0011.a
		duel = {
			skills = { diplomacy stewardship }
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0011.a.success
				save_scope_as = lc_0001_success
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = scope:rich_local.medium_gold_value
						target = scope:rich_local
					}
					scope:task_contract = { complete_task_contract = success_standard }
				}
			}
			25 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0011.a.failure
				custom_tooltip = gdp_merchant_luxury_contract.some_other_way
			}
		}
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		trigger_event = {
			id = gdp_merchant_luxury_contract.0012
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_sociability = 0.25
				ai_greed = -0.25
			}
			modifier = {
				short_term_gold < scope:rich_local.major_gold_value
				factor = 0
			}
			modifier = {
				diplomacy < scope:rich_local.diplomacy_double_value
				factor = 0.5
			}
			modifier = {
				stewardship < scope:rich_local.stewardship_double_value
				factor = 0.5
			}
		}
	}

	option = { # Go to wilds
		name = gdp_merchant_luxury_contract.0011.b
		flavor = gdp_merchant_luxury_contract.0001.a.flavor
		trigger = {
			NOT = { has_character_flag = menagerie_acquisition_rejected_other_path }
		}
		add_character_flag = { flag = menagerie_acquisition_rejected_other_path months = 6 }
		scope:task_contract = { remove_variable = artifact }
		custom_tooltip = gdp_merchant_luxury_contract_back_to_wilderness_tt
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_wilds_flag
		}
		stress_and_fulfillment_impact = {
			impatient = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		trigger_event = {
			on_action = gdp_menagerie_acquisition_random_pool_start
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}
}

gdp_merchant_luxury_contract.0012 = { # Offer outcome
	type = character_event
	title = gdp_merchant_luxury_contract.0012.t
	desc = {
		desc = gdp_merchant_luxury_contract.0012.desc
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:lc_0001_success }
				desc = gdp_merchant_luxury_contract.0012.success
			}
			desc = gdp_merchant_luxury_contract.0012.failure
		}
	}
	theme = trade
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:lc_0001_success }
			animation = happiness
		}
		triggered_animation = {
			trigger = { NOT = { exists = scope:lc_0001_success } }
			animation = stress
		}
	}
	right_portrait = {
		character = scope:rich_local
		triggered_animation = {
			trigger = { exists = scope:lc_0001_success }
			animation = steward
		}
		triggered_animation = {
			trigger = { NOT = { exists = scope:lc_0001_success } }
			animation = dismissal
		}
	}
	artifact = {
		target = scope:rich_local_creature
		position = lower_center_portrait
	}
	override_background = { reference = market }

	immediate = {
		if = {
			limit = { exists = scope:lc_0001_success }
			pay_short_term_gold = {
				gold = scope:rich_local.medium_gold_value
				target = scope:rich_local
			}
		}
		scope:task_contract = {
			set_variable = {
				name = artifact
				value = scope:rich_local_creature
			}
		}
	}

	option = { # Yay!
		name = gdp_merchant_luxury_contract.0012.a
		trigger = { exists = scope:lc_0001_success }
		scope:task_contract = { complete_task_contract = success_standard }
		scope:rich_local = { remove_variable = animal_type }
	}

	option = { # Make ridiculous offer
		name = gdp_merchant_luxury_contract.0012.b
		trigger = {
			NOT = { exists = scope:lc_0001_success }
			gold >= scope:rich_local.major_gold_value
		}
		show_as_unavailable = {
			NOT = { exists = scope:lc_0001_success }
		}
		pay_short_term_gold = {
			gold = scope:rich_local.major_gold_value
			target = scope:rich_local
		}
		scope:task_contract = { complete_task_contract = success_standard }
		scope:rich_local = { remove_variable = animal_type }
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
			impatient = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = -0.5
			}
			modifier = {
				short_term_gold < scope:rich_local.massive_gold_value
				factor = 0
			}
		}
	}

	option = { # Plan theft
		name = gdp_merchant_luxury_contract.0012.c
		trigger = {
			NOT = { exists = scope:lc_0001_success }
		}
		duel = {
			skill = intrigue
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0012.c.success
				show_as_tooltip = {
					scope:task_contract = { complete_task_contract = success_standard }
					reverse_add_opinion = {
						modifier = stole_artifact_from_me
						target = scope:rich_local
					}
				}
				save_scope_as = lc_0001_success
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0012.c.failure
				show_as_tooltip = {
					scope:task_contract = { complete_task_contract = failure_standard }
					reverse_add_opinion = {
						modifier = attempted_to_steal_artifact_from_me
						target = scope:rich_local
					}
					random = {
						chance = 25
						increase_wounds_no_death_effect = { REASON = fight }
					}
				}
			}
		}
		show_as_tooltip = {
			scope:rich_local = {
				progress_towards_rival_effect = {
					REASON = rival_stole_creature
					CHARACTER = root
					OPINION = 0
				}
			}
		}
		stress_and_fulfillment_impact = {
			craven = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		trigger_event = gdp_merchant_luxury_contract.0013
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = -0.25
				ai_boldness = 0.25
			}
			modifier = {
				intrigue < scope:rich_local.intrigue_double_value
				factor = 0
			}
		}
	}

	option = { # Give up
		name = gdp_merchant_luxury_contract.0012.d
		trigger = {
			NOR = {
				exists = scope:lc_0001_success
				has_character_flag = menagerie_acquisition_failed_other_path
				has_character_flag = menagerie_acquisition_rejected_other_path
			}
		}
		add_character_flag = { flag = menagerie_acquisition_failed_other_path months = 6 }
		scope:task_contract = { remove_variable = artifact }
		scope:rich_local = { remove_variable = animal_type }
		custom_tooltip = gdp_merchant_luxury_contract_back_to_wilderness_tt
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_wilds_flag
		}
		stress_and_fulfillment_impact = {
			impatient = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		trigger_event = {
			on_action = gdp_menagerie_acquisition_random_pool_start
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}

	option = { # Really give up
		name = gdp_merchant_luxury_contract.0012.e
		trigger = {
			NOT = { exists = scope:lc_0001_success }
		}
		scope:task_contract = { remove_variable = artifact }
		scope:rich_local = { remove_variable = animal_type }
		scope:task_contract = { complete_task_contract = failure_standard }
		ai_chance = {
			base = -100
		}
	}
}

gdp_merchant_luxury_contract.0013 = { # Theft outcome
	type = character_event
	title = gdp_merchant_luxury_contract.0013.t
	desc = {
		desc = gdp_merchant_luxury_contract.0013.desc
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:lc_0001_success }
				desc = gdp_merchant_luxury_contract.0013.success
			}
			desc = gdp_merchant_luxury_contract.0013.failure
		}
	}
	theme = trade
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:lc_0001_success }
			animation = scheme
		}
		triggered_animation = {
			trigger = { NOT = { exists = scope:lc_0001_success } }
			animation = sadness
		}
		camera = camera_event_very_right
	}
	lower_right_portrait = scope:rich_local
	artifact = {
		target = scope:rich_local_creature
		position = lower_center_portrait
	}
	override_background = { reference = alley_night }

	immediate = {
		add_character_flag = use_stealth_clothes
		if = {
			limit = { exists = scope:lc_0001_success }
			reverse_add_opinion = {
				modifier = stole_artifact_from_me
				target = scope:rich_local
			}
		}
		else = {
			random = {
				chance = 25
				increase_wounds_no_death_effect = { REASON = fight }
			}
			reverse_add_opinion = {
				modifier = attempted_to_steal_artifact_from_me
				target = scope:rich_local
			}
		}
		progress_towards_rival_effect = {
			REASON = rival_stole_creature
			CHARACTER = scope:rich_local
			OPINION = 0
		}
	}

	option = { # Success
		name = gdp_merchant_luxury_contract.0013.a
		trigger = { exists = scope:lc_0001_success }
		scope:task_contract = { complete_task_contract = success_standard }
		scope:rich_local = { add_personal_artifact_claim = scope:rich_local_creature }
	}

	option = { # Failure
		name = gdp_merchant_luxury_contract.0013.b
		trigger = {
			NOT = { exists = scope:lc_0001_success }
		}
		scope:task_contract = { complete_task_contract = failure_standard }
	}

	after = {
		remove_character_flag = use_stealth_clothes
		scope:rich_local = { remove_variable = animal_type }
	}
}

scripted_effect luxury_contract_find_or_create_dealer_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
		}
		weight = {
			base = 1
			modifier = { add = stewardship }
		}
		save_scope_as = dealer
	}
	if = {
		limit = { NOT = { exists = scope:dealer } }
		if = {
			limit = {
				exists = location.culture
				exists = location.faith
			}
			create_character = {
				template = merchant_template
				dynasty = none
				location = location
				culture = location.culture
				faith = location.faith
				save_scope_as = dealer
			}
		}
		else = {
			create_character = {
				template = merchant_template
				dynasty = none
				location = location
				save_scope_as = dealer
			}
		}
		scope:dealer = { add_character_flag = destroy_me }
	}
	scope:dealer ?= { assign_quirk_effect = yes }
}

### Dealer sub-chain
gdp_merchant_luxury_contract.0021 = { # Start
	type = character_event
	title = gdp_merchant_luxury_contract.0021.t
	desc = gdp_merchant_luxury_contract.0021.desc
	theme = trade
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:dealer
		animation = flirtation_left
	}
	artifact = {
		target = scope:dealer_creature_1
		position = lower_center_portrait
	}
	artifact = {
		target = scope:dealer_creature_2
		position = lower_right_portrait
	}
	override_background = { reference = market }

	trigger = {
		scope:lc_active_path_flag ?= flag:lc_0001_urban_flag
	}

	immediate = {
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_dealer_flag
		}
		luxury_contract_find_or_create_dealer_effect = yes
		scope:dealer = {
			select_dealer_creature_effect = { TYPE = dealer }
		}
		luxury_contract_reward_quality_effect = yes
		hidden_effect_new_object = {
			create_creature_artifact_effect = {
				OWNER = scope:dealer
				CREATOR = scope:dealer
			}
			scope:newly_created_artifact = { save_scope_as = dealer_creature_1 }
			set_variable = {
				name = animal_type
				value = scope:dealer.var:animal_type
			}
			switch = {
				trigger = scope:dealer.var:animal_type
				flag:peacock = { save_scope_value_as = { name = reserved_type value = flag:peacock } }
				flag:parrot = { save_scope_value_as = { name = reserved_type value = flag:parrot } }
				flag:cockatoo = { save_scope_value_as = { name = reserved_type value = flag:cockatoo } }
				flag:crane = { save_scope_value_as = { name = reserved_type value = flag:crane } }
				flag:monkey = { save_scope_value_as = { name = reserved_type value = flag:monkey } }
			}
			scope:dealer = {
				remove_variable = animal_type
				save_scope_as = small_local_creature
				select_local_creature_effect = { TYPE = dealer }
				clear_saved_scope = small_local_creature
			}
			luxury_contract_fallback_reward_quality_effect = yes
			create_creature_artifact_effect = {
				OWNER = scope:dealer
				CREATOR = scope:dealer
			}
			scope:newly_created_artifact = { save_scope_as = dealer_creature_2 }
		}
		scope:task_contract = {
			set_variable = {
				name = artifact
				value = scope:dealer_creature_1
			}
		}
	}

	option = { # Asking price
		name = gdp_merchant_luxury_contract.0021.a
		save_scope_as = lc_0001_success
		save_scope_value_as = {
			name = price
			value = {
				value = medium_gold_value
				multiply = 1.25
			}
		}
		show_as_tooltip = {
			pay_short_term_gold = {
				gold = scope:price
				target = scope:dealer
			}
			scope:task_contract = { complete_task_contract = success_standard }
		}
		scope:dealer = {
			set_variable = {
				name = animal_type
				value = scope:merchant.var:animal_type
			}
		}
		scope:task_contract = {
			set_variable = {
				name = artifact
				value = scope:dealer_creature_1
			}
		}
		remove_variable = animal_type
		hidden_effect = { destroy_artifact = scope:dealer_creature_2 }
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			improvident = medium_stress_impact_loss
		}
		trigger_event = gdp_merchant_luxury_contract.0023
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = -0.25
				ai_energy = 0.25
			}
			modifier = {
				short_term_gold < major_gold_value
				factor = 0
			}
		}
	}

	option = { # Haggle
		name = gdp_merchant_luxury_contract.0021.b
		flavor = gdp_merchant_luxury_contract.0021.b.tt
		save_scope_as = lc_0001_haggle_flag
		duel = {
			skills = { diplomacy stewardship }
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0021.b.success_critical
				save_scope_as = lc_0001_success
				save_scope_value_as = {
					name = price
					value = {
						value = medium_gold_value
						multiply = 0.75
					}
				}
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = scope:price
						target = scope:dealer
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0021.b.success
				save_scope_value_as = {
					name = price
					value = medium_gold_value
				}
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = scope:price
						target = scope:dealer
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0021.b.failure
				save_scope_as = lc_0001_failure
				save_scope_value_as = {
					name = price
					value = {
						value = medium_gold_value
						multiply = 1.5
					}
				}
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = scope:price
						target = scope:dealer
					}
				}
			}
		}
		show_as_tooltip = {
			scope:task_contract = { complete_task_contract = success_standard }
		}
		stress_and_fulfillment_impact = {
			gregarious = minor_stress_impact_loss
			impatient = minor_stress_impact_gain
		}
		trigger_event = gdp_merchant_luxury_contract.0022
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 0.25
				ai_sociability = 0.25
			}
			modifier = {
				short_term_gold < major_gold_value
				factor = 0
			}
			modifier = {
				diplomacy < very_high_skill_rating
				factor = 0.5
			}
			modifier = {
				stewardship < very_high_skill_rating
				factor = 0.5
			}
		}
	}

	option = { # Take cheap animal
		name = gdp_merchant_luxury_contract.0021.c
		save_scope_as = lc_0001_success
		save_scope_as = lc_0001_cheap_flag
		scope:task_contract = {
			set_variable = {
				name = artifact
				value = scope:dealer_creature_2
			}
		}
		save_scope_value_as = {
			name = price
			value = {
				value = medium_gold_value
				multiply = 0.5
			}
		}
		show_as_tooltip = {
			pay_short_term_gold = {
				gold = scope:price
				target = scope:dealer
			}
			# Pseudo effect due to variable change
			custom_description_no_bullet = { text = task_contract_success_pseudo }
			add_prestige = menagerie_acquisition_prestige_reward_value
			scope:dealer_creature_2 = { set_owner = root }
		}
		scope:dealer = { remove_variable = animal_type }
		hidden_effect = { destroy_artifact = scope:dealer_creature_1 }
		stress_and_fulfillment_impact = {
			arrogant = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
		trigger_event = gdp_merchant_luxury_contract.0023
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = -0.25
				ai_boldness = -0.25
			}
			modifier = {
				short_term_gold < medium_gold_value
				factor = 0
			}
		}
	}

	option = { # Wilds
		name = gdp_merchant_luxury_contract.0021.d
		flavor = gdp_merchant_luxury_contract.0001.a.flavor
		trigger = {
			NOT = { has_character_flag = menagerie_acquisition_rejected_other_path }
		}
		add_character_flag = { flag = menagerie_acquisition_rejected_other_path months = 6 }
		custom_tooltip = gdp_merchant_luxury_contract_back_to_wilderness_tt
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_wilds_flag
		}
		stress_and_fulfillment_impact = {
			impatient = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		trigger_event = {
			on_action = gdp_menagerie_acquisition_random_pool_start
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}
}

gdp_merchant_luxury_contract.0022 = { # Haggle outcome
	type = character_event
	title = gdp_merchant_luxury_contract.0022.t
	desc = {
		desc = gdp_merchant_luxury_contract.0022.desc
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:lc_0001_success }
				desc = gdp_merchant_luxury_contract.0022.success
			}
			triggered_desc = {
				trigger = { exists = scope:lc_0001_failure }
				desc = gdp_merchant_luxury_contract.0022.failure
			}
			desc = gdp_merchant_luxury_contract.0022.neutral
		}
	}
	theme = trade
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:lc_0001_success }
			animation = war_over_tie
		}
		triggered_animation = {
			trigger = { exists = scope:lc_0001_failure }
			animation = disgust
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_0001_success
					exists = scope:lc_0001_failure
				}
			}
			animation = thinking
		}
	}
	right_portrait = {
		character = scope:dealer
		triggered_animation = {
			trigger = { exists = scope:lc_0001_success }
			animation = war_over_win
		}
		triggered_animation = {
			trigger = { exists = scope:lc_0001_failure }
			animation = anger
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_0001_success
					exists = scope:lc_0001_failure
				}
			}
			animation = debating
		}
	}
	artifact = {
		target = scope:dealer_creature_1
		position = lower_center_portrait
	}
	artifact = {
		target = scope:dealer_creature_2
		position = lower_right_portrait
	}

	option = { # Give cash
		name = gdp_merchant_luxury_contract.0022.a
		scope:dealer = { remove_variable = animal_type }
		show_as_tooltip = {
			pay_short_term_gold = {
				gold = scope:price
				target = scope:dealer
			}
			scope:task_contract = { complete_task_contract = success_standard }
		}
		stress_and_fulfillment_impact = {
			stubborn = minor_stress_impact_loss
		}
		trigger_event = gdp_merchant_luxury_contract.0023
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 0.25
				ai_boldness = 0.25
			}
			modifier = {
				short_term_gold < major_gold_value
				factor = 0
			}
		}
	}

	option = { # Cheaper animal
		name = gdp_merchant_luxury_contract.0022.b
		save_scope_value_as = {
			name = price
			value = {
				value = medium_gold_value
				multiply = 0.5
			}
		}
		scope:task_contract = {
			set_variable = {
				name = artifact
				value = scope:dealer_creature_2
			}
		}
		set_variable = {
			name = animal_type
			value = scope:dealer.var:animal_type
		}
		scope:dealer = { remove_variable = animal_type }
		show_as_tooltip = {
			pay_short_term_gold = {
				gold = scope:price
				target = scope:dealer
			}
			# Pseudo effect due to variable change
			custom_description_no_bullet = { text = task_contract_success_pseudo }
			add_prestige = menagerie_acquisition_prestige_reward_value
			scope:dealer_creature_2 = { set_owner = root }
		}
		stress_and_fulfillment_impact = {
			arrogant = minor_stress_impact_gain
			fickle = minor_stress_impact_loss
		}
		trigger_event = gdp_merchant_luxury_contract.0023
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 0
				ai_boldness = -0.25
			}
			modifier = {
				short_term_gold < medium_gold_value
				factor = 0
			}
		}
	}

	option = { # Give up
		name = gdp_merchant_luxury_contract.0022.c
		trigger = {
			NOR = {
				has_character_flag = menagerie_acquisition_failed_other_path
				has_character_flag = menagerie_acquisition_rejected_other_path
			}
		}
		add_character_flag = { flag = menagerie_acquisition_failed_other_path months = 6 }
		scope:task_contract = { remove_variable = artifact }
		scope:dealer = { remove_variable = animal_type }
		custom_tooltip = gdp_merchant_luxury_contract_back_to_wilderness_tt
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_wilds_flag
		}
		stress_and_fulfillment_impact = {
			impatient = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		trigger_event = {
			on_action = gdp_menagerie_acquisition_random_pool_start
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}

	option = { # Really give up
		name = gdp_merchant_luxury_contract.0012.e
		trigger = {
			NOT = { exists = scope:lc_0001_success }
		}
		scope:task_contract = { remove_variable = artifact }
		scope:dealer = { remove_variable = animal_type }
		scope:task_contract = { complete_task_contract = failure_standard }
		ai_chance = {
			base = -100
		}
	}
}

gdp_merchant_luxury_contract.0023 = { # Dealer outcome
	type = character_event
	title = gdp_merchant_luxury_contract.0023.t
	desc = {
		desc = gdp_merchant_luxury_contract.0023.desc
	}
	theme = trade
	left_portrait = {
		character = root
		animation = happiness
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = terrain }

	immediate = {
		pay_short_term_gold = {
			gold = scope:price
			target = scope:dealer
		}
		scope:task_contract.var:artifact = { save_scope_as = artifact }
		set_variable = { name = animal_type value = scope:artifact.var:animal_type years = 3 }
		scope:task_contract = { complete_task_contract = success_standard }
	}

	option = { # Asking price
		name = gdp_merchant_luxury_contract.0023.a
	}
}

scripted_effect luxury_contract_find_or_create_hunter_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = this }
		}
		weight = {
			base = 1
			modifier = { add = prowess }
			modifier = {
				has_trait = lifestyle_hunter
				factor = 10
			}
		}
		save_scope_as = hunter
	}
	if = {
		limit = { NOT = { exists = scope:hunter } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = hunter_template
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:lc_spawn_faith
			save_scope_as = hunter
		}
		scope:hunter = { add_character_flag = destroy_me }
	}
	scope:hunter = { assign_quirk_effect = yes }
}

### Hunt sub-chain
gdp_merchant_luxury_contract.0041 = { # Start
	type = character_event
	title = gdp_merchant_luxury_contract.0041.t
	desc = gdp_merchant_luxury_contract.0041.desc
	theme = trade
	left_portrait = {
		character = root
		animation = throne_room_two_handed_passive_1
	}
	override_background = { reference = terrain }

	trigger = {
		scope:lc_active_path_flag ?= flag:lc_0001_wilds_flag
	}

	immediate = {
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_hunt_flag
		}
		if = {
			limit = { exists = scope:task_contract.var:target_animal_type }
			if = {
				limit = {
					NOT = { exists = scope:creature_location }
				}
				location = { save_scope_as = creature_location }
			}
			set_variable = { name = animal_type value = scope:task_contract.var:target_animal_type years = 3 }
		}
		else = {
			save_scope_as = big_local_creature
			select_local_creature_effect = { TYPE = hunt }
			clear_saved_scope = big_local_creature
		}
	}

	option = { # Into the wilds
		name = gdp_merchant_luxury_contract.0041.a
		add_internal_flag = dangerous
		custom_tooltip = gdp_merchant_luxury_contract.0041.a.tt
		trigger_event = {
			on_action = gdp_menagerie_acquisition_wilds_pool_start
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.25
				ai_energy = 0.25
			}
		}
	}

	option = { # Go to the market
		name = gdp_merchant_luxury_contract.0041.b
		trigger = {
			NOT = { has_character_flag = menagerie_acquisition_rejected_other_path }
		}
		add_character_flag = { flag = menagerie_acquisition_rejected_other_path months = 6 }
		custom_tooltip = gdp_merchant_luxury_contract_back_to_town_tt
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_urban_flag
		}
		stress_and_fulfillment_impact = {
			brave = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		trigger_event = {
			on_action = gdp_menagerie_acquisition_random_pool_start
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.25
				ai_boldness = -0.25
			}
		}
	}
}

gdp_merchant_luxury_contract.0042 = { # Baby
	type = character_event
	title = gdp_merchant_luxury_contract.0042.t
	desc = gdp_merchant_luxury_contract.0042.desc
	theme = trade
	left_portrait = {
		character = root
		animation = shock
		camera = camera_event_very_left
	}
	artifact = {
		target = scope:baby_creature
		position = lower_center_portrait
	}
	override_background = { reference = terrain }

	immediate = {
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_baby_flag
		}
		luxury_contract_fallback_reward_quality_effect = yes
		hidden_effect_new_object = {
			create_creature_artifact_effect = {
				OWNER = root
				CREATOR = root
			}
		}
		scope:newly_created_artifact = {
			save_scope_as = baby_creature
			set_artifact_name = baby_creature_artifact_name
		}
		scope:task_contract = {
			set_variable = {
				name = artifact
				value = scope:baby_creature
			}
		}
	}

	option = { # Press on
		name = gdp_merchant_luxury_contract.0042.a
		custom_tooltip = gdp_merchant_luxury_contract.0042.a.tt
		hidden_effect = {
			destroy_artifact = scope:baby_creature
			clear_saved_scope = baby_creature
			clear_saved_scope = newly_created_artifact
			clear_saved_scope = quality
			clear_saved_scope = wealth
		}
		stress_and_fulfillment_impact = {
			lazy = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		trigger_event = {
			id = gdp_merchant_luxury_contract.0044
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.25
				ai_energy = 0.25
			}
		}
	}

	option = { # Use it as bait
		name = gdp_merchant_luxury_contract.0042.b
		duel = {
			skills = { intrigue prowess }
			value = decent_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0042.b.success
				save_scope_as = lc_0001_success
				show_as_tooltip = {
					custom_description_no_bullet = { text = task_contract_success_pseudo }
					add_prestige = {
						value = medium_prestige_gain
						add = menagerie_acquisition_prestige_reward_value
					}
					scope:baby_creature = { set_owner = root }
				}
				custom_tooltip = gdp_merchant_luxury_contract.0042.b.success.tt
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0042.b.failure
				save_scope_as = lc_0001_failure
				show_as_tooltip = {
					scope:task_contract = { complete_task_contract = failure_standard }
				}
			}
		}
		stress_and_fulfillment_impact = {
			content = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		trigger_event = {
			id = gdp_merchant_luxury_contract.0044
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = -0.25
				ai_rationality = 0.25
			}
			modifier = {
				intrigue < very_high_skill_rating
				factor = 0.5
			}
			modifier = {
				prowess < very_high_skill_rating
				factor = 0.5
			}
		}
	}

	option = { # Take it
		name = gdp_merchant_luxury_contract.0042.c
		scope:task_contract = { complete_task_contract = success_standard }
		hidden_effect = {
			send_interface_toast = {
				type = msg_artifact_gained
				right_icon = scope:baby_creature
				show_as_tooltip = {
					scope:baby_creature = { set_owner = root }
				}
			}
		}
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = -0.25
				ai_boldness = -0.25
			}
		}
	}
}

gdp_merchant_luxury_contract.0043 = { # Trapper
	type = character_event
	title = gdp_merchant_luxury_contract.0043.t
	desc = gdp_merchant_luxury_contract.0043.desc
	theme = trade
	left_portrait = {
		character = root
		animation = shock
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:hunter
		animation = hunting_shortbow_rest_arrow_default
	}
	override_background = { reference = terrain }

	immediate = {
		luxury_contract_find_or_create_hunter_effect = yes
	}

	option = { # Accept
		name = gdp_merchant_luxury_contract.0043.a
		pay_short_term_gold = {
			gold = minor_gold_value
			target = scope:hunter
		}
		custom_tooltip = gdp_merchant_luxury_contract.0043.b.success_tt
		save_scope_as = lc_0001_trapper_flag
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = -0.25
				ai_boldness = 0.25
			}
			modifier = {
				short_term_gold < medium_gold_value
				factor = 0
			}
		}
	}

	option = { # Persuade
		name = gdp_merchant_luxury_contract.0043.b
		duel = {
			skill = diplomacy
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0043.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_merchant_luxury_contract.0043.b.success
					right_icon = scope:hunter
					custom_tooltip = gdp_merchant_luxury_contract.0043.b.success_tt
				}
				save_scope_as = lc_0001_trapper_flag
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0043.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_merchant_luxury_contract.0043.b.failure
					right_icon = scope:hunter
					# Destroy unused characters
					scope:hunter ?= { luxury_contract_cleanup_unused_character_effect = yes }
				}
			}
		}
		stress_and_fulfillment_impact = {
			shy = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.25
				ai_sociability = 0.25
			}
			modifier = {
				diplomacy < very_high_skill_rating
				factor = 0
			}
		}
	}

	option = { # Dismiss
		name = gdp_merchant_luxury_contract.0043.c
		add_prestige = miniscule_prestige_gain
		# Destroy unused characters
		scope:hunter ?= { luxury_contract_cleanup_unused_character_effect = yes }
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_sociability = -0.25
			}
		}
	}

	after = {
		trigger_event = {
			id = gdp_merchant_luxury_contract.0044
			days = 3
		}
	}
}

gdp_merchant_luxury_contract.0044 = { # Hunt outcome
	type = character_event
	title = gdp_merchant_luxury_contract.0044.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:lc_active_path_flag = flag:lc_0001_baby_flag }
				desc = gdp_merchant_luxury_contract.0044.bait
			}
			triggered_desc = {
				trigger = { exists = scope:lc_0001_trapper_flag }
				desc = gdp_merchant_luxury_contract.0044.trapper
			}
			desc = gdp_merchant_luxury_contract.0044.desc
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:lc_0001_success
					scope:lc_active_path_flag = flag:lc_0001_baby_flag
				}
				desc = gdp_merchant_luxury_contract.0044.bait_success
			}
			triggered_desc = {
				trigger = {
					exists = scope:lc_0001_failure
					scope:lc_active_path_flag = flag:lc_0001_baby_flag
				}
				desc = gdp_merchant_luxury_contract.0044.bait_failure
			}
			triggered_desc = {
				trigger = { exists = scope:lc_0001_success }
				desc = gdp_merchant_luxury_contract.0044.success
			}
			desc = gdp_merchant_luxury_contract.0044.failure
		}
	}
	theme = trade
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_0001_success
					exists = scope:lc_0001_hunt_success_flag
				}
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_0001_failure
					exists = scope:lc_0001_hunt_failure_flag
				}
			}
			animation = stress
		}
	}
	right_portrait = {
		character = scope:hunter
		trigger = { exists = scope:lc_0001_trapper_flag }
		triggered_animation = {
			trigger = {
				NOT = {
					exists = scope:lc_0001_failure
				}
			}
			animation = war_over_tie
		}
		triggered_animation = {
			trigger = {
				exists = scope:lc_0001_failure
			}
			animation = eyeroll
		}
	}
	artifact = {
		target = scope:hunt_creature
		position = lower_center_portrait
	}
	artifact = {
		target = scope:baby_creature
		position = lower_right_portrait
	}
	override_background = { reference = terrain }

	immediate = {
		if = {
			limit = { exists = scope:baby_creature }
			if = {
				limit = { exists = scope:lc_0001_success }
				add_prestige = medium_prestige_gain
				hidden_effect = {
					send_interface_toast = {
						type = msg_artifact_gained
						right_icon = scope:baby_creature
						show_as_tooltip = {
							scope:baby_creature = { set_owner = root }
						}
					}
				}
			}
			else = {
				hidden_effect = { destroy_artifact = scope:baby_creature }
			}
		}
		if = {
			limit = {
				NOR = {
					exists = scope:lc_0001_success
					exists = scope:lc_0001_failure
				}
			}
			hidden_effect = {
				duel = {
					skills = { martial prowess }
					value = decent_skill_rating
					50 = {
						modifier = {
							exists = scope:lc_0001_trapper_flag
							add = 10
						}
						compare_modifier = {
							value = scope:duel_value
							multiplier = 3.5
							min = -49
						}
						min = 10
						save_scope_as = lc_0001_hunt_success_flag
					}
					50 = {
						compare_modifier = {
							value = scope:duel_value
							multiplier = -3.5
							min = -49
						}
						min = 10
						save_scope_as = lc_0001_hunt_failure_flag
					}
				}
			}
		}
		else_if = { # Outcome already decided by an earlier sub-chain, carry it over
			limit = { exists = scope:lc_0001_success }
			save_scope_as = lc_0001_hunt_success_flag
		}
		else = {
			save_scope_as = lc_0001_hunt_failure_flag
		}
		# CREATE MAIN REWARD CREATURE
		if = {
			limit = { exists = scope:lc_0001_hunt_success_flag }
			luxury_contract_reward_quality_effect = yes
			hidden_effect_new_object = {
				create_creature_artifact_effect = {
					OWNER = root
					CREATOR = root
				}
			}
			scope:newly_created_artifact ?= { save_scope_as = hunt_creature }
			scope:task_contract = {
				set_variable = {
					name = artifact
					value = scope:hunt_creature
				}
			}
		}
	}

	option = { # Wahoo
		name = {
			trigger = { exists = scope:baby_creature }
			text = gdp_merchant_luxury_contract.0044.a
		}
		name = {
			trigger = {
				NOT = { exists = scope:baby_creature }
			}
			text = gdp_merchant_luxury_contract.0044.c
		}
		trigger = { exists = scope:lc_0001_hunt_success_flag }
		scope:task_contract = { complete_task_contract = success_standard }
		hidden_effect = {
			send_interface_toast = {
				type = msg_artifact_gained
				right_icon = scope:hunt_creature
				show_as_tooltip = {
					scope:hunt_creature = { set_owner = root }
				}
			}
		}
		scope:hunter ?= {
			if = {
				limit = { has_character_flag = destroy_me }
				silent_disappearance_effect = yes
			}
		}
		ai_chance = {
			base = 10
		}
	}

	option = { # Fail
		name = {
			trigger = { exists = scope:baby_creature }
			text = gdp_merchant_luxury_contract.0044.b
		}
		name = {
			trigger = {
				NOT = { exists = scope:baby_creature }
			}
			text = gdp_merchant_luxury_contract.0044.d
		}
		trigger = { exists = scope:lc_0001_hunt_failure_flag }
		scope:task_contract = { complete_task_contract = failure_standard }
		scope:hunter ?= {
			if = {
				limit = { exists = scope:fallback_creature }
				hidden_effect = { destroy_artifact = scope:fallback_creature }
			}
		}
		# Destroy unused characters
		scope:hunter ?= { luxury_contract_cleanup_unused_character_effect = yes }
		ai_chance = {
			base = 10
		}
	}

	option = { # Hire Trapper
		name = gdp_merchant_luxury_contract.0044.e
		trigger = {
			scope:hunter ?= { is_alive = yes }
			exists = scope:lc_0001_trapper_flag
			NOT = {
				scope:hunter = { is_courtier_of = root }
			}
		}
		if = {
			limit = { exists = scope:lc_0001_hunt_success_flag }
			scope:task_contract = { complete_task_contract = success_standard }
			hidden_effect = {
				send_interface_toast = {
					type = msg_artifact_gained
					right_icon = scope:hunt_creature
					show_as_tooltip = {
						scope:hunt_creature = { set_owner = root }
					}
				}
			}
		}
		else = {
			scope:task_contract = { complete_task_contract = failure_standard }
		}
		pay_short_term_gold = {
			target = scope:hunter
			gold = minor_gold_value
		}
		add_courtier = scope:hunter
		hidden_effect = {
			reverse_add_opinion = {
				target = scope:hunter
				modifier = recruited_me_opinion
				opinion = 50
			}
		}
		if = {
			limit = { is_travelling = yes }
			current_travel_plan = { add_companion = scope:hunter }
		}
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = -0.25
				ai_sociability = 0.25
			}
			modifier = {
				short_term_gold < medium_gold_value
				factor = 0
			}
		}
	}
}

### Poach sub-chain
gdp_merchant_luxury_contract.0051 = { # Start
	type = character_event
	title = gdp_merchant_luxury_contract.0051.t
	desc = gdp_merchant_luxury_contract.0051.desc
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:hunter
		animation = hunting_knife_start
	}
	lower_center_portrait = scope:rich_local
	override_background = { reference = terrain }

	trigger = {
		scope:lc_active_path_flag ?= flag:lc_0001_wilds_flag
		luxury_contract_any_rich_local_trigger = yes
	}

	immediate = {
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_poach_flag
		}
		luxury_contract_select_rich_local_effect = yes
		scope:rich_local = {
			save_scope_as = big_local_creature
			select_local_creature_effect = { TYPE = rich_local }
			assign_quirk_effect = yes
		}
		luxury_contract_find_or_create_hunter_effect = yes
	}

	option = { # Go for it
		name = gdp_merchant_luxury_contract.0051.a
		flavor = gdp_merchant_luxury_contract.0051.a.flavor
		add_internal_flag = dangerous
		custom_tooltip = gdp_merchant_luxury_contract.0051.a.tt
		stress_and_fulfillment_impact = {
			honest = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		trigger_event = {
			id = gdp_merchant_luxury_contract.0052
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = -0.25
				ai_greed = 0.25
			}
		}
	}

	option = { # No way Jose
		name = gdp_merchant_luxury_contract.0051.b
		flavor = gdp_merchant_luxury_contract.0001.b.flavor
		trigger = {
			NOT = { has_character_flag = menagerie_acquisition_rejected_other_path }
		}
		add_character_flag = { flag = menagerie_acquisition_rejected_other_path months = 6 }
		custom_tooltip = gdp_merchant_luxury_contract_back_to_town_tt
		save_scope_value_as = {
			name = lc_active_path_flag
			value = flag:lc_0001_urban_flag
		}
		scope:hunter ?= {
			if = {
				limit = { has_character_flag = destroy_me }
				silent_disappearance_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			brave = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		trigger_event = {
			on_action = gdp_menagerie_acquisition_random_pool_start
			days = 3
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.25
				ai_boldness = -0.25
			}
		}
	}
}

gdp_merchant_luxury_contract.0052 = { # Poaching time
	type = character_event
	title = gdp_merchant_luxury_contract.0052.t
	desc = gdp_merchant_luxury_contract.0052.desc
	theme = trade
	left_portrait = {
		character = root
		animation = paranoia
	}
	right_portrait = {
		character = scope:hunter
		animation = eavesdrop
	}
	lower_right_portrait = scope:rich_local
	artifact = {
		target = scope:rich_local_creature
		position = lower_center_portrait
	}
	override_background = { reference = terrain }

	immediate = {
		luxury_contract_reward_quality_effect = yes
		hidden_effect_new_object = {
			create_creature_artifact_effect = {
				OWNER = scope:rich_local
				CREATOR = scope:rich_local
			}
		}
		scope:newly_created_artifact ?= { save_scope_as = rich_local_creature }
		scope:task_contract = {
			set_variable = {
				name = artifact
				value = scope:rich_local_creature
			}
		}
	}

	option = { # Go for it
		name = gdp_merchant_luxury_contract.0052.a
		add_internal_flag = dangerous
		duel = {
			skills = { martial prowess }
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0052.a.success
				save_scope_as = lc_0001_success
				show_as_tooltip = {
					scope:task_contract = { complete_task_contract = success_standard }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.0052.a.neutral
				custom_tooltip = gdp_merchant_luxury_contract.0052.b.tt
				hidden_effect = { destroy_artifact = scope:rich_local_creature }
				random = {
					chance = 25
					save_scope_as = lc_0001_poach_wound_flag
					show_as_tooltip = {
						increase_wounds_no_death_effect = { REASON = fight }
					}
				}
			}
		}
		stress_and_fulfillment_impact = {
			craven = major_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
			modifier = {
				prowess < very_high_skill_rating
				factor = 0
			}
		}
	}

	option = { # Hide
		name = gdp_merchant_luxury_contract.0052.b
		custom_tooltip = gdp_merchant_luxury_contract.0052.b.tt
		hidden_effect = { destroy_artifact = scope:rich_local_creature }
		stress_and_fulfillment_impact = {
			brave = major_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.25
				ai_boldness = -0.25
			}
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.0053
	}
}

gdp_merchant_luxury_contract.0053 = { # Poaching outcome
	type = character_event
	title = gdp_merchant_luxury_contract.0053.t
	desc = {
		desc = gdp_merchant_luxury_contract.0053.desc
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:lc_0001_success }
				desc = gdp_merchant_luxury_contract.0053.success
			}
			desc = gdp_merchant_luxury_contract.0053.failure
		}
	}
	theme = trade
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:lc_0001_success }
			animation = war_over_tie
		}
		triggered_animation = {
			trigger = {
				NOT = { exists = scope:lc_0001_success }
				NOT = { exists = scope:lc_0001_poach_wound_flag }
			}
			animation = anger
		}
		triggered_animation = {
			trigger = { exists = scope:lc_0001_poach_wound_flag }
			animation = loss_1
		}
	}
	right_portrait = {
		character = scope:hunter
		animation = shame
	}
	lower_right_portrait = scope:rich_local
	artifact = {
		target = scope:rich_local_creature
		position = lower_center_portrait
		trigger = {
			NOT = { exists = scope:lc_0001_failure }
		}
	}
	artifact = {
		target = scope:fallback_creature
		position = lower_left_portrait
	}
	override_background = { reference = terrain }

	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:lc_0001_success }
			}
			save_scope_as = harmless_local_creature
			scope:hunter = {
				select_local_creature_effect = { TYPE = fallback }
			}
			luxury_contract_fallback_reward_quality_effect = yes
			hidden_effect_new_object = {
				create_creature_artifact_effect = {
					OWNER = scope:hunter
					CREATOR = scope:hunter
				}
			}
			scope:newly_created_artifact = { save_scope_as = fallback_creature }
			scope:task_contract = {
				set_variable = {
					name = artifact
					value = scope:fallback_creature
				}
			}
		}
		else = {
			scope:task_contract = { complete_task_contract = success_standard }
		}
		if = {
			limit = { exists = scope:lc_0001_poach_wound_flag }
			increase_wounds_no_death_effect = { REASON = hunting_accident }
		}
	}

	option = { # Wahoo
		name = gdp_merchant_luxury_contract.0053.a
		trigger = { exists = scope:lc_0001_success }
		# Destroy unused characters
		scope:hunter ?= { luxury_contract_cleanup_unused_character_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_gain
			brave = major_stress_impact_gain
		}
		ai_chance = {
			base = 10
		}
	}

	option = { # Take responsibility
		name = gdp_merchant_luxury_contract.0053.b
		flavor = gdp_merchant_luxury_contract.0053.b.flavor
		trigger = { exists = scope:lc_0001_success }
		add_prestige = minor_prestige_gain
		reverse_add_opinion = {
			modifier = stole_artifact_from_me
			target = scope:rich_local
			opinion = -50
		}
		scope:rich_local = { add_personal_artifact_claim = scope:rich_local_creature }
		add_courtier = scope:hunter
		hidden_effect = {
			reverse_add_opinion = {
				target = scope:hunter
				modifier = recruited_me_opinion
				opinion = 50
			}
		}
		if = {
			limit = { is_travelling = yes }
			current_travel_plan = { add_companion = scope:hunter }
		}
		stress_and_fulfillment_impact = {
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = 0.25
				ai_compassion = 0.25
			}
		}
	}

	option = { # Gosh darned it
		name = gdp_merchant_luxury_contract.0053.c
		trigger = {
			NOT = { exists = scope:lc_0001_success }
		}
		scope:task_contract = { complete_task_contract = failure_standard }
		hidden_effect = {
			scope:hunter = { destroy_artifact = scope:fallback_creature }
		}
		# Destroy unused characters
		scope:hunter ?= { luxury_contract_cleanup_unused_character_effect = yes }
		ai_chance = {
			base = 10
		}
	}

	option = { # Recruit
		name = gdp_merchant_luxury_contract.0053.d
		trigger = {
			NOT = { exists = scope:lc_0001_success }
		}
		hidden_effect = {
			scope:hunter = { destroy_artifact = scope:fallback_creature }
		}
		scope:task_contract = { complete_task_contract = failure_standard }
		pay_short_term_gold = {
			gold = minor_gold_value
			target = scope:hunter
		}
		add_courtier = scope:hunter
		hidden_effect = {
			reverse_add_opinion = {
				target = scope:hunter
				modifier = recruited_me_opinion
				opinion = 50
			}
		}
		if = {
			limit = { is_travelling = yes }
			current_travel_plan = { add_companion = scope:hunter }
		}
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_sociability = 0.25
				ai_greed = -0.25
			}
			modifier = {
				short_term_gold < medium_gold_value
				factor = 0
			}
		}
	}

	option = { # Fallback
		name = gdp_merchant_luxury_contract.0053.e
		trigger = {
			NOT = { exists = scope:lc_0001_success }
		}
		scope:task_contract = { complete_task_contract = success_standard }
		pay_short_term_gold = {
			target = scope:hunter
			gold = medium_gold_value
		}
		# Destroy unused characters
		scope:hunter ?= { luxury_contract_cleanup_unused_character_effect = yes }
		stress_and_fulfillment_impact = {
			stubborn = minor_stress_impact_loss
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
			modifier = {
				short_term_gold < medium_gold_value
				factor = 0
			}
		}
	}

	after = {
		remove_variable = animal_type
	}
}

scripted_effect lc_curio_next_building_option_effect = {
	custom_tooltip = gdp_merchant_luxury_contract.$TOOLTIP$.tt
	# Save flag
	save_scope_value_as = {
		name = lc_active_building_flag
		value = flag:$FLAG$
	}
	# Destroy unused artifact
	if = {
		limit = { exists = scope:task_contract.var:artifact }
		destroy_artifact = scope:task_contract.var:artifact
	}
	# Trigger event
	trigger_event = {
		id = gdp_merchant_luxury_contract.$EVENT_ID$
		days = 3
	}
}

scripted_effect lc_curio_next_path_option_effect = {
	custom_tooltip = gdp_merchant_luxury_contract.$TOOLTIP$.tt
	# Setup path scope
	save_scope_value_as = {
		name = lc_active_path_flag
		value = flag:$FLAG$
	}
	# Trigger event
	trigger_event = {
		id = gdp_merchant_luxury_contract.$EVENT_ID$
		days = 3
	}
}

scripted_trigger lc_curio_next_building_option_trigger = {
	trigger_if = {
		limit = {
			OR = { # Barter options allow changing your mind
				scope:lc_active_path_flag = flag:lc_1101_urchin_flag
				scope:lc_active_path_flag = flag:lc_1101_antiques_flag
				scope:lc_active_path_flag = flag:lc_1101_bookseller_flag
			}
		}
	}
	trigger_else = {
		NOR = {
			exists = scope:lc_1001_success_critical
			exists = scope:lc_1001_success
		}
	}
	scope:merchant = {
		NOR = {
			any_in_list = {
				variable = lc_building_completed_list
				this = flag:$FLAG$
			}
			any_in_list = {
				variable = lc_building_completed_list
				count >= 2
			}
		}
		any_in_list = {
			variable = lc_building_potential_list
			this = flag:$FLAG$
		}
	}
}

scripted_trigger lc_curio_bad_success_option_trigger = {
	exists = scope:task_contract.var:artifact
	NOR = {
		exists = scope:lc_1001_success_critical
		exists = scope:lc_1001_success
	}
}

scripted_trigger lc_curio_give_up_option_trigger = {
	trigger_if = {
		limit = {
			OR = { # Barter options allow changing your mind
				scope:lc_active_path_flag = flag:lc_1101_urchin_flag
				scope:lc_active_path_flag = flag:lc_1101_antiques_flag
				scope:lc_active_path_flag = flag:lc_1101_bookseller_flag
			}
		}
	}
	trigger_else = {
		NOR = {
			exists = scope:lc_1001_success_critical
			exists = scope:lc_1001_success
			exists = scope:task_contract.var:artifact # why fail when you can take it
		}
	}
}

scripted_effect lc_curio_give_up_option_effect = {
	scope:task_contract = { complete_task_contract = failure_standard }
	lc_curio_clean_up_variables_effect = yes
}

scripted_effect lc_curio_success_option_effect = {
	scope:task_contract = { complete_task_contract = success_standard }
	lc_curio_clean_up_variables_effect = yes
}

scripted_effect lc_curio_failure_option_effect = {
	hidden_effect = {
		if = {
			limit = { exists = scope:artifact }
		 	destroy_artifact = scope:artifact
		}
	}
	scope:task_contract = { remove_variable = artifact }
	clear_saved_scope = artifact
}

scripted_effect lc_curio_clean_up_variables_effect = {
	scope:merchant = {
		clear_variable_list = lc_path_options_list
		clear_variable_list = lc_building_fallback_list
		clear_variable_list = lc_building_potential_list
		clear_variable_list = lc_building_completed_list
	}
}

####
# gdp_merchant_luxury_contract.1001-2000 - Find Curio
###

gdp_merchant_luxury_contract.1001 = { # Intro
	type = character_event
	title = gdp_merchant_luxury_contract.1001.t
	desc = {
		desc = gdp_merchant_luxury_contract.1001.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					location = {
						OR = {
							terrain = desert
							terrain = desert_mountains
						}
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.desert
			}
			triggered_desc = {
				trigger = { 
					location = {
						terrain = mountains
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.mountain
			}
			triggered_desc = {
				trigger = { 
					location = {
						terrain = jungle
					}
				}
				desc = gdp_merchant_luxury_contract.0001.desc.jungle
			}
			desc = gdp_merchant_luxury_contract.0001.desc.plains
		}
		desc = double_line_break
		first_valid = {
			triggered_desc = {
				trigger = {	knows_language_of_culture = location.county.culture }
				desc = gdp_merchant_luxury_contract.1001.desc.locals_language
			}
			desc = gdp_merchant_luxury_contract.1001.desc.locals
		}
		random_valid = {
			triggered_desc = {
				trigger = {
					any_in_list = {
						variable = lc_building_potential_list
						this = flag:religious_building
					}
				}
				desc = gdp_merchant_luxury_contract.1001.desc.religious
			}
			triggered_desc = {
				trigger = {
					any_in_list = {
						variable = lc_building_potential_list
						this = flag:scholarly_building
					}
				}
				desc = gdp_merchant_luxury_contract.1001.desc.scholarly
			}
			desc = gdp_merchant_luxury_contract.1001.desc.fallback
		}
		desc = double_line_break
		desc = gdp_merchant_luxury_contract.0001.desc.close
	}
	theme = trade
	left_portrait = {
		character = root
		animation = survey
	}
	override_background = { reference = market }

	immediate = {
		save_scope_as = merchant
		hidden_effect = {
			location = {
				save_scope_as = local_province
				barony = { save_scope_as = local_barony }
				county = { save_scope_as = local_county }
				duchy = {
					# Pick a building path via flags and interests
					while = {
						count = 2
						random_list = {
							# Religious
							10 = {
								trigger = {
									any_de_jure_county = {
										any_county_province = { gdp_find_curio_poi_religious_province_trigger = yes }
									}
									NOT = {
										scope:merchant = {
											any_in_list = {
												variable = lc_building_potential_list
												this = flag:religious_building
											}
										}
									}
								}
								modifier = { add = scope:merchant.learning }
								modifier = {
									scope:merchant = { has_trait = theologian }
									add = 20
								}
								modifier = {
									scope:merchant = { has_trait = cynical }
									add = -20
								}
								random_de_jure_county = {
									limit = {
										any_county_province = { gdp_find_curio_poi_religious_province_trigger = yes }
									}
									random_county_province = {
										limit = { gdp_find_curio_poi_religious_province_trigger = yes }
										save_scope_as = religious_building_province
										random_built_buildings = {
											limit = {
												building_district = { gdp_find_curio_poi_religious_province_trigger = yes }
											}
											building_district = { save_scope_as = religious_building_district }
										}
										scope:merchant = {
											add_to_variable_list = {
												name = lc_building_potential_list
												target = flag:religious_building
											}
										}
										barony = {
											save_temporary_scope_as = holy_site_temp
											# Save main faith for loc purposes
											if = {
												limit = {
													is_holy_site_of = scope:religious_building_province.faith
													OR = {
														AND = {
															scope:religious_building_province.religion = religion:hinduism_religion
															title_province = { has_building_with_flag = holy_building_hinduism }
														}
														AND = {
															scope:religious_building_province.religion = religion:buddhism_religion
															title_province = { has_building_with_flag = holy_building_buddhism }
														}
														AND = {
															OR = { scope:religious_building_province.religion = religion:catholic_religion scope:religious_building_province.religion = religion:protestant_religion scope:religious_building_province.religion = religion:eastern_orthodox_religion scope:religious_building_province.religion = religion:oriental_orthodox_religion }
															title_province = { has_building_with_flag = holy_building_christianity }
														}
														AND = {
															scope:religious_building_province.religion = religion:islam_religion
															title_province = { has_building_with_flag = holy_building_islam }
														}
														AND = {
															scope:religious_building_province.religion = religion:judaism_religion
															title_province = { has_building_with_flag = holy_building_judaism }
														}
														AND = {
															scope:religious_building_province.religion = religion:shintoism_religion
															title_province = { has_building_with_flag = holy_building_shintoism }
														}
													}
												}
												scope:religious_building_province.faith = { save_scope_as = religious_building_faith }
											}
											else_if = {
												limit = {
													title_province = { has_building_with_flag = holy_building_hinduism }
												}
												religion:hinduism_religion = {
													ordered_faith = {
														order_by = num_county_followers
														save_scope_as = religious_building_faith
													}
												}
											}
											else_if = {
												limit = {
													title_province = { has_building_with_flag = holy_building_buddhism }
												}
												religion:buddhism_religion = {
													ordered_faith = {
														order_by = num_county_followers
														save_scope_as = religious_building_faith
													}
												}
											}
											else_if = {
												limit = {
													title_province = { has_building_with_flag = holy_building_christianity }
												}
												scope:religious_building_province.religion = {
													ordered_faith = {
														order_by = num_county_followers
														save_scope_as = religious_building_faith
													}
												}
											}
											else_if = {
												limit = {
													title_province = { has_building_with_flag = holy_building_islam }
												}
												religion:islam_religion = {
													ordered_faith = {
														order_by = num_county_followers
														save_scope_as = religious_building_faith
													}
												}
											}
											else_if = {
												limit = {
													title_province = { has_building_with_flag = holy_building_judaism }
												}
												religion:judaism_religion = {
													ordered_faith = {
														order_by = num_county_followers
														save_scope_as = religious_building_faith
													}
												}
											}
											else_if = {
												limit = {
													title_province = { has_building_with_flag = holy_building_shintoism }
												}
												religion:shintoism_religion = {
													ordered_faith = {
														order_by = num_county_followers
														save_scope_as = religious_building_faith
													}
												}
											}
											else = {
												scope:religious_building_province.faith = { save_scope_as = religious_building_faith }
											}
										}
									}
								}
							}
							# Scholarly
							10 = {
								trigger = {
									any_de_jure_county = {
										any_county_province = { gdp_find_curio_poi_scholarly_province_trigger = yes }
									}
									NOT = {
										scope:merchant = {
											any_in_list = {
												variable = lc_building_potential_list
												this = flag:scholarly_building
											}
										}
									}
								}
								modifier = { add = scope:merchant.learning }
								modifier = {
									scope:merchant = { has_trait = lifestyle_scholar }
									add = 20
								}
								modifier = {
									scope:merchant = { has_trait = erudite }
									add = 20
								}
								random_de_jure_county = {
									limit = {
										any_county_province = { gdp_find_curio_poi_scholarly_province_trigger = yes }
									}
									random_county_province = {
										limit = { gdp_find_curio_poi_scholarly_province_trigger = yes }
										save_scope_as = scholarly_building_province
										random_built_buildings = {
											limit = {
												building_district = { gdp_find_curio_poi_scholarly_province_trigger = yes }
											}
											building_district = { save_scope_as = scholarly_building_district }
										}
										scope:merchant = {
											add_to_variable_list = {
												name = lc_building_potential_list
												target = flag:scholarly_building
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	option = { # Urban
		name = gdp_merchant_luxury_contract.1001.a
		flavor = gdp_merchant_luxury_contract.1001.a.flavor
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.a
			FLAG = urban_building
			EVENT_ID = 1101
		}
		stress_and_fulfillment_impact = {
			lazy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}
	
	option = { # Religious
		name = gdp_merchant_luxury_contract.1001.e
		flavor = gdp_merchant_luxury_contract.1001.e.flavor
		trigger = {
			scope:merchant = {
				any_in_list = {
					variable = lc_building_potential_list
					this = flag:religious_building
				}
			}
		}
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.e
			FLAG = religious_building
			EVENT_ID = 1501
		}
		stress_and_fulfillment_impact = {
			zealous = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}

	option = { # Scholarly
		name = gdp_merchant_luxury_contract.1001.f
		flavor = gdp_merchant_luxury_contract.1001.f.flavor
		trigger = {
			scope:merchant = {
				any_in_list = {
					variable = lc_building_potential_list
					this = flag:scholarly_building
				}
			}
		}
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.f
			FLAG = scholarly_building
			EVENT_ID = 1601
		}
		stress_and_fulfillment_impact = {
			diligent = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}
}

scripted_trigger lc_curio_select_fallback_location_trigger = {
	scope:merchant = {
		any_in_list = {
			variable = lc_building_potential_list
			this = flag:$FLAG$
		}
		NOT = {
			any_in_list = {
				variable = lc_building_completed_list
				this = flag:$FLAG$
			}
		}
	}
}

scripted_effect lc_curio_select_fallback_location_effect = {
	hidden_effect = {
		while = {
			count = 1
			scope:merchant = {
				random_list = {
					1 = {
						trigger = {
							lc_curio_select_fallback_location_trigger = { FLAG = religious_building }
						}
						add_to_variable_list = {
							name = lc_building_fallback_list
							target = flag:religious_building
						}
					}
					1 = {
						trigger = {
							lc_curio_select_fallback_location_trigger = { FLAG = scholarly_building }
						}
						add_to_variable_list = {
							name = lc_building_fallback_list
							target = flag:scholarly_building
						}
					}
				}
			}
		}
	}
}

scripted_effect lc_curio_reforge_effect = {
	hidden_effect_new_object = {
		scope:artifact ?= {
			if = {
				limit = {
					NOT = { artifact_type = $TYPE$ }
				}
				reforge_artifact = { type = $TYPE$ }
			}
			if = {
				limit = { artifact_type = library_item }
				domicile_library_artifact_modifiers_effect = yes
			}
			else = {
				domicile_curio_artifact_modifiers_effect = yes
			}
		}
	}
	scope:task_contract = {
		set_variable = {
			name = artifact
			value = scope:artifact
		}
	}
	clear_saved_scope = newly_created_artifact
}

scripted_effect lc_curio_portrait_scope_effect = {
	save_scope_as = portrait
	save_scope_as = bg_override_char
}

scripted_effect lc_curio_fallback_artifact_effect = {
	if = {
		limit = {
			NOT = { exists = scope:lc_1001_success_critical }
			trigger_if = {
				limit = { exists = scope:lc_1001_success }
				OR = {
					scope:lc_active_path_flag = flag:lc_1101_antiques_flag
					scope:lc_active_path_flag = flag:lc_1101_bookseller_flag
				}
			}
			NOT = { scope:lc_active_path_flag = flag:lc_1501_tomb_flag }
			$OWNER$ = { is_alive = yes }
			scope:merchant = {
				OR = {
					any_in_list = {
						variable = lc_building_completed_list
						count >= 2
					}
					NOT = {
						any_in_list = { variable = lc_building_fallback_list }
					}
				}
			}
		}
		hidden_effect = {
			luxury_contract_fallback_reward_quality_effect = yes
			$OWNER$ = {
				create_curio_artifact_effect = {
					OWNER = $OWNER$
					CREATOR = dummy_female
				}
			}
			if = {
				limit = { exists = scope:new_trinket }
				scope:new_trinket = { save_scope_as = fallback_artifact }
				clear_saved_scope = new_trinket
			}
			else_if = {
				limit = { exists = scope:newly_created_artifact }
				scope:newly_created_artifact = { save_scope_as = fallback_artifact }
				clear_saved_scope = newly_created_artifact
			}
			clear_saved_scope = quality
			clear_saved_scope = wealth
		}
	}
}

scripted_trigger lc_curio_fallback_option_trigger = {
	exists = scope:fallback_artifact
	scope:merchant = {
		OR = {
			any_in_list = {
				variable = lc_building_completed_list
				count >= 2
			}
			NOT = {
				any_in_list = { variable = lc_building_fallback_list }
			}
		}
	}
}

scripted_effect lc_curio_fallback_option_effect = {
	custom_description_no_bullet = { text = task_contract_success_pseudo }
	remove_short_term_gold = minor_gold_value
	show_as_tooltip = {
		add_prestige = find_curio_prestige_reward_value
		scope:fallback_artifact ?= { set_owner = scope:merchant }
	}
	scope:task_contract = {
		set_variable = {
			name = artifact
			value = scope:fallback_artifact
		}
	}
	hidden_effect = {
		scope:task_contract = { complete_task_contract = success_standard }
	}
}

scripted_effect lc_curio_cleanup_path_scopes_effect = {
	clear_saved_scope = portrait
	clear_saved_scope = lc_1001_success
	clear_saved_scope = lc_1001_success_critical
	clear_saved_scope = lc_1001_failure_critical
}

scripted_effect luxury_contract_wound_effect = {
	if = {
		limit = { exists = var:lc_wound_flag }
		increase_wounds_no_death_effect = { REASON = fight }
		remove_variable = lc_wound_flag
	}
}

### Market sub-chain

scripted_effect luxury_contract_find_or_create_urchin_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			age <= 18
			NOR = {
				scope:dealer ?= this
				scope:traveler ?= this
				scope:gambler ?= this
			}
		}
		weight = {
			base = 1
			modifier = { add = intrigue }
		}
		save_scope_as = urchin
	}
	if = {
		limit = { NOT = { exists = scope:urchin } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = criminal_fingers_character
			age = { 8 16 }
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:lc_spawn_faith
			save_scope_as = urchin
		}
		scope:urchin = { add_character_flag = destroy_me }
	}
	scope:urchin ?= {
		assign_quirk_effect = yes
		add_character_flag = peasant_outfit
	}
}

scripted_effect luxury_contract_find_or_create_traveler_effect = {
	scope:local_county.duchy = {
		every_de_jure_county = {
			every_county_province = {
				every_province_domicile = {
					limit = {
						is_domicile_type = camp
						owner = {
							is_available_quick = {
								ai = yes
								adult = yes
								imprisoned = no
								incapable = no
								in_army = no
							}
						}
					}
					owner = { add_to_list = potential_travelers }
				}
			}
		}
	}
	random_in_list = {
		list = potential_travelers
		limit = {
			NOR = {
				culture = scope:merchant.culture
				culture = scope:local_county.culture
			}
		}
		alternative_limit = { always = yes }
		save_scope_as = traveler
	}
	if = {
		limit = {
			NOT = { exists = scope:traveler }
		}
		random_pool_character = {
			province = scope:merchant.location
			limit = {
				is_available_quick = {
					adult = yes
					imprisoned = no
					incapable = no
					in_army = no
				}
				NOR = {
					scope:dealer ?= this
					scope:urchin ?= this
					scope:gambler ?= this
					culture = scope:merchant.culture
					culture = scope:local_county.culture
			
				}
				is_lowborn = yes
			}
			weight = {
				base = 1
				modifier = { add = sum_of_all_skills_and_prowess_value }
			}
			save_scope_as = traveler
		}
	}
	if = {
		limit = { NOT = { exists = scope:traveler } }
		scope:dealer = { save_traveler_culture_effect = yes }
		scope:traveler_culture_2 = {
			random_culture_county = {
				limit = {
					NOR = {
						culture = scope:dealer.culture
						culture = scope:merchant.culture
					}
				}
				faith = { save_scope_as = traveler_faith }
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:traveler_faith }
			}
			location.faith = { save_scope_as = traveler_faith }
		}
		create_character = {
			template = foreign_mercenary_template
			dynasty = none
			location = location
			culture = scope:traveler_culture_2
			faith = scope:traveler_faith
			save_scope_as = traveler
		}
		scope:traveler = { add_character_flag = destroy_me }
	}
	scope:traveler ?= { assign_quirk_effect = yes }
}

scripted_effect luxury_contract_find_or_create_gambler_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			NOR = {
				scope:dealer ?= this
				scope:urchin ?= this
				scope:traveler ?= this
			}
		}
		weight = {
			base = 1
			modifier = {
				add = {
					value = 0
					subtract = ai_honor
				}
			}
		}
		save_scope_as = gambler
	}
	if = {
		limit = { NOT = { exists = scope:gambler } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = criminal_brains_character
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:lc_spawn_faith
			save_scope_as = gambler
		}
		random = {
			chance = 33
			random_list = {
				10 = { add_trait = one_legged }
				10 = { add_trait = one_eyed }
				10 = { add_trait = scarred }
			}
		}
		scope:gambler = { add_character_flag = destroy_me }
	}
	scope:gambler ?= { assign_quirk_effect = yes }
}

scripted_effect luxury_contract_find_other_merchant_effect = {
	# Find merchants
	scope:local_barony.trade_market ?= {
		every_character_in_market = {
			limit = {
				government_has_flag = government_is_merchant
				is_ai = yes
				NOT = { this = scope:merchant }
				capital_province.kingdom = {
					OR = {
						this = scope:local_county.kingdom
						any_title_to_title_neighboring_and_across_water_kingdom = { this = scope:local_county.kingdom }
					}
				}
			}
			add_to_list = potential_merchants
		}
	}
}

# Intro
gdp_merchant_luxury_contract.1101 = { # Start
	type = character_event
	title = gdp_merchant_luxury_contract.1101.t
	desc = {
		desc = gdp_merchant_luxury_contract.1101.desc
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_urchin_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1101.urchin
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_antiques_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1101.antiques
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_bookseller_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1101.bookseller
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_travelers_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1101.travelers
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_gambler_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1101.tavern
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_merchant_flag
				}
			}
			desc = gdp_merchant_luxury_contract.1101.merchant
		}
	}
	theme = trade
	left_portrait = {
		character = root
		animation = interested
	}
	override_background = { reference = market }

	trigger = {
		scope:lc_active_building_flag ?= flag:urban_building
	}

	immediate = {
		# Prevent repeats
		add_to_variable_list = {
			name = lc_building_completed_list
			target = flag:urban_building
		}
		# Save paths
		luxury_contract_find_other_merchant_effect = yes
		hidden_effect = {
			while = {
				count = 2
				random_list = {
					10 = { # Urchin
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1101_urchin_flag
									# Intrigue group
									this = flag:lc_1101_gambler_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1101_urchin_flag
						}
					}
					10 = { # Antiques
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1101_antiques_flag
									# Barter group
									this = flag:lc_1101_bookseller_flag
								}
							}
							NOT = {
								any_in_list = {
									variable = lc_path_options_list
									this = flag:lc_1101_antiques_flag
									# Barter group
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1101_antiques_flag
						}
					}
					10 = { # Bookseller
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1101_bookseller_flag
									# Barter group
									this = flag:lc_1101_antiques_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1101_bookseller_flag
						}
					}
					10 = { # Travelers
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1101_travelers_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1101_travelers_flag
						}
					}
					10 = { # Gambler
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1101_gambler_flag
									# Intrigue group
									this = flag:lc_1101_urchin_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1101_gambler_flag
						}
					}
					30 = { # Merchant
						trigger = {
							any_in_list = { list = potential_merchants }
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1101_merchant_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1101_merchant_flag
						}
					}
				}
			}
		}
		# Save scopes
		luxury_contract_find_or_create_dealer_effect = yes
		scope:dealer = { save_scope_as = bg_override_char }
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_urchin_flag
				}
			}
			luxury_contract_find_or_create_urchin_effect = yes
		}
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_travelers_flag
				}
			}
			luxury_contract_find_or_create_traveler_effect = yes
		}
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_gambler_flag
				}
			}
			luxury_contract_find_or_create_gambler_effect = yes
		}
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1101_merchant_flag
				}
			}
			random_in_list = {
				list = potential_merchants
				save_scope_as = other_merchant
				assign_quirk_effect = yes
				random_trade_route = {
					limit = {
						any_trade_market_on_route = { this = scope:local_barony.trade_market }
					}
					random_traded_good = { save_scope_as = merchant_good }
				}
			}
		}
	}

	option = { # Urchin
		name = gdp_merchant_luxury_contract.1101.a
		flavor = gdp_merchant_luxury_contract.1101.a.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1101_urchin_flag
			}
		}
		# Destroy unused characters
		scope:gambler ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1101.a
			FLAG = lc_1101_urchin_flag
			EVENT_ID = 1111
		}
	}

	option = { # Antiques
		name = gdp_merchant_luxury_contract.1101.b
		flavor = gdp_merchant_luxury_contract.1101.b.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1101_antiques_flag
			}
		}
		# Destroy unused characters
		scope:urchin ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:gambler ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1101.b
			FLAG = lc_1101_antiques_flag
			EVENT_ID = 1121
		}
	}

	option = { # Bookseller
		name = gdp_merchant_luxury_contract.1101.c
		flavor = gdp_merchant_luxury_contract.1101.c.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1101_bookseller_flag
			}
		}
		# Destroy unused characters
		scope:urchin ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:gambler ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1101.c
			FLAG = lc_1101_bookseller_flag
			EVENT_ID = 1131
		}
	}

	option = { # Travelers
		name = {
			trigger = {
				NOT = { knows_language_of_culture = scope:traveler.culture }
			}
			text = gdp_merchant_luxury_contract.1101.d
		}
		name = {
			trigger = { knows_language_of_culture = scope:traveler.culture }
			text = gdp_merchant_luxury_contract.1101.d.lingua
		}
		flavor = gdp_merchant_luxury_contract.1101.d.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1101_travelers_flag
			}
		}
		# Destroy unused characters
		scope:urchin ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:gambler ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1101.d
			FLAG = lc_1101_travelers_flag
			EVENT_ID = 1141
		}
	}

	option = { # Gambler
		name = gdp_merchant_luxury_contract.1101.e
		flavor = gdp_merchant_luxury_contract.1101.e.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1101_gambler_flag
			}
		}
		# Destroy unused characters
		scope:urchin ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1101.e
			FLAG = lc_1101_gambler_flag
			EVENT_ID = 1151
		}
	}

	option = { # Merchant
		name = gdp_merchant_luxury_contract.1101.f
		flavor = gdp_merchant_luxury_contract.1101.f.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1101_merchant_flag
			}
		}
		# Destroy unused characters
		scope:urchin ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:gambler ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1101.f
			FLAG = lc_1101_merchant_flag
			EVENT_ID = 1161
		}
	}

	after = {
		clear_variable_list = lc_path_options_list
		clear_variable_list = lc_building_fallback_list
		clear_variable_list = lc_building_potential_list
		clear_variable_list = lc_building_completed_list
	}
}

# Duel Outcome
gdp_merchant_luxury_contract.1102 = { # End
	type = character_event
	title = gdp_merchant_luxury_contract.1101.t
	desc = {
		first_valid = {
			triggered_desc = { # Urchin
				trigger = { scope:lc_active_path_flag = flag:lc_1101_urchin_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1102.urchin
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success_critical }
							desc = gdp_merchant_luxury_contract.1102.urchin.success_critical
						}
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1102.urchin.success
						}
						desc = gdp_merchant_luxury_contract.1102.urchin.failure
					}
				}
			}
			triggered_desc = { # Antiques
				trigger = { scope:lc_active_path_flag = flag:lc_1101_antiques_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1102.antiques
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success_critical }
							desc = gdp_merchant_luxury_contract.1102.antiques.success
						}
						desc = gdp_merchant_luxury_contract.1102.antiques.failure
					}
				}
			}
			triggered_desc = { # Bookseller
				trigger = { scope:lc_active_path_flag = flag:lc_1101_bookseller_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1102.bookseller
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success_critical }
							desc = gdp_merchant_luxury_contract.1102.bookseller.success
						}
						desc = gdp_merchant_luxury_contract.1102.bookseller.failure
					}
				}
			}
			triggered_desc = { # Travelers
				trigger = { scope:lc_active_path_flag = flag:lc_1101_travelers_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1102.travelers
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1102.travelers.success
						}
						desc = gdp_merchant_luxury_contract.1102.travelers.failure
					}
				}
			}
			triggered_desc = { # Gambler
				trigger = { scope:lc_active_path_flag = flag:lc_1101_gambler_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1102.tavern
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1102.tavern.success
						}
						triggered_desc = {
							trigger = { exists = scope:lc_1001_failure_critical }
							desc = gdp_merchant_luxury_contract.1102.tavern.failure_critical
						}
						desc = gdp_merchant_luxury_contract.1102.tavern.failure
					}
				}
			}
			triggered_desc = { # Merchant
				trigger = { scope:lc_active_path_flag = flag:lc_1101_merchant_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1102.merchant
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1102.merchant.success
						}
						desc = gdp_merchant_luxury_contract.1102.merchant.failure
					}
				}
			}
		}
	}
	theme = trade
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
			}
			animation = stress
		}
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:portrait
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				NOT = {
					scope:lc_active_path_flag = flag:lc_1101_gambler_flag
				}
			}
			animation = dismissal
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				scope:lc_active_path_flag = flag:lc_1101_gambler_flag
			}
			animation = steward
		}
		triggered_animation = {
			trigger = {
				OR = {
					AND = {
						exists = scope:lc_1001_success_critical
						scope:lc_active_path_flag = flag:lc_1101_urchin_flag
					}
					AND = {
						exists = scope:lc_1001_success
						NOT = { scope:lc_active_path_flag = flag:lc_1101_gambler_flag }
					}
				}
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_1001_success
					exists = scope:lc_1001_success_critical
				}
				scope:lc_active_path_flag = flag:lc_1101_gambler_flag
			}
			animation = rage
		}
		triggered_animation = {
			trigger = {
				exists = scope:lc_1001_success
				scope:lc_active_path_flag = flag:lc_1101_urchin_flag
			}
			animation = beg
		}
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	artifact = {
		target = scope:fallback_artifact
		position = lower_center_portrait
	}
	override_background = {
		trigger = {
			OR = {
				scope:lc_active_path_flag = flag:lc_1101_bookseller_flag
				scope:lc_active_path_flag = flag:lc_1101_merchant_flag
			}
		}
		reference = study 
	}
	override_background = {
		trigger = {
			scope:lc_active_path_flag = flag:lc_1101_gambler_flag
		}
		reference = tavern 
	}
	override_background = {
		trigger = {
			NOR = {
				scope:lc_active_path_flag = flag:lc_1101_bookseller_flag
				scope:lc_active_path_flag = flag:lc_1101_gambler_flag
				scope:lc_active_path_flag = flag:lc_1101_merchant_flag
			}
		}
		reference = market 
	}

	immediate = {
		lc_curio_fallback_artifact_effect = { OWNER = scope:dealer }
		luxury_contract_wound_effect = yes
		lc_curio_select_fallback_location_effect = yes
		switch = {
			trigger = scope:lc_active_path_flag
			flag:lc_1101_gambler_flag = {
				if = {
					limit = { exists = scope:lc_1001_failure_critical }
					pay_short_term_gold = {
						gold = minor_gold_value
						target = scope:gambler
					}
				}
				else_if = {
					limit = { exists = scope:lc_1001_success }
					add_short_term_gold = medium_gold_value
				}
				else = { add_short_term_gold = minor_gold_value }
			}
			flag:lc_1101_merchant_flag = {
				if = {
					limit = { exists = scope:lc_1001_success }
					scope:merchant.house = {
						change_house_relation_effect = {
							HOUSE = scope:other_merchant.house
							VALUE =  house_relation_improve_medium_value
							REASON = trade_opportunity_cooperation
							CHAR = scope:merchant
							TARGET_CHAR = scope:other_merchant
							TITLE = dummy_female
						}
					}
				}
				else = {
					scope:merchant.house = {
						change_house_relation_effect = {
							HOUSE = scope:other_merchant.house
							VALUE =  house_relation_damage_medium_value
							REASON = trade_opportunity_friction
							CHAR = scope:merchant
							TARGET_CHAR = scope:other_merchant
							TITLE = dummy_female
						}
					}
				}
			}
		}
	}

	option = { # Success!
		name = gdp_merchant_luxury_contract.1102.a
		trigger = {
			OR = {
				exists = scope:lc_1001_success_critical
				exists = scope:lc_1001_success
			}
		}
		# SALE OUTCOMES
		if = {
			limit = {
				OR = {
					scope:lc_active_path_flag = flag:lc_1101_antiques_flag
					scope:lc_active_path_flag = flag:lc_1101_bookseller_flag
				}
				scope:dealer ?= { is_alive = yes }
			}
			if = {
				limit = { exists = scope:lc_1001_success_critical }
				pay_short_term_gold = {
					gold = minor_gold_value
					target = scope:dealer
				}
			}
			else = {
				pay_short_term_gold = {
					gold = medium_gold_value
					target = scope:dealer
				}
			}
		}
		# HIRE OUTCOMES
		else_if = {
			limit = {
				scope:lc_active_path_flag = flag:lc_1101_urchin_flag
				exists = scope:lc_1001_success
			}
			pay_short_term_gold = {
				gold = medium_gold_value
				target = scope:urchin
			}
		}
		lc_curio_success_option_effect = yes
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_greed = 0.25
			}
		}
	}

	option = { # Bad success!
		name = gdp_merchant_luxury_contract.1102.b
		trigger = { lc_curio_bad_success_option_trigger = yes }
		lc_curio_success_option_effect = yes
		stress_impact = {
			compassionate = minor_stress_impact_gain
			just = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = -0.25
				ai_greed = 0.25
			}
		}
	}

	option = { # Religious
		name = gdp_merchant_luxury_contract.1001.return.religious
		flavor = gdp_merchant_luxury_contract.1001.e.flavor
		trigger = {
			lc_curio_next_building_option_trigger = { FLAG = religious_building }
		}
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.e
			FLAG = religious_building
			EVENT_ID = 1501
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_rationality = 0.25
			}
		}
	}

	option = { # Scholarly
		name = gdp_merchant_luxury_contract.1001.return.scholarly
		flavor = gdp_merchant_luxury_contract.1001.f.flavor
		trigger = {
			lc_curio_next_building_option_trigger = { FLAG = scholarly_building }
		}
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.f
			FLAG = scholarly_building
			EVENT_ID = 1601
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_rationality = 0.25
			}
		}
	}

	option = { # Fallback!
		name = gdp_merchant_luxury_contract.1001.fallback
		flavor = gdp_merchant_luxury_contract.1001.fallback.flavor
		trigger = { lc_curio_fallback_option_trigger = yes }
		lc_curio_fallback_option_effect = yes
		ai_chance = {
			base = 0
		}
	}

	option = { # Give up!
		name = gdp_merchant_luxury_contract.1001.give_up
		trigger = { lc_curio_give_up_option_trigger = yes }
		lc_curio_give_up_option_effect = yes
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = -0.25
				ai_greed = -0.25
			}
		}
	}

	after = {
		lc_curio_cleanup_path_scopes_effect = yes
		scope:dealer ?= { luxury_contract_cleanup_unused_character_effect = yes }
	}
}

# Duel Events
gdp_merchant_luxury_contract.1111 = { # Urchin 
	type = character_event
	title = gdp_merchant_luxury_contract.1101.t
	desc = gdp_merchant_luxury_contract.1111.desc
	theme = trade
	left_portrait = {
		character = root
		animation = admiration
	}
	right_portrait = {
		character = scope:urchin
		animation = nervous
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = alley_day }

	immediate = {
		# Save portrait scope for ending event
		scope:urchin = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:urchin = {
				random_list = {
					10 = {
						create_artifact_ring_effect = {
							OWNER = scope:urchin
							SMITH = dummy_female
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1111.artifact.ring
							set_artifact_description = gdp_merchant_luxury_contract.1111.artifact.ring.desc
						}
					}
					10 = {
						create_artifact_brooch_effect = {
							OWNER = scope:urchin
							SMITH = dummy_female
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1111.artifact.brooch
							set_artifact_description = gdp_merchant_luxury_contract.1111.artifact.brooch.desc
						}
					}
					10 = {
						create_artifact_necklace_effect = {
							OWNER = scope:urchin
							SMITH = dummy_female
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1111.artifact.necklace
							set_artifact_description = gdp_merchant_luxury_contract.1111.artifact.necklace.desc
						}
					}
				}
			}
			# Save artifact to contract for tooltips
			lc_curio_reforge_effect = { TYPE = curio }
		}
	}

	option = { # Duel
		name = gdp_merchant_luxury_contract.1111.a
		duel = {
			skills = { intrigue diplomacy }
			value = decent_skill_rating
			25 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = gallowsbait
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1111.a.success_critical
				save_scope_as = lc_1001_success_critical
				add_courtier = scope:urchin
				reverse_add_opinion = {
					target = scope:urchin
					modifier = trust_opinion
					opinion = 25
				}
				hidden_effect = {
					reverse_add_opinion = {
						target = scope:urchin
						modifier = recruited_me_opinion
						opinion = 50
					}
					if = {
						limit = { is_travelling = yes }
						current_travel_plan = { add_companion = scope:urchin }
					}
				}
				show_as_tooltip = {
					scope:task_contract = { complete_task_contract = success_standard }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1111.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = medium_gold_value
						target = scope:urchin
					}
					scope:task_contract = { complete_task_contract = success_standard }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:urchin }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1111.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1102
	}
}

gdp_merchant_luxury_contract.1121 = { # Antiques
	type = character_event
	title = gdp_merchant_luxury_contract.1101.t
	desc = gdp_merchant_luxury_contract.1121.desc
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:dealer
		animation = debating
	}
	artifact = {
		target = scope:artifact
		position = lower_center_portrait
	}
	override_background = { reference = alley_day }

	immediate = {
		# Save portrait scope for ending event
		scope:dealer = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:dealer = {
				random_list = {
					10 = {
						random_dummy_gender_effect = yes
						create_artifact_weapon_effect = {
							OWNER = scope:dealer
							CREATOR = scope:dummy_gender
							SET_WEAPON_TYPE = flag:no
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1121.artifact.weapon
							set_artifact_description = gdp_merchant_luxury_contract.1121.artifact.weapon.desc
						}
					}
					10 = {
						create_artifact_bowl_effect = {
							OWNER = scope:dealer
							SMITH = dummy_female
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1121.artifact.bowl
						}
					}
					10 = {
						create_artifact_plate_effect = {
							OWNER = scope:dealer
							SMITH = dummy_female
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_description = gdp_merchant_luxury_contract.1121.artifact.plate
						}
					}
					10 = {
						random_dummy_gender_effect = yes
						create_artifact_urn_effect = {
							OWNER = scope:dealer
							POTTER = scope:dummy_gender
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_description = gdp_merchant_luxury_contract.1121.artifact.urn
						}
					}
				}
			}
			# Save artifact to contract for tooltips
			lc_curio_reforge_effect = { TYPE = curio }
		}
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1121.a
		duel = {
			skills = { diplomacy stewardship }
			value = decent_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = lifestyle_scholar
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1121.a.success_critical
				save_scope_as = lc_1001_success_critical
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = minor_gold_value
						target = scope:dealer
					}
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1121.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = medium_gold_value
						target = scope:dealer
					}
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1102
	}
}

gdp_merchant_luxury_contract.1131 = { # Bookseller
	type = character_event
	title = gdp_merchant_luxury_contract.1101.t
	desc = gdp_merchant_luxury_contract.1131.desc
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:dealer
		animation = debating
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = study }

	immediate = {
		# Save portrait scope for ending event
		scope:dealer = { lc_curio_portrait_scope_effect = yes }
		# Create potential reward artifact
		scope:dealer = {
			luxury_contract_reward_quality_effect = yes
			random_dummy_gender_effect = yes
			create_library_artifact_effect = {
				OWNER = scope:dealer
				CREATOR = scope:dummy_gender
				SUBJECT = flag:no
				TOPIC = flag:no
			}
		}
		# Save artifact scope for ending event
		scope:newly_created_artifact ?= {
			save_scope_as = artifact
			set_artifact_description = gdp_merchant_luxury_contract.1131.desc
		}
		# Save artifact to contract for tooltips
		lc_curio_reforge_effect = { TYPE = library_item }
	}

	option = { # Duel
		name = gdp_merchant_luxury_contract.1131.a
		duel = {
			skills = { diplomacy stewardship }
			value = decent_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = erudite
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1131.a.success_critical
				save_scope_as = lc_1001_success_critical
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = minor_gold_value
						target = scope:dealer
					}
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1131.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					pay_short_term_gold = {
						gold = medium_gold_value
						target = scope:dealer
					}
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1102
	}
}

gdp_merchant_luxury_contract.1141 = { # Travelers
	type = character_event
	title = gdp_merchant_luxury_contract.1101.t
	desc = gdp_merchant_luxury_contract.1141.desc
	theme = trade
	left_portrait = {
		character = root
		animation = admiration
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:traveler
		animation = war_over_win
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = alley_day }

	immediate = {
		# Save portrait scope for ending event
		scope:traveler = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:traveler = {
				random_list = {
					10 = {
						random_dummy_gender_effect = yes
						create_artifact_weapon_effect = {
							OWNER = scope:traveler
							CREATOR = scope:dummy_gender
							SET_WEAPON_TYPE = flag:no
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_description = gdp_merchant_luxury_contract.1141.artifact.weapon.desc
						}
					}
					10 = {
						create_artifact_brooch_effect = {
							OWNER = scope:traveler
							SMITH = dummy_female
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1141.artifact.brooch
							set_artifact_description = gdp_merchant_luxury_contract.1141.artifact.brooch.desc
						}
					}
				}
			}
			# Save artifact to contract for tooltips
			lc_curio_reforge_effect = { TYPE = curio }
		}
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1141.a
		flavor = gdp_merchant_luxury_contract.1141.a.flavor
		save_scope_value_as = {
			name = pseudo_duel_value
			value = {
				value = scope:merchant.diplomacy
				add = {
					value = scope:merchant.prestige_level
					multiply = 3
				}
				subtract = decent_skill_rating
				subtract = 6
			}
		}
		random_list = {
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = adventurer
					add = 10
				}
				modifier = {
					has_trait = lifestyle_traveler
					add = 10
				}
				modifier = {
					has_trait = lifestyle_surveyor
					add = 10
				}
				modifier = {
					has_trait = lifestyle_wayfarer
					add = 10
				}
				modifier = {
					has_trait = lifestyle_voyager
					add = 10
				}
				modifier = {
					has_trait = gallivanter
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1141.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract = {
						complete_task_contract = success_standard
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:traveler }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1141.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_sociability = 0.25
				ai_greed = -0.25
			}
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1102
	}
}

gdp_merchant_luxury_contract.1151 = { # Gambler
	type = character_event
	title = gdp_merchant_luxury_contract.1101.t
	desc = gdp_merchant_luxury_contract.1151.desc
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:gambler
		animation = steward
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = tavern }

	immediate = {
		# Save portrait scope for ending event
		scope:gambler = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:gambler = {
				create_artifact = {
					name = gdp_merchant_luxury_contract.1151.artifact.dice
					description = gdp_merchant_luxury_contract.1151.artifact.dice.desc
					type = curio
					visuals = pouch
					modifier = artifact_monthly_prestige_2_modifier
					modifier = artifact_intrigue_1_modifier
					quality = scope:quality
					wealth = scope:wealth
					max_durability = 30
					generate_history = no
					save_scope_as = artifact
				}
			}
			# Save artifact to contract for tooltips
			lc_curio_reforge_effect = { TYPE = curio }
		}
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1151.a
		flavor = gdp_merchant_luxury_contract.1151.a.flavor
		save_scope_value_as = {
			name = pseudo_duel_value
			value = {
				value = scope:merchant.intrigue
				add = {
					value = {
						integer_range = {
							min = 5
							max = 15
						}
					}
				}
				subtract = decent_skill_rating
				subtract = {
					value = {
						integer_range = {
							min = 5
							max = 15
						}
					}
				}
			}
		}
		random_list = {
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = lifestyle_reveler
					add = 10
				}
				modifier = {
					has_trait = drunkard
					add = 10
				}
				modifier = {
					has_trait = gallowsbait
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1151.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					add_short_term_gold = medium_gold_value
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 1
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1151.a.failure
				lc_curio_failure_option_effect = yes
				show_as_tooltip = {
					add_short_term_gold = minor_gold_value
				}
			}
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1151.a.failure_critical
				lc_curio_failure_option_effect = yes
				save_scope_as = lc_1001_failure_critical
				show_as_tooltip = {
					remove_short_term_gold = minor_gold_value
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_sociability = 0.25
				ai_greed = -0.25
			}
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1102
	}
}

gdp_merchant_luxury_contract.1161 = { # Merchant
	type = character_event
	title = gdp_merchant_luxury_contract.1101.t
	desc = gdp_merchant_luxury_contract.1161.desc
	theme = trade
	left_portrait = {
		character = root
		animation = war_over_win
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:other_merchant
		animation = interested
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = market }

	immediate = {
		# Save portrait scope for ending event
		scope:other_merchant = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:other_merchant = {
				random_list = {
					10 = {
						create_artifact = {
							name = gdp_merchant_luxury_contract.1161.artifact.fabric
							description = gdp_merchant_luxury_contract.1161.artifact.fabric.desc
							type = miscellaneous
							visuals = fabric_roll
							quality = scope:quality
							wealth = scope:wealth
							modifier = artifact_monthly_prestige_3_modifier
							modifier = artifact_trade_competitiveness_add_1_modifier
							save_scope_as = artifact
						}
					}
					10 = {
						create_artifact_pedestal_gold_effect = { OWNER = scope:other_merchant }
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1161.artifact.gold
							set_artifact_description = gdp_merchant_luxury_contract.1161.artifact.gold.desc
						}
					}
					10 = {
						create_artifact_pedestal_diamond_effect = { OWNER = scope:other_merchant }
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1161.artifact.gem
							set_artifact_description = gdp_merchant_luxury_contract.1161.artifact.gem.desc
						}
					}
				}
			}
			lc_curio_reforge_effect = { TYPE = curio }
		}
	}

	option = { # 
		name = gdp_merchant_luxury_contract.1161.a
		flavor = gdp_merchant_luxury_contract.1161.a.flavor
		save_scope_value_as = {
			name = pseudo_duel_value
			value = {
				value = scope:merchant.stewardship
				add = {
					value = scope:merchant.prestige_level
					multiply = 3
				}
				subtract = decent_skill_rating
				subtract = 6
			}
		}
		random_list = {
			10 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = administrator
					add = 10
				}
				modifier = {
					has_trait = diplomat
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1161.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
				scope:merchant.house = {
					change_house_relation_effect = {
						HOUSE = scope:other_merchant.house
						VALUE =  house_relation_improve_medium_value
						REASON = trade_opportunity_cooperation
						CHAR = scope:merchant
						TARGET_CHAR = scope:other_merchant
						TITLE = dummy_female
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:other_merchant }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1161.a.failure
				lc_curio_failure_option_effect = yes
				scope:merchant.house = {
					change_house_relation_effect = {
						HOUSE = scope:other_merchant.house
						VALUE =  house_relation_damage_medium_value
						REASON = trade_opportunity_friction
						CHAR = scope:merchant
						TARGET_CHAR = scope:other_merchant
						TITLE = dummy_female
					}
				}
			}
		}
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_sociability = 0.25
				ai_greed = -0.25
			}
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1102
	}
}

### Religious sub-chain

scripted_effect luxury_contract_find_or_create_priest_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_clergy = yes
			is_lowborn = yes
			faith = scope:religious_building_faith
			NOT = { faith.religious_head ?= this }
		}
		weight = {
			base = 1
			modifier = { add = learning }
			modifier = {
				has_trait = devoted
				factor = 10
			}
		}
		save_scope_as = priest
	}
	scope:local_county.holder = {
		if = {
			limit = { faith = scope:religious_building_faith }
			if = {
				limit = {
					cp:councillor_court_chaplain ?= {
						NOT = { faith.religious_head ?= this }
					}
				}
				cp:councillor_court_chaplain = { save_scope_as = priest }
			}
			else_if = {
				limit = {
					is_clergy = yes
					NOT = { faith.religious_head ?= this }
				}
				save_scope_as = priest
			}
		}
	}
	if = {
		limit = { NOT = { exists = scope:priest } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = priest_character_template
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:religious_building_faith
			save_scope_as = priest
		}
		scope:priest = { add_character_flag = destroy_me }
	}
	scope:priest ?= { assign_quirk_effect = yes }
}

scripted_effect luxury_contract_find_or_create_pilgrim_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_clergy = no
			is_lowborn = yes
			NOT = { has_trait = devoted }
			faith = scope:religious_building_faith
			NOR = {
				scope:priest ?= this
				scope:monk ?= this
			}
		}
		weight = {
			base = 1
		}
		save_scope_as = pilgrim
	}
	if = {
		limit = { NOT = { exists = scope:pilgrim } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = location_pilgrim_template
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:religious_building_faith
			save_scope_as = pilgrim
		}
		scope:pilgrim = { add_character_flag = destroy_me }
	}
	scope:pilgrim ?= { assign_quirk_effect = yes }
}

scripted_effect luxury_contract_find_or_create_monk_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			faith = scope:religious_building_faith
			has_trait = devoted
			NOR = {
				scope:priest ?= this
				scope:pilgrim ?= this
			}
		}
		weight = {
			base = 1
		}
		save_scope_as = monk
	}
	if = {
		limit = { NOT = { exists = scope:monk } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = monk_character_template
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:religious_building_faith
			save_scope_as = monk
		}
		scope:monk = { add_character_flag = destroy_me }
	}
	scope:monk ?= { assign_quirk_effect = yes }
}

# Intro
gdp_merchant_luxury_contract.1501 = { # Start
	type = character_event
	title = gdp_merchant_luxury_contract.1501.t
	desc = {
		desc = gdp_merchant_luxury_contract.1501.desc
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1501_site_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1501.site
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1501_tomb_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1501.tombs
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1501_pilgrim_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1501.pilgrim
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1501_monks_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1501.monks
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1501_keepsake_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1501.keepsake
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1501_apostate_flag
				}
			}
			desc = gdp_merchant_luxury_contract.1501.apostate
		}
	}
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
	}
	override_background = { reference = holy_site_generic_scope }

	trigger = {
		scope:lc_active_building_flag ?= flag:religious_building
	}

	immediate = {
		# Prevent repeats
		add_to_variable_list = {
			name = lc_building_completed_list
			target = flag:religious_building
		}
		# Save paths
		hidden_effect = {
			while = {
				count = 2
				random_list = {
					10 = { # Site
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1501_site_flag
									# Learning group
									this = flag:lc_1501_monks_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1501_site_flag
						}
					}
					10 = { # Tomb
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1501_tomb_flag
									# Intrigue group
									this = flag:lc_1501_pilgrim_flag
									this = flag:lc_1501_keepsake_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1501_tomb_flag
						}
					}
					10 = { # Pilgrim
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1501_pilgrim_flag
									# Intrigue group
									this = flag:lc_1501_tomb_flag
									this = flag:lc_1501_keepsake_flag
									# Pilgrim group
									this = flag:lc_1501_apostate_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1501_pilgrim_flag
						}
					}
					10 = { # Monks
						trigger = {
							scope:religious_building_faith = { faith_has_monasticism_trigger = yes }
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1501_monks_flag
									# Learning group
									this = flag:lc_1501_site_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1501_monks_flag
						}
					}
					10 = { # Keepsake
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1501_keepsake_flag
									# Intrigue group
									this = flag:lc_1501_tomb_flag
									this = flag:lc_1501_pilgrim_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1501_keepsake_flag
						}
					}
					10 = { # Apostate
						trigger = {
							religion != scope:religious_building_faith.religion
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1501_apostate_flag
									# Pilgrim group
									this = flag:lc_1501_pilgrim_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1501_apostate_flag
						}
					}
				}
			}
		}
		# Source priest character
		luxury_contract_find_or_create_priest_effect = yes
		scope:priest = { save_scope_as = bg_override_char }
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					OR = {
						this = flag:lc_1501_pilgrim_flag
						this = flag:lc_1501_apostate_flag
					}
				}
			}
			luxury_contract_find_or_create_pilgrim_effect = yes
		}
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1501_monks_flag
				}
			}
			luxury_contract_find_or_create_monk_effect = yes
		}
		# Save background scope
		scope:religious_building_province = { save_scope_as = holy_site_scope }
	}

	option = { # Site
		name = gdp_merchant_luxury_contract.1501.a
		flavor = gdp_merchant_luxury_contract.1501.a.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1501_site_flag
			}
		}
		# Destroy unneeded characters
		scope:pilgrim ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:monk ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1501.a
			FLAG = lc_1501_site_flag
			EVENT_ID = 1521
		}
	}

	option = { # Tombs
		name = gdp_merchant_luxury_contract.1501.b
		flavor = gdp_merchant_luxury_contract.1501.b.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1501_tomb_flag
			}
		}
		# Destroy unneeded characters
		scope:pilgrim ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:monk ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1501.b
			FLAG = lc_1501_tomb_flag
			EVENT_ID = 1511
		}
	}

	option = { # Pilgrim
		name = gdp_merchant_luxury_contract.1501.c
		flavor = gdp_merchant_luxury_contract.1501.c.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1501_pilgrim_flag
			}
		}
		# Destroy unneeded characters
		scope:monk ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1501.c
			FLAG = lc_1501_pilgrim_flag
			EVENT_ID = 1531
		}
	}

	option = { # Monks
		name = gdp_merchant_luxury_contract.1501.d
		flavor = gdp_merchant_luxury_contract.1501.d.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1501_monks_flag
			}
		}
		# Destroy unneeded characters
		scope:pilgrim ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1501.d
			FLAG = lc_1501_monks_flag
			EVENT_ID = 1541
		}
	}

	option = { # Keepsake
		name = gdp_merchant_luxury_contract.1501.e
		flavor = gdp_merchant_luxury_contract.1501.e.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1501_keepsake_flag
			}
		}
		# Destroy unneeded characters
		scope:pilgrim ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:monk ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1501.e
			FLAG = lc_1501_keepsake_flag
			EVENT_ID = 1551
		}
	}

	option = { # Apostate
		name = gdp_merchant_luxury_contract.1501.f
		flavor = gdp_merchant_luxury_contract.1501.f.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1501_apostate_flag
			}
		}
		# Destroy unneeded characters
		scope:monk ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1501.f
			FLAG = lc_1501_apostate_flag
			EVENT_ID = 1561
		}
	}
}

# Duel Outcomes
gdp_merchant_luxury_contract.1502 = { # End
	type = character_event
	title = gdp_merchant_luxury_contract.1501.t
	desc = {
		first_valid = {
			triggered_desc = { # Site
				trigger = { scope:lc_active_path_flag = flag:lc_1501_site_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1502.site
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1502.site.success
						}
						desc = gdp_merchant_luxury_contract.1502.site.failure
					}
				}
			}
			triggered_desc = { # Tomb
				trigger = { scope:lc_active_path_flag = flag:lc_1501_tomb_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1502.tomb
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success_critical }
							desc = gdp_merchant_luxury_contract.1502.tomb.success_critical
						}
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1502.tomb.success
						}
						desc = gdp_merchant_luxury_contract.1502.tomb.failure
					}
				}
			}
			triggered_desc = { # Pilgrim
				trigger = { scope:lc_active_path_flag = flag:lc_1501_pilgrim_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1502.pilgrim
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1502.pilgrim.success
						}
						desc = gdp_merchant_luxury_contract.1502.pilgrim.failure
					}
				}
			}
			triggered_desc = { # Monks
				trigger = { scope:lc_active_path_flag = flag:lc_1501_monks_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1502.monks
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1502.monks.success
						}
						desc = gdp_merchant_luxury_contract.1502.monks.failure
					}
				}
			}
			triggered_desc = { # Keepsake
				trigger = { scope:lc_active_path_flag = flag:lc_1501_keepsake_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1502.keepsake
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1502.keepsake.success
						}
						desc = gdp_merchant_luxury_contract.1502.keepsake.failure
					}
				}
			}
			triggered_desc = { # Apostate
				trigger = { scope:lc_active_path_flag = flag:lc_1501_apostate_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1502.apostate
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success_critical }
							desc = gdp_merchant_luxury_contract.1502.apostate.success_critical
						}
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1502.apostate.success
						}
						desc = gdp_merchant_luxury_contract.1502.apostate.failure
					}
				}
			}
		}
	}
	theme = trade
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				scope:lc_active_path_flag != flag:lc_1501_apostate_flag
			}
			animation = nervous
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				scope:lc_active_path_flag = flag:lc_1501_apostate_flag
			}
			animation = fear
		}
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:portrait
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				OR = {
					scope:lc_active_path_flag = flag:lc_1501_pilgrim_flag
				}
			}
			animation = sadness
		}
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				NOR = {
					scope:lc_active_path_flag = flag:lc_1501_pilgrim_flag
				}
			}
			animation = interested
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				OR = {
					scope:lc_active_path_flag = flag:lc_1501_pilgrim_flag
					scope:lc_active_path_flag = flag:lc_1501_apostate_flag
				}
			}
			animation = anger
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				OR = {
					scope:lc_active_path_flag = flag:lc_1501_site_flag
				}
			}
			animation = dismissal
		}
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	artifact = {
		target = scope:fallback_artifact
		position = lower_center_portrait
	}
	override_background = {
		trigger = {
			scope:lc_active_path_flag = flag:lc_1501_site_flag
		}
		reference = temple 
	}
	override_background = {
		trigger = {
			scope:lc_active_path_flag = flag:lc_1501_tomb_flag
		}
		reference = bp1_bonfire 
	}
	override_background = {
		trigger = {
			NOR = {
				scope:lc_active_path_flag = flag:lc_1501_site_flag
				scope:lc_active_path_flag = flag:lc_1501_tomb_flag
			}
		}
		reference = holy_site_generic_scope 
	}

	immediate = {
		lc_curio_fallback_artifact_effect = { OWNER = scope:priest }
		hidden_effect = {
			switch = {
				trigger = scope:lc_active_path_flag
				flag:lc_1501_tomb_flag = {
					if = {
						limit = { exists = scope:lc_1001_success_critical }
						save_temporary_scope_value_as = {
							name = quality
							value = { 65 90 }
						}
						# Create artifact
						scope:priest = {
							random_dummy_gender_effect = yes
							create_artifact_urn_effect = {
								OWNER = scope:priest
								POTTER = scope:dummy_gender
							}
							scope:newly_created_artifact ?= {
								save_scope_as = artifact
								set_artifact_name = gdp_merchant_luxury_contract.1511.artifact.urn
								set_artifact_description = gdp_merchant_luxury_contract.1511.artifact.urn.desc
							}
						}
					}
					else_if = {
						limit = { exists = scope:lc_1001_success }
						save_temporary_scope_value_as = {
							name = quality
							value = { 45 70 }
						}
						# Create artifact
						scope:priest = {
							random_dummy_gender_effect = yes
							create_artifact_urn_effect = {
								OWNER = scope:priest
								POTTER = scope:dummy_gender
							}
							scope:newly_created_artifact ?= {
								save_scope_as = artifact
								set_artifact_name = gdp_merchant_luxury_contract.1511.artifact.urn
								set_artifact_description = gdp_merchant_luxury_contract.1511.artifact.urn.desc
							}
						}
					}
					else = {
						scope:priest = {
							luxury_contract_fallback_reward_quality_effect = yes
							create_artifact_pedestal_human_skull_effect = {
								OWNER = scope:priest
								CREATOR = dummy_female
								DESKULLED = dummy_female
							}
							scope:newly_created_artifact ?= {
								save_scope_as = artifact
								hidden_effect = {
									random_list = {
										10 = {
											set_artifact_name = gdp_merchant_luxury_contract.1511.artifact.skull
											set_artifact_description = gdp_merchant_luxury_contract.1511.artifact.skull.desc
										}
										10 = {
											set_artifact_name = gdp_merchant_luxury_contract.1511.artifact.bone
											set_artifact_description = gdp_merchant_luxury_contract.1511.artifact.bone.desc
										}
									}
								}
							}
						}
					}
				}
			}
			# Save artifact to contract for tooltips
			lc_curio_reforge_effect = { TYPE = curio }
		}
		luxury_contract_wound_effect = yes
		lc_curio_select_fallback_location_effect = yes
	}

	option = { # Success!
		name = {
			trigger = { exists = scope:lc_1001_success_critical }
			text = gdp_merchant_luxury_contract.1502.a.critical
		}
		name = {
			trigger = {
				NOT = { exists = scope:lc_1001_success_critical }
			}
			text = gdp_merchant_luxury_contract.1502.a
		}
		trigger = {
			OR = {
				exists = scope:lc_1001_success_critical
				exists = scope:lc_1001_success
			}
		}
		lc_curio_success_option_effect = yes
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_greed = 0.25
			}
		}
	}

	option = { # Bad success!
		name = gdp_merchant_luxury_contract.1502.b
		trigger = { lc_curio_bad_success_option_trigger = yes }
		lc_curio_success_option_effect = yes
		stress_impact = {
			compassionate = minor_stress_impact_gain
			just = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = -0.25
				ai_greed = 0.25
			}
		}
	}

	option = { # Scholarly
		name = gdp_merchant_luxury_contract.1001.return.scholarly
		flavor = gdp_merchant_luxury_contract.1001.f.flavor
		trigger = {
			lc_curio_next_building_option_trigger = { FLAG = scholarly_building }
		}
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.f
			FLAG = scholarly_building
			EVENT_ID = 1601
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_rationality = 0.25
			}
		}
	}

	option = { # Urban
		name = gdp_merchant_luxury_contract.1001.return.urban
		flavor = gdp_merchant_luxury_contract.1001.a.flavor
		trigger = {
			NOR = {
				exists = scope:lc_1001_success_critical
				exists = scope:lc_1001_success
				scope:merchant = {
					any_in_list = {
						variable = lc_building_completed_list
						count >= 2
					}
					any_in_list = {
						variable = lc_building_completed_list
						this = flag:urban_building
					}
				}
			}
		}
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.a
			FLAG = urban_building
			EVENT_ID = 1101
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_greed = 0.25
			}
		}
	}

	option = { # Fallback!
		name = gdp_merchant_luxury_contract.1001.fallback
		flavor = gdp_merchant_luxury_contract.1001.fallback.flavor
		trigger = { lc_curio_fallback_option_trigger = yes }
		lc_curio_fallback_option_effect = yes
		ai_chance = {
			base = 0
		}
	}

	option = { # Give up!
		name = gdp_merchant_luxury_contract.1001.give_up
		trigger = { lc_curio_give_up_option_trigger = yes }
		lc_curio_give_up_option_effect = yes
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = -0.25
				ai_greed = -0.25
			}
		}
	}

	after = {
		lc_curio_cleanup_path_scopes_effect = yes
		scope:priest ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:pilgrim ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:monk ?= { luxury_contract_cleanup_unused_character_effect = yes }
	}
}

# Duel Events
gdp_merchant_luxury_contract.1511 = { # Tomb
	type = character_event
	title = gdp_merchant_luxury_contract.1501.t
	desc = gdp_merchant_luxury_contract.1511.desc
	theme = trade
	left_portrait = {
		character = root
		animation = paranoia
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = bp1_bonfire }

	option = { # Duel
		name = gdp_merchant_luxury_contract.1511.a
		duel = {
			skills = { intrigue prowess }
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = gallowsbait
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1511.a.success_critical
				custom_tooltip = gdp_merchant_luxury_contract.1511.a.success_critical.tt
				save_scope_as = lc_1001_success_critical
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1511.a.success
				custom_tooltip = gdp_merchant_luxury_contract.1511.a.success.tt
				save_scope_as = lc_1001_success
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1511.a.failure
				custom_tooltip = gdp_merchant_luxury_contract.1511.a.failure.tt
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			arbitrary = minor_stress_impact_loss
			cynical = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1502
	}
}

gdp_merchant_luxury_contract.1521 = { # Site
	type = character_event
	title = gdp_merchant_luxury_contract.1501.t
	desc = gdp_merchant_luxury_contract.1521.desc
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:priest
		animation = war_over_tie
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}
	override_background = { reference = temple }

	immediate = {
		# Save portrait scope for ending event
		scope:priest = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:priest = {
				set_variable = {
					name = religious_text
					value = faith
				}
				random_dummy_gender_effect = yes
				create_library_artifact_effect = {
					OWNER = scope:priest
					CREATOR = scope:dummy_gender
					SUBJECT = flag:religious_text
					TOPIC = flag:religious_text
				}
				remove_variable = religious_text
			}
		}
		scope:newly_created_artifact ?= { save_scope_as = artifact }
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1521.a
		flavor = gdp_merchant_luxury_contract.1521.a.flavor
		save_scope_value_as = {
			name = pseudo_duel_value
			value = {
				value = scope:merchant.learning
				add = {
					value = scope:merchant.piety_level
					multiply = 3
				}
				subtract = decent_skill_rating
				subtract = 6
			}
		}
		random_list = {
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = theologian
					add = 10
				}
				modifier = {
					has_trait = heresiarch
					add = 10
				}
				modifier = {
					has_perk = apostate_perk
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1521.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:artifact = { set_owner = root }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:priest }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1521.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			fickle = minor_stress_impact_loss
			cynical = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1502
	}
}

gdp_merchant_luxury_contract.1531 = { # Pilgrim
	type = character_event
	title = gdp_merchant_luxury_contract.1501.t
	desc = gdp_merchant_luxury_contract.1531.desc
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:pilgrim
		animation = worry
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = holy_site_generic_scope }

	immediate = {
		# Save portrait scope for ending event
		scope:pilgrim = { lc_curio_portrait_scope_effect = yes }
		# Create potential reward artifact
		scope:pilgrim = {
			luxury_contract_reward_quality_effect = yes
			create_appropriate_relic_artifact_effect = {
				OWNER = scope:pilgrim
				CREATOR = dummy_female
			}
		}
		# Save artifact scope for ending event
		hidden_effect = {
			scope:newly_created_artifact ?= {
				save_scope_as = artifact
			}
		}
		# Save artifact to contract for tooltips
		lc_curio_reforge_effect = { TYPE = curio }
	}

	option = { # Duel
		name = gdp_merchant_luxury_contract.1531.a
		duel = {
			skills = { diplomacy intrigue }
			value = decent_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = pilgrim
					add = 10
				}
				modifier = {
					has_trait = pilgrim
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1531.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:pilgrim }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1531.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			deceitful = minor_stress_impact_loss
			arbitrary = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1502
	}
}

gdp_merchant_luxury_contract.1541 = { # Monks
	type = character_event
	title = gdp_merchant_luxury_contract.1501.t
	desc = gdp_merchant_luxury_contract.1541.desc
	theme = trade
	left_portrait = {
		character = root
		animation = happiness
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:monk
		animation = thinking
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = holy_site_generic_scope }

	immediate = {
		# Save portrait scope for ending event
		scope:monk = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:monk = {
				random_list = {
					10 = {
						trigger = {
							scope:religious_building_faith = {
								NOR = {
									religion = religion:islam_religion
									main_rite = { rite_has_tenet = tenet_aniconism }
								}
							}
						}
						create_artifact_icon_effect = {
							OWNER = scope:monk
							CREATOR = scope:monk
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_name = gdp_merchant_luxury_contract.1541.artifact.icon
							set_artifact_description = gdp_merchant_luxury_contract.1541.artifact.icon.desc
						}
					}
					10 = {
						create_artifact = {
							name = gdp_merchant_luxury_contract.1541.artifact.prayer_beads
							description = gdp_merchant_luxury_contract.1541.artifact.prayer_beads.desc
							type = miscellaneous
							visuals = small_box
							modifier = artifact_monthly_prestige_2_modifier
							modifier = artifact_monthly_piety_1_modifier
							max_durability = 30
							generate_history = no
							save_scope_as = artifact
						}
					}
				}
			}
			# Save artifact to contract for tooltips
			lc_curio_reforge_effect = { TYPE = curio }
		}
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1541.a
		flavor = gdp_merchant_luxury_contract.1541.a.flavor
		save_scope_value_as = {
			name = pseudo_duel_value
			value = {
				value = scope:merchant.diplomacy
				add = {
					value = scope:merchant.piety_level
					multiply = 3
				}
				subtract = decent_skill_rating
				subtract = 6
			}
		}
		random_list = {
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = devoted
					add = 10
				}
				modifier = {
					has_trait = theologian
					add = 10
				}
				modifier = {
					has_trait = lifestyle_mystic
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1541.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract = {
						complete_task_contract = success_standard
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:monk }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1541.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			diligent = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1502
	}
}

gdp_merchant_luxury_contract.1551 = { # Keepsake
	type = character_event
	title = gdp_merchant_luxury_contract.1501.t
	desc = gdp_merchant_luxury_contract.1551.desc
	theme = trade
	left_portrait = {
		character = root
		animation = paranoia
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = holy_site_generic_scope }

	immediate = {
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:priest = {
				create_artifact = {
					name = gdp_merchant_luxury_contract.1551.artifact.edifice
					description = gdp_merchant_luxury_contract.1551.artifact.edifice.desc
					type = miscellaneous
					visuals = rock
					modifier = artifact_monthly_prestige_2_modifier
					modifier = artifact_zealot_vassal_opinion_2_modifier
					max_durability = 30
					quality = scope:quality
					wealth = scope:wealth
					generate_history = no
					save_scope_as = artifact
				}
				# Save artifact to contract for tooltips
				lc_curio_reforge_effect = { TYPE = curio }
			}
		}
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1551.a
		duel = {
			skills = { intrigue prowess }
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = athletic
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1551.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1551.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			deceitful = minor_stress_impact_loss
			arbitrary = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1502
	}
}

gdp_merchant_luxury_contract.1561 = { # Apostate
	type = character_event
	title = gdp_merchant_luxury_contract.1501.t
	desc = gdp_merchant_luxury_contract.1561.desc
	theme = trade
	left_portrait = {
		character = root
		animation = worry
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:pilgrim
		animation = grief
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = holy_site_generic_scope }

	immediate = {
		# Save portrait scope for ending event
		scope:pilgrim = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:pilgrim = {
				set_variable = {
					name = religious_text
					value = faith
				}
				random_dummy_gender_effect = yes
				create_library_artifact_effect = {
					OWNER = scope:pilgrim
					CREATOR = scope:dummy_gender
					SUBJECT = flag:religious_text
					TOPIC = flag:religious_text
				}
				remove_variable = religious_text
			}
			scope:newly_created_artifact ?= {
				set_artifact_name = gdp_merchant_luxury_contract.1561.artifact.holy_book
				set_artifact_description = gdp_merchant_luxury_contract.1561.artifact.holy_book.desc
				save_scope_as = artifact
			}
			lc_curio_reforge_effect = { TYPE = library_item }
		}
	}

	option = { # Convert
		name = gdp_merchant_luxury_contract.1561.a
		flavor = gdp_merchant_luxury_contract.1561.a.flavor
		save_scope_value_as = {
			name = pseudo_duel_value
			value = {
				value = scope:merchant.diplomacy
				add = {
					value = scope:merchant.piety_level
					multiply = 3
				}
				subtract = decent_skill_rating
				subtract = 6
			}
		}
		random_list = {
			10 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_perk = apostate_perk
					add = 10
				}
				modifier = {
					has_trait = heresiarch
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1561.a.success_critical
				save_scope_as = lc_1001_success_critial
				scope:pilgrim = { set_character_faith = root.faith }
				add_courtier = scope:pilgrim
				reverse_add_opinion = {
					target = scope:pilgrim
					modifier = inspired_opinion
					opinion = 25
				}
				hidden_effect = {
					reverse_add_opinion = {
						target = scope:pilgrim
						modifier = recruited_me_opinion
						opinion = 50
					}
					if = {
						limit = { is_travelling = yes }
						current_travel_plan = { add_companion = scope:pilgrim }
					}
				}
				show_as_tooltip = {
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 1
					min = -49
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1561.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:pilgrim }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1561.a.failure
				random = {
					chance = 25
					show_as_tooltip = {
						increase_wounds_no_death_effect = { REASON = fight }
					}
					set_variable = {
						name = lc_wound_flag
						weeks = 1
					}
				}
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			gregarious = minor_stress_impact_loss
			zealous = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1502
	}
}

### Scholarly sub-chain

scripted_effect luxury_contract_find_or_create_scholar_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			age >= 35
			NOR = {
				scope:sage ?= this
				scope:physician ?= this
				scope:student ?= this
				scope:botanist ?= this
			}
		}
		weight = {
			base = 1
			modifier = { add = learning }
			modifier = {
				has_trait = erudite
				factor = 10
			}
			modifier = {
				has_trait = lifestyle_scholar
				factor = 10
			}
		}
		save_scope_as = scholar
	}
	if = {
		limit = { NOT = { exists = scope:scholar } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = scholar_character
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:lc_spawn_faith
			save_scope_as = scholar
		}
		scope:scholar = { add_character_flag = destroy_me }
	}
	scope:scholar ?= {
		assign_quirk_effect = yes
		add_character_flag = has_reading_glasses
	}
}

scripted_effect luxury_contract_find_or_create_physician_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			has_trait = lifestyle_physician
			NOR = {
				scope:scholar ?= this
				scope:sage ?= this
				scope:student ?= this
				scope:botanist ?= this
			}
		}
		weight = {
			base = 1
			modifier = { add = learning }
			modifier = {
				has_trait = lifestyle_herbalist
				factor = 10
			}
			modifier = {
				has_trait = lifestyle_gardener
				factor = 10
			}
		}
		save_scope_as = physician
	}
	if = {
		limit = { NOT = { exists = scope:physician } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = physician_high_character_template
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:lc_spawn_faith
			save_scope_as = physician
		}
		scope:physician = { add_character_flag = destroy_me }
	}
	scope:physician ?= { assign_quirk_effect = yes }
}

scripted_effect luxury_contract_find_or_create_student_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			has_trait = lifestyle_physician
			age < 25
			NOR = {
				scope:scholar ?= this
				scope:sage ?= this
				scope:physician ?= this
				scope:botanist ?= this
			}
		}
		weight = {
			base = 1
			modifier = { add = learning }
			modifier = {
				has_trait = erudite
				factor = 10
			}
			modifier = {
				has_trait = lifestyle_scholar
				factor = 10
			}
		}
		save_scope_as = student
	}
	if = {
		limit = { NOT = { exists = scope:student } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = physician_low_character_template
			age = { 18 24 }
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:lc_spawn_faith
			save_scope_as = student
		}
		scope:student = { add_character_flag = destroy_me }
	}
	scope:student ?= { assign_quirk_effect = yes }
}

scripted_effect luxury_contract_find_or_create_sage_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			has_trait = lifestyle_mystic
			NOR = {
				scope:scholar ?= this
				scope:physician ?= this
				scope:student ?= this
				scope:botanist ?= this
			}
		}
		weight = {
			base = 1
			modifier = { add = learning }
			modifier = {
				has_trait = lifestyle_scholar
				factor = 10
			}
			modifier = {
				has_trait = erudite
				factor = 10
			}
			modifier = {
				has_trait = theologian
				factor = 10
			}
		}
		save_scope_as = sage
	}
	if = {
		limit = { NOT = { exists = scope:sage } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = garden_hermit_character
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:lc_spawn_faith
			save_scope_as = sage
		}
		scope:sage = { add_character_flag = destroy_me }
	}
	scope:sage ?= { assign_quirk_effect = yes }
}

scripted_effect luxury_contract_find_or_create_botanist_effect = {
	random_pool_character = {
		province = scope:merchant.location
		limit = {
			is_available_quick = {
				adult = yes
				imprisoned = no
				incapable = no
				in_army = no
			}
			is_lowborn = yes
			OR = {
				has_trait = lifestyle_gardener
				has_trait = lifestyle_herbalist
			}
			NOR = {
				scope:scholar ?= this
				scope:sage ?= this
				scope:physician ?= this
				scope:student ?= this
			}
		}
		weight = {
			base = 1
			modifier = { add = learning }
			modifier = {
				has_trait = lifestyle_gardener
				factor = 10
			}
			modifier = {
				has_trait = lifestyle_herbalist
				factor = 10
			}
		}
		save_scope_as = botanist
	}
	if = {
		limit = { NOT = { exists = scope:botanist } }
		luxury_contract_save_spawn_culture_and_faith_effect = yes
		create_character = {
			template = gardener_template
			dynasty = none
			location = location
			culture = scope:lc_spawn_culture
			faith = scope:lc_spawn_faith
			save_scope_as = botanist
		}
		scope:botanist = { add_character_flag = destroy_me }
	}
	scope:botanist ?= { assign_quirk_effect = yes }
}

# Intro
gdp_merchant_luxury_contract.1601 = { # Start
	type = character_event
	title = gdp_merchant_luxury_contract.1601.t
	desc = {
		desc = gdp_merchant_luxury_contract.1601.desc
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_dean_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1601.dean
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_sages_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1601.sages
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_library_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1601.library
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_physician_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1601.physician
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_student_flag
				}
			}
			desc = {
				desc = gdp_merchant_luxury_contract.1601.student
				desc = double_line_break
			}
		}
		triggered_desc = {
			trigger = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_botanist_flag
				}
			}
			desc = gdp_merchant_luxury_contract.1601.botanist
		}
	}
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
	}
	override_background = { reference = bp2_university }

	trigger = {
		scope:lc_active_building_flag ?= flag:scholarly_building
	}

	immediate = {
		# Prevent repeats
		add_to_variable_list = {
			name = lc_building_completed_list
			target = flag:scholarly_building
		}
		# Save paths
		hidden_effect = {
			while = {
				count = 2
				random_list = {
					10 = { # Dean
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1601_dean_flag
									this = flag:lc_1601_library_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1601_dean_flag
						}
					}
					10 = { # Sages
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1601_sages_flag
								}
							}
						}
						modifier = {
							scope:local_county = {
								any_county_province = { gdp_find_curio_poi_religious_province_trigger = yes }
							}
							factor = 2
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1601_sages_flag
						}
					}
					10 = { # Library
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1601_library_flag
									this = flag:lc_1601_dean_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1601_library_flag
						}
					}
					10 = { # Physician
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1601_physician_flag
									this = flag:lc_1601_botanist_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1601_physician_flag
						}
					}
					10 = { # Student
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1601_student_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1601_student_flag
						}
					}
					10 = { # Botanist
						trigger = {
							any_in_list = {
								variable = lc_path_options_list
								count = 0
								OR = {
									this = flag:lc_1601_botanist_flag
									this = flag:lc_1601_physician_flag
								}
							}
						}
						add_to_variable_list = {
							name = lc_path_options_list
							target = flag:lc_1601_botanist_flag
						}
					}
				}
			}
		}
		# Source characters
		luxury_contract_find_or_create_scholar_effect = yes
		scope:scholar = { save_scope_as = bg_override_char }
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_physician_flag
				}
			}
			luxury_contract_find_or_create_physician_effect = yes
		}
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_student_flag
				}
			}
			luxury_contract_find_or_create_student_effect = yes
		}
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_sages_flag
				}
			}
			luxury_contract_find_or_create_sage_effect = yes
		}
		if = {
			limit = {
				any_in_list = {
					variable = lc_path_options_list
					this = flag:lc_1601_botanist_flag
				}
			}
			luxury_contract_find_or_create_botanist_effect = yes
		}
	}

	option = { # Dean
		name = gdp_merchant_luxury_contract.1601.a
		flavor = gdp_merchant_luxury_contract.1601.a.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1601_dean_flag
			}
		}
		# Destroy unused characters
		scope:physician ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:student ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:sage ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:botanist ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1601.a
			FLAG = lc_1601_dean_flag
			EVENT_ID = 1611
		}
	}

	option = { # Sages
		name = gdp_merchant_luxury_contract.1601.b
		flavor = gdp_merchant_luxury_contract.1601.b.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1601_sages_flag
			}
		}
		# Destroy unused characters
		scope:physician ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:student ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:botanist ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1601.b
			FLAG = lc_1601_sages_flag
			EVENT_ID = 1621
		}
	}

	option = { # Library
		name = gdp_merchant_luxury_contract.1601.c
		flavor = gdp_merchant_luxury_contract.1601.c.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1601_library_flag
			}
		}
		# Destroy unused characters
		scope:physician ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:student ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:sage ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:botanist ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1601.c
			FLAG = lc_1601_library_flag
			EVENT_ID = 1631
		}
	}

	option = { # Physician
		name = gdp_merchant_luxury_contract.1601.d
		flavor = gdp_merchant_luxury_contract.1601.d.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1601_physician_flag
			}
		}
		# Destroy unused characters
		scope:student ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:sage ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:botanist ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1601.d
			FLAG = lc_1601_physician_flag
			EVENT_ID = 1641
		}
	}

	option = { # Students
		name = gdp_merchant_luxury_contract.1601.e
		flavor = gdp_merchant_luxury_contract.1601.e.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1601_student_flag
			}
		}
		# Destroy unused characters
		scope:physician ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:sage ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:botanist ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1601.e
			FLAG = lc_1601_student_flag
			EVENT_ID = 1651
		}
	}

	option = { # Botanist
		name = gdp_merchant_luxury_contract.1601.f
		flavor = gdp_merchant_luxury_contract.1601.f.flavor
		trigger = {
			any_in_list = {
				variable = lc_path_options_list
				this = flag:lc_1601_botanist_flag
			}
		}
		# Destroy unused characters
		scope:physician ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:sage ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:student ?= { luxury_contract_cleanup_unused_character_effect = yes }
		# Trigger event
		lc_curio_next_path_option_effect = {
			TOOLTIP = 1601.f
			FLAG = lc_1601_botanist_flag
			EVENT_ID = 1661
		}
	}
}

# Duel Outcome
gdp_merchant_luxury_contract.1602 = { # End
	type = character_event
	title = gdp_merchant_luxury_contract.1601.t
	desc = {
		first_valid = {
			triggered_desc = { # Dean
				trigger = { scope:lc_active_path_flag = flag:lc_1601_dean_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1602.dean
					first_valid = {
						triggered_desc = {
							trigger = {
								OR = {
									exists = scope:lc_1001_success
									exists = scope:lc_1001_success_critical
								}
							}
							desc = gdp_merchant_luxury_contract.1602.dean.success
						}
						desc = gdp_merchant_luxury_contract.1602.dean.failure
					}
				}
			}
			triggered_desc = { # Sages
				trigger = { scope:lc_active_path_flag = flag:lc_1601_sages_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1602.sages
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1602.sages.success
						}
						desc = gdp_merchant_luxury_contract.1602.sages.failure
					}
				}
			}
			triggered_desc = { # Library
				trigger = { scope:lc_active_path_flag = flag:lc_1601_library_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1602.library
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1602.library.success
						}
						desc = gdp_merchant_luxury_contract.1602.library.failure
					}
				}
			}
			triggered_desc = { # Physician
				trigger = { scope:lc_active_path_flag = flag:lc_1601_physician_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1602.physician
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1602.physician.success
						}
						desc = gdp_merchant_luxury_contract.1602.physician.failure
					}
				}
			}
			triggered_desc = { # 
				trigger = { scope:lc_active_path_flag = flag:lc_1601_student_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1602.student
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1602.student.success
						}
						desc = gdp_merchant_luxury_contract.1602.student.failure
					}
				}
			}
			triggered_desc = { # Botanist
				trigger = { scope:lc_active_path_flag = flag:lc_1601_botanist_flag }
				desc = {
					desc = gdp_merchant_luxury_contract.1602.botanist
					first_valid = {
						triggered_desc = {
							trigger = { exists = scope:lc_1001_success }
							desc = gdp_merchant_luxury_contract.1602.botanist.success
						}
						desc = gdp_merchant_luxury_contract.1602.botanist.failure
					}
				}
			}
		}
	}
	theme = trade
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
			}
			animation = admiration
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
			}
			animation = disappointed
		}
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:portrait
		trigger = {
			trigger_if = {
				limit = { scope:lc_active_path_flag = flag:lc_1601_student_flag }
				OR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
			}
		}
		triggered_animation = {
			trigger = {
				OR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
			}
			animation = happiness
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				scope:lc_active_path_flag = flag:lc_1601_sages_flag
			}
			animation = war_over_tie
		}
		triggered_animation = {
			trigger = {
				NOR = {
					exists = scope:lc_1001_success_critical
					exists = scope:lc_1001_success
				}
				NOR = {
					scope:lc_active_path_flag = flag:lc_1601_sages_flag
				}
			}
			animation = dismissal
		}
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	artifact = {
		target = scope:fallback_artifact
		position = lower_center_portrait
	}
	override_background = {
		trigger = {
			scope:lc_active_path_flag = flag:lc_1601_physician_flag
		}
		reference = physicians_study 
	}
	override_background = {
		trigger = {
			OR = {
				scope:lc_active_path_flag = flag:lc_1601_sages_flag
				scope:lc_active_path_flag = flag:lc_1601_botanist_flag
			}
		}
		reference = garden 
	}
	override_background = {
		trigger = {
			scope:lc_active_path_flag = flag:lc_1601_student_flag
		}
		reference = alley_night 
	}
	override_background = {
		trigger = {
			NOR = {
				scope:lc_active_path_flag = flag:lc_1601_sages_flag
				scope:lc_active_path_flag = flag:lc_1601_botanist_flag
				scope:lc_active_path_flag = flag:lc_1601_physician_flag
				scope:lc_active_path_flag = flag:lc_1601_student_flag
			}
		}
		reference = study 
	}

	immediate = {
		lc_curio_fallback_artifact_effect = { OWNER = scope:scholar }
		if = {
			limit = {	
				exists = scope:lc_1001_success
				scope:lc_active_path_flag = flag:lc_1601_student_flag
			}
			# Save artifact to contract for tooltips
			lc_curio_reforge_effect = { TYPE = curio }
		}
		luxury_contract_wound_effect = yes
		lc_curio_select_fallback_location_effect = yes
	}

	option = { # Success!
		name = gdp_merchant_luxury_contract.1602.a
		trigger = {
			OR = {
				exists = scope:lc_1001_success_critical
				exists = scope:lc_1001_success
			}
		}
		if = {
			limit = {
				scope:lc_active_path_flag = flag:lc_1601_dean_flag
				NOT = { exists = scope:lc_1001_success_critical }
			}
			pay_short_term_gold = {
				gold = medium_gold_value
				target = scope:scholar
			}
		}
		lc_curio_success_option_effect = yes
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_greed = 0.25
			}
		}
	}

	option = { # Bad success!
		name = gdp_merchant_luxury_contract.1602.b
		trigger = { lc_curio_bad_success_option_trigger = yes }
		lc_curio_success_option_effect = yes
		stress_impact = {
			compassionate = minor_stress_impact_gain
			just = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = -0.25
				ai_greed = 0.25
			}
		}
	}
	
	option = { # Religious
		name = gdp_merchant_luxury_contract.1001.e
		flavor = gdp_merchant_luxury_contract.1001.e.flavor
		trigger = {
			lc_curio_next_building_option_trigger = { FLAG = religious_building }
		}
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.e
			FLAG = religious_building
			EVENT_ID = 1501
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_boldness = 0.25
			}
		}
	}

	option = { # Urban
		name = gdp_merchant_luxury_contract.1001.return.urban
		flavor = gdp_merchant_luxury_contract.1001.a.flavor
		trigger = {
			lc_curio_next_building_option_trigger = { FLAG = urban_building }
		}
		lc_curio_next_building_option_effect = {
			TOOLTIP = 1001.a
			FLAG = urban_building
			EVENT_ID = 1101
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 0.25
				ai_greed = 0.25
			}
		}
	}

	option = { # Fallback!
		name = gdp_merchant_luxury_contract.1001.fallback
		flavor = gdp_merchant_luxury_contract.1001.fallback.flavor
		trigger = { lc_curio_fallback_option_trigger = yes }
		lc_curio_fallback_option_effect = yes
		ai_chance = {
			base = 0
		}
	}

	option = { # Give up!
		name = gdp_merchant_luxury_contract.1001.give_up
		trigger = { lc_curio_give_up_option_trigger = yes }
		lc_curio_give_up_option_effect = yes
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = -0.25
				ai_greed = -0.25
			}
		}
	}

	after = {
		lc_curio_cleanup_path_scopes_effect = yes
		scope:scholar ?= {
			remove_character_flag = has_reading_glasses
			luxury_contract_cleanup_unused_character_effect = yes
		}
		scope:sage ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:physician ?= { luxury_contract_cleanup_unused_character_effect = yes }
		scope:botanist ?= { luxury_contract_cleanup_unused_character_effect = yes }
	}
}

# Duel Events
gdp_merchant_luxury_contract.1611 = { # Dean
	type = character_event
	title = gdp_merchant_luxury_contract.1601.t
	desc = gdp_merchant_luxury_contract.1611.desc
	theme = trade
	left_portrait = {
		character = root
		animation = war_over_tie
	}
	right_portrait = {
		character = scope:scholar
		animation = flirtation
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = study }

	immediate = {
		# Save portrait scope for ending event
		scope:scholar = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:scholar = {
				create_artifact = {
					name = gdp_merchant_luxury_contract.1611.artifact.certificate
					description = gdp_merchant_luxury_contract.1611.artifact.certificate.desc
					type = curio
					visuals = scroll_bundle_artifact
					modifier = artifact_monthly_prestige_3_modifier
					max_durability = 30
					quality = scope:quality
					wealth = scope:wealth
					generate_history = no
					save_scope_as = artifact
				}
				lc_curio_reforge_effect = { TYPE = curio }
			}
		}
	}

	option = { # Duel
		name = gdp_merchant_luxury_contract.1611.a
		flavor = gdp_merchant_luxury_contract.1611.a.flavor
		save_scope_value_as = {
			name = pseudo_duel_value
			value = {
				value = scope:merchant.diplomacy
				add = {
					value = scope:merchant.prestige_level
					multiply = 3
				}
				subtract = decent_skill_rating
				subtract = 6
			}
		}
		random_list = {
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 3.5
					min = -49
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1611.a.success_critical
				save_scope_as = lc_1001_success_critical
				show_as_tooltip = {
					scope:artifact = { set_owner = scope:merchant }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 1
					min = -49
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1611.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:artifact = { set_owner = scope:merchant }
					pay_short_term_gold = {
						gold = medium_gold_value
						target = scope:scholar
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:scholar }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1611.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			gregarious = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1602
	}
}

gdp_merchant_luxury_contract.1621 = { # Sage
	type = character_event
	title = gdp_merchant_luxury_contract.1601.t
	desc = gdp_merchant_luxury_contract.1621.desc
	theme = trade
	left_portrait = {
		character = root
		animation = nervous
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:sage
		animation = holding_staff
		camera = camera_event_very_right
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}
	override_background = { reference = garden }

	immediate = {
		# Save portrait scope for ending event
		scope:sage = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:sage = {
				create_curio_artifact_effect = {
					OWNER = scope:sage
					CREATOR = dummy_female
				}
			}
		}
		if = {
			limit = { exists = scope:new_trinket }
			scope:new_trinket = { save_scope_as = artifact }
			clear_saved_scope = new_trinket
		}
		else_if = {
			limit = { exists = scope:newly_created_artifact }
			scope:newly_created_artifact = { save_scope_as = artifact }
			clear_saved_scope = newly_created_artifact
		}
		lc_curio_reforge_effect = { TYPE = curio }
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1621.a
		flavor = gdp_merchant_luxury_contract.1621.a.flavor
		save_scope_value_as = {
			name = pseudo_duel_value
			value = {
				value = scope:merchant.learning
				add = {
					value = scope:merchant.piety_level
					multiply = 3
				}
				subtract = decent_skill_rating
				subtract = 6
			}
		}
		random_list = {
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = theologian
					add = 10
				}
				modifier = {
					has_trait = lifestyle_mystic
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1621.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract = { complete_task_contract = success_standard }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:pseudo_duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:sage }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1621.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			zealous = minor_stress_impact_loss
			diligent = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1602
	}
}

gdp_merchant_luxury_contract.1631 = { # Library
	type = character_event
	title = gdp_merchant_luxury_contract.1601.t
	desc = gdp_merchant_luxury_contract.1631.desc
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:scholar
		animation = reading
	}
	artifact = {
		target = scope:artifact
		position = lower_center_portrait
	}
	override_background = { reference = study }

	immediate = {
		# Save portrait scope for ending event
		scope:scholar = { lc_curio_portrait_scope_effect = yes }
		# Create potential reward artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:scholar = {
				random_dummy_gender_effect = yes
				random_list = {
					10 = {
						create_library_artifact_effect = {
							OWNER = scope:scholar
							CREATOR = scope:dummy_gender
							SUBJECT = flag:medicine
							TOPIC = flag:artifact_book_topic_medicine
						}
					}
					10 = {
						create_library_artifact_effect = {
							OWNER = scope:scholar
							CREATOR = scope:dummy_gender
							SUBJECT = flag:medicine
							TOPIC = flag:artifact_book_topic_science
						}
					}
					20 = {
						create_library_artifact_effect = {
							OWNER = scope:scholar
							CREATOR = scope:dummy_gender
							SUBJECT = flag:learning
							TOPIC = flag:no
						}
					}
					10 = {
						create_library_artifact_effect = {
							OWNER = scope:scholar
							CREATOR = scope:dummy_gender
							SUBJECT = flag:alchemy
							TOPIC = flag:artifact_book_topic_alchemy
						}
					}
					5 = {
						trigger = {
						 	scope:scholar.culture = { has_cultural_pillar = heritage_latin }
						}
						create_library_artifact_effect = {
							OWNER = scope:scholar
							CREATOR = scope:dummy_gender
							SUBJECT = flag:diplomacy
							TOPIC = flag:cicero
						}
					}
					5 = {
						create_library_artifact_effect = {
							OWNER = scope:scholar
							CREATOR = scope:dummy_gender
							SUBJECT = flag:martial
							TOPIC = flag:martial_ancient_military_campaigns
						}
					}
				}
				scope:newly_created_artifact ?= {
					save_scope_as = artifact
					set_artifact_description = gdp_merchant_luxury_contract.1631.artifact.book.desc
				}
			}
		}
		# Save artifact to contract for tooltips
		lc_curio_reforge_effect = { TYPE = library_item }
	}

	option = { # Duel
		name = gdp_merchant_luxury_contract.1631.a
		duel = {
			skills = { diplomacy learning }
			value = decent_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = lifestyle_scholar
					add = 10
				}
				modifier = {
					has_trait = erudite
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1631.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:scholar }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1631.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			shy = minor_stress_impact_loss
			diligent = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1602
	}
}

gdp_merchant_luxury_contract.1641 = { # Physician
	type = character_event
	title = gdp_merchant_luxury_contract.1601.t
	desc = gdp_merchant_luxury_contract.1641.desc
	theme = trade
	left_portrait = {
		character = root
		animation = thinking
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:physician
		animation = debating
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = physicians_study }

	immediate = {
		# Save portrait scope for ending event
		scope:physician = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:physician = {
				random_list = {
					10 = {
						create_artifact_elixir_effect = {
							OWNER = scope:physician
							ALCHEMIST = scope:physician
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_description = gdp_merchant_luxury_contract.1641.artifact.elixir.desc
						}
					}
					10 = {
						create_artifact_pedestal_human_skull_effect = {
							OWNER = scope:physician
							CREATOR = dummy_female
							DESKULLED = scope:physician
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							random_list = {
								10 = {
									set_artifact_name = gdp_merchant_luxury_contract.1641.artifact.skull
									set_artifact_description = gdp_merchant_luxury_contract.1641.artifact.skull.desc
								}
								10 = {
									set_artifact_name = gdp_merchant_luxury_contract.1641.artifact.bone
									set_artifact_description = gdp_merchant_luxury_contract.1641.artifact.bone.desc
								}
							}
						}
					}
				}
			}
			# Save artifact to contract for tooltips
			lc_curio_reforge_effect = { TYPE = curio }
		}
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1641.a
		duel = {
			skill = learning
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = torturer
					add = 10
				}
				modifier = {
					has_trait = lifestyle_physician
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1641.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract = {
						complete_task_contract = success_standard
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:physician }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1641.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			vengeful = minor_stress_impact_loss
			diligent = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1602
	}
}

gdp_merchant_luxury_contract.1651 = { # Student
	type = character_event
	title = gdp_merchant_luxury_contract.1601.t
	desc = gdp_merchant_luxury_contract.1651.desc
	theme = trade
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:student
		triggered_animation = {
			trigger = { use_goblet_in_tavern_trigger = yes }
			animation = drink_goblet
		}
		triggered_animation = {
			trigger = { use_goblet_in_tavern_trigger = no }
			animation = drink
		}
	}
	override_background = { reference = relaxing_room }

	immediate = {
		# Save portrait scope for ending event
		scope:student = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:student = {
				create_curio_artifact_effect = {
					OWNER = scope:student
					CREATOR = dummy_female
				}
				if = {
					limit = { exists = scope:new_trinket }
					scope:new_trinket = { save_scope_as = artifact }
					clear_saved_scope = new_trinket
				}
				else_if = {
					limit = { exists = scope:newly_created_artifact }
					scope:newly_created_artifact = { save_scope_as = artifact }
					clear_saved_scope = newly_created_artifact
				}
			}
		}
	}

	option = { # Continue
		name = gdp_merchant_luxury_contract.1651.a
		duel = {
			skills = { diplomacy prowess }
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = lifestyle_reveler
					add = 10
				}
				modifier = {
					has_trait = drunkard
					add = 10
				}
				modifier = {
					has_trait = hashishiyah
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1651.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:student }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1651.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			gregarious = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1602
	}
}

gdp_merchant_luxury_contract.1661 = { # Botanist
	type = character_event
	title = gdp_merchant_luxury_contract.1601.t
	desc = gdp_merchant_luxury_contract.1661.desc
	theme = trade
	left_portrait = {
		character = root
		animation = admiration
		camera = camera_event_very_left
	}
	right_portrait = {
		character = scope:botanist
		animation = war_over_tie
	}
	artifact = {
		target = scope:artifact
		position = lower_right_portrait
	}
	override_background = { reference = study }

	immediate = {
		# Save portrait scope for ending event
		scope:botanist = { lc_curio_portrait_scope_effect = yes }
		# Create artifact
		hidden_effect = {
			luxury_contract_reward_quality_effect = yes
			scope:botanist = {
				random_list = {
					10 = {
						create_artifact_pressed_flower_effect = { OWNER = scope:botanist } 
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_description = gdp_merchant_luxury_contract.1661.artifact.flower.desc
						}
						clear_saved_scope = flower_species
					}
					10 = {
						create_artifact_animal_trinket_effect = {
							OWNER = scope:botanist
							HUNTER = scope:botanist
							LEGENDARY = no
							ANIMAL = flag:none
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_description = gdp_merchant_luxury_contract.1661.artifact.animal.desc
						}
					}
					10 = {
						create_artifact_bird_feather_effect = {
							OWNER = scope:botanist
							HUNTER = scope:botanist
							ANIMAL = flag:none
						}
						scope:newly_created_artifact ?= {
							save_scope_as = artifact
							set_artifact_description = gdp_merchant_luxury_contract.1661.artifact.feather.desc
						}
					}
				}
			}
			lc_curio_reforge_effect = { TYPE = curio }
		}
	}

	option = { # 
		name = gdp_merchant_luxury_contract.1661.a
		duel = {
			skills = { diplomacy learning }
			value = decent_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_trait = lifestyle_herbalist
					add = 10
				}
				modifier = {
					has_trait = lifestyle_hunter
					add = 10
				}
				modifier = {
					has_trait = lifestyle_gardener
					add = 10
				}
				merchant_find_shared_duel_success_modifier = yes # boost success on 2nd pass
				min = 10
				desc = gdp_merchant_luxury_contract.1661.a.success
				save_scope_as = lc_1001_success
				show_as_tooltip = {
					scope:task_contract ?= { complete_task_contract = success_standard }
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					NOT = { knows_language_of_character = scope:botanist }
					add = 10
				}
				min = 10
				desc = gdp_merchant_luxury_contract.1661.a.failure
				lc_curio_failure_option_effect = yes
			}
		}
		stress_and_fulfillment_impact = {
			calm = minor_stress_impact_loss
			patient = minor_stress_impact_loss
		}
	}

	after = {
		trigger_event = gdp_merchant_luxury_contract.1602
	}
}

### MAINTENANCE
gdp_merchant_luxury_contract.9999 = { # Suppressor
	type = character_event
	hidden = yes
	orphan = yes
	trigger = {
		scope:lc_active_path_flag = flag:lc_0001_urban_flag
		scope:lc_active_path_flag = flag:lc_0001_dealer_flag
		scope:lc_active_path_flag = flag:lc_0001_poach_flag
		scope:lc_active_path_flag = flag:lc_0001_hunt_flag 
		scope:lc_active_path_flag = flag:lc_0001_baby_flag 
		exists = scope:harmless_local_creature
		exists = scope:dangerous_local_creature
		exists = scope:prowling_local_creature
		exists = scope:creature_type
		any_in_list = { variable = lc_path_options_list }
		any_in_list = { variable = lc_building_fallback_list }
		any_in_list = { variable = lc_building_potential_list }
		any_in_list = { variable = lc_building_completed_list }
	}
	immediate = {
		save_scope_as = harmless_local_creature
		save_scope_as = dangerous_local_creature
		save_scope_as = prowling_local_creature
		save_scope_as = creature_type
		add_to_variable_list = {
			name = lc_path_options_list
			target = flag:none
		}
		add_to_variable_list = {
			name = lc_building_fallback_list
			target = flag:none
		}
		add_to_variable_list = {
			name = lc_building_potential_list
			target = flag:none
		}
		add_to_variable_list = {
			name = lc_building_completed_list
			target = flag:none
		}
	}
}
