﻿namespace = travel_danger_events

##########################################################
# Travel Danger Terrain Events							#
# travel_danger_events - 1000-1999						#
# by Chad Uhl								 			#
##########################################################

travel_danger_events.1000 = { # Hills Terrain - Mounts get tired
	type = character_event
	title = travel_danger_events.1000.t
	desc = travel_danger_events.1000.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = worry
	}

	right_portrait = {
		character = scope:travel_leader
		animation = pain
	}
	
	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes

		location = {
			travel_danger_type = {
				travel_plan = root.current_travel_plan
				terrain = hills
			}
		}

		current_travel_plan = {
			exists = travel_leader 
		}
	}

	cooldown = { months = 1 }

	immediate = {
		mp_delay_travel_plan = { DAYS = 90 }
		current_travel_plan = {
			travel_leader = { save_scope_as = travel_leader }
			# save destination scope 
			next_destination_province = { save_scope_as = destination }
		}
		traveler_danger_xp_effect = {
			MIN = 1
			MAX = 3
		}
	}

	option = { # Stop to rest
		name = travel_danger_events.1000.a
		current_travel_plan = {
			delay_travel_plan = {
				days = 10 
			}
		}
		scope:travel_leader = {
			add_opinion = {
				target = root 
				modifier = pleased_opinion
				opinion = 10
			}
		}
	}

	option = { # Press onward
		name = travel_danger_events.1000.b
		scope:travel_leader = {
			add_opinion = {
				target = root 
				modifier = dismissive_opinion
				opinion = -20
			}
		}
		hidden_effect = {
			random = {
				chance = 25
				trigger_event = {
					id = travel_danger_events.1001
					days = 5
				}
			}
		}
	}

	after = {
		mp_resume_travel_plan = yes
	}
}

travel_danger_events.1001 = { # Hills Terrain - Mounts get tired follow-up
	type = character_event
	title = travel_danger_events.1001.t
	desc = travel_danger_events.1001.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = stress
	}

	right_portrait = {
		character = scope:travel_leader
		animation = schadenfreude
	}
	
	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		# Check that we haven't arrived yet
		exists = current_travel_plan.next_destination_province
		NOT = { location = current_travel_plan.next_destination_province }
	}

	immediate = {
		mp_delay_travel_plan = { DAYS = 90 }
		current_travel_plan = {
			next_destination_province = { save_scope_as = destination }
		}
		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
	}

	option = { # Buy new mounts
		name = travel_danger_events.1001.a
		current_travel_plan = { delay_travel_plan = { days = 5 } }
		remove_short_term_gold = minor_gold_value
	}

	option = { # Go on foot
		name = travel_danger_events.1001.b
		current_travel_plan = {
			add_travel_plan_modifier = travel_walking_modifier
			every_entourage_character = {
				add_opinion = {
					target = root 
					modifier = hate_opinion
					opinion = -30
				}
			}
		}
	}

	after = {
		mp_resume_travel_plan = yes
	}
}

