﻿namespace = ep3_travel_events

##################################################
#	EP3 Travel Events
#	by James Beaumont
#
#	8000-8009	To Belong Somewhere

scripted_trigger ep3_travel_8000_valid_prince = {
	is_courtier_of = $PARENT$
	is_adult = yes
	age <= 25
	is_married = no
	could_marry_character_trigger = { CHARACTER = $CHILD$ }
	save_temporary_scope_as = temp_prospective_prince
	matching_gender_and_sexuality_trigger = {
		CHARACTER_1 = scope:temp_prospective_prince
		CHARACTER_2 = $CHILD$
	}
	trait_compatibility = {
		target = $CHILD$
		value >= medium_positive_trait_compatibility
	}
}

scripted_effect ep3_travel_8000_a = {
	scope:prince_parent = {	add_courtier = scope:romantic_child }
	marry_on_realm_law = {
		SPOUSE_1 = scope:prospective_prince
		SPOUSE_2 = scope:romantic_child
	}
}

# To Belong Somewhere
# Young adult child falls in love and wants to stop travelling with you
ep3_travel_events.8000 = { 
	type = character_event
	title = ep3_travel_events.8000.t
	desc = {
		desc = ep3_travel_events.8000.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:romantic_child = {
						ai_boldness >= medium_positive_ai_value
					}
				}
				desc = ep3_travel_events.8000.desc.mid2.bold_child
			}
			desc = ep3_travel_events.8000.desc.mid2.timid_child
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_relation_rival = scope:romantic_child
						opinion = {
							target = scope:romantic_child
							value = low_negative_opinion
						}
					}
				}
				desc = ep3_travel_events.8000.outro.dislikes_child
			}
			desc = ep3_travel_events.8000.outro
		}
	}
	theme = travel
	left_portrait = {
		character = root
	   	triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = sadistic
					has_trait = family_first
					has_trait = diligent
					has_trait = stubborn
				}
			}
			animation = anger
		}
	   	triggered_animation = {
			trigger = {
				OR = {
					has_trait = compassionate
					has_trait = gallant
				}
			}
			animation = wedding_happy_cry
		}
		animation = worry
	}
	right_portrait = {
		character = scope:romantic_child
	   	triggered_animation = {
			trigger = {
				ai_boldness >= medium_positive_ai_value
			}
			animation = beg
		}
	   	triggered_animation = {
			trigger = {
				ai_boldness < medium_positive_ai_value
			}
			animation = sadness
		}
	}
	lower_right_portrait = {
		character = scope:prospective_prince
	}
	cooldown = { years = 75 }
	trigger = {
		has_government = landless_adventurer_government
		is_available_travelling = yes
		is_location_valid_for_travel_event_on_land = yes
		root.location.county.holder = { save_temporary_scope_as = temp_prince_parent }
		any_child = {
			is_courtier_of = root
			is_adult = yes
			age <= 25 # An adult but still young
			save_temporary_scope_as = temp_child
			scope:temp_prince_parent = {
				any_child = {
					ep3_travel_8000_valid_prince = {
						PARENT = scope:temp_prince_parent
						CHILD = scope:temp_child
					}
				}
			}
		}
	}
	immediate = {
		save_scope_as = laamp
		location = {
			save_scope_as = location
			county.holder = { save_scope_as = prince_parent }
		}
		random_child = {
			limit = {
				is_courtier_of = root
				is_adult = yes
				age <= 25
				save_temporary_scope_as = temp_child
				scope:prince_parent = {
					any_child = {
						ep3_travel_8000_valid_prince = {
							PARENT = scope:prince_parent
							CHILD = scope:temp_child
						}
					}
				}
			}
			save_scope_as = romantic_child
			scope:prince_parent = {
				random_child = {
					limit = {
						ep3_travel_8000_valid_prince = {
							PARENT = scope:prince_parent
							CHILD = scope:romantic_child
						}
					}
					save_scope_as = prospective_prince
				}
			}
		}
		scope:romantic_child = {
			set_relation_soulmate = {
				target = scope:prospective_prince
				reason = soulmate_laamp_adventure
			}
		}
	}
	# Goodbye Susan
	option = {
		name = ep3_travel_events.8000.a
		show_as_tooltip = {
			ep3_travel_8000_a = yes
		}
		hidden_effect = {
			scope:prince_parent = {
				trigger_event = {
					id = ep3_travel_events.8001
					days = 1
				}
			}
		}
		scope:romantic_child = {
			progress_towards_friend_effect = {
				CHARACTER = root
				OPINION = 50
				REASON = friend_let_me_go
			}
		}
		stress_impact = {
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
			family_first = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			content = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -1.5
				ai_compassion = 1.5
			}
		}
	}
	# Convince the young prince/princess to come with you!
	option = {
		name = ep3_travel_events.8000.b
		trigger = {
			scope:prince_parent = { is_ai = yes }
			has_trait = eccentric
		}
		add_courtier = scope:prospective_prince
		marry_spouse_1_dominant = {
			SPOUSE_1 = scope:romantic_child
			SPOUSE_2 = scope:prospective_prince
		}
		scope:prince_parent = {
			progress_towards_rival_effect = {
				CHARACTER = root
				OPINION = -50
				REASON = rival_laamp_stole_my_child
			}
		}
		scope:romantic_child = {
			progress_towards_friend_effect = {
				CHARACTER = root
				OPINION = 50
				REASON = friend_let_me_go
			}
		}
		stress_impact = {
			content = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			gallant = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			deceitful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -1.5
				ai_vengefulness = 1.5
				ai_compassion = 1.5
			}
		}
	}
	# Come along now child
	option = {
		name = ep3_travel_events.8000.c
		if = {
			limit = {
				scope:romantic_child = {
					ai_boldness >= medium_positive_ai_value
				}
			}
			reverse_add_opinion = {
				target = scope:romantic_child
				modifier = hate_opinion
				opinion = -25
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:romantic_child
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		stress_impact = {
			content = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			gallant = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			deceitful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1.5
				ai_vengefulness = 1.5
				ai_compassion = -1.5
			}
		}
	}
}

