﻿namespace = gdp_merchant_activity_events

###################################################################################
## By Axel Näslund
## gdp_merchant_activity_events.0001 - Activity host has skimped on food options
## gdp_merchant_activity_events.0005 - Host wants to hear about your exotic domicile artifact
## gdp_merchant_activity_events.0010 - Gift-giving war with other merchant family
## gdp_merchant_activity_events.0015 - Peasants outside of the activity are hungry
## gdp_merchant_activity_events.0020 - Host boasts counterfeit artifact
## gdp_merchant_activity_events.0025 - Swap tales of luxury contracts with another merchant
###################################################################################


# Activity host has skimped on food options
gdp_merchant_activity_events.0001 = {
	type = activity_event
	title = gdp_merchant_activity_events.0001.t
	desc = {
		desc = gdp_merchant_activity_events.0001.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:activity.activity_host = root }
				desc = gdp_merchant_activity_events.0001.host
			}
			desc = gdp_merchant_activity_events.0001.guest
		}
	}

	theme = feast_activity

	left_portrait = {
		character = root
		animation = pondering
		camera = camera_event_left_crowning_observation
	}
	right_portrait = {
		character = scope:guest
		animation = eyeroll
	}
	lower_right_portrait = {
		character = scope:host
		trigger = {
			NOT = { this = root }
		}
	}

	cooldown = { years = 1 }

	trigger = {
		government_has_flag = government_is_merchant
		scope:activity = {
			OR = {
				has_activity_option = {
					category = feast_option_food
					option = feast_food_bad
				}
				has_activity_option = {
					category = feast_option_food
					option = feast_food_normal
				}
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_bad
				}
				has_activity_option = {
					category = feast_option_courses
					option = feast_courses_normal
				}
			}
			any_attending_character = {
				this != root
				this != scope:host
				house != root.house
				NOT = { liege = root }
			}
		}
	}

	immediate = {
		scope:activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = {
					this != root
					this != scope:host
					house != root.house
					NOT = { liege = root }
				}
				weight = {
					base = 1
					modifier = {
						is_ruler = yes
						add = 1
					}
				}
				save_scope_as = guest
			}
		}
		scope:guest = { assign_quirk_effect = yes }
	}

	option = { # I will donate from the goodness of my heart
		name = {
			text = {
				first_valid = {
					triggered_desc = {
						trigger = { this = scope:host }
						desc = gdp_merchant_activity_events.0001.a.host
					}
					desc = gdp_merchant_activity_events.0001.a
				}
			}
		}
		trigger = {	short_term_gold >= massive_gold_value }
		show_as_unavailable = { short_term_gold < massive_gold_value }
		if = {
			limit = { this = scope:host }
			remove_short_term_gold = medium_gold_value
		}
		else = { remove_short_term_gold = massive_gold_value }
		add_prestige = medium_prestige_gain
		if = {
			limit = {
				NOT = { this = scope:host }
			}
			reverse_add_opinion = {
				modifier = kindness_opinion
				target = scope:host
				opinion = 30
			}
		}
		else = {
			scope:activity = {
				every_attending_character = {
					limit = { this != root }
					custom = every_guest_scope_tt
					add_opinion = {
						target = root
						modifier = respect_opinion
						opinion = 10
					}
				}
			}
		}
		stress_and_fulfillment_impact = {
			fickle = minor_stress_impact_loss
			generous = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 25
				OR = {
					has_trait = generous
					has_trait = compassionate
				}
			}
			modifier = {
				OR = {
					has_trait = greedy
					short_term_gold < monumental_gold_value
				}
				factor = 0
			}
		}
	}

	option = { # I will donate... for a hook
		name = gdp_merchant_activity_events.0001.b
		trigger = {
			NOR = {
				this = scope:host
				has_hook_of_type = {
					target = scope:host
					type = strong_indebted_hook
				}
			}
			short_term_gold >= medium_gold_value
			can_add_hook = {
				target = scope:host
				type = indebted_hook
			}
		}
		show_as_unavailable = {
			NOT = {
				this = scope:host
				short_term_gold < medium_gold_value
				can_add_hook = {
					target = scope:host
					type = indebted_hook
				}
			}
		}
		remove_short_term_gold = medium_gold_value
		add_hook = {
			target = scope:host
			type = indebted_hook
		}
		stress_and_fulfillment_impact = {
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_boldness = 1
			}
			modifier = {
				add = 75
				has_trait = ambitious
			}
			modifier = {
				OR = {
					has_trait = honest
					short_term_gold < massive_gold_value
				}
				factor = 0
			}
		}
	}

	option = { #I am an luxury merchant!
		name = gdp_merchant_activity_events.0001.e
		trigger = {
			this = scope:host
			government_has_flag = government_is_merchant
			custom_tooltip = {
				text = trade_category_comforts_trade_route_trigger
				any_trade_route_and_market_with_goods_category_produced_trigger = { CATEGORY = comforts }
			}
		}
		reason = have_comforts_route
		show_as_unavailable = { government_has_flag = government_is_merchant }
		save_random_trade_route_and_market_with_goods_category_produced_effect = { CATEGORY = comforts }
		scope:goods_market ?= {
			add_trade_market_modifier = {
				modifier = activity_used_trade_market_comforts_modifier
				years = 10
			}
		}
		add_prestige = medium_prestige_gain
		reverse_add_opinion = {
			target = scope:guest
			modifier = impressed_opinion
			opinion = 20
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = ambitious
			}
		}
	}

	option = { # Out out
		name = gdp_merchant_activity_events.0001.d
		trigger = {
			this = scope:host
			NOT = { scope:activity.special_guest:honorary_guest ?= scope:guest }
		}
		add_prestige = {
			value = miniscule_prestige_gain
			multiply = scope:guest.highest_held_title_tier
			min = miniscule_prestige_gain
		}
		scope:guest = {
			remove_from_activity = scope:activity
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:host }
				}
				progress_towards_rival_effect = {
					REASON = rival_feast_thrown_out
					CHARACTER = scope:host
					OPINION = default_rival_opinion
				}
			}
			else = {
				add_opinion = {
					target = scope:host
					modifier = insult_opinion
					opinion = -25
				}
			}
			house = {
				change_house_relation_effect = {
					HOUSE = scope:host.house
					VALUE = house_relation_damage_minor_value
					REASON = feast_decrease
					CHAR = scope:host
					TARGET_CHAR = scope:guest
					TITLE = scope:dummy_gender
				}
			}
		}
		stress_and_fulfillment_impact = {
			forgiving = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			calm = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
			opinion_modifier = {
				opinion_target = scope:guest
				multiplier = -1
			}
		}
	}

	option = { # Be thankful you dolt
		name = gdp_merchant_activity_events.0001.c
		if = {
			limit = { this = scope:host }
			reverse_add_opinion = {
				modifier = annoyed_opinion
				target = scope:guest
				opinion = -10
			}
		}
		else = {
			reverse_add_opinion = {
				modifier = kindness_opinion
				target = scope:host
				opinion = 5
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
			}
		}
	}
}