travel_danger_events.1002 = { # Mountain Terrain - Bandits
	type = character_event
	title = travel_danger_events.1002.t
	desc = travel_danger_events.1002.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = fear
	}

	right_portrait = {
		character = scope:bandit
		animation = threatening
	}
	
	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		location = {
			travel_danger_type = {
				travel_plan = root.current_travel_plan
				terrain = mountains
			}
		}
		NOR = {
			has_character_flag = had_travel_event_1003_bandit_event_recently
			has_character_flag = had_travel_event_3070_bandit_event_recently
		}
	}

	cooldown = { months = 1 }

	weight_multiplier = {
		base = 1
	}

	immediate = {
		wayfarer_storyteller_fame_effect = { VALUE = roaming_reward_fame_medium }
		mp_delay_travel_plan = { DAYS = 90 }
		current_travel_plan = {
			ordered_entourage_character = {
				order_by = stewardship
				save_scope_as = travel_leader
			}
			current_location = { save_scope_as = current_location }
		}
		# find head bandit
		random_pool_character = {
			province = root.location
			limit = {
				is_available_ai_adult = yes
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = THIS }
			}
			save_scope_as = bandit
			add_character_flag = wear_armor
		}
		if = { #As a backup create the character
			limit = {
				NOT = { exists = scope:bandit }
			}
			hidden_effect = {
				create_character = {
					template = new_warrior_character
					gender_female_chance = location_faith_dominant_gender_female_chance
					location = root.location
					culture = root.location.culture
					faith = root.location.faith
					save_scope_as = bandit
					after_creation = { #Unop Add created flag so we could only disappear created characters
						add_character_flag = created
					}
				}
				scope:bandit = {
					move_to_pool = yes
				}
			}
		}
		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
		add_character_flag = {
			flag = had_travel_danger_event_1002_bandit_event_recently
			years = 5
		}
	}

	option = { # special guard option
		name = travel_danger_events.1002.c
		trigger = {
			current_travel_plan = {
				OR = {
					has_travel_option = hire_experienced_mercenaries_option
					has_travel_option = military_recruits_option
				}
			}
		}
		custom_tooltip = travel_danger_events.1002.c.tt
		ai_chance = {
			base = 1000
		}
	}

	option = { # persuade him to let you pass - diplomacy
		name = travel_danger_events.1002.a
		
		trigger = {
			diplomacy >= 16
		}
		skill = diplomacy

		duel = {
			skill = diplomacy
			value = medium_skill_rating
			50 = {
				desc = travel_danger_events.1002.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = travel_danger_events.1002.a.success 
					left_icon = root 
					right_icon = scope:bandit
					custom_tooltip = travel_danger_events.1002.a.success.desc
					add_prestige = minor_prestige_gain
				}
			}
			50 = {
				desc = travel_danger_events.1002.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = travel_danger_events.1002.a.failure
					left_icon = root 
					right_icon = scope:bandit
					custom_tooltip = travel_danger_events.1002.a.failure.desc
					remove_short_term_gold = medium_gold_value
				}
			}
		}
	}

	option = { # battle them - prowess
		name = travel_danger_events.1002.b
		skill = prowess

		duel = {
			skill = prowess
			target = scope:bandit
			50 = {
				desc = travel_danger_events.1002.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -49
				}
				send_interface_toast = {
					title = travel_danger_events.1002.b.success 
					left_icon = root 
					right_icon = scope:bandit
					custom_tooltip = travel_danger_events.1002.b.success.desc
					add_gold = minor_gold_value
					add_prestige = minor_prestige_gain
				}
			}
			50 = {
				desc = travel_danger_events.1002.b.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -49
				}
				send_interface_toast = {
					title = travel_danger_events.1002.b.failure
					left_icon = root 
					right_icon = scope:bandit
					custom_tooltip = travel_danger_events.1002.b.failure.desc
					remove_short_term_gold = medium_gold_value
					increase_wounds_effect = { REASON = fight }
				}
			}
		}
	}

	option = { # hire guide
		name = travel_danger_events.1002.d
		trigger = {
			current_travel_plan = {
				NOT = { has_travel_plan_modifier = travel_guide_modifier }
			}
			stewardship >= 10
		}
		skill = stewardship
		random_list = {
			40 = { # succeed
				modifier = {
					culture = scope:bandit.culture
					add = 80
				}
				modifier = {
					culture != scope:bandit.culture
					culture = {
						cultural_acceptance = {
							target = scope:bandit.culture
							value >= 90
						}
					}
					add = 15
				}
				modifier = {
					culture != scope:bandit.culture
					culture = {
						cultural_acceptance = {
							target = scope:bandit.culture
							value >= 60
						}
					}
					
					add = 15
				}
				modifier = {
					culture != scope:bandit.culture
					culture = {
						cultural_acceptance = {
							target = scope:bandit.culture
							value >= 40
						}
					}
					
					add = 15
				}
				modifier = {
					culture != scope:bandit.culture
					culture = {
						cultural_acceptance = {
							target = scope:bandit.culture
							value >= 20
						}
					}
					
					add = 15
				}
				modifier = {
					add = {
						value = stewardship
						multiply = 3
					}
				}
				desc = travel_danger_events.1002.a.success
				current_travel_plan = {
					add_companion = scope:bandit
					if = {
						limit = {
							NOT = { has_travel_plan_modifier = travel_guide_modifier }
						}
						add_travel_plan_modifier = travel_guide_modifier
					}
				}
				send_interface_toast = {
					title = travel_danger_events.1002.a.success
					left_icon = root 
					right_icon = scope:bandit
					if = {
						limit = { culture != scope:bandit.culture }
						culture = {
							change_cultural_acceptance = {
								target = scope:bandit.culture
								value = minor_cultural_acceptance_gain
								desc = travel_hired_foreign_guide
							}
						}
					}
					remove_short_term_gold = minor_gold_value
				}
			}
			60 = { # fail
				modifier = {
					culture != scope:bandit.culture
					culture = {
						cultural_acceptance = {
							target = scope:bandit.culture
							value <= 0
						}
					}
					add = 20
				}
				desc = travel_danger_events.1002.a.failure
				send_interface_toast = {
					title = travel_danger_events.1002.a.failure
					left_icon = root 
					right_icon = scope:bandit
					remove_short_term_gold = medium_gold_value
				}
			}
		}
	}

	option = { # pay the price
		name = travel_danger_events.1002.e
		remove_short_term_gold = medium_gold_value
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				gold <= medium_gold_value
			}
		}
	}

	after = {
		mp_resume_travel_plan = yes
		scope:bandit = {
			silent_disappearance_ai_if_created_effect = yes #Unop Only disappear created characters
		}
	}
}

