﻿namespace = gdp_travel_events

#Event adding relevant characters to your travel entourage
gdp_travel_events.0001 = {
	hidden = yes
	trigger = {
		government_has_flag = government_is_merchant
	}
	immediate = {
		every_courtier = {
			limit = {
				is_adult = yes
				is_available_ai = yes
				NOT = { has_court_position = partner_court_position }
				save_temporary_scope_as = gdp_entourage_candidate
				NOT = {
					root = {
						any_scheme = {
							scheme_is_character_agent = scope:gdp_entourage_candidate
						}
					}
				}
			}
			add_to_list = gdp_entourage_members
		}

		every_child = {
			limit = {
				is_available_ai_child = yes
				is_courtier_of = root
			}
			add_to_list = gdp_entourage_members
		}

		ordered_in_list = {
			list = gdp_entourage_members
			order_by = {
				value = 0
				if = {
					limit = {
						OR = {
							has_court_position = fixer_court_position
							has_court_position = translator_court_position
							has_court_position = market_agent_court_position
							has_court_position = bailiff_court_position
						}
					}
					add = 200
				}
				if = {
					limit = { has_trait = merchant_associate }
					add = 100
				}
				if = {
					limit = {
						OR = {
							is_spouse_of = root
							is_close_family_of = root
						}
					}
					add = 50
				}
			}
			max = 10
			check_range_bounds = no
			root.current_travel_plan ?= { add_companion = prev }
		}
	}
}