# Host wants to hear about your exotic domicile artifact
gdp_merchant_activity_events.0005 = {
	type = activity_event
	title = gdp_merchant_activity_events.0005.t
	desc = {
		desc = gdp_merchant_activity_events.0005.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						prestige_level >= 3					
						scope:admirer = {
							opinion = {
								target = root
								value >= 50
							}
						}
						has_relation_friend = scope:admirer
					}
				}
				desc = gdp_merchant_activity_events.0005.desc_esteemed
			}
			desc = gdp_merchant_activity_events.0005.desc_fallback
		}
		desc = gdp_merchant_activity_events.0005.desc_outro
	}

	theme = feast_activity
	override_background = { reference = courtyard }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				NOT = { has_trait = arrogant }
				OR = {
					prestige_level >= 3					
					scope:admirer = {
						opinion = {
							target = root
							value >= 50
						}
					}
					has_relation_friend = scope:admirer
				}
			}
			animation = admiration
		}
		animation = war_over_win
	}

	center_portrait = {
		character = scope:guest
		animation = interested_left
		camera = camera_event_center_pointing_forward_fov35
	}

	right_portrait = {
		character = scope:admirer
		animation = storyteller
	}

	artifact = {
		target = scope:luxury_artifact
		position = lower_center_portrait
	}

	# Fairly rare
	cooldown = { years = 10 }

	trigger = {
		government_has_flag = government_is_merchant
		any_character_artifact = {
			NOT = {
				has_variable = used_in_activity_event
			}
			OR = {
				artifact_slot_type = library
				artifact_slot_type = creature
				artifact_slot_type = curio
			}
		}
		scope:activity = {
			any_attending_character = {
				count >= 2
				NOT = { this = root }
			}
		}
	}

	immediate = {
		scope:activity = {
			random_attending_character = {
				limit = {
					this = scope:activity.activity_host
					this != root
				}
				alternative_limit = { this != root }
				weight = { # Fetch relevant guest character
					base = 1
					is_of_minor_interest_to_weight_up_modifier = { CHARACTER = root }
					is_of_major_interest_to_weight_up_modifier = { CHARACTER = root }
				}
				save_scope_as = admirer
			}
			random_attending_character = {
				limit = {
					this != root
					this != scope:admirer
				}
				weight = { # Fetch relevant guest character
					base = 1
					is_of_minor_interest_to_weight_up_modifier = { CHARACTER = scope:host }
					is_of_major_interest_to_weight_up_modifier = { CHARACTER = scope:host }
				}
				save_scope_as = guest
			}
		}
		random_character_artifact = {
			limit = {
				OR = {
					artifact_slot_type = library
					artifact_slot_type = creature
					artifact_slot_type = curio
				}
			}
			weight = { # Fetch relevant artifact
				base = 1
				# Rare is better
				modifier = {
					add = 5
					OR = {					
						rarity = illustrious
						rarity = famed
						rarity = masterwork
					}
				}
				# Creatures are always more prestigious
				modifier = {
					add = 10
					artifact_slot_type = creature
				}
			}
			save_scope_as = luxury_artifact
			set_variable = used_in_activity_event
		}
	}

	option = { # Imma blow your minds, lyrical-style
		name = gdp_merchant_activity_events.0005.c
		trigger = { has_trait = lifestyle_poet }
		show_as_unavailable = { always = yes }
		trait = lifestyle_poet
		add_internal_flag = special
		add_prestige = medium_prestige_gain
		add_trait_xp = {
			trait = lifestyle_poet
			value = { 5 10 }
		}
		reverse_add_opinion = {
			modifier = pleased_opinion
			target = scope:admirer
			opinion = 15
		}
		ai_chance = {
			# Special option - should always be taken
			base = 1000
		}
	}

	option = { # I can't believe I made it out alive!
		name = gdp_merchant_activity_events.0005.b
		duel = {
			skill = intrigue
			target = scope:admirer
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = gdp_merchant_activity_events.0005.b.success
				send_interface_toast = {
					title = gdp_merchant_activity_events.0005.b.success
					left_icon = scope:admirer
					add_prestige = medium_prestige_gain
					reverse_add_opinion = {
						modifier = pleased_opinion
						target = scope:admirer
						opinion = 15
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = gdp_merchant_activity_events.0005.b.failure
				send_interface_toast = {
					title = gdp_merchant_activity_events.0005.b.failure
					left_icon = scope:admirer
					stress_and_fulfillment_impact = {
						base = medium_stress_impact_gain
					}
				}
			}
		}
		stress_and_fulfillment_impact = {
			honest = medium_stress_impact_gain
			humble = medium_stress_impact_gain
			shy = medium_stress_impact_gain
			deceitful = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
			}
			modifier = {
				intrigue >= good_skill_level
				add = 20
			}
			modifier = {
				stress_level > 1
				factor = 0
			}
		}
	}

	option = { # It was nothing, really
		name = gdp_merchant_activity_events.0005.a
		add_prestige = minor_prestige_gain
		reverse_add_opinion = {
			modifier = irritated_opinion
			target = scope:admirer
			opinion = -10
		}
		stress_and_fulfillment_impact = {
			arrogant = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
			humble = minor_stress_impact_loss
			shy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
			}
		}
	}

	option = { # What about my trade market tho
		name = gdp_merchant_activity_events.0005.d
		add_character_modifier = {
			modifier = gdp_boasted_market_competence_modifier
			years = 5
		}
		reverse_add_opinion = {
			modifier = irritated_opinion
			target = scope:admirer
			opinion = -10
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}
}