travel_danger_events.1003 = { # Companion disappears in the bog
	type = character_event
	title = travel_danger_events.1003.t
	desc = travel_danger_events.1003.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = worry
	}

	right_portrait = {
		character = scope:travel_leader
		animation = stress
	}

	lower_center_portrait = {
		character = scope:missing_companion
	}
	
	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		exists = current_travel_plan.travel_leader 
		current_travel_plan = {
			any_entourage_character = {
				this != prev.travel_leader
				is_available_travelling_adult = yes 
				is_ai = yes
			}
		}

		location = {
			travel_danger_type = {
				travel_plan = root.current_travel_plan
				terrain = wetlands
			}
		}		
	}

	cooldown = { months = 1 }

	weight_multiplier = {
		base = 1
	}

	immediate = {
		mp_delay_travel_plan = { DAYS = 90 }
		current_travel_plan = {
			travel_leader = {
				save_scope_as = travel_leader
			}
			ordered_entourage_character = {
				limit = {
					this != scope:travel_leader
					is_ai = yes 
					is_available_travelling_adult = yes 
				}
				save_scope_as = missing_companion
			}
			current_location = { save_scope_as = current_location }
			final_destination_province = { save_scope_as = destination }
		}
		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
	}

	option = { # Send travel leader to look for the missing person
		name = travel_danger_events.1003.a
		current_travel_plan = { delay_travel_plan = { days = 5 } }
		scope:travel_leader = {
			duel = {
				skill = stewardship
				value = high_skill_rating
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					root = {
						send_interface_toast = {
							title = travel_danger_events.1003.b.success 
							left_icon = scope:missing_companion
							custom_tooltip = travel_danger_events.1003.b.success.desc
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					root = {
						send_interface_toast = {
							title = travel_danger_events.1003.b.failure 
							left_icon = scope:missing_companion
							scope:missing_companion = {
								death = {
									death_reason = death_lost_in_the_bog
								}
							}
						}
					}
				}
			}
		}
	}

	option = { # they dead fo sho
		name = travel_danger_events.1003.b
		# Possible follow-up where the character returns before the end of the travel or they die
		scope:missing_companion = {
			death = {
				death_reason = death_lost_in_the_bog
			}
		}
	}

	after = {
		mp_resume_travel_plan = yes
	}
}

