namespace = ep3_story_cycle_violet_poet

##################################################
# Maintenance events
# 0001-0999
##################################################

#andalusian_0003
#Visit Orphanage

#Lead-in event
ep3_story_cycle_violet_poet.0001 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.0001.t
	desc = ep3_story_cycle_violet_poet.0001.desc
	theme = violet_poet
	left_portrait = {
		character = root
		animation = thinking
	}
	artifact = {
		target = scope:double_moon_book
		position = lower_center_portrait
	}
	cooldown = { years = 100 }

	trigger = {
		has_ep3_dlc_trigger = yes
	}

	immediate = {
		title:c_toledo.holder = {
			save_scope_as = toledo_owner
		}
		title:c_toledo = {
			save_scope_as = toledo
		}
		location = {
			save_scope_as = cordoba
		}
		create_story = story_cycle_violet_poet
		create_artifact = {
			name = artifact_double_moon_book
			description = artifact_double_moon_book_description
			type = journal
			visuals = book
			modifier = double_moon_modifier
			save_scope_as = double_moon_book
		}
		hidden_effect = {
			scope:double_moon_book = {
				set_artifact_rarity = illustrious
			}
			#Error log suppression, the variable is set in the 01_laamp_titles.txt and checked in 00_succession_laws.txt
			if = {
				limit = { always = no }
				primary_title = {
					set_variable = {
						name = can_keep_realm_law
						value = flag:equal_law
					}
				}
			}
		}
	}

	option = { #Stay in Cordoba
		name = ep3_story_cycle_violet_poet.0001.a

		flavor = ep3_story_cycle_violet_poet.0001.a.tt

		stress_impact = {
			content = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #Leave for pastures new
		name = ep3_story_cycle_violet_poet.0001.b

		flavor = ep3_story_cycle_violet_poet.0001.b.tt

		custom_tooltip = ep3_story_cycle_violet_poet.0001.b.travel

		start_travel_plan = {
			destination = scope:toledo_owner.capital_province
			travel_with_domicile = yes
			players_use_planner = no
			return_trip = no
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 0 #Prioritise her staying in Cordoba for AI
		}
	}

	after = {
		hidden_effect = {
			scope:double_moon_book = {
				set_artifact_description = artifact_double_moon_book_description_append
			}
		}
		if = {
			limit = {
				NOT = {
					has_character_flag = violet_poet_designated_heir
				}
			}
			trigger_event = {
				id = ep3_story_cycle_violet_poet.0002
				years = { 4 5 }
			}
		}
	}
}

#Heir designation event two-parter
#Triggered within the first five years of violet_poet's life
ep3_story_cycle_violet_poet.0002 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.0002.t
	desc = ep3_story_cycle_violet_poet.0002.desc
	theme = violet_poet
	left_portrait = {
		character = root
		animation = worry
	}
	artifact = {
		target = scope:double_moon_book
		position = lower_center_portrait
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		any_courtier = {
			count > 1
		}
		any_character_artifact = {
			has_artifact_modifier = double_moon_modifier
		} 
	}

	immediate = {
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}
	}

	option = { #Go for it
		name = ep3_story_cycle_violet_poet.0002.a

		flavor = ep3_story_cycle_violet_poet.0002.a.tt

		trigger_event = {
			id = ep3_story_cycle_violet_poet.0003
			days = { 1 2 }
		}

		add_character_flag = violet_poet_designated_heir

		stress_impact = {
			base = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #Do not designate an heir
		name = ep3_story_cycle_violet_poet.0002.b

		flavor = ep3_story_cycle_violet_poet.0002.b.flavor
		custom_tooltip = ep3_story_cycle_violet_poet.0002.b.tt

		if = {
			limit = {
				NOT = {
					has_character_flag = violet_poet_designated_heir
				}
			}
			trigger_event = {
				id = ep3_story_cycle_violet_poet.0002
				years = 5
			}
		}

		stress_impact = {
			base = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 0 #We want her to designate an heir
		}
	}
}