# Gift-giving war with other merchant family
gdp_merchant_activity_events.0010 = {
	type = activity_event
	title = gdp_merchant_activity_events.0010.t
	desc = gdp_merchant_activity_events.0010.desc
	theme = feast_activity
	left_portrait = {
		character = root
		animation = dismissal
	}
	right_portrait = {
		character = scope:receiver
		animation = interested_left
	}
	center_portrait = {
		character = scope:merchant
		animation = steward
	}

	cooldown = { years = 1 }

	trigger = {
		government_has_flag = government_is_merchant
		scope:activity = {
			any_attending_character = {
				this != root
				this != scope:host
				exists = house
				house =  { this != root.house }
				government_has_flag = government_is_merchant
				exists = domicile
				any_trade_route = { count >= 1 }
			}
		}
	}

	immediate = {
		scope:activity = {
			activity_host = { save_scope_as = host }
			random_attending_character = {
				limit = {
					this != root
					this != scope:host
					exists = house
					house = { this != root.house }
					government_has_flag = government_is_merchant
					any_trade_route = { count >= 1 }
				}
				save_scope_as = merchant
			}
			if = {
				limit = { root != scope:host }
				scope:host = { save_scope_as = receiver }
			}
			else = {
				random_attending_character = {
					limit = {
						this != root
						this != scope:merchant
						root.suzerain ?= this
					}
					alternative_limit = {
						this != root
						this != scope:merchant
						is_landed = yes
					}
					alternative_limit = {
						this != root
						this != scope:merchant
						is_ruler = yes
					}
					alternative_limit = {
						this != root
						this != scope:merchant
					}
					weight = {
						base = 1
						modifier = { add = highest_held_title_tier }
					}
					save_scope_as = receiver
				}

			}
		}
		scope:merchant = {
			random_trade_route = {
				random_traded_good = { save_scope_as = good }
			}
			add_character_flag = {
				flag = gdp_merchant_activity_events.0010_cooldown
				years = 1
			}
		}
	}

	option = { # Out-gift them
		name = gdp_merchant_activity_events.0010.a
		trigger = { short_term_gold >= scope:merchant.massive_gold_value }
		show_as_unavailable = { always = yes }
		remove_short_term_gold = scope:merchant.massive_gold_value
		add_prestige = medium_prestige_gain
		reverse_add_opinion = {
			modifier = insulted_opinion
			target = scope:merchant
			opinion = -15
		}
		reverse_add_opinion = {
			modifier = kindness_opinion
			target = scope:receiver
			opinion = 15
		}
		house ?= {
			if = {
				limit = {
					NOT = { has_house_relation_with = scope:merchant.house }
				}
				scope:merchant = { save_scope_as = char }
				root = { save_scope_as = target_char }
				set_house_relation = {
					target = scope:merchant.house
					level = quarrel
					description = house_relation_reason_feast_decrease_desc
				}
			}
			else = {
				change_house_relation_effect = {
					HOUSE = scope:merchant.house
					VALUE = house_relation_damage_minor_value
					REASON = feast_decrease
					CHAR = scope:merchant
					TARGET_CHAR = root
					TITLE = scope:dummy_gender
				}
			}
		}
		stress_and_fulfillment_impact = {
			generous = minor_stress_impact_loss
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_boldness = 1
			}
			modifier = {
				add = 25
				has_trait = generous
			}
			modifier = {
				OR = {
					has_trait = greedy
					short_term_gold < scope:merchant.monumental_gold_value
				}
				factor = 0
			}
		}
	}

	option = { # Schmooze
		name = gdp_merchant_activity_events.0010.d
		trigger = { has_activity_intent = schmooze_intent }
		duel = {
			skill = diplomacy
			value = decent_skill_rating
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				desc = gdp_merchant_activity_events.0010.b.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_merchant_activity_events.0010.b.success
					left_icon = scope:merchant
					right_icon = scope:receiver
					gdp_log_schmooze_successful_effect = {
						CHAR = root
						TARGET = scope:receiver
						MARKET = scope:province.barony.trade_market
					}
					scope:activity = {
						every_attending_character = {
							limit = {
								this != scope:host
								this != scope:receiver
								this != root
								is_alive = yes
								has_no_particular_noble_roots_trigger = no
							}
							custom = custom.every_attending_noble
							add_opinion = {
								modifier = pleased_opinion
								target = root
								opinion = 5
							}
						}
					}
				}
			}
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				desc = gdp_merchant_activity_events.0010.b.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_merchant_activity_events.0010.b.failure
					left_icon = scope:merchant
					right_icon = scope:receiver
					add_prestige = medium_prestige_loss
					reverse_add_opinion = {
						modifier = contempt_opinion
						target = scope:receiver
						opinion = -10
					}
				}
			}
		}
		stress_and_fulfillment_impact = {
			arrogant = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 0.5
				ai_sociability = 0.5
			}
			modifier = {
				has_trait = shrewd
				add = 10
			}
			modifier = {
				has_trait = humble
				add = 10
			}
		}
	}

	option = { # Compliment the gift
		name = gdp_merchant_activity_events.0010.b
		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:merchant
			opinion = 15
		}
		house ?= {
			if = {
				limit = {
					NOT = { has_house_relation_with = scope:merchant.house }
				}
				scope:merchant = { save_scope_as = char }
				root = { save_scope_as = target_char }
				set_house_relation = {
					target = scope:merchant.house
					level = cordial
					description = house_relation_reason_feast_increase_desc
				}
			}
			else = {
				change_house_relation_effect = {
					HOUSE = scope:merchant.house
					VALUE = house_relation_improve_minor_value
					REASON = feast_increase
					CHAR = scope:merchant
					TARGET_CHAR = root
					TITLE = scope:dummy_gender
				}
			}
		}
		stress_and_fulfillment_impact = {
			compassionate = minor_stress_impact_loss
			arrogant = medium_stress_impact_gain
			ambitious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
			modifier = {
				has_trait = compassionate
				add = 20
			}
			modifier = {
				has_trait = arrogant
				factor = 0
			}
		}
	}

	option = { # Opt out
		name = gdp_merchant_activity_events.0010.c
		stress_and_fulfillment_impact = {
			base = minor_stress_impact_loss
			shy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
			}
		}
	}
}