travel_danger_events.1006 = { # Lost in the forest
	type = character_event
	title = travel_danger_events.1006.t
	desc = travel_danger_events.1006.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = worry
	}

	right_portrait = {
		character = scope:travel_leader
		animation = disbelief
	}

	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		location = {
			OR = {
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = forest
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = taiga
				}
			}
		}
		is_character_not_specialized_in_terrain = yes
		NOT = { has_character_flag = had_2006_lost_pilgrimage_event_recently }
	}

	cooldown = { months = 1 }

	weight_multiplier = {
		base = 1
		modifier = {
			exists = current_travel_plan.travel_leader
			current_travel_plan.travel_leader = {
				aptitude:travel_leader_court_position < 10
			}
			add = 1
		}
	}

	immediate = {
		wayfarer_storyteller_fame_effect = { VALUE = roaming_reward_fame_small }
		#Some cooldown between Lost-themed events
		add_character_flag = {
			flag = had_1006_travel_danger_lost_event_recently
			months = 3
		}
		mp_delay_travel_plan = { DAYS = 90 }
		current_travel_plan = {
			ordered_entourage_character = {
				order_by = stewardship
				save_scope_as = travel_leader
			}
			current_location = { save_scope_as = current_location }
			next_destination_province = { save_scope_as = destination }
		}
		if = {
			limit = {
				any_pool_character = {
					province = root.location 
					is_available_ai_adult = yes 
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					is_available_ai_adult = yes 
				}
				save_scope_as = guide
			}
		}
		else = {
			create_character = {
				template = guide_character
				dynasty = none
				location = root.location
				gender_female_chance = 50 
				save_scope_as = guide
				after_creation = { #Unop Add created flag so we could only disappear created characters
					add_character_flag = created
				}
			}
		}
		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
	}

	option = { # Find a guide
		name = travel_danger_events.1006.b
		trigger = {
			stewardship >= 16
			is_landless_adventurer = no
			current_travel_plan = {
				NOT = { has_travel_plan_modifier = travel_guide_modifier }
			}
		}
		skill = stewardship
		
		custom_tooltip = travel_danger_events.1006.b.hire_guide
		current_travel_plan = {
			add_companion = scope:guide
			add_travel_plan_modifier = travel_guide_modifier
		}
		pay_short_term_gold = {
			target = scope:guide
			gold = tiny_gold_value
		}
		if = {
			limit = { culture != scope:guide.culture }
			culture = {
				change_cultural_acceptance = {
					target = scope:guide.culture
					value = minor_cultural_acceptance_gain
					desc = travel_hired_foreign_guide
				}
			}
		}
	}

	option = { # I know where we're going!
		name = travel_danger_events.1006.a
		duel = {
			skill = learning
			value = medium_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {

				}
				send_interface_toast = {
					title = travel_danger_events.1006.a.success 
					left_icon = root
					traveler_danger_xp_effect = {
						MIN = 6
						MAX = 10
					}
					add_prestige = minor_prestige_gain
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = travel_danger_events.1006.a.failure 
					left_icon = root
					current_travel_plan = {
						every_entourage_character = {
							custom = every_entourage_tt
							add_opinion = {
								target = root 
								modifier = frustrated_opinion
								opinion = -20
							}
						}
						delay_travel_plan = { days = 20 }
					}
				}
			}
		}
	}

	option = { # Barge Ahead
		name = travel_danger_events.1006.c
		current_travel_plan = {
			delay_travel_plan = { days = 15 }
		}
	}

	after = {
		mp_resume_travel_plan = yes
		scope:guide = {
			silent_disappearance_ai_if_created_effect = yes #Unop Only disappear created characters
		}
	}
}

travel_danger_events.1007 = { # Desert/Desert Mountains/Drylands - Running out of water
	type = character_event
	title = travel_danger_events.1007.t
	desc = travel_danger_events.1007.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = pain
	}

	right_portrait = {
		character = scope:water_hider
		animation = worry
	}

	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		current_travel_plan = {
			any_entourage_character = { }
		}
		location = {
			OR = {
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = desert
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = desert_mountains
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = drylands
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					terrain = steppe
				}
			}
		}
		root.culture = {
			NOR = {
				has_cultural_tradition = tradition_saharan_nomads
				has_cultural_tradition = tradition_desert_nomads
			}
		}
	}

	cooldown = { months = 1 }

	weight_multiplier = {
		base = 1
	}

	immediate = {
		mp_delay_travel_plan = { DAYS = 90 }
		current_travel_plan = {
			ordered_entourage_character = {
				order_by = intrigue
				save_scope_as = water_hider
			}
			current_location = {
				save_scope_as = current_location
				if = {
					limit = {
						any_neighboring_province = {
							terrain = oasis
						}
					}
					random_neighboring_province = {
						limit = {
							terrain = oasis
						}
						save_scope_as = oasis_province_scope
					}
				}
			}
			next_destination_province = { save_scope_as = destination }
		}
		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
	}

	option = {
		name = travel_danger_events.1007.d
		trigger = {
			domicile ?= { has_domicile_building = supply_tent_reserve_water }
		}
		reason = has_building_supply_tent_reserve_water
		domicile = {
			change_provisions = miniscule_provisions_loss
		}
	}

	option = { # You know of an oasis ahead
		name = travel_danger_events.1007.a
		trigger = {
			# check if the next province is an oasis
			scope:current_location = {
				any_neighboring_province = {
					terrain = oasis
				}
			}
		}
		custom_tooltip = travel_danger_events.1007.a.tt
		current_travel_plan = {
			add_travel_waypoint = scope:oasis_province_scope
		}
	}

	option = {
		name = travel_danger_events.1007.b
		random_list = {
			10 = {
				send_interface_toast = {
					title = travel_danger_events.1007.b.success.desc
					left_icon = root 
					right_icon = scope:water_hider
					scope:water_hider = {
						death = { death_reason = death_thirst }
					}
				}
			}
			90 = {
				send_interface_toast = {
					title = travel_danger_events.1007.b.failure.desc
					left_icon = root 
					right_icon = scope:water_hider
					scope:water_hider = {
						add_opinion = {
							target = root 
							modifier = cruelty_opinion
							opinion = -50
						}
						add_character_modifier = {
							modifier = ep3_laamp_flavour_ewan_4021_extended_period_of_dehydration_t2_modifier
							years = 2
						}
					}
				}
			}
		}
	}

	option = { # Push on
		name = travel_danger_events.1007.c
		add_character_modifier = {
			modifier = dehydrated_modifier
			years = 2
		}
		current_travel_plan = {
			every_entourage_character = {
				custom = every_entourage_tt
				add_character_modifier = {
					modifier = dehydrated_modifier
					years = 2
				}
			}
		}
	}
	after = {
		mp_resume_travel_plan = yes
	}
}