#Heir designation event
ep3_story_cycle_violet_poet.0003 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.0003.t
	desc = {
		desc = ep3_story_cycle_violet_poet.0003.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:heir1 = {
						has_trait = lifestyle_poet
					}
				}
				desc = ep3_story_cycle_violet_poet.0003.poet
			}
			desc = ep3_story_cycle_violet_poet.0003.diplomat
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:heir2 = {
						is_female = yes
					}
				}
				desc = ep3_story_cycle_violet_poet.0003.woman
			}
			desc = ep3_story_cycle_violet_poet.0003.young
		}
		desc = ep3_story_cycle_violet_poet.0003.heir3
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:heir3 = {
						has_trait = intellect_good
					}
				}
				desc = ep3_story_cycle_violet_poet.0003.intelligent
			}
			triggered_desc = {
				trigger = {
					scope:heir3 = {
						has_trait = beauty_good
					}
				}
				desc = ep3_story_cycle_violet_poet.0003.beautiful
			}
		}
		desc = ep3_story_cycle_violet_poet.0003.ending
	}	

	theme = violet_poet
	left_portrait = {
		character = root
		animation = thinking
	}
	lower_left_portrait = {
		character = scope:heir1
	}
	lower_center_portrait = {
		character = scope:heir2
	}
	lower_right_portrait = {
		character = scope:heir3
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		this = character:andalusian_0003
		any_courtier = {
			count > 1
		}
		any_character_artifact = {
			has_artifact_modifier = double_moon_modifier
		}
	}

	immediate = {
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}

		#Heir 1
		#Prefers poets and high diplo, fallback is created
		if = {
			limit = {
				any_courtier = {
					OR = {
						has_trait = lifestyle_poet
						diplomacy > 20
					}
				}
			}
			random_courtier = {
				limit = {
					OR = {
						has_trait = lifestyle_poet
						diplomacy > 20
					}
				}
				weight = {
					base = 1
					modifier = {
						factor = 4
						has_trait = lifestyle_poet
					}
					modifier = {
						factor = 2
						diplomacy > 20
					}
				}
				save_scope_as = heir1
			}
		}
		else = {
			hidden_effect = {
				create_character = {
					template = generic_peasant_character
					culture = location.county.culture
					faith = location.county.faith
					gender_female_chance = 50
					location = root.location
					save_scope_as = heir1
				}
			}
		}

		#Heir 2
		#Prefers women and also young people, fallback is created
		if = {
			limit = {
				any_courtier = {
					OR = {
						is_female = yes
						age < 25
					}
				}
			}
			random_courtier = {
				limit = {
					OR = {
						is_female = yes
						age < 25
					}
				}
				weight = {
					base = 1
					modifier = {
						factor = 4
						is_female = yes
					}
					modifier = {
						factor = 2
						age < 25
					}
				}
				save_scope_as = heir2
			}
		}
		else = {
			hidden_effect = {
				create_character = {
					template = generic_peasant_character
					culture = location.county.culture
					faith = location.county.faith
					gender_female_chance = 100
					location = root.location
					save_scope_as = heir2
				}
			}
		}

		hidden_effect = {
			create_character = {
				template = ep3_wallada_heir_template
				culture = location.county.culture
				faith = location.county.faith
				gender_female_chance = 100
				location = root.location
				save_scope_as = heir3
			}
		}
	}

	option = { #Choose heir 1
		name = ep3_story_cycle_violet_poet.0003.a

		set_designated_heir = scope:heir1
		if = {
			limit = {
				scope:heir1 = {
					NOT = { is_courtier_of = root }
				}
			}
			add_courtier = scope:heir1
		}

		adopt_effect = {
			CHILD = scope:heir1
			ADOPTER = root
		}

		stress_impact = {
			base = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 25
		}
	}

	option = { #Choose heir 2
		name = ep3_story_cycle_violet_poet.0003.b

		set_designated_heir = scope:heir2
		if = {
			limit = {
				scope:heir2 = {
					NOT = { is_courtier_of = root }
				}
			}
			add_courtier = scope:heir2
		}

		adopt_effect = {
			CHILD = scope:heir2
			ADOPTER = root
		}

		stress_impact = {
			base = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 25
		}
	}

	option = { #Choose heir 3
		name = ep3_story_cycle_violet_poet.0003.c

		set_designated_heir = scope:heir3
		if = {
			limit = {
				scope:heir3 = {
					NOT = { is_courtier_of = root }
				}
			}
			add_courtier = scope:heir3
		}

		adopt_effect = {
			CHILD = scope:heir3
			ADOPTER = root
		}

		stress_impact = {
			base = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 100 #Prefer the cool one
		}
	}
}

#Passing over things
ep3_story_cycle_violet_poet.0004 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.0004.t
	desc = ep3_story_cycle_violet_poet.0004.desc
	theme = violet_poet
	left_portrait = {
		character = root
		animation = grief
	}
	artifact = {
		target = scope:double_moon_book
		position = lower_center_portrait
	}

	trigger = {
		has_ep3_dlc_trigger = yes
	}

	immediate = {
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}
	}

	option = { #Pass over things
		name = ep3_story_cycle_violet_poet.0004.a

		add_trait = violet_poet

		hidden_effect = { #To avoid redundancy
			if = {
				limit = {
					has_trait = lifestyle_poet
				}
				remove_trait = lifestyle_poet
			}

			###Give them XP in the trait based off a few factors
			#If they're, you know, living up to her standards
			if = {
				limit = {
					any_memory = {
						memory_type = had_sex
						count > 4 
					}
				}
				add_trait_xp = {
					trait = violet_poet
					value = { 4 8 }
				}
			}
			#If they're bi
			if = {
				limit = {
					has_sexuality = bisexual
				}
				add_trait_xp = {
					trait = violet_poet
					value = { 6 10 }
				}
			}
			#If they're not tied down
			if = {
				limit = {
					is_married = no
				}
				add_trait_xp = {
					trait = violet_poet
					value = { 2 4 }
				}
			}
		}

		ai_chance = {
			base = 100
		}
	}
}

## Maintenance events for Write Muwashshah Poem
# Sell Poem
ep3_story_cycle_violet_poet.0010 = {
	hidden = yes

	immediate = {
		send_interface_message = {
			type = event_title_good
			title = ep3_story_cycle_violet_poet.0010.title
			left_icon = root

			if = {
				limit = {
					has_character_modifier = ep3_quality_control_modifier
				}
				add_gold = { medium_gold_laamps_value major_gold_laamps_value }
			}
			else = {
				add_gold = { minor_gold_laamps_value medium_gold_laamps_value }
			}
		}
	}
}

# Keep Poem
ep3_story_cycle_violet_poet.0011 = {
	hidden = yes

	immediate = {
		if = {
			limit = {
				any_character_artifact = {
					has_artifact_modifier = double_moon_modifier
				}
			}
			random_character_artifact = {
				limit = {
					has_artifact_modifier = double_moon_modifier
				}
				save_scope_as = double_moon_book
			}
		}
		send_interface_message = {
			type = msg_poem_kept
			title = ep3_story_cycle_violet_poet.0011.title
			desc = ep3_story_cycle_violet_poet.0011.message
			left_icon = root
			right_icon = scope:double_moon_book

			add_randomised_double_moon_modifier_effect = yes
		}
	}
}

# Distribute Poem
ep3_story_cycle_violet_poet.0012 = {
	hidden = yes

	immediate = {
		send_interface_message = {
			type = event_title_good
			title = ep3_story_cycle_violet_poet.0012.title
			left_icon = root

			if = {
				limit = {
					has_character_modifier = ep3_focused_on_studies_modifier
				}
				add_prestige = { minor_prestige_gain medium_prestige_gain }
			}
			else = {
				add_prestige = { minor_prestige_gain major_prestige_gain }
			}
		}
	}
}

##################################################
# Violet poet Events
# by Nick Meredith & Eilidh MacRuaidhri
##################################################