# Peasants outside the activity are hungry
gdp_merchant_activity_events.0015 = {
	type = activity_event
	title = gdp_merchant_activity_events.0015.t
	desc = gdp_merchant_activity_events.0015.desc

	theme = feast_activity
	override_background = { reference = alley_night }

	left_portrait = {
		character = root
		animation = pondering
	}

	center_portrait = {
		character = scope:peasant_2
		animation = holding_crutch
		hide_info = yes
		camera = camera_event_center_pointing_left
	}

	right_portrait = {
		character = scope:peasant
		animation = beg
		hide_info = yes
	}

	lower_right_portrait = {
		character = scope:host
		trigger = { NOT = { this = root } }
	}

	cooldown = { years = 1 }

	trigger = { government_has_flag = government_is_merchant }

	immediate = {
		scope:activity.activity_host = { save_scope_as = host }
		# Create some scene-setting characters
		create_character = {
			template = tournament_locale_character
			dynasty = none
			location = scope:activity.activity_location
			save_scope_as = peasant
			after_creation = { add_character_flag = peasant_outfit }
		}
		create_character = {
			template = tournament_locale_character
			age = { 50 55 }
			dynasty = none
			location = scope:activity.activity_location
			save_scope_as = peasant_2
			after_creation = { add_character_flag = peasant_outfit }
		}
	}

	option = { # Great PR opportunity
		name = gdp_merchant_activity_events.0015.a
		trigger = { short_term_gold >= massive_gold_value }
		show_as_unavailable = { always = yes }
		remove_short_term_gold = massive_gold_value
		add_prestige = medium_prestige_gain
		scope:activity.activity_location.county = { add_popular_opinion = 10 }
		stress_and_fulfillment_impact = {
			generous = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
			greedy = medium_stress_impact_gain
			arrogant = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 25
				OR = {
					has_trait = generous
					has_trait = compassionate
				}
			}
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = arrogant
					has_trait = callous
					short_term_gold < monumental_gold_value
				}
				factor = 0
			}
		}
	}

	option = { # I'm more interested in making friends over here
		name = {
			text = {
				random_valid = {
					triggered_desc = {
						trigger = {
							OR = {
								has_trait = drunkard
								drinks_alcohol_trigger = yes
							}
						}
						desc = gdp_merchant_activity_events.0015.b.alcohol
					}
					desc = gdp_merchant_activity_events.0015.b
				}
			}
		}
		trigger = { has_activity_intent = schmooze_intent }
		flavor = available_because_of_intent
		remove_short_term_gold = minor_gold_value
		gdp_log_schmooze_successful_empty_effect = {
			CHAR = root
			MARKET = scope:province.barony.trade_market
		}
		scope:activity = {
			every_attending_character = {
				limit = {
					this != scope:host
					this != root
					has_no_particular_noble_roots_trigger = no
				}
				custom = custom.every_attending_noble
				add_opinion = {
					modifier = pleased_opinion
					target = root
					opinion = 5
				}
			}
		}
		if = {
			limit = {
				can_set_relation_friend_trigger = { CHARACTER = scope:host }
			}
			progress_towards_friend_effect = {
				REASON = friend_feast_talking_and_laughing
				CHARACTER = scope:host
				OPINION = default_friend_opinion
			}
		}
		stress_and_fulfillment_impact = {
			shy = medium_stress_impact_gain
			craven = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_boldness = 1
			}
			modifier = {
				has_trait = shy
				factor = 0
			}
		}
	}

	option = { # _these_ are my people
		name = gdp_merchant_activity_events.0015.c
		if = {
			limit = {
				NOT = { has_trait = lifestyle_merchant }
			}
			add_trait = lifestyle_merchant
		}
		else = {
			add_trait_xp = {
				trait = lifestyle_merchant
				track = artisan
				value = 2
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = -1
			}
		}
	}

	option = { # away!
		name = gdp_merchant_activity_events.0015.d
		trigger = { this = scope:host }
		add_prestige = miniscule_prestige_gain
		scope:activity.activity_location.county = { add_popular_opinion = -10 }
		stress_and_fulfillment_impact = {
			humble = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			callous = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_boldness = 1
			}
		}
	}
	after = {
		# Event cleanup
		scope:peasant = { silent_disappearance_effect = yes }
		scope:peasant_2 = { silent_disappearance_effect = yes }
	}
}