travel_danger_events.1008 = { # Occupied Territory
	type = character_event
	title = travel_danger_events.1008.t
	desc = travel_danger_events.1008.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = shock
	}

	right_portrait = {
		character = scope:zombie
		animation = anger
		outfit_tags = { beggar_rags }
	}

	lower_center_portrait = {
		character = scope:guard
	}

	override_background = { reference = battlefield }

	trigger = {
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		location = {
			travel_danger_type = {
				travel_plan = root.current_travel_plan
				type = occupation
			}
		}
		# Check to make sure we have an available character to pull from the local pool
		any_pool_character = {
			province = root.location 
			is_available_ai_adult = yes 
		}
		current_travel_plan = {
			any_entourage_character = {
				count > 3
			}
		}
	}

	cooldown = { months = 1 }

	weight_multiplier = {
		base = 1
	}

	immediate = {
		wayfarer_storyteller_fame_effect = { VALUE = roaming_reward_fame_small }
		mp_delay_travel_plan = { DAYS = 90 }
		current_travel_plan = {
			ordered_entourage_character = {
				order_by = {
					value = prowess
					# weight characters based on their position within root's court
					# We want to pick out bodyguards first, then knights, then the marshal
					if = {
						limit = { has_council_position = councillor_marshal }
						multiply = 1.5
					}
					if = {
						limit = {
							is_knight = yes
						}
						multiply = 2
					}
					if = {
						limit = { has_court_position = bodyguard_court_position }
						multiply = 3
					}
					if = {
						limit = { has_court_position = akolouthos_court_position }
						multiply = 3
					}
				}
				limit = {
					is_available_ai_adult = yes
					can_be_warrior_trigger = { ARMY_OWNER = root }
					NOR = {
						this = root
						this = root.current_travel_plan.travel_leader
					}
				}
				save_scope_as = guard
			}
			current_location = {
				save_scope_as = current_location
				barony = { save_scope_as = current_location_barony }
			}
			next_destination_province = { save_scope_as = destination }
		}

		hidden_effect = {	
			if = {
				limit = {
					any_pool_character = {
						province = root.location 
						is_available_ai_adult = yes 
					}
				}
			}
			random_pool_character = {
				province = root.location
				limit = {
					is_available_ai_adult = yes 
				}
				save_scope_as = zombie
				change_current_weight = -100
				increase_wounds_no_death_effect = { REASON = battle }
			}
		}
		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
	}

	option = { # Guards! Stop that GetWomanMan!
		name = travel_danger_events.1008.a

		trigger = {
			current_travel_plan = {
				OR = {
					has_travel_option = hire_experienced_mercenaries_option
					has_travel_option = military_recruits_option
				}
			}
		}
		
		send_interface_toast = {
			title = travel_danger_events.1008.a.tt
			left_icon = scope:zombie 

			if = {
				limit = { exists = scope:guard }
				scope:zombie = {
					death = {
						killer = scope:guard 
						death_reason = death_fight
					}
				}
			}
			else = {
				scope:zombie = {
					death = {
						killer = root
						death_reason = death_fight
					}
				}
			}
		}

		stress_impact = {
			compassionate = massive_stress_impact_gain
			trusting = massive_stress_impact_gain
			just = medium_stress_impact_gain
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_vengefulness = 0.5
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = compassionate
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = trusting
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = just
			}
		}
	}

	option = { # I'm sure GetSheHe means us no harm.
		name = travel_danger_events.1008.b

		trigger = {
			NOR = {
				has_trait = callous 
				has_trait = sadistic 
			}
		}
		
		duel = {
			skill = diplomacy
			target = scope:zombie
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				custom_tooltip = travel_danger_events.1008.good_intentions
				trigger_event = travel_danger_events.1009

				modifier = {
					scope:zombie = { has_trait = compassionate }
					add = 20
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				custom_tooltip = travel_danger_events.1008.bad_intentions
				trigger_event = travel_danger_events.1010
			}
		}

		stress_impact = {
			craven = massive_stress_impact_gain
			paranoid = medium_stress_impact_gain
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_sociability = 0.5
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = craven
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = paranoid
			}
			modifier = {
				add = 50
				has_trait = trusting
			}
		}
	}

	option = { # Take this and let us leave
		name = travel_danger_events.1008.c

		if = {
			limit = {
				is_landless_adventurer = yes
			}
			domicile = {
				change_provisions = minor_provisions_loss
			}
		}
		else = {
			pay_short_term_gold = {
				target = scope:zombie
				gold = minor_gold_value
			}
		}

		stress_impact = {
			craven = massive_stress_impact_gain
			paranoid = medium_stress_impact_gain
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_sociability = 0.5
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = craven
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = paranoid
			}
			modifier = {
				add = 30
				has_trait = trusting
			}
		}
	}

	after = {
		mp_resume_travel_plan = yes
	}
}