# Nature's Bounty
# Travel event
ep3_story_cycle_violet_poet.1000 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.1000.t
	desc = ep3_story_cycle_violet_poet.1000.desc
	theme = travel
	override_background = { reference = wilderness }
	left_portrait = {
		character = root
		animation = thinking
	}
	artifact = {
		target = scope:double_moon_book
		position = lower_center_portrait
	}
	cooldown = { years = 30 }

	trigger = {
		has_ep3_dlc_trigger = yes
		is_landless_ruler = yes
		is_available_travelling = yes
		has_trait = violet_poet
		any_character_artifact = {
			has_artifact_modifier = double_moon_modifier
		}
	}

	immediate = {
		location = { save_scope_as = location }
		province:1995 = { save_scope_as = cordoba } # b_cordoba
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}
	}

	option = { #Write a poem
		name = ep3_story_cycle_violet_poet.1000.a

		add_learning_lifestyle_xp = minor_lifestyle_experience

		scope:double_moon_book = {
			set_artifact_description = ep3_story_cycle_violet_poet.1000.a.book
			custom_tooltip = ep3_story_cycle_violet_poet.book.tt
			hidden_effect = {
				add_artifact_modifier = artifact_independent_ruler_opinion_2_modifier
			}
		}

		stress_impact = {
			base = miniscule_stress_impact_loss
			greedy = minor_stress_impact_gain
			content = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
		}
	}

	option = { #Forage for wild plants
		name = ep3_story_cycle_violet_poet.1000.b

		add_character_modifier = {
			modifier = ep3_foraged_plants
			years = 10
		}

		if = {
			limit = {
				NOT = {
					has_trait = lifestyle_herbalist
				}
			}
			random = {
				chance = 30
				add_trait = lifestyle_herbalist
			}
		}

		stress_impact = {
			diligent = miniscule_stress_impact_loss
			greedy = miniscule_stress_impact_loss
			brave = miniscule_stress_impact_loss
			craven = miniscule_stress_impact_gain
			lazy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
		}
	}
}

# A Fine Apprentice
ep3_story_cycle_violet_poet.1005 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.1005.t
	desc = ep3_story_cycle_violet_poet.1005.desc
	theme = violet_poet
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
		animation = eavesdrop
	}
	right_portrait = {
		character = scope:child
		animation = throne_room_conversation_1
	}
	cooldown = { years = 30 }

	trigger = {
		has_ep3_dlc_trigger = yes
		has_trait = violet_poet
		any_character_artifact = {
			has_artifact_modifier = double_moon_modifier
		}
	}

	immediate = {
		location = { save_scope_as = location }
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}
		hidden_effect = {
			create_character = {
				template = peasant_child_character
				culture = location.county.culture
				faith = location.county.faith
				gender_female_chance = 100
				learning = 14
				diplomacy = 16
				age = { 12 14 }
				location = root.location
				save_scope_as = child
			}
		}
	}

	option = { #Take them in
		name = ep3_story_cycle_violet_poet.1005.a

		flavor = ep3_story_cycle_violet_poet.1005.a.tt

		remove_short_term_gold = minor_gold_value

		add_courtier = scope:child

		stress_impact = {
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			callous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 1
				ai_boldness = 1
			}
		}
	}

	option = { #Write a poem about it
		name = ep3_story_cycle_violet_poet.1005.b

		scope:double_moon_book = {
			set_artifact_description = ep3_story_cycle_violet_poet.1005.b.book
			custom_tooltip = ep3_story_cycle_violet_poet.book.tt
			hidden_effect = {
				add_artifact_modifier = artifact_child_opinion_2_modifier
			}
		}

		hidden_effect = {
			scope:child = {
				move_to_pool = yes
			}
		}

		stress_impact = {
			base = miniscule_stress_impact_loss
			diligent = miniscule_stress_impact_loss
			greedy = miniscule_stress_impact_loss
			lazy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_sociability = 1
			}
		}
	}

	option = { #Pay for their tuition
		name = ep3_story_cycle_violet_poet.1005.c

		flavor = ep3_story_cycle_violet_poet.1005.c.tt

		remove_short_term_gold = medium_gold_value

		add_character_modifier = {
			modifier = ep3_tuition_paid
			years = 10
		}

		hidden_effect = {
			scope:child = {
				move_to_pool = yes
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			callous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
			}
		}
	}
}

# The Romance of Poetry
ep3_story_cycle_violet_poet.1010 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.1010.t
	desc = ep3_story_cycle_violet_poet.1010.desc
	theme = violet_poet
	override_background = { reference = corridor_day }
	left_portrait = {
		character = root
		animation = flirtation_left
	}
	right_portrait = {
		character = scope:ruler_spouse
		animation = admiration
	}
	lower_center_portrait = {
		character = scope:ruler
	}
	cooldown = { years = 30 }

	trigger = {
		has_ep3_dlc_trigger = yes
		has_trait = violet_poet
		location.barony.holder = {
			any_spouse = {
				is_attracted_to_gender_of = root
			}
		}
		any_character_artifact = {
			has_artifact_modifier = double_moon_modifier
		}
	}

	immediate = {
		location = { save_scope_as = location }
		location.barony.holder = {
			random_spouse = {
				limit = {
					is_attracted_to_gender_of = root
				}
				save_scope_as = ruler_spouse
			}
			save_scope_as = ruler
		}
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}
	}

	option = { #Offer 'private poetry reading'
		name = ep3_story_cycle_violet_poet.1010.a

		duel = {
			skill = intrigue
			value = decent_skill_rating
			
			50 = { #She's down
				desc = ep3_story_cycle_violet_poet.1010.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
				}

				modifier = {
					attraction >= low_positive_attraction
					factor = 1.2
				}
				modifier = {
					attraction >= medium_positive_attraction
					factor = 1.2
				}
				modifier = {
					attraction >= high_positive_attraction
					factor = 1.2
				}

				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.1010.a.success
					left_icon = root
					right_icon = scope:ruler_spouse

					had_sex_with_effect = {
						CHARACTER = scope:ruler_spouse
						PREGNANCY_CHANCE = pregnancy_chance
					}
				}
			}

			50 = { #She ain't down
				desc = ep3_story_cycle_violet_poet.1010.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
				}

				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.1010.a.failure
					left_icon = root
					right_icon = scope:ruler_spouse

					add_stress = medium_stress_gain

					reverse_add_opinion = {
						target = scope:ruler
						modifier = suspicious_opinion
						opinion = -5
					}
				}
			}
		}

		stress_impact = {
			lustful = minor_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
			seducer = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}

	option = { #Write about it
		name = ep3_story_cycle_violet_poet.1010.b

		scope:double_moon_book = {
			set_artifact_description = ep3_story_cycle_violet_poet.1010.b.book
			custom_tooltip = ep3_story_cycle_violet_poet.book.tt
			hidden_effect = {
				add_artifact_modifier = artifact_seduce_scheme_phase_duration_add_2_modifier
			}
		}

		add_prestige = minor_prestige_gain

		stress_impact = {
			base = miniscule_stress_impact_loss
			shy = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
				ai_sociability = -1
			}
		}
	}

	option = { #Start romance scheme
		name = ep3_story_cycle_violet_poet.1010.c

		trigger = {
			can_start_scheme = {
				type = courting
				target_character = scope:ruler_spouse
			}
		}

		start_scheme = {
			type = courting
			target_character = scope:ruler_spouse
		}

		custom_tooltip = ep3_story_cycle_violet_poet.1010.c.tt

		hidden_effect = {
			random_scheme = {
				type = courting
				limit = {
					scheme_target_character = scope:ruler_spouse
				}
				add_scheme_modifier = {
					type = extra_success_chance_modifier
				}
			}
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			callous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
				ai_sociability = 1
			}
		}
	}
}