# Roots of My Own
# Holder response
ep3_travel_events.8001 = { 
	type = character_event
	title = ep3_travel_events.8001.t
	desc = ep3_travel_events.8001.desc
	theme = family
	left_portrait = {
		character = root
	   	triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = sadistic
					has_trait = family_first
					has_trait = diligent
					has_trait = stubborn
				}
			}
			animation = anger
		}
	   	triggered_animation = {
			trigger = {
				OR = {
					has_trait = compassionate
					has_trait = gallant
				}
			}
			animation = wedding_happy_cry
		}
		animation = worry
	}
	right_portrait = {
		character = scope:prospective_prince
	   	animation = beg
	}
	lower_right_portrait = {
		character = scope:romantic_child
	}
	immediate = {
		show_as_tooltip = {
			scope:romantic_child = {
				set_relation_soulmate = {
					target = scope:prospective_prince
					reason = soulmate_laamp_adventure
				}
			}
		}
	}
	# A fine match!
	option = {
		name = ep3_travel_events.8001.a
		ep3_travel_8000_a = yes
		stress_impact = {
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
			family_first = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			content = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = -1.5
				ai_compassion = 1.5
			}
		}
	}
	# I forbid this wedding!
	option = {
		name = ep3_travel_events.8001.b
		if = {
			limit = {
				scope:prospective_prince = {
					ai_boldness >= medium_positive_ai_value
				}
			}
			reverse_add_opinion = {
				target = scope:prospective_prince
				modifier = hate_opinion
				opinion = -25
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:prospective_prince
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		hidden_effect = {
			scope:laamp = {
				trigger_event = {
					id = ep3_travel_events.8002
					days = 1
				}
			}
		}
		stress_impact = {
			content = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			gallant = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			deceitful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_rationality = 1.5
				ai_vengefulness = 1.5
				ai_compassion = -1.5
			}
		}
	}
}

# In Another Time
# Laamp notification
ep3_travel_events.8002 = { 
	type = character_event
	title = ep3_travel_events.8002.t
	desc = ep3_travel_events.8002.desc
	theme = family
	left_portrait = {
		character = root
		animation = disappointed
	}
	right_portrait = {
		character = scope:romantic_child
	   	animation = grief
	}
	# I'm sorry my dear
	option = {
		name = ep3_travel_events.8002.a
		reverse_add_opinion = {
			target = scope:romantic_child
			modifier = love_opinion
			opinion = 25
		}
	}
}

# Won't Be Missed
# Do some graverobbing?
ep3_travel_events.8010 = { 
	type = character_event
	title = ep3_travel_events.8010.t
	desc = ep3_travel_events.8010.desc
	theme = travel
	left_portrait = {
		character = root
		animation = survey
	}
	override_background = { reference = ce1_catacombs }
	cooldown = { years = 15 }
	trigger = {
		is_landless_ruler = yes
		is_available_travelling = yes
		location = { has_holding = no }
		is_location_valid_for_travel_event_on_land = yes
	}
	immediate = {
		location = { save_scope_as = location }
	}
	# Oh boy, goodies!
	option = {
		name = ep3_travel_events.8010.a
		duel = {
		 	skill = intrigue
		 	value = medium_skill_rating
		 	25 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				min = 5
				send_interface_toast = {
					title = ep3_travel_events.8010.a.win
					left_icon = root
					add_gold = medium_gold_value
				}
		 	}
		 	25 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				min = 5
				send_interface_toast = {
					title = ep3_travel_events.8010.a.lose
					left_icon = root
			 		reverse_add_opinion = {
			 			target = location.county.holder
			 			modifier = graverobber_opinion
			 			years = 20
			 		}
			 	}
		 	}
		 }
		stress_impact = {
			eccentric = medium_stress_impact_gain
			lazy = minor_stress_impact_gain
			ambitious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1.5
				ai_rationality = 1.5
				ai_greed = 1.5
			}
		}
	}
	# I'm not risking that!
	option = {
		name = ep3_travel_events.8010.b
		stress_impact = {
			content = minor_stress_impact_loss
			ambitious = minor_stress_impact_gain
		}
		add_piety = miniscule_piety_gain
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -1.5
				ai_rationality = -1.5
				ai_greed = -1.5
			}
		}
	}
}