travel_danger_events.1009 = { # Occupied Territory: Good intentions
	type = character_event
	title = travel_danger_events.1009.t
	desc = travel_danger_events.1009.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = worry
	}

	right_portrait = {
		character = scope:zombie
		animation = beg
		outfit_tags = { beggar_rags }
	}

	lower_center_portrait = {
		trigger = {
			root = { has_trait = sadistic }
		}
		character = scope:guard
	}

	override_background = { reference = battlefield }

	immediate = {
		mp_delay_travel_plan = { DAYS = 90 }
		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
	}

	option = { # Give gold
		name = travel_danger_events.1009.a
		
		pay_short_term_gold = {
			target = scope:zombie
			gold = tiny_gold_value
		}
		add_piety = minor_piety_gain

		stress_impact = {
			greedy = medium_stress_impact_gain
			avaricious = massive_stress_impact_gain
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_sociability = 0.5
				ai_greed = -0.5
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = greedy
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = avaricious
			}
		}
	}

	option = { # KILL GETHERHIM ANYWAY
		name = travel_danger_events.1009.b

		trigger = { has_trait = sadistic }

		send_interface_toast = {
			title = travel_danger_events.1008.a.tt
			left_icon = scope:guard 
			right_icon = scope:zombie

			scope:zombie = {
				death = {
					killer = scope:guard 
					death_reason = death_fight
				}
			}
		}

		stress_impact = {
			just = massive_stress_impact_gain
			sadistic = medium_stress_impact_loss
			callous = minor_stress_impact_loss
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_sociability = -0.5
				ai_vengefulness = 0.5
				ai_boldness = 0.3
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = just
			}
			modifier = {
				add = 50
				OR = {
					has_trait = sadistic
					has_trait = callous 
				}
			}
		}
	}

	option = { # Join us!
		name = travel_danger_events.1009.c

		add_courtier = scope:zombie
		current_travel_plan = {
			add_companion = scope:zombie
			if = {
				limit = {
					NOT = { has_travel_plan_modifier = travel_guide_modifier }
				}
				add_travel_plan_modifier = travel_guide_modifier
			}
		}

		stress_impact = {
			craven = medium_stress_impact_gain
			paranoid = massive_stress_impact_gain
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_sociability = 0.5
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = craven
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = paranoid
			}
			modifier = {
				add = 30
				has_trait = trusting
			}
		}
	}

	option = { # Not really my problem, is it?
		name = travel_danger_events.1009.d

		stress_impact = {
			greedy = massive_stress_impact_gain
		}

		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.5
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = greedy
			}
		}
	}

	after = {
		mp_resume_travel_plan = yes
	}
}