# A Follower, Enamored
ep3_story_cycle_violet_poet.1015 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.1015.t
	desc = ep3_story_cycle_violet_poet.1015.desc
	theme = violet_poet
	override_background = { reference = bp1_bonfire }
	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = scope:stranger
		animation = admiration
	}

	cooldown = { years = 30 }

	trigger = {
		has_ep3_dlc_trigger = yes
		has_trait = violet_poet
	}

	immediate = {
		location = { save_scope_as = location }
		create_character = {
			template = beautiful_peasant_character #Make 'em pretty, just for fun
			age = { 30 70 }
			gender_female_chance = root_attraction_based_female_chance
			location = root.location
			faith = root.faith
			culture = root.culture

			after_creation = {
				set_sexuality = bisexual #Screw it
			}

			save_scope_as = stranger
		}
	}

	option = { #Dang, you sit with that ass?
		name = ep3_story_cycle_violet_poet.1015.a

		trigger = {
			has_trait = lustful
		}

		duel = {
			skill = intrigue
			value = decent_skill_rating
			
			50 = { #They're down
				desc = ep3_story_cycle_violet_poet.1015.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
				}

				modifier = {
					attraction >= low_positive_attraction
					factor = 1.2
				}
				modifier = {
					attraction >= medium_positive_attraction
					factor = 1.2
				}
				modifier = {
					attraction >= high_positive_attraction
					factor = 1.2
				}

				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.1015.a.success
					left_icon = root
					right_icon = scope:stranger

					had_sex_with_effect = {
						CHARACTER = scope:stranger
						PREGNANCY_CHANCE = pregnancy_chance
					}
				}
			}

			50 = { #They ain't down
				desc = ep3_story_cycle_violet_poet.1015.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
				}

				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.1015.a.failure
					left_icon = root
					right_icon = scope:stranger
					
					hidden_effect = {
						scope:stranger = {
							move_to_pool = yes
						}
					}

					add_stress = minor_stress_gain
				}
			}
		}

		stress_impact = {
			lustful = minor_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			shy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}

	option = { #Offer them a place in your camp
		name = ep3_story_cycle_violet_poet.1015.b

		reverse_add_opinion = {
			target = scope:stranger
			modifier = grateful_opinion
			opinion = 35
		}

		add_courtier = scope:stranger

		if = {
			limit = {
				NOT = {
					employs_court_position = travel_leader_court_position
				}
			}
			court_position_grant_effect = {
				CANDIDATE = scope:stranger
				POS = travel_leader
				EMPLOYER = root
			}
		}

		stress_impact = {
			lustful = minor_stress_impact_gain
			gregarious = miniscule_stress_impact_loss
			trusting = miniscule_stress_impact_loss
			paranoid = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -0.5
				ai_sociability = 1
			}
		}
	}

	option = { #Take the compliment
		name = ep3_story_cycle_violet_poet.1015.c

		add_character_modifier = {
			modifier = ep3_from_far_and_wide
			years = 10
		}

		scope:stranger = {
			silent_disappearance_effect = yes
		}

		stress_impact = {
			base = minor_stress_impact_loss
			humble = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
				ai_sociability = 1
			}
		}
	}
}