#Desert Oasis Dilema, Travel Danger
gdp_travel_events.1000 = {
	type = character_event
	title = gdp_travel_events.1000.t
	desc = gdp_travel_events.1000.desc
	theme = travel_danger

	widget = { gui = event_window_widget_vfx_heat_wave container = background_shader_vfx_container }

	override_effect_2d = { reference = legend_glow }

	cooldown = { years = 10 }

	left_portrait = {
		character = scope:entourage_member_one
		animation = divine_ecstasy
		camera = camera_event_center_pointing_right
	}
	right_portrait = {
		character = root
		animation = dromedary_holding
		camera = camera_event_dromedary_holding_right
	}
	
	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		government_has_flag = government_is_merchant		
		location = {
			terrain = desert
			travel_danger_type = {
				travel_plan = root.current_travel_plan
				terrain = desert
			}
		}
		current_travel_plan = { num_entourage_characters > 1 }
	}

	immediate = {
		current_travel_plan = {
			random_entourage_character = {
				save_scope_as = entourage_member_one
			}
		}
		save_scope_value_as = { #For a bit of randomness in the random_list
			name = oasis_value
			value = {
				integer_range = {
					min = 0
					max = 1.5
				}
			}
		}
	}
	#You have enough experience to know where the oasis is 
	option = {
		name = gdp_travel_events.1000.a
		trigger = {
			custom_tooltip = {
				text = low_caravaneer_experience_reason_tooltip
				has_trait_xp = {
					trait = lifestyle_merchant
					track = caravaneer
					value >= 100
				}
			}
		}
		show_as_unavailable = { always = yes }
		current_travel_plan = {
			add_travel_plan_modifier = {
				modifier = gdp_oasis_of_hope_modifier
				months = 10
			}
		}
		stress_and_fulfillment_impact = {
			brave = minor_stress_impact_loss
			impatient = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 50
				OR = {
					has_trait = brave
					has_trait = impatient
				}
			}
		}
	}
	#Take a chance on the oasis being real
	option = {
		name = gdp_travel_events.1000.b

		random_list = {
			# Success it was real
			25 = {
			modifier = {
				factor = 0.5
				has_trait = zealous
			}
			modifier = {
				factor = scope:oasis_value
			}
				desc = gdp_travel_events.1000.b.success
				send_interface_toast = {
					title = gdp_travel_events.1000.b.success
					left_icon = scope:entourage_member_one
					current_travel_plan = {
						add_travel_plan_modifier = {
							modifier = gdp_oasis_of_hope_modifier
							months = 2
						}
					}
					scope:entourage_member_one = {
						add_trait = desert_warrior
					}
				}
			}	
			# Failure it was a mirage
			75 = {
				desc = gdp_travel_events.1000.b.failure
				send_interface_toast = {
					title = gdp_travel_events.1000.b.failure
					left_icon = scope:entourage_member_one
					add_prestige = minor_prestige_loss
					add_trait_xp = {
						trait = lifestyle_merchant
						track = caravaneer
						value = lifestyle_merchant_xp_gain_minor_value
					}
				}
			}
		}
		stress_and_fulfillment_impact = {
			brave = minor_stress_impact_loss
			zealous = medium_stress_impact_loss
			craven = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			impatient = medium_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = impatient
					has_trait = craven
				}
			}
		}
	}
	#Push on despite the heat
	option = {
		name = gdp_travel_events.1000.c
		add_prestige = minor_prestige_gain
		add_trait_xp = {
			trait = lifestyle_merchant
			track = caravaneer
			value = lifestyle_merchant_xp_gain_minor_value
		}

		stress_and_fulfillment_impact = {
			arrogant = minor_stress_impact_loss
			ambitious = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
			sadistic = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			calm = minor_stress_impact_gain
			zealous = medium_stress_impact_gain
		}

		current_travel_plan = {
			add_travel_plan_modifier = {
				modifier = gdp_low_morale_entourage_modifier
				months = 2
			}
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = calm
					has_trait = zealous
				}
			}
		}
	}
}
#Travelers seeking refuge
gdp_travel_events.1010 = {
	type = character_event
	title = gdp_travel_events.1010.t
	desc = gdp_travel_events.1010.desc
	theme = travel
	override_effect_2d = { reference = flies }

	cooldown = { years = 10 }

	left_portrait = {
		character = scope:traveler_child
		animation = clutching_doll
		camera = camera_event_near_angle_345_close
	}
	right_portrait = {
		character = scope:traveler_father
		animation = donkey_standing_baggage
		camera = camera_event_donkey_holding_right
	}
	
	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		government_has_flag = government_is_merchant
	}

	immediate = {
		#Create Traveler family
		#Father
		create_character = {
			template = generic_peasant_character
			location = root.location
			culture = root.location.culture
			faith = root.location.faith
			gender = male
			age = { 29 33 }
			save_scope_as = traveler_father
			after_creation = {
				remove_character_flag = peasant_outfit
				add_character_flag = created
			}
		}
		#Child
		create_character = {
			template = generic_peasant_character
			location = root.location
			culture = root.location.culture
			faith = root.location.faith
			age = { 8 10 }
			father = scope:traveler_father
			save_scope_as = traveler_child
			after_creation = {
				remove_character_flag = peasant_outfit
				add_character_flag = created
			}
		}
	}
	#Let them shelter with you
	option = {
		name = gdp_travel_events.1010.a
		scope:traveler_child = { add_to_court_and_entourage_effect = yes }
		scope:traveler_father = { add_to_court_and_entourage_effect = yes }
		stress_and_fulfillment_impact = {
			compassionate = medium_stress_impact_loss
			generous = minor_stress_impact_loss
			callous = medium_stress_impact_gain
			greedy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 50
			modifier = {
				factor = 0
				OR = {
					has_trait = callous
					has_trait = greedy
				}
			}
			modifier = {
				OR = {
					has_trait = compassionate
					has_trait = generous
				}
				add = 50
			}
		}
	}
	#Let them stay, but they have to pay
	option = {
		name = gdp_travel_events.1010.b
		current_travel_plan = {
			delay_travel_plan = {
				days = 5 
			}
		}
		scope:traveler_father = {
			pay_short_term_gold = {
				target = root
				gold = minor_gold_value
			}
		}
		stress_and_fulfillment_impact = {
			ambitious = minor_stress_impact_loss
			greedy = minor_stress_impact_loss
			generous = medium_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = content
				}
			}
		}
	}
	#Let them stay... if they give you all they have
	option = {
		trigger = {
			has_trait = greedy
		}
		name = gdp_travel_events.1010.c
		current_travel_plan = {
			delay_travel_plan = {
				days = 5 
			}
		}
		scope:traveler_father = {
			pay_short_term_gold = {
				target = root
				gold = major_gold_value
			}
		}
		current_travel_plan = {
			every_entourage_character = {
				custom = custom.every_compassionate_entourage_character
				limit = { has_trait = compassionate }
				add_opinion = {
					target = root
					modifier = cruelty_opinion
					opinion = -15
				}
			}		
		}

		stress_and_fulfillment_impact = {
			ambitious = medium_stress_impact_loss
			greedy = medium_stress_impact_loss
			generous = medium_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = content
				}
			}
			modifier = {
				has_trait = greedy
				add = 100
			}
		}
	}
	#Send them away  
	option = {
		name = gdp_travel_events.1010.d
		
		stress_and_fulfillment_impact = {
			callous = minor_stress_impact_loss
			compassionate = medium_stress_impact_gain
			generous = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = compassionate
					has_trait = greedy
				}
			}
		}
		current_travel_plan = {
			every_entourage_character = {
				custom = custom.every_compassionate_entourage_character
				limit = { has_trait = compassionate }
				add_opinion = {
					target = root
					modifier = cruelty_opinion
					opinion = -15
				}
			}
		}
	}
	after = {
		scope:traveler_father = { silent_disappear_ai_if_not_hired_with_flag = yes }
		scope:traveler_child = { silent_disappear_ai_if_not_hired_with_flag = yes }
	}
}
#What xp you gain for listening to your associate
scripted_effect gdp_associate_lifestyle_xp_gain_effect = {
	if = {
		limit = {
			scope:associate = { has_trait = education_stewardship }
		}
		add_trait_xp = {
			trait = lifestyle_merchant
			track = caravaneer
			value = lifestyle_merchant_xp_gain_medium_value
		}
	}
	else_if = {
		limit = {
			scope:associate = { has_trait = education_learning }
		}
		add_trait_xp = {
			trait = lifestyle_merchant
			track = artisan
			value = lifestyle_merchant_xp_gain_medium_value
		}
	}
	else_if = {
		limit = {
			scope:associate = { has_trait = education_diplomacy }
		}
		add_trait_xp = {
			trait = lifestyle_merchant
			track = caravaneer
			value = lifestyle_merchant_xp_gain_medium_value
		}
	}
	else_if = {
		limit = {
			scope:associate = { has_trait = education_intrigue }
		}
		add_trait_xp = {
			trait = lifestyle_merchant
			track = creditor
			value = lifestyle_merchant_xp_gain_medium_value
		}
	}
	else_if = {
		limit = {
			scope:associate = { has_trait = education_martial }
		}
		add_trait_xp = {
			trait = lifestyle_merchant
			track = creditor
			value = lifestyle_merchant_xp_gain_medium_value
		}
	}
}
# Associate has something interesting to share
gdp_travel_events.1020 = {
	type = character_event
	title = gdp_travel_events.1020.t
	desc = {
		desc = gdp_travel_events.1020.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:associate = { 
						OR = {
							has_trait = education_stewardship
							has_trait = education_diplomacy
						}
					}
				}
				desc = gdp_travel_events.1020.desc.caravaneer
			}
			triggered_desc = {
				trigger = {
					scope:associate = { has_trait = education_learning }
				}
				desc = gdp_travel_events.1020.desc.artisan
			}
			triggered_desc = {
				trigger = {
					scope:associate = {
						OR = {
							has_trait = education_intrigue
							has_trait = education_martial
						}
					}
				}
				desc = gdp_travel_events.1020.desc.creditor
			}
		}
	}
	theme = travel

	cooldown = { years = 10 }

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { char_uses_camel_trigger = yes }
			animation = dromedary_riding
			camera = camera_event_dromedary_left_facing_right
		}
		triggered_animation = {
			trigger = { char_uses_camel_trigger = no }
			animation = donkey_riding
			camera = camera_event_donkey_left_facing_right
		}
		animation = donkey_riding
		camera = camera_event_donkey_left_facing_right
	}
	right_portrait = {
		character = scope:associate
		triggered_animation = {
			trigger = { char_uses_camel_trigger = yes }
			animation = dromedary_riding
			camera = camera_event_dromedary_right_facing_right
		}
		triggered_animation = {
			trigger = { char_uses_camel_trigger = no }
			animation = donkey_riding
			camera = camera_event_donkey_right_facing_right
		}
		animation = donkey_riding
		camera = camera_event_donkey_right_facing_right
	}
	
	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		government_has_flag = government_is_merchant
		current_travel_plan = {
			any_entourage_character = {
				is_adult = yes
				NOT = { this = root }
				is_courtier_of = root
			}
		}
	}

	immediate = {
		current_travel_plan = {
			random_entourage_character = {
				limit = {
					is_adult = yes
					NOT = { this = root }
					is_courtier_of = root
				}
				weight = {
					base = 1
					modifier = {
						add = 25
						has_trait = lifestyle_merchant
					}
				}
				save_scope_as = associate
			}
			departure_location = { save_scope_as = journey_start }
		}
	}
	#Eagerly listen to them
	option = {
		name = gdp_travel_events.1020.a
		scope:associate = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 30
			}
		}
		gdp_associate_lifestyle_xp_gain_effect = yes

		stress_and_fulfillment_impact = {
			ambitious = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = content
				}
			}
		}
	}
	#No no listen to ME instead
	option = {
		name = gdp_travel_events.1020.b
		duel = {
			skills = { diplomacy }
			target = scope:associate
			50 = {
				desc = gdp_travel_events.1020.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = gdp_travel_events.1020.b.success
					left_icon = root
					right_icon = scope:associate
					add_prestige = medium_prestige_gain
					scope:associate = {
						add_opinion = {
							modifier = impressed_opinion
							target = root
							opinion = 15
						}
					}
				}
			}
			50 = {
				desc = gdp_travel_events.1020.b.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = gdp_travel_events.1020.b.failure
					left_icon = root
					right_icon = scope:associate
					add_prestige = minor_prestige_loss
				}
			}
		}

		stress_and_fulfillment_impact = {
			ambitious = minor_stress_impact_loss
			arbitrary = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = arbitrary
					has_trait = content
				}
			}
		}
	}
	#No more talking
	option = {
		name = gdp_travel_events.1020.c
		scope:associate = {
			add_opinion = {
				modifier = hurt_opinion
				target = root
				opinion = -15
			}
		}
		stress_and_fulfillment_impact = {
			callous = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = content
				}
			}
		}
	}
}
#Another associate wants to replace your partner 
gdp_travel_events.1030 = {
	type = character_event
	title = gdp_travel_events.1030.t
	desc = gdp_travel_events.1030.desc
	theme = travel
	
	cooldown = { years = 10 }

	left_portrait = {
		character = scope:ambitious_associate
		triggered_animation = {
			trigger = { char_uses_camel_trigger = yes }
			animation = dromedary_leading
			camera = camera_event_dromedary_leading_left_facing_right
		}
		triggered_animation = {
			trigger = { char_uses_camel_trigger = no }
			animation = donkey_leading
			camera = camera_event_donkey_leading_left_facing_right
		}
		animation = donkey_riding
		camera = camera_event_donkey_leading_left_facing_right
	}
	right_portrait = {
		character = root
		triggered_animation = {
			trigger = { char_uses_camel_trigger = yes }
			animation = dromedary_leading
			camera = camera_event_dromedary_leading_right_facing_right
		}
		triggered_animation = {
			trigger = { char_uses_camel_trigger = no }
			animation = donkey_leading
			camera = camera_event_donkey_leading_right_facing_right
		}
		animation = donkey_riding
		camera = camera_event_donkey_leading_right_facing_right
	}
	lower_left_portrait = {
		character = scope:current_partner
	}
	
	trigger = {
		employs_court_position = partner_court_position
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		government_has_flag = government_is_merchant
	    court_position:partner_court_position = {
	    	house = root.house
	        any_secret = {
	            NOT = { is_known_by = root }
	        }
	    }
		current_travel_plan = {
	        any_entourage_character = {
	            is_ai = yes
	            is_adult = yes
	            NOT = { this = root }
				NOT = { has_court_position = partner_court_position }
	            can_be_employed_as = partner_court_position
	        }
    	}
	}

	immediate = {
	    court_position:partner_court_position ?= {
        	save_scope_as = current_partner
    	}
		scope:current_partner = {
			random_secret = {
				limit = {
					NOT = { is_known_by = root }
				}
				save_scope_as = secret_to_reveal
			}
		}
		current_travel_plan = {
			random_entourage_character = {
				limit = {
					is_ai = yes
					is_adult = yes
					NOT = { this = root }
					NOT = { this = scope:current_partner }
					can_be_employed_as = partner_court_position
				}
				save_scope_as = ambitious_associate
			}
		}
	}
	#Hear them out
	option = {
		name = gdp_travel_events.1030.a

		show_as_tooltip = {
			scope:secret_to_reveal = { reveal_to = root }
		}
		hidden_effect = {
			scope:secret_to_reveal = {
				reveal_to = scope:ambitious_associate
				reveal_to = root
			}
		}
		house = {
			add_unity_value = {
				value = major_unity_loss
				character = root
				desc = gdp_travel_events.1030.a.unity_loss.desc
			}
		}
		add_hook = {
			target = scope:ambitious_associate
			type = obligation_hook
		}
		add_opinion = {
			target = root
			modifier = pleased_opinion
			opinion = 30
		}

		stress_and_fulfillment_impact = {
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = content
				}
			}
		}
	}
	#Dimiss them
	option = {
		name = gdp_travel_events.1030.b
		add_opinion = {
			target = root
			modifier = insult_opinion
			opinion = -10
		}
		house = {
			add_unity_value = {
				value = major_unity_gain
				character = root
				desc = gdp_travel_events.1030.b.unity_gain.desc
			}
		}
		stress_and_fulfillment_impact = {
			ambitious = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = content
				}
			}
		}
	}
}