# Someone boasts counterfeit artifact
gdp_merchant_activity_events.0020 = {
	type = activity_event
	title = gdp_merchant_activity_events.0020.t
	desc = gdp_merchant_activity_events.0020.desc
	theme = feast_activity
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:other
		animation = admiration
	}
	artifact = {
		target = scope:fake_artifact
		position = lower_center_portrait
	}
	cooldown = { years = 1 }

	trigger = {
		government_has_flag = government_is_merchant
		has_realm_law = company_purpose_artisan
		scope:activity = {
			trigger_if = {	
				limit = {
					NOT = { activity_host = root }
				}
				any_attending_character = {
					NOT = { this = root }
					is_ruler = yes
				}
			}
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = { this = scope:activity.activity_host }
			}
			scope:activity.activity_host = { save_scope_as = other }
		}
		else = {
			scope:activity = {
				random_attending_character = {
					limit = {
						NOT = { this = root }
						is_ruler = yes
					}
					save_scope_as = other
				}
			}
		}
		scope:other = { assign_quirk_effect = yes }
		
		# First we generate some far-off merchant who created the artifact
		random_empire = {
			limit = {
				any_de_jure_county = { culture != root.culture }
			}
			random_de_jure_county = {
				limit = { culture != root.culture }
				save_scope_as = foreign_trader_home
			}
		}
		create_character = {
			template = generic_peasant_character
		    location = root.location
		    dynasty = none 
		    culture = scope:foreign_trader_home.culture
		    faith = scope:foreign_trader_home.faith
			save_scope_as = foreigner
		}
		scope:host = {		
	 		hidden_effect = {
	 			create_artifact = {
					name = fake_artifact_name
					description = fake_artifact_desc
					modifier = artifact_attraction_opinion_1_modifier
					creator = scope:foreigner
					type = miscellaneous
					visuals = necklace
					save_scope_as = fake_artifact
				}
	 		}
		}
	}

	option = { # Publicly expose the counterfeit artifact
		name = gdp_merchant_activity_events.0020.a
		add_prestige = medium_prestige_gain
		if = {
			limit = {
				can_set_relation_rival_trigger = { CHARACTER = scope:other }
			}
			scope:other = {			
				progress_towards_rival_effect = {
					REASON = rival_public_embarrasment
					CHARACTER = root
					OPINION = default_rival_opinion
				}
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:other
				modifier = annoyed_opinion
				opinion = -15
			}
		}
		stress_and_fulfillment_impact = {
			shy = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
				ai_sociability = -1
			}
			modifier = { # There's already bad blood
				add = 20
				scope:other = {
					opinion = {
						target = root
						value <= -50
					}
				}
			}
			modifier = { # Relationship is good
				add = -50		
				has_relation_friend = scope:other
			}
			modifier = { # Shy or compassionate characters would never
				OR = {
					has_trait = shy
					has_trait = compassionate
				}
				factor = 0
			}
		}
	}

	option = { # Let me... handle that for you.
		name = gdp_merchant_activity_events.0020.b
	    send_interface_toast = {
			title = gdp_merchant_activity_events.0020.b.equipped_tt
		    left_icon = root
		    right_icon = scope:fake_artifact
		    scope:fake_artifact = {
		    	set_variable = {
					name = suppress_artifact_notifications
					value = yes
					days = 1
				}
		        set_owner = {
		        	target = root
					history = {
						location = scope:activity.activity_location
						actor = scope:other
						recipient = root
						type = given
					}
				}
			}
		}
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_loss

		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				# Greedy chars always want more
				ai_greed = 1
				ai_sociability = 1
			}
		}
	}

	option = { # Very impressive!
		name = gdp_merchant_activity_events.0020.c
		reverse_add_opinion = {
			target = scope:other
			modifier = pleased_opinion
			opinion = 10
		}
		stress_and_fulfillment_impact = {
			loyal = minor_stress_impact_loss
			content = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
			}
			modifier = {
				add = 20
				OR = {
					has_trait = loyal
					has_trait = content
				}
			}
		}
	}

	after = {
		# Event cleanup
		scope:foreigner = { silent_disappearance_effect = yes }
		hidden_effect = {		
			if = {
				limit = {
					NOT = {
						any_character_artifact = { this = scope:fake_artifact }
					}
				}
				destroy_artifact = scope:fake_artifact
			}
		}
	}
}