# The Fog that Clouds All
ep3_story_cycle_violet_poet.1020 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.1020.t
	desc = ep3_story_cycle_violet_poet.1020.desc
	theme = violet_poet
	left_portrait = {
		character = root
		animation = stress
	}
	lower_right_portrait = {
		trigger = { scope:poet = { is_alive = yes } }
		character = scope:poet
	}
	artifact = {
		target = scope:double_moon_book
		position = lower_center_portrait
	}

	cooldown = { years = 30 }

	trigger = {
		has_ep3_dlc_trigger = yes
		has_trait = violet_poet
		any_character_artifact = {
			has_artifact_modifier = double_moon_modifier
		}
	}

	immediate = {
		location = { save_scope_as = location }
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}
		if = {
			limit = {
				any_courtier = {
					diplomacy > 20
				}
			}
			random_courtier = {
				limit = {
					diplomacy > 20
				}
				save_scope_as = poet
			}
		}
	}

	option = { #Ask another poet to help
		name = ep3_story_cycle_violet_poet.1020.a
		reason = skilled_follower

		trigger = {
			custom_description = {
				text = followers_over_diplomacy	
				any_courtier = {
					diplomacy > 20
				}
			}
		}
		show_as_unavailable = {
			custom_description = {
				text = followers_over_diplomacy	
				NOT = {
					any_courtier = {
						diplomacy > 20
					}
				}
			}
		}

		scope:double_moon_book = {
			set_artifact_description = ep3_story_cycle_violet_poet.1020.a.book
			custom_tooltip = ep3_story_cycle_violet_poet.book.tt
			hidden_effect = {
				add_artifact_modifier = artifact_personal_scheme_phase_duration_add_2_modifier
			}
		}

		progress_towards_friend_effect = {
			REASON = friend_helped_poetry
			CHARACTER = scope:poet
			OPINION = default_friend_opinion
		}

		stress_impact = {
			base = minor_stress_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	option = { #Try and persevere
		name = ep3_story_cycle_violet_poet.1020.b

		duel = {
			skill = learning
			value = decent_skill_rating
			
			50 = { #It works
				desc = ep3_story_cycle_violet_poet.1020.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}

				scope:double_moon_book = {
					set_artifact_description = ep3_story_cycle_violet_poet.1020.a.book
					custom_tooltip = ep3_story_cycle_violet_poet.book.tt
					hidden_effect = {
						add_artifact_modifier = artifact_personal_scheme_phase_duration_add_2_modifier
					}
				}
			}

			50 = { #She ain't down
				desc = ep3_story_cycle_violet_poet.1020.b.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}

				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.1020.b.failure
					left_icon = root

					add_character_modifier = {
						modifier = ep3_pushed_too_hard
						years = 5
					}
				}
			}
		}

		stress_impact = {
			lazy = medium_stress_impact_gain
			diligent = miniscule_stress_impact_loss
			ambitious = miniscule_stress_impact_loss
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 1
			}
		}
	}

	option = { #Take a break and enjoy life
		name = ep3_story_cycle_violet_poet.1020.c

		random_list = {
			10 = { #It works
				desc = ep3_story_cycle_violet_poet.1020.c.success
				modifier = {
					trigger = {
						has_trait = lazy
					}
					add = 5
				}
				modifier = {
					trigger = {
						has_trait = content
					}
					add = 3
				}
				modifier = {
					trigger = {
						has_trait = calm
					}
					add = 2
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = ep3_story_cycle_violet_poet.1020.c.success
					left_icon = root

					add_character_modifier = ep3_refreshed_and_relaxed
				}
			}
			
			10 = { #Didn't work
				desc = ep3_story_cycle_violet_poet.1020.c.failure
				modifier = {
					trigger = {
						has_trait = diligent
					}
					add = 5
				}
				modifier = {
					trigger = {
						has_trait = ambitious
					}
					add = 3
				}
				modifier = {
					trigger = {
						has_trait = wrathful
					}
					add = 2
				}
				send_interface_toast = {
					type = event_toast_effect_bad
					title = ep3_story_cycle_violet_poet.1020.c.failure
					left_icon = root

					add_stress = medium_stress_gain
				}
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
			}
		}
	}
}

scripted_effect save_the_orphans_effect = {
	add_to_list = list_of_orphans
	if = {
		limit = { exists = scope:orphan3 }
		save_scope_as = orphan4
	}
	else_if = {
		limit = { exists = scope:orphan2 }
		save_scope_as = orphan3
	}
	else = { save_scope_as = orphan2 }
}

#Adopt orphans
ep3_story_cycle_violet_poet.1025 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.1025.t
	desc = ep3_story_cycle_violet_poet.1025.desc
	theme = violet_poet
	override_background = { reference = courtyard }
	left_portrait = {
		character = root
		animation = worry
	}
	right_portrait = {
		character = scope:orphan
		animation = clutching_toy
	}
	lower_center_portrait = {
		character = scope:orphan2
	}
	lower_left_portrait = {
		character = scope:orphan3
	}
	lower_right_portrait = {
		character = scope:orphan4
	}
	cooldown = { years = 30 }

	trigger = {
		has_ep3_dlc_trigger = yes
		has_trait = violet_poet
	}

	immediate = {
		location = { save_scope_as = location }
		scope:location.county.holder = { save_scope_as = holder }
		# Orphan 1
		create_character = {
			template = fp1_capital_county_orphan_character
			culture = location.county.culture
			faith = location.county.faith
			gender_female_chance = 100 #For protege purposes
			location = root.location
			save_scope_as = orphan
		}
		hidden_effect = {
			scope:orphan = {
				add_learning_skill = 5 #Make her an interesting choice
				add_to_list = list_of_orphans
			}
		}
		# Orphans 2-4
		ordered_pool_character = {
			province = root.location
			limit = {
				age < 11
				location = root.location
				is_lowborn = yes
				NOT = { is_in_list = list_of_orphans }
			}
			order_by = age
			max = 3
			check_range_bounds = no
			save_the_orphans_effect = yes
		}
		while = {
			limit = {
				any_in_list = {
					list = list_of_orphans
					count < 4
				}
			}
			create_character = {
				template = fp1_capital_county_orphan_character
				culture = location.county.culture
				faith = location.county.faith
				gender_female_chance = 50
				location = root.location
				save_scope_as = new_orphan
			}
			scope:new_orphan = { save_the_orphans_effect = yes }
		}
	}

	option = { #I'll take them all!
		name = ep3_story_cycle_violet_poet.1025.a

		flavor = ep3_story_cycle_violet_poet.1025.a.tt

		remove_short_term_gold = major_gold_value

		add_courtier = scope:orphan
		add_courtier = scope:orphan2
		add_courtier = scope:orphan3
		add_courtier = scope:orphan4

		every_in_list = {
			list = list_of_orphans
			custom = 1025_every_orphan
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 35
			}
			random = {
				chance = 50
				add_trait = loyal
			}
		}

		add_character_modifier = {
			modifier = ep3_friend_to_orphans
			years = 30
		}

		stress_impact = {
			generous = minor_stress_loss
			compassionate = minor_stress_loss
			greedy = medium_stress_gain
			callous = medium_stress_gain
			sadistic = medium_stress_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_greed = -1
			}
		}
	}

	option = { #Take the actually talented one lol
		name = ep3_story_cycle_violet_poet.1025.b

		flavor = ep3_story_cycle_violet_poet.1025.b.tt

		remove_short_term_gold = minor_gold_value

		add_character_flag = one_orphan_taken_flag

		add_courtier = scope:orphan

		reverse_add_opinion = {
			target = scope:orphan
			modifier = grateful_opinion
			opinion = 45
		}

		random = {
			chance = 50
			send_interface_toast = {
				type = event_toast_effect_good
				title = ep3_story_cycle_violet_poet.1025.b.success
				left_icon = root
				right_icon = scope:orphan
				scope:orphan = {
					add_diplomacy_skill = { 1 3 }
				}
			}
		}

		stress_impact = {
			generous = medium_stress_gain
			compassionate = medium_stress_gain
			greedy = minor_stress_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
				ai_greed = -0.5
			}
		}
	}

	option = { #Try to shame the local lord into paying
		name = ep3_story_cycle_violet_poet.1025.c

		trigger = {
			scope:holder = {
				is_ai = yes
			}
		}

		flavor = ep3_story_cycle_violet_poet.1025.c.tt

		add_character_flag = no_orphans_taken_flag

		duel = {
			skill = diplomacy
			target = scope:holder
			
			50 = { #He accepts
				desc = ep3_story_cycle_violet_poet.1025.c.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				min = 10
				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.1025.c.success
					left_icon = root
					right_icon = scope:holder

					scope:holder = {
						remove_short_term_gold = minor_gold_value
					}

					scope:location.county = {
						add_county_modifier = {
							modifier = ep3_healthy_orphanages_modifier
							years = 20
						}
					}
				}
			}

			50 = { #He declines
				desc = ep3_story_cycle_violet_poet.1025.c.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				min = 10
				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.1025.c.failure
					left_icon = root
					right_icon = scope:holder

					add_stress = medium_stress_gain
				}
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
			}
		}
	}

	after = {
		if = {
			limit = {
				OR = {
					has_character_flag = one_orphan_taken_flag
					has_character_flag = no_orphans_taken_flag
				}
			}
			every_in_list = {
				list = list_of_orphans
				limit = {
					trigger_if = {
						limit = {
							root = { has_character_flag = one_orphan_taken_flag }
						}
						NOT = { scope:orphan ?= this } 
					}
				}
				silent_disappearance_effect = yes
			}
		}		
		remove_character_flag = one_orphan_taken_flag
		remove_character_flag = no_orphans_taken_flag
	}
}