# DANGER: Unmaintained Well - Party stops at an icky well
gdp_travel_events.1040 = {
	type = character_event
	title = gdp_travel_events.1040.t
	desc = gdp_travel_events.1040.desc
	theme = travel_danger
	
	cooldown = { months = 1 }
	
	right_portrait = {
		character = scope:thirsty_traveler
		animation = sick_stomach
		camera = camera_event_very_right
	}
	left_portrait = {
		character = root
		animation = eyeroll
		camera = camera_event_donkey_left_facing_right
	}

	override_effect_2d = { reference = flies }

	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		location = {
			has_holding = no
			county = { prosperity_level <= bad_prosperity_level }
		}
		current_travel_plan = { num_entourage_characters > 1 }
	}
	
	immediate = {
		current_travel_plan = {
			random_entourage_character = {
				save_scope_as = thirsty_traveler
			}
		}
	}

	option = { # Drink Anyway (Success)
		name = gdp_travel_events.1040.a
		trigger = {
			OR = {
				has_trait = strong
				has_trait = physique_good_1
				has_trait = physique_good_2
				has_trait = physique_good_3
				has_trait = whole_of_body
			}
		}
		stress_and_fulfillment_impact = {
			base = medium_stress_impact_loss
			brave = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
			impatient = minor_stress_impact_loss
		}
		scope:thirsty_traveler = {
			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 15
			}
		}
		ai_chance = {
			base = 1000
		}
	}

	option = { # Purify Water
		name = gdp_travel_events.1040.b
		trigger = {
			trigger_if = {
				limit = {
					has_trait = lifestyle_herbalist
				}
				has_trait = lifestyle_herbalist
			}
			trigger_else = {
				learning >= high_skill_rating
			}
		}
		show_as_unavailable = {
			NOR = {
				learning >= high_skill_rating
				has_trait = lifestyle_herbalist
			}
		}
		if = {
			limit = {
				has_government = landless_adventurer_government
			}
			domicile = {
				change_provisions = minor_provisions_gain
			}
		}
		current_travel_plan = {
			add_travel_plan_modifier = {
				modifier = gdp_pure_waters_modifier
				months = 5
			}
		}
		ai_chance = {
			base = 500
		}
	}

	option = { # Ration Water
		name = gdp_travel_events.1040.c
		trigger = {
			OR = {
				has_trait = logistician
				has_trait = overseer
				has_trait = administrator
				has_trait_xp = {
					trait = lifestyle_merchant
					track = caravaneer
					value >= 50
				}
			}
		}
		show_as_unavailable = {
			NOR = {
				has_trait = logistician
				has_trait = overseer
				has_trait = administrator
				has_trait_xp = {
					trait = lifestyle_merchant
					track = caravaneer
					value >= 50
				}
			}
		}
		current_travel_plan = {
			add_travel_plan_modifier = {
				modifier = gdp_rationing_water_modifier
				months = 3
			}
			every_entourage_character = {
				custom = custom.every_entourage_character
				add_opinion = {
					target = root
					modifier = unimpressed_opinion
					opinion = -10
				}
			}
		}
		ai_chance = {
			base = 60
		}
	}

	option = { # Press On
		name = gdp_travel_events.1040.d
		stress_and_fulfillment_impact = {
			base = medium_stress_impact_gain
		}
		if = {
			limit = {
				has_government = landless_adventurer_government
			}
			domicile = {
				change_provisions = medium_provisions_loss
			}
		}
		add_character_modifier = {
			modifier = gdp_thirsty_traveler_modifier
			months = 6
		}
		ai_chance = {
			base = 10
		}
	}

	option = { # Drink anyway
		name = gdp_travel_events.1040.e
		trigger = {
			NOR = {
				has_trait = strong
				has_trait = physique_good_1
				has_trait = physique_good_2
				has_trait = physique_good_3
				has_trait = whole_of_body
				has_trait = dysentery
			}
		}
		if = { 
			limit = {
				NOT = { has_trait = ill }
			}
			random_list = {
				20 = { # Success
					send_interface_toast = {
						type = event_toast_effect_good
						title = gdp_travel_events.1040.e.success
						left_icon = root
						custom_tooltip = gdp_travel_events.1040.e.success.desc
					}
				}
				60 = { # Failure
					contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
					stress_and_fulfillment_impact = {
						paranoid = minor_stress_impact_gain
					}
				}
				20 = { # Critical Failure
					contract_disease_effect = { DISEASE = dysentery TREATMENT_EVENT = yes }
					stress_and_fulfillment_impact = {
						paranoid = minor_stress_impact_gain
					}
				}
			}
		}
		else = {
			random_list = {
				50 = { # Success
					send_interface_toast = {
						type = event_toast_effect_good
						title = gdp_travel_events.1040.e.success
						left_icon = root
						custom_tooltip = gdp_travel_events.1040.e.success.desc
					}
				}
				50 = { # Critical Failure
						if = {
							limit = {
								has_trait = ill
							}
							hidden_effect = {
								recover_from_disease_effect = { DISEASE = ill }
								remove_disease_treatment_effect = yes
							}
							custom_tooltip = gdp_travel_events.1040.e.critical_failure.tt
						}
					add_trait_force_tooltip = dysentery
					contract_disease_effect = { DISEASE = dysentery TREATMENT_EVENT = yes }
					stress_and_fulfillment_impact = {
						paranoid = minor_stress_impact_gain
					}
				}
			}
		}
		ai_chance = {
			base = 1
			modifier = {
				has_trait = ill
				has_trait = paranoid
				add = -100
			}
		}
	}
}