travel_danger_events.1010 = { # Occupied Territory: Bad intentions
	type = character_event
	title = travel_danger_events.1010.t
	desc = travel_danger_events.1010.desc
	theme = travel_danger

	left_portrait = {
		character = root
		animation = worry
	}

	right_portrait = {
		character = scope:zombie
		animation = aggressive_unarmed
		outfit_tags = { beggar_rags }
	}

	lower_center_portrait = {
		character = scope:guard
	}

	override_background = { reference = battlefield }

	immediate = {
		wayfarer_storyteller_fame_effect = { VALUE = roaming_reward_fame_medium }
		mp_delay_travel_plan = { DAYS = 90 }

		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
	}

	option = { # You fend off the wretch yourself
		name = travel_danger_events.1010.a

		duel = {
			skill = prowess
			target = scope:zombie
			# Victory! You easily fend off the zombie
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					title = travel_danger_events.1010.a.success
					left_icon = root 
					right_icon = scope:zombie

					scope:zombie = {
						increase_wounds_effect = { REASON = fight }
					}
					custom_tooltip = travel_danger_events.1010.tt
				}
			}
			# Defeat! You get wounded
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = travel_danger_events.1010.a.failure
					left_icon = root 
					right_icon = scope:zombie

					increase_wounds_no_death_effect = { REASON = fight }
					custom_tooltip = travel_danger_events.1010.tt
				}
			}
		}

		stress_impact = {
			craven = massive_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_vengefulness = 0.5
				ai_energy = 0.5
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = craven
			}
		}

	}

	option = { # You call on your guard to fend off the wretch
		name = travel_danger_events.1010.b
		
		trigger = {
			exists = scope:guard
		}

		scope:guard = {
			duel = {
				skill = prowess
				target = scope:zombie
				# Victory! Your guard easily fends off the zombie
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					root = {
						send_interface_toast = {
							title = travel_danger_events.1010.b.success
							left_icon = scope:guard 
							right_icon = scope:zombie

							scope:zombie = {
								increase_wounds_effect = { REASON = fight }
							}
							custom_tooltip = travel_danger_events.1010.tt
						}
					}
				}
				# Defeat! You get wounded
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					root = {
						send_interface_toast = {
							title = travel_danger_events.1010.b.failure
							left_icon = scope:guard 
							right_icon = scope:zombie

							scope:guard = { increase_wounds_no_death_effect = { REASON = fight } }
							custom_tooltip = travel_danger_events.1010.tt
						}
					}
				}
			}
		}
		stress_impact = {
			brave = massive_stress_impact_gain
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -0.5
				ai_rationality = 0.5
			}
			modifier = {	# don't let the ai do something that causes a stress break
				factor = 0
				has_trait = brave
			}
		}
	}

	after = {
		mp_resume_travel_plan = yes
	}
}

##########################################################
# Travel Danger											
# travel_danger_events - 1020-1030						
# by Anna Johansson								 			
##########################################################