#Tutor a local noblewoman
ep3_story_cycle_violet_poet.1030 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.1030.t
	desc = ep3_story_cycle_violet_poet.1030.desc
	theme = violet_poet
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:noblewoman
		animation = ecstasy
	}
	lower_center_portrait = {
		trigger = { scope:courtier_poet = { is_alive = yes} }
		character = scope:courtier_poet
	}
	cooldown = { years = 30 }

	trigger = {
		has_ep3_dlc_trigger = yes
		has_trait = violet_poet
		location.county = { #Take the county you're in
			any_neighboring_county = { #Now scope to a neighbouring county
				holder = { #and their holder
					OR = {
						any_courtier_or_guest = { #and finally their noble courtiers/guests
							is_lowborn = no
							is_available = yes
							is_healthy = yes
							is_female = yes
							is_physically_able_ai_adult = yes
						}
						any_close_family_member = { #in case there are none, take their family member
							is_lowborn = no
							is_available = yes
							is_healthy = yes
							is_female = yes
							is_physically_able_ai_adult = yes
						}
					}
				}
			}
		}
	}

	immediate = {
		location = { save_scope_as = location }
		location.county.holder = { save_scope_as = holder }
		location.county = { #Take the county you're in
			random_neighboring_county = { #Now scope to a neighbouring county
				limit = {
					holder = {
						OR = {
							any_courtier_or_guest = { #and finally their noble courtiers/guests
								is_lowborn = no
								is_available = yes
								is_healthy = yes
								is_female = yes
								is_physically_able_ai_adult = yes
							}
							any_close_family_member = { #in case there are none, take their family member
								is_lowborn = no
								is_available = yes
								is_healthy = yes
								is_female = yes
								is_physically_able_ai_adult = yes
							}
						}
					}
				}
				save_scope_as = neighbouring_county
				holder = { #and their holder
					if = {
						limit = {
							any_courtier_or_guest = {
								is_lowborn = no
								is_available = yes
								is_healthy = yes
								is_female = yes
								is_physically_able_ai_adult = yes
							}
						}
						random_courtier_or_guest = { #and finally their noble courtiers/guests
							limit = {
								is_lowborn = no
								is_available = yes
								is_healthy = yes
								is_female = yes
								is_physically_able_ai_adult = yes
							}
							save_scope_as = noblewoman
						}
					}
					else = {
						random_close_family_member = { #in case there are none, take their family member
							limit = {
								is_lowborn = no
								is_available = yes
								is_healthy = yes
								is_female = yes
								is_physically_able_ai_adult = yes
							}
							save_scope_as = noblewoman
						}
					}
				}
			}
		}
		if = {
			limit = {
				any_courtier = {
					is_physically_able_ai_adult = yes
					has_trait = lifestyle_poet
				}
			}
			random_courtier = {
				limit = {
					is_physically_able_ai_adult = yes
					has_trait = lifestyle_poet
				}
				save_scope_as = courtier_poet
			}
		}
	}

	option = { #I'll do it!
		name = ep3_story_cycle_violet_poet.1030.a

		scope:noblewoman = {
			pay_short_term_gold = {
				target = root
				gold = major_gold_value
			}
		}

		add_character_modifier = {
			modifier = ep3_tutoring_noblewoman_modifier
			years = 5
		}

		reverse_add_opinion = {
			target = scope:noblewoman
			modifier = pleased_opinion
			opinion = 25
		}

		stress_impact = {
			compassionate = minor_stress_loss
			greedy = minor_stress_loss
			callous = medium_stress_gain
			sadistic = medium_stress_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_greed = 1
			}
		}
	}

	option = { #I cannot spare the time
		name = ep3_story_cycle_violet_poet.1030.b

		add_character_modifier = {
			modifier = ep3_focused_on_studies_modifier
			years = 5
		}

		reverse_add_opinion = {
			target = scope:noblewoman
			modifier = disappointed_opinion
			opinion = -10
		}

		stress_impact = {
			compassionate = medium_stress_gain
			greedy = medium_stress_gain
			callous = minor_stress_loss
			sadistic = minor_stress_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
				ai_greed = -1
			}
		}
	}

	option = { #Perhaps I can offer you a replacement?
		name = ep3_story_cycle_violet_poet.1030.c

		trigger = {
			exists = scope:courtier_poet
		}

		flavor = ep3_story_cycle_violet_poet.1030.c.tt

		scope:noblewoman = {
			pay_short_term_gold = {
				target = root
				gold = minor_gold_value
			}
			pay_short_term_gold = {
				target = scope:courtier_poet
				gold = minor_gold_value
			}
		}

		reverse_add_opinion = {
			target = scope:noblewoman
			modifier = pleased_opinion
			opinion = 10
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
			}
		}
	}
}