# DANGER: Toppled Timber - The road is blocked by fallen trees
gdp_travel_events.1050 = {
	type = character_event
	title = gdp_travel_events.1050.t
	desc = gdp_travel_events.1050.desc
	theme = travel_danger
	
	cooldown = { months = 1 }
	

	right_portrait = {
		character = scope:local_worker
		animation = marshal_axe
		camera = camera_event_right_pointing_right
		hide_info = yes
	}

	left_portrait = {
		character = root
		animation = throne_room_conversation_3
		camera = camera_event_very_left
	}

	override_effect_2d = { reference = rain }

	trigger = {
		is_available_travelling = yes
		location = {
			OR = {
				terrain = forest
				terrain = jungle
			}
			OR = {
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = forest
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = jungle
				}
			}
		}
		NOT = {
			current_season_trigger = { SEASON = dry_season }
		}
	}	

	weight_multiplier = {
		base = 1
		modifier = {
			current_season_trigger = { SEASON = rainy_season }
			add = 2
		}
	}

	immediate = {
		create_character = {
			template = generic_peasant_character
			location = root.location
			culture = root.location.culture
			faith = root.location.faith
			gender = male
			age = { 19 35 }
			save_scope_as = local_worker
			after_creation = {
				remove_character_flag = peasant_outfit
				add_character_flag = created
			}
		}
	}

	option = { # Warhorse Aid
		name = gdp_travel_events.1050.x
		trigger = {
			any_owned_story = { story_type = story_cycle_martial_lifestyle_warhorse }
		}
		add_prestige = medium_prestige_gain
		add_martial_lifestyle_xp = medium_lifestyle_xp
		ai_chance = {
			base = 1000
		}
	}

	option = { # Get to Chopping
		name = gdp_travel_events.1050.a
		trigger = {
			OR = {
				has_trait = whole_of_body
				has_trait = athletic
				has_trait = giant
				has_trait = strong
				has_trait = physique_good_1
				has_trait = physique_good_2
				has_trait = physique_good_3
			}
		}
		show_as_unavailable = {
			NOR = {
				has_trait = whole_of_body
				has_trait = athletic
				has_trait = giant
				has_trait = strong
				has_trait = physique_good_1
				has_trait = physique_good_2
				has_trait = physique_good_3
			}
		}
		add_prowess_skill = 1
		add_character_modifier = {
			modifier = gdp_workout_modifier
			months = 6
		}
		current_travel_plan = {
			every_entourage_character = {
				custom = custom.every_entourage_character
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 10
				}
			}
		}
		stress_and_fulfillment_impact = {
			diligent = minor_stress_impact_loss
			athletic = minor_stress_impact_loss
			arrogant = minor_stress_impact_gain
			impatient = minor_stress_impact_loss
			stubborn = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 500
			modifier = {
				add = 500
				OR = {
					has_trait = diligent
					has_trait = athletic
					has_trait = impatient
					has_trait = stubborn
				}
			}
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = lazy
				}
				add = -1000
			}
		}
	}

	option = { # Study the Workers
		name = gdp_travel_events.1050.b
		trigger = {
			has_trait = lifestyle_merchant
			learning >= 10
		}
		show_as_unavailable = {
			OR = {
				has_government = landless_adventurer_government
				has_trait = lifestyle_merchant
			}
		}
		# Add Carpentries Experience
		primary_title = {
			add_trade_good_category_xp = {
				target = trade_good_category:trade_category_carpentry_supplies
				value = trade_expertise_xp_monumental_value
			}
		}
		current_travel_plan = { delay_travel_plan = { days = 50 } }
		stress_and_fulfillment_impact = {
			impatient = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 80
			modifier = {
				factor = 0
				OR = {
					has_trait = impatient
					has_trait = lazy
					exists = involved_activity
				}
			}
		}
	}

	option = { # Find Alternative Route
		name = gdp_travel_events.1050.c
		trigger = {
			trigger_if = {
				limit = { 
					has_trait = lifestyle_traveler
					has_trait_xp = {
						trait = lifestyle_traveler
						track = danger
						value >= 50
					} 
				}
				has_trait = lifestyle_traveler
			}
		}
		random_list = {
			50 = { # Success
				modifier = {
					has_trait_xp = {
						trait = lifestyle_traveler
						track = danger
						value >= 50
					}
					add = 150
				}
				send_interface_toast = {
					type = event_toast_effect_good
					title = gdp_travel_events.1050.c.success
					left_icon = root
					if = {
						limit = {
							NOT = {
								has_trait = lifestyle_traveler
							}
						}
						add_trait = lifestyle_traveler
					}
					else_if = {
						limit = {
							has_trait_xp = {
								trait = lifestyle_traveler
								track = danger
								value >= 100
							}
						}
						add_stress = minor_stress_loss
					}
					else = {
						add_trait_xp = {
							trait = lifestyle_traveler
							track = danger
							value = 15
						}
					}
				}
			}
			50 = { # Failure
				increase_wounds_effect = { REASON = accident }
				send_interface_toast = {
					type = event_toast_effect_bad
					title = gdp_travel_events.1050.c.failure
					left_icon = root
				}
				stress_and_fulfillment_impact = {
					base = minor_stress_impact_gain
				}
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				ai_boldness >= high_positive_ai_value
				add = 100
			}
			modifier = {
				has_trait_xp = {
					trait = lifestyle_traveler
					track = danger
					value >= 50
				}
				add = 1000
			}
		}
	}

	option = { # Wait it Out
		name = gdp_travel_events.1050.d
		current_travel_plan = { delay_travel_plan = { days = 20 } }
		stress_and_fulfillment_impact = {
			base = minor_stress_impact_gain
		}
		if = {
			limit = {
				has_government = landless_adventurer_government
			}
			domicile = {
				change_provisions = minor_provisions_loss
			}
		}
		ai_chance = {
			base = 30
			modifier = {
				factor = 0
				exists = involved_activity
			}
		}
	}

	after = {
		scope:local_worker = { silent_disappearance_ai_if_created_effect = yes }
	}
}