scripted_trigger gdp_merchant_activity_events_0025_artifact_trigger = {
	OR = {
		artifact_slot_type = curio
		artifact_slot_type = library
		AND = {
			artifact_slot_type = creature
			var:animal_type ?= {
				OR = {
					this = flag:parrot
					this = flag:cockatoo
					this = flag:monkey
				}
			}
		}
	}
}

# Swap tales of luxury contracts with another merchant
gdp_merchant_activity_events.0025 = {
	type = activity_event
	title = gdp_merchant_activity_events.0025.t
	desc = {
		desc = gdp_merchant_activity_events.0025.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:luxury_artifact = { var:animal_type = flag:monkey }
				}
				desc = gdp_merchant_activity_events.0025.desc_ape
			}
			desc = gdp_merchant_activity_events.0025.desc_bird
		}
		desc = gdp_merchant_activity_events.0025.desc_cont
	}
	theme = feast_activity
	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:merchant
		animation = storyteller
	}
	artifact = {
		target = scope:luxury_artifact
		position = lower_center_portrait
	}

	# We don't want to spawn too many luxury contracts
	cooldown = { years = 20 }

	trigger = {
		government_has_flag = government_is_merchant
		can_create_task_contract = { type_name = menagerie_acquisition }
		scope:activity = {
			any_attending_character = {
				NOT = { has_character_flag = gdp_merchant_activity_events.0010_cooldown }
				this != root
				house ?= { this != root.house }
				government_has_flag = government_is_merchant
				any_character_artifact = { gdp_merchant_activity_events_0025_artifact_trigger = yes }
			}
		}
	}

	immediate = {
		scope:activity = {
			random_attending_character = {
				limit = {
					NOT = { has_character_flag = gdp_merchant_activity_events.0010_cooldown }
					this != root
					house ?= { this != root.house }
					government_has_flag = government_is_merchant
					any_character_artifact = { gdp_merchant_activity_events_0025_artifact_trigger = yes }
				}
				save_scope_as = merchant
			}
			scope:merchant = {
				assign_quirk_effect = yes
				random_artifact = {
					limit = { gdp_merchant_activity_events_0025_artifact_trigger = yes }
					save_scope_as = luxury_artifact
				}
			}
		}
	}

	option = { # You have the caravaneer company purpose
		name = gdp_merchant_activity_events.0025.a
		trigger = { has_realm_law = company_purpose_caravaneer }
		reason = purpose_caravaneer
		add_internal_flag = special
		scope:luxury_artifact = {
			switch = {
				trigger = artifact_slot_type
				creature = {
					root = {
						trigger_event = { on_action = gdp_menagerie_acquisition }
						custom_tooltip = gdp_merchant_activity_events.0025.tt.menagerie
					}
				}
				fallback = {
					root = {
						trigger_event = { on_action = gdp_find_curio }
						custom_tooltip = gdp_merchant_activity_events.0025.tt.curio
					}
				}
			}
		}
		ai_chance = { # Special option should always be picked
			base = 1000
		}
	}

	option = { # Fallback duel
		name = gdp_merchant_activity_events.0025.b
		trigger = {
			NOT = { has_realm_law = company_purpose_caravaneer }
		}
		duel = {
			skill = diplomacy
			target = scope:merchant
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_activity_events.0025.b.success
				send_interface_toast = {
					title = gdp_merchant_activity_events.0025.b.success
					left_icon = scope:merchant
					scope:luxury_artifact = {
						switch = {
							trigger = artifact_slot_type
							creature = {
								root = {
									trigger_event = { on_action = gdp_menagerie_acquisition }
									custom_tooltip = gdp_merchant_activity_events.0025.tt.menagerie
								}
							}
							fallback = {
								root = {
									trigger_event = { on_action = gdp_find_curio }
									custom_tooltip = gdp_merchant_activity_events.0025.tt.curio
								}
							}
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 10
				desc = gdp_merchant_activity_events.0025.b.failure
				send_interface_toast = {
					title = gdp_merchant_activity_events.0025.b.failure
					left_icon = scope:merchant
					stress_and_fulfillment_impact = {
						base = medium_stress_impact_gain
					}
				}
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = 1
			}
			modifier = {
				diplomacy >= good_skill_level
				add = 20
			}
			modifier = {
				stress_level > 1
				factor = 0
			}
		}
	}

	option = { # Tell me more about this place!
		name = gdp_merchant_activity_events.0025.c
		if = {
			limit = {			
				NOT = {
					has_trait = lifestyle_traveler
				}
			}
			add_trait = lifestyle_traveler
		}
		add_trait_xp = {
			trait = lifestyle_traveler
			track = travel
			value = 5
		}
		stress_and_fulfillment_impact = {
			content = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				OR = {
					has_trait = content
					has_trait = lazy
				}
				add = 25
			}
		}
	}
}