### Ibn Zaydun chain
# Whenever darkness falls
ep3_story_cycle_violet_poet.2000 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.2000.t
	desc = ep3_story_cycle_violet_poet.2000.desc
	theme = violet_poet
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:zaydun
		animation = love
	}
	artifact = {
		target = scope:double_moon_book
		position = lower_center_portrait
	}

	cooldown = { years = 100 }

	trigger = {
		has_ep3_dlc_trigger = yes
		has_trait = violet_poet
		character:andalusian_0003 = this
		character:andalusian_0004 = { #Ibn Zaydun
			is_alive = yes
			is_available_ai_adult = yes
		}
		any_character_artifact = {
			has_artifact_modifier = double_moon_modifier
		} 
	}

	immediate = {
		location = { save_scope_as = location }
		character:andalusian_0004 = {
			save_scope_as = zaydun
		}
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}
		scope:zaydun.location = {
			save_scope_as = zaydun_original_location
		}
	}

	option = { #Perhaps I should write him a letter...
		name = ep3_story_cycle_violet_poet.2000.a

		custom_tooltip = ep3_story_cycle_violet_poet.2000.a.tt

		trigger_event = { #Since Ibn Zaydun is AI, just fake the interaction
			id = ep3_story_cycle_violet_poet.2001
			days = { 11 15 }
		}

		stress_impact = {
			brave = minor_stress_impact_loss
			craven = medium_stress_impact_gain
			lustful = miniscule_stress_impact_loss
			chaste = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	option = { #Write a poem in memory of a lost love
		name = ep3_story_cycle_violet_poet.2000.b

		scope:double_moon_book = {
			set_artifact_description = ep3_story_cycle_violet_poet.2000.a.book
			custom_tooltip = ep3_story_cycle_violet_poet.book.tt
			hidden_effect = {
				add_artifact_modifier = artifact_courting_scheme_phase_duration_add_3_modifier
			}
		}

		stress_impact = {
			content = miniscule_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			forgiving = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
				ai_sociability = -1
			}
		}
	}

	option = { #The time has passed
		name = ep3_story_cycle_violet_poet.2000.c

		add_character_modifier = {
			modifier = ep3_star_crossed_modifier
			years = 5
		}

		scope:zaydun = {
			add_character_modifier = {
				modifier = ep3_star_crossed_modifier
				years = 5
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -1
			}
		}
	}
}

ep3_story_cycle_violet_poet.2001 = {
	type = letter_event
	opening = ep3_story_cycle_violet_poet.2001.t
	desc = ep3_story_cycle_violet_poet.2001.desc
	sender = scope:zaydun

	trigger = {
		character:andalusian_0003 = this
		character:andalusian_0004 = { #Ibn Zaydun
			is_alive = yes
			is_available_ai_adult = yes
		}
	}

	immediate = {
		location = { save_scope_as = location }
		character:andalusian_0004 = {
			save_scope_as = zaydun
		}
	}

	option = {
		name = ep3_story_cycle_violet_poet.2001.a
		flavor = ep3_story_cycle_violet_poet.2001.a.flavor
		custom_tooltip = ep3_story_cycle_violet_poet.2001.a.tt


		hidden_effect = {
			scope:zaydun = {
				trigger_event = {
					id = ep3_story_cycle_violet_poet.2002
					days = { 7 14 }
				}
			}
		}
	}

	option = {
		name = ep3_story_cycle_violet_poet.2001.b
		scope:zaydun = {
			add_stress = major_stress_gain
		}
	}
}

ep3_story_cycle_violet_poet.2002 = {
	type = character_event
	hidden = yes

	immediate = {
		character:andalusian_0003 = {
			add_courtier = scope:zaydun
			trigger_event = ep3_story_cycle_violet_poet.2005
		}
	}
}

#He arrives
ep3_story_cycle_violet_poet.2005 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.2005.t
	desc = ep3_story_cycle_violet_poet.2005.desc
	theme = love
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = love
	}
	right_portrait = {
		character = scope:zaydun
		animation = flirtation
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		character:andalusian_0003 = this
		character:andalusian_0004 = { #Ibn Zaydun
			is_alive = yes
			is_available_ai_adult = yes
		}
	}

	immediate = {
		location = { save_scope_as = location }
		character:andalusian_0004 = {
			save_scope_as = zaydun
		}
	}

	option = { #It's him!
	name = ep3_story_cycle_violet_poet.2005.a

		flavor = ep3_story_cycle_violet_poet.2005.a.tt

		add_character_modifier = {
			modifier = ep3_reunited_modifier
			years = 3
		}

		scope:zaydun = {
			add_character_modifier = {
				modifier = ep3_reunited_modifier
				years = 3
			}
		}

		stress_impact = {
			lustful = minor_stress_impact_loss
			chaste = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	option = { #How useful to me!
	name = ep3_story_cycle_violet_poet.2005.b

		add_character_modifier = {
			modifier = ep3_famous_connections_modifier
			years = 5
		}

		reverse_add_opinion = {
			target = scope:zaydun
			modifier = annoyed_opinion
			opinion = -25
		}

		stress_impact = {
			ambitious = minor_stress_impact_loss
			content = medium_stress_impact_gain
			lustful = minor_stress_impact_gain
			chaste = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -1
			}
		}
	}

	after = {
		trigger_event = {
			id = ep3_story_cycle_violet_poet.2010
			days = { 12 18 }
		}
	}
}