# DANGER: Rats in the Hold - Rats are gnawing on the ship's supplies
gdp_travel_events.1060 = {
	type = character_event
	title = gdp_travel_events.1060.t
	desc = gdp_travel_events.1060.desc
	theme = travel_danger
	
	cooldown = { months = 1 }

	right_portrait = {
		character = scope:entourage_member_one
		animation = fear
		camera = camera_event_right_forward
	}

	left_portrait = {
		character = root
		animation = worry
		camera = camera_event_center
	}

	trigger = {
		is_available_travelling = yes
		location = {
			OR = {
				terrain = sea
				terrain = coastal_sea
			}
			OR = {
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = sea
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = coastal_sea
				}
			}
		}
		current_travel_plan = { num_entourage_characters > 1 }
	}

	immediate = {
		if = {
			random_courtier_or_guest = {
				limit = {
					is_of_major_interest_trigger = { CHARACTER = root }
				}
				save_scope_as = entourage_member_one
			}
		}
		else_if = {
			limit = { exists = current_travel_plan.travel_leader }
			current_travel_plan.travel_leader = { save_scope_as = entourage_member_one }
		}
		else = {
			current_travel_plan = {
				random_entourage_character = {
					save_scope_as = entourage_member_one
				}
			}
		}
	}

	option = { # Release the Cat
		name = gdp_travel_events.1060.x
		trigger = {
			any_owned_story = { story_type = story_cycle_pet_cat }
		}
		current_travel_plan = {
			every_entourage_character = {
				custom = custom.every_entourage_character
				add_opinion = {
					target = root
					modifier = impressed_opinion
					opinion = 10
				}
				add_character_modifier = {
					modifier = gdp_cat_rats_modifier
					years = 5
				}
			}
		}
		ai_chance = {
			base = 1000
		}

	}

	option = { # Hunter: Go Fishing
		name = gdp_travel_events.1060.a
		trigger = {
				has_trait = lifestyle_hunter
		}
		show_as_unavailable = {
			NOT = {
				has_trait = lifestyle_hunter
			}
		}
		add_trait_xp = {
			trait = lifestyle_hunter
			track = hunter
			value = 5
		}
		if = {
			limit = {
				has_government = landless_adventurer_government
			}
			domicile = {
				change_provisions = minor_provisions_gain
			}
		}
		stress_and_fulfillment_impact = {
			base = minor_stress_impact_loss
			calm = minor_stress_impact_loss
			eccentric = minor_stress_impact_loss
		}
		if = {
			limit = {
				has_trait = lifestyle_merchant
			}
			add_character_modifier = {
				modifier = gdp_fishing_modifier
				years = 5
			}
		}
		ai_chance = {
			base = 1000
			modifier = {
				OR = {
					has_trait = calm
					has_trait = eccentric
				}
				add = 1000
			}
		}
	}

	option = { # Cereals Expertise: Arrange Proper Storage
		name = gdp_travel_events.1060.b
		trigger = {
			has_trait = lifestyle_merchant
			custom_tooltip = {
				text = gdp_travel_events.1060.b.tt
				primary_title = {
					trade_good_category_xp = {
						target = trade_good_category:trade_category_cereals
						value >= 25
					}
				}
			}
		}
		show_as_unavailable = {
			OR = {
				has_government = landless_adventurer_government
				has_trait = lifestyle_merchant
			}
		}
		primary_title = {
			add_trade_good_category_xp = {
				target = trade_good_category:trade_category_cereals
				value = 300 # 2 levels
			}
		}
		stress_and_fulfillment_impact = {
			lazy = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
			diligent = minor_stress_impact_loss
		}
		ai_chance = {
			base = 1000
			modifier = {
				OR = {
					has_trait = lazy
					has_trait = paranoid
				}
				add = -1000
			}
			modifier = {
				has_trait = diligent
				add = 1000
			}
		}
	}

	option = { # Restock at Shore
		name = gdp_travel_events.1060.c
		remove_short_term_gold = minor_gold_value
		stress_and_fulfillment_impact = {
			greedy = medium_stress_impact_gain
			arrogant = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			generous = minor_stress_impact_loss
			forgiving = minor_stress_impact_loss
			profligate = minor_stress_impact_loss
		}
		ai_chance = {
			base = 1
			modifier = {
				OR = {
					has_trait = greedy
					has_trait = arrogant
					has_trait = impatient
				}
				add = -100
			}
			modifier = {
				has_trait = generous
				has_trait = forgiving
				has_trait = profligate
				add = 100
			}
			modifier = {
				exists = involved_activity
				add = -1000
			}
		}
	}

	option = { # Catch Rats
		name = gdp_travel_events.1060.d
		current_travel_plan = {
			every_entourage_character = {
				custom = custom.every_entourage_character
				add_character_modifier = {
					modifier = gdp_catch_rats_modifier
					years = 5
				}
				add_opinion = {
					target = root
					modifier = angry_opinion
					opinion = -10
				}
			}
		}
		stress_and_fulfillment_impact = {
			arrogant = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			sadistic = medium_stress_impact_loss
			compassionate = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_trait = arrogant
					has_trait = lazy
					has_trait = wrathful
					has_trait = callous
					has_trait = sadistic
				}
				add = 300
			}
			modifier = {
				has_trait = compassionate
				has_trait = just
				add = -1000
			}
		}
	}
}