travel_danger_events.1020 = {
	type = character_event
	title = { 
		desc = travel_danger_events.1020.t 
		first_valid = {
			triggered_desc = {
				trigger = {
					location = { 
						terrain = wetlands
					}
				}
				desc = travel_danger_events.1020.t.wetlands
			}
			triggered_desc = {
				trigger = {
					location = {
						terrain = floodplains
					}
				}
				desc = travel_danger_events.1020.t.floodplains
			}
			triggered_desc = {
				trigger = {
					location = {
						terrain = jungle
					}
				}
				desc = travel_danger_events.1020.t.jungle
			}
			triggered_desc = {
				trigger = {
					location = {
						terrain = taiga
					}
				}
				desc = travel_danger_events.1020.t.taiga
			}
		}
	}
	desc = {
		desc = travel_danger_events.1020.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { 
					location = {
						terrain = wetlands 
					}
				}
				desc = travel_danger_events.1020.wetlands
			}
		}
		triggered_desc = {
			trigger = {
				location = {
					terrain = floodplains
				}
			}
			desc = travel_danger_events.1020.floodplains
		}
		triggered_desc = {
			trigger = { 
				location = { 
					terrain = jungle
				}
			}
			desc = travel_danger_events.1020.jungle	
		}
		triggered_desc = {
			trigger = {
				location = {
					terrain = taiga
				}
			}
			desc = travel_danger_events.1020.taiga
		}
	}

	theme = travel_danger

	left_portrait = {
		character = root
		animation = pain
	}

	right_portrait = {
		character = scope:horse_helper
		animation = shock
	}

	trigger = {
		static_group_filter = {
			group = travel_danger_events.1020
			match = 0.1
		}
		is_available_travelling_adult = yes
		is_location_valid_for_travel_event_on_land = yes
		any_owned_story = { story_type = story_cycle_martial_lifestyle_warhorse }

		#Places a horse can get stuck
		location = {
			OR = {
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					#Swamp
					terrain = wetlands
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					#Floods
					terrain = floodplains
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					#Quicksand
					terrain = jungle
				}
				travel_danger_type = {
					travel_plan = root.current_travel_plan
					#Big random hole
					terrain = taiga
				}
			}
		}

		current_travel_plan = {
			any_entourage_character = {
				is_physically_able_adult = yes
			}
		}
	}

	cooldown = { years = 10 }

	immediate = {
		random_owned_story = {
			limit = {
				story_type = story_cycle_martial_lifestyle_warhorse
			}
			save_scope_as = horse_story
		}

		current_travel_plan = {
			random_entourage_character = {
				limit = {
					is_ai = yes
					is_available_travelling_adult = yes 
					is_physically_able_adult = yes
				}
				weight = {
					base = 1
					modifier = {
						add = 5
						has_trait = brave
					}
					modifier = {
						add = 5
						has_trait = strong
					}
					modifier = {
						add = 5
						has_trait = athletic
					}
					modifier = {
						add = prowess
					}
				}
				save_scope_as = horse_helper
			}
			delay_travel_plan = { days = 5 }
		}

		traveler_danger_xp_effect = {
			MIN = 3
			MAX = 6
		}
	}

	#Save the horse yourself, prowess duel
	option = {
		name = travel_danger_events.1020.a

		duel = {
			skill = prowess
			value = medium_skill_rating
			50 = {
				desc = travel_danger_events.1020.a.success
				min = 5
				max = 95
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				if = {
					limit = {
						NOT = {
							has_trait = strong
						}
					}
					random = {
						chance = 20
						add_trait = strong
					}
				}
				send_interface_toast = {
					title = travel_danger_events.1020.a.success
					type = event_toast_effect_good
					left_icon = root
					add_prestige = minor_prestige_gain
				}
			}
			50 = {
				desc = travel_danger_events.1020.a.failure
				min = 5
				max = 95
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					title = travel_danger_events.1020.a.failure
					type = event_toast_effect_bad
					left_icon = root
					right_icon = scope:horse_helper
					increase_wounds_effect = { REASON = drowning_in_terrain }
					if = {
						limit = {
							exists = scope:horse_story
						}
						scope:horse_story = { end_story = yes }
						remove_character_modifier = horse_story_modifier
					}
				}
			}
		}
		stress_impact = {
			brave = minor_stress_loss
			craven = minor_stress_gain
			compassionate = minor_stress_gain
			callous = minor_stress_loss
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 1
				ai_boldness = 1
			}
		}
	}

	#Tell an entourage member to help your steed, prowess duel
	option = {
		name = travel_danger_events.1020.b
		scope:horse_helper = {
			duel = {
				skill = prowess
				value = medium_skill_rating
				50 = {
					desc = travel_danger_events.1020.b.success
					min = 5
					max = 95
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					root = {
						send_interface_toast = {
							title = travel_danger_events.1020.b.success
							type = event_toast_effect_good
							left_icon = root
							right_icon = scope:horse_helper
							scope:horse_helper = {
								add_prestige = minor_prestige_gain
							}
							scope:horse_helper = {
								if = {
									limit = {
										NOT = {
											has_trait = strong
										}
									}
									random = {
										chance = 20
										add_trait = strong
									}
								}
							}	
						}
					}
				}
				50 = {
					desc = travel_danger_events.1020.b.failure
					min = 5
					max = 95
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					root = {
						send_interface_toast = {
							title = travel_danger_events.1020.b.failure
							type = event_toast_effect_bad
							left_icon = root
							right_icon = scope:horse_helper
							scope:horse_helper = {
								death = {
									death_reason = death_drowning_in_terrain
									killer = root
								}
							}
							if = {
								limit = {
									exists = scope:horse_story
								}
								scope:horse_story = { end_story = yes }
								remove_character_modifier = horse_story_modifier
							}
						}
					}
				}
			}
		}
		stress_impact = {
			brave = minor_stress_gain
			craven = minor_stress_loss
			compassionate = minor_stress_gain
			callous = minor_stress_loss
			sadistic = minor_stress_loss
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = 1
				ai_boldness = -1
			}
		}
	}

	#Leave the horse to it's fate, lose it forever
	option = {
		name = travel_danger_events.1020.c
		if = {
			limit = {
				exists = scope:horse_story
			}
			scope:horse_story = { end_story = yes }
			remove_character_modifier = horse_story_modifier
		}

		stress_impact = {
			brave = minor_stress_gain
			craven = minor_stress_loss
			compassionate = minor_stress_gain
			callous = minor_stress_loss
			sadistic = minor_stress_loss
		}
		ai_chance = {
			base = 1
			ai_value_modifier = {
				ai_compassion = -1
				ai_boldness = -1
				ai_rationality = 1
			}
		}
	}
}