#He offers to collaborate on some poetry with you
ep3_story_cycle_violet_poet.2010 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.2010.t
	desc = ep3_story_cycle_violet_poet.2010.desc
	theme = violet_poet
	override_background = { reference = relaxing_room }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:zaydun
		animation = flirtation
	}
	artifact = {
		target = scope:double_moon_book
		position = lower_center_portrait
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		any_character_artifact = {
			has_artifact_modifier = double_moon_modifier
		}
		character:andalusian_0003 = this
		character:andalusian_0004 = { #Ibn Zaydun
			is_alive = yes
			is_available_ai_adult = yes
		}
	}

	immediate = {
		location = { save_scope_as = location }
		random_character_artifact = {
			limit = {
				has_artifact_modifier = double_moon_modifier
			}
			save_scope_as = double_moon_book
		}
	}

	option = { #Agree
	name = ep3_story_cycle_violet_poet.2010.a

		scope:double_moon_book = {
			set_artifact_description = ep3_story_cycle_violet_poet.1020.a.book
			custom_tooltip = ep3_story_cycle_violet_poet.book.tt
			hidden_effect = {
				add_artifact_modifier = artifact_learning_per_prestige_level_modifier
			}
		}

		reverse_add_opinion = {
			target = scope:zaydun
			modifier = pleased_opinion
			opinion = 10
		}

		stress_impact = {
			callous = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			forgiving = minor_stress_impact_loss
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
			}
		}
	}

	option = { #Disagree
	name = ep3_story_cycle_violet_poet.2010.b

		add_character_modifier = {
			modifier = ep3_quality_control_modifier
			years = 10
		}

		reverse_add_opinion = {
			target = scope:zaydun
			modifier = disappointed_opinion
			opinion = -10
		}

		stress_impact = {
			callous = minor_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
			}
		}
	}

	after = {
		trigger_event = {
			id = ep3_story_cycle_violet_poet.2015
			days = { 12 18 }
		}
	}
}

#Ibn Zaydun is about to leave
ep3_story_cycle_violet_poet.2015 = {
	type = character_event
	title = ep3_story_cycle_violet_poet.2015.t
	desc = ep3_story_cycle_violet_poet.2015.desc
	theme = violet_poet
	override_background = { reference = garden }
	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = scope:zaydun
		triggered_animation = {
			trigger = { OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion } }
			animation = acknowledging # anim uses crucifix scepter
		}
		animation = war_over_tie
	}
	artifact = {
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_ep3_dlc_trigger = yes
		character:andalusian_0003 = this
		character:andalusian_0004 = { #Ibn Zaydun
			is_alive = yes
			is_available_ai_adult = yes
		}
	}

	immediate = {
		location = { save_scope_as = location }

		hidden_effect = {
			random_dummy_gender_effect = yes
		 	create_artifact_ring_effect = {
				OWNER = scope:zaydun
				SMITH = scope:dummy_gender
			}
			scope:newly_created_artifact = {
				set_artifact_description = ep3_story_cycle_violet_poet.2015.artifact
				set_artifact_rarity = famed
				add_artifact_modifier = artifact_learn_language_scheme_phase_duration_add_2_modifier
				add_artifact_modifier = artifact_health_gain_1_modifier
				add_artifact_modifier = artifact_stress_gain_3_modifier
				set_owner = root
			}
		}
	}

	option = { #Beg him to stay
	name = ep3_story_cycle_violet_poet.2015.a

		duel = {
			skill = intrigue
			value = decent_skill_rating
			
			75 = { #He accepts
				desc = ep3_story_cycle_violet_poet.2015.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
				}

				modifier = {
					add = 5
					opinion = {
						target = root
						value >= 25
					}
				}
				modifier = {
					add = 10
					opinion = {
						target = root
						value >= 45
					}
				}
				modifier = {
					add = 15
					opinion = {
						target = root
						value >= 65
					}
				}

				modifier = {
					attraction >= low_positive_attraction
					factor = 1.2
				}
				modifier = {
					attraction >= medium_positive_attraction
					factor = 1.2
				}
				modifier = {
					attraction >= high_positive_attraction
					factor = 1.2
				}

				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.2015.a.success
					left_icon = root
					right_icon = scope:zaydun

					add_character_modifier = {
						modifier = ep3_power_couple_modifier
					}

					set_relation_lover = {
						target = scope:zaydun
						reason = lover_old_flame
					}

					scope:zaydun = {
						remove_trait = depressed_1
					}

					add_courtier = scope:zaydun
				}
			}

			25 = { #He declines
				desc = ep3_story_cycle_violet_poet.2015.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
				}

				send_interface_toast = {
					title = ep3_story_cycle_violet_poet.2015.a.failure
					left_icon = root
					right_icon = scope:zaydun

					scope:zaydun = {
						start_travel_plan = {
							destination = scope:zaydun_original_location
							players_use_planner = no
							return_trip = no
						}
					}

					add_stress = major_stress_gain
				}
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_vengefulness = -1
			}
		}
	}

	option = { #Wish him a fond farewell
	name = ep3_story_cycle_violet_poet.2015.b

		flavor = ep3_story_cycle_violet_poet.2015.b.tt

		scope:zaydun = {
			start_travel_plan = {
				destination = scope:zaydun_original_location
				players_use_planner = no
				return_trip = no
			}
		}

		reverse_add_opinion = {
			target = scope:zaydun
			modifier = disappointed_opinion
			opinion = -10
		}

		stress_impact = {
			callous = minor_stress_impact_loss
			vengeful = miniscule_stress_impact_loss
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -0.5
			}
		}
	}

	option = { #Wish him an unfond farewell
	name = ep3_story_cycle_violet_poet.2015.c

		scope:zaydun = {
			start_travel_plan = {
				destination = scope:zaydun_original_location
				players_use_planner = no
				return_trip = no
			}
			add_trait = reclusive
			add_stress = major_stress_gain
		}

		random = {
			chance = 20
			send_interface_toast = {
				title = ep3_story_cycle_violet_poet.2015.c.tt
				left_icon = root
				right_icon = scope:zaydun

				add_trait = contrite
			}
		}

		reverse_add_opinion = {
			target = scope:zaydun
			modifier = emotionally_devastated_opinion
			opinion = -70
		}

		stress_impact = {
			callous = medium_stress_impact_loss
			vengeful = medium_stress_impact_loss
			compassionate = major_stress_impact_gain
			forgiving = major_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
			}
		}
	}
}