# High-Stakes Bartering: Bandits smell gold
gdp_travel_events.1070 = {
	type = character_event
	title = gdp_travel_events.1070.t
	desc = gdp_travel_events.1070.desc
	theme = widgetless_travel_danger
	right_portrait = {
		character = scope:bandit_leader
		animation = horse_archer_aggressive
		camera = camera_event_right_to_the_right_more_right
	}
	override_background = { reference = wilderness }

	trigger = {
		is_available_travelling_adult = yes
		is_playable_character = yes
		is_location_valid_for_travel_event_on_land = yes
		exists = var:local_deals_last_haggle_gold
		current_travel_plan ?= { has_travel_option = adventurers_make_local_deals_option }
		location = {
			travel_danger_type = {
				travel_plan = root.current_travel_plan
				type = county_control
			}
		}
	}

	immediate = {
		mp_delay_travel_plan = { DAYS = 90 }
		add_character_flag = {
			flag = local_deals_haggle_bandit_cooldown
			days = 120
		}
		traveler_danger_xp_effect = {
			MIN = 2
			MAX = 5
		}
		if = {
			limit = {
				any_pool_character = {
					province = root.location
					is_physically_able_ai_adult = yes
					prowess >= medium_skill_rating
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					is_physically_able_ai_adult = yes
					prowess >= medium_skill_rating
				}
				save_scope_as = bandit_leader
			}
		}
		else = {		
			create_character = {
				template = bandit_character
				location = root.location
				culture = root.location.culture
				faith = root.location.faith
				save_scope_as = bandit_leader
				after_creation = {
					add_character_flag = created
				}
			}
		}
		scope:bandit_leader = { add_character_flag = need_military_outfit }
	}

	option = { # You wanna mess with my Charter holder?
		name = gdp_travel_events.1070.a
		trigger = {
			merchant_has_usable_charter_trigger = {
				ONLY_EQUIPPED = yes
				INCLUDE_FORGERIES = no
			}
		}
		reason = charter
		send_interface_toast = {
			title = gdp_travel_events.1070.a.success
			left_icon = root
			add_prestige = medium_prestige_gain
		}
		ai_chance = {
			base = 1000
		}
	}

	option = { #Intimidate
		name = gdp_travel_events.1070.b
		duel = {
			skills = { martial prowess }
			value = decent_skill_rating
			10 = {
				desc = gdp_travel_events.1070.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1
					min = -49
				}
				modifier = { add = current_travel_plan.num_entourage_characters }
				modifier = { 
					add = {
						value = current_travel_plan.travel_safety
						divide = 20
					} 
				}
				modifier = {
					add = {
						value = dread
						divide = 4
					}
				}
				send_interface_toast = {
					title = travel_danger_events.6010.c.success
					left_icon = root
					add_prestige = medium_prestige_gain
				}
			}
			10 = {
				desc = gdp_travel_events.1070.b.failure
				min = 3
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = -49
				}
				remove_short_term_gold = local_deals_bandit_demand_gold_value
				random = {
					chance = 50
					custom_tooltip = travel_danger_events.6010.c.wound
					hidden_effect = {
						current_travel_plan = {
							random_entourage_character = {
								limit = { is_adult = yes }
								weight = {
									base = 1
									modifier = { add = prowess }
									modifier = {
										add = 10
										has_court_position = bodyguard_court_position
									}
									modifier = {
										add = 10
										has_court_position = akolouthos_court_position
									}
									modifier = {
										add = 10
										is_knight_of = root
									}
								}
								save_scope_as = woundee
							}
						}
						if = {
							limit = { exists = scope:woundee }
							send_interface_toast = {
								title = travel_danger_events.6010.c.wound
								left_icon = scope:woundee
								scope:woundee = {
									increase_wounds_effect = { REASON = battle }
								}
							}
						}
					}
				}
			}
		}
		stress_and_fulfillment_impact = {
			craven = medium_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = craven
			}
		}
	}

	option = { # Just... take it.
		name = gdp_travel_events.1070.c
		remove_short_term_gold = local_deals_bandit_demand_gold_value
		stress_and_fulfillment_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_boldness = -0.5
			}
			modifier = {
				factor = 0
				gold < local_deals_bandit_demand_gold_value
			}
		}
	}

	after = {
		mp_resume_travel_plan = yes
		remove_variable = local_deals_last_haggle_gold
		scope:bandit_leader = { silent_disappearance_ai_if_created_effect = yes }
	}
}

gdp_travel_events.2000 = {
	type = character_event
	title = gdp_travel_events.2000.t
	desc = gdp_travel_events.2000.desc
	theme = travel
	override_background = { reference = pam_romanesque_church_exterior }

	left_portrait = {
		character = root
		animation = shock
	}
	
	right_portrait = {
		character = scope:mason
		animation = ecstasy
	}

	trigger = {
		location = {
			has_variable = tower_of_pisa_to_inspect
			has_building = tower_of_pisa
			province_owner = root
		}
	}

	immediate = {
		location = { save_scope_as = pisa_province }
		hidden_effect = {
			scope:pisa_province = { tower_of_pisa_lean_effect = yes }
		}
		pan_camera_to_province = scope:pisa_province
		random_pool_character = {
			province = scope:pisa_province
			limit = {
				is_available_ai_adult = yes
				stewardship >= excellent_skill_level
			}
			save_scope_as = mason
		}
		if = {
			limit = {
				NOT = { exists = scope:mason }
			}
			create_character = {
				template = foreign_architect_template
				culture = scope:pisa_province.culture
				faith = scope:pisa_province.faith
				rite = scope:pisa_province.rite
				gender_female_chance = location_faith_dominant_gender_female_chance
				location = scope:pisa_province
				save_scope_as = mason
			}
			scope:mason = { add_character_flag = created }
		}
	}

	option = {
		name = gdp_travel_events.2000.a
		custom_tooltip = tower_of_pisa_leans_tt
		add_prestige = minor_prestige_gain
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = gdp_travel_events.2000.b
		custom_tooltip = tower_of_pisa_leans_tt
		add_courtier = scope:mason
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:mason = { silent_disappear_ai_if_not_hired_with_flag = yes }
	}
}

gdp_travel_events.2001 = {
	type = character_event
	hidden = yes

	immediate = {
		scope:tower_of_pisa_province ?= { tower_of_pisa_lean_effect = yes }
	}
}

scripted_effect tower_of_pisa_go_see_effect = {
	if = {
		limit = { location = scope:tower_of_pisa_province }
		trigger_event = gdp_travel_events.2000
	}
	else = {
		start_travel_plan = {
			destination = scope:tower_of_pisa_province
			on_arrival_event = gdp_travel_events.2000
			on_travel_planner_cancel_event = gdp_travel_events.2004
		}
	}
}

gdp_travel_events.2002 = {
	type = letter_event
	opening = gdp_travel_events.2002.opening
	desc = gdp_travel_events.2002.desc
	sender = {
		character = scope:tower_of_pisa_messenger
		animation = worry
	}

	# Go and see it
	option = {
		name = gdp_travel_events.2002.a
		trigger = {
			OR = {
				location = scope:tower_of_pisa_province
				is_travelling = no
			}
		}
		show_as_unavailable = { always = yes }
		tower_of_pisa_go_see_effect = yes
		ai_chance = {
			base = 100
		}
	}

	# Leave it be
	option = {
		name = gdp_travel_events.2002.b
		custom_tooltip = tower_of_pisa_leans_tt
		hidden_effect = {
			scope:tower_of_pisa_province = { tower_of_pisa_lean_effect = yes }
		}
		ai_chance = {
			base = 100
		}
	}
}

gdp_travel_events.2003 = {
	type = letter_event
	window = anonymous_letter_event
	opening = gdp_travel_events.2002.opening
	desc = gdp_travel_events.2002.desc
	sender = root

	option = {
		name = gdp_travel_events.2002.a
		trigger = {
			OR = {
				location = scope:tower_of_pisa_province
				is_travelling = no
			}
		}
		show_as_unavailable = { always = yes }
		tower_of_pisa_go_see_effect = yes
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = gdp_travel_events.2002.b
		custom_tooltip = tower_of_pisa_leans_tt
		hidden_effect = {
			scope:tower_of_pisa_province = { tower_of_pisa_lean_effect = yes }
		}
		ai_chance = {
			base = 100
		}
	}
}

gdp_travel_events.2004 = {
	type = character_event
	hidden = yes

	immediate = {
		every_directly_owned_province = {
			limit = { has_variable = tower_of_pisa_to_inspect }
			tower_of_pisa_lean_effect = yes
		}
	}
}
