﻿namespace = tour_travel
############################
### Highwaymen on your route
### By James Beaumont
############################
tour_travel.9010 = {
	type = character_event
	title = tour_travel.9010.t
	desc = tour_travel.9010.desc
	theme = travel_tour
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_trait = craven
			}
			animation = fear
		}
		triggered_animation = {
			trigger = { has_trait = brave }
			animation = personality_bold
		}
		animation = thinking
	}
	right_portrait = {
		character = scope:travel_leader
		animation = worry
	}

	cooldown = { years = 2 }

	trigger = {
		has_activity_intent = justice_intent
		root.location.county = {
			NOT = { county_control = 100 }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 2
			root.location.county = {
				NOT = { county_control <= 75 }
			}
		}
		modifier = {
			add = 2
			root.location.county = {
				NOT = { county_control <= 50 }
			}
		}
		modifier = {
			add = 2
			root.location.county = {
				NOT = { county_control <= 25 }
			}
		}
	}

	immediate = {
		if = {
			limit = {
				exists = current_travel_plan.travel_leader
			}
			current_travel_plan.travel_leader = { save_scope_as = travel_leader }
		}
		else = {
			current_travel_plan = {
				random_entourage_character = {
					weight = {
						base = 1
						modifier = {
							add = prowess
						}
					}
					save_scope_as = travel_leader
				}
			}
		}
		current_travel_plan = {
			next_destination_province = { save_scope_as = next_destination } 
		}
	}

	option = { #Just go around them
		name = tour_travel.9010.a
		current_travel_plan = {
			delay_travel_plan = { weeks = 1 }
		}
		stress_impact = {
			craven = minor_stress_impact_loss
			patient = minor_stress_impact_loss
			impatient = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = 1
				ai_boldness = -1
				ai_vengefulness = -1
				ai_honor = -1
			}
		}
	}

	option = { #Go in and clear em out!
		name = tour_travel.9010.b
		scope:travel_leader = {
			duel = {
				skill = prowess
				value = high_skill_rating
				# Success.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						min = -49
					}
					root = {
						send_interface_toast = {
							title = tour_travel.9010.success
							left_icon = scope:travel_leader
							location.county = {
								change_county_control = 20
								add_county_modifier = {
									modifier = highwaymen_eliminated_modifier
									years = 15
								}
							}
						}
					}
				}
				# Failure.
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						min = -49
					}
					root = {
						send_interface_toast = {
							title = tour_travel.9010.failure
							left_icon = scope:travel_leader
							scope:travel_leader = { increase_wounds_effect = { REASON = fight } }
							increase_wounds_no_death_effect = { REASON = fight }
						}
					}
				}
			}
		}
		stress_impact = {
			just = minor_stress_impact_loss
			brave = minor_stress_impact_loss
			patient = minor_stress_impact_gain
			craven = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_energy = -1
				ai_boldness = 1
				ai_vengefulness = 1
				ai_honor = 1
			}
		}
	}
}

############################
### Possibly innocent man up for execution
### By James Beaumont
############################
scripted_trigger tour_travel_9020_valid_criminal_trigger = {
	is_physically_able_adult = yes
	OR = {
		any_secret = { is_criminal_for = prev }
		root = {
			has_imprisonment_reason = prev
		}
		trait_is_criminal_in_faith_trigger = {
			TRAIT = adulterer
			FAITH = root.faith
			GENDER_CHARACTER = this
		}
		trait_is_criminal_in_faith_trigger = {
			TRAIT = fornicator
			FAITH = root.faith
			GENDER_CHARACTER = this
		}
		trait_is_criminal_in_faith_trigger = {
			TRAIT = sodomite
			FAITH = root.faith
			GENDER_CHARACTER = this
		}
		trait_is_criminal_in_faith_trigger = {
			TRAIT = witch
			FAITH = root.faith
			GENDER_CHARACTER = this
		}
		trait_is_criminal_in_faith_trigger = {
			TRAIT = cannibal
			FAITH = root.faith
			GENDER_CHARACTER = this
		}
		trait_is_criminal_in_faith_trigger = {
			TRAIT = deviant
			FAITH = root.faith
			GENDER_CHARACTER = this
		}
		trait_is_criminal_in_faith_trigger = {
			TRAIT = incestuous
			FAITH = root.faith
			GENDER_CHARACTER = this
		}
		has_trait = murderer
	}
}

tour_travel.9020 = {
	type = character_event
	title = tour_travel.9020.t
	desc = {
		desc = tour_travel.9020.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_character = {
						tour_travel_9020_valid_criminal_trigger = yes
					}
				}
				desc = tour_travel.9020.desc.outro.guilty
			}
			desc = tour_travel.9020.desc.outro
		}
	}
	theme = travel_tour
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:accused_character
		animation = prisonhouse
		triggered_outfit = {
			remove_default_outfit = no
			outfit_tags = { beggar_rags }
		}
	}

	cooldown = { years = 2 }

	trigger = {
		has_activity_intent = justice_intent
	}
	immediate = {
		hidden_effect = {
			if = {
				limit = {
					any_pool_character = {
						province = root.location
					}
				}
				random_pool_character = {
					province = root.location
					weight = {
						base = 1
						modifier = {
							factor = 2
							tour_travel_9020_valid_criminal_trigger = yes
						}
					}
					save_scope_as = accused_character
				}
			}
			else = {
				create_character = {
					location = root.capital_province
					template = generic_peasant_character
					faith = root.location.faith
					culture = root.location.culture
					save_scope_as = accused_character
				}
				scope:accused_character = {
					add_character_flag = {
						flag = silently_disappear_me
						years = 1
					}
					random_list = {
						10 = {
							trigger = {
								root.faith = { has_doctrine_parameter = deviancy_illegal }
							}
							add_trait = deviant
						}
						10 = {
							trigger = {
								root.faith = { has_doctrine_parameter = witchcraft_illegal }
							}
							add_trait = witch
						}
						10 = {
							trigger = {
								trait_is_criminal_in_faith_trigger = {
									TRAIT = adulterer
									FAITH = root.faith
									GENDER_CHARACTER = this
								}
							}
							add_trait = adulterer
						}
						10 = {
							trigger = {
								trait_is_criminal_in_faith_trigger = {
									TRAIT = fornicator
									FAITH = root.faith
									GENDER_CHARACTER = this
								}
							}
							add_trait = fornicator
						}
						10 = {
							trigger = {
								trait_is_criminal_in_faith_trigger = {
									TRAIT = cannibal
									FAITH = root.faith
									GENDER_CHARACTER = this
								}
							}
							add_trait = cannibal
						}
						10 = {
							add_trait = murderer
						}
						60 = { # They're innocent
							
						}
					}
				}
			}
			decide_court_position_to_give_effect = {
				CANDIDATE = scope:accused_character
				EMPLOYER = root
			}
		}
	}

	option = { # Support the execution
		name = tour_travel.9020.a
		root.location.county = {
			change_county_control = minor_county_control_gain
		}
		scope:accused_character = {
			death = {
				death_reason = death_execution
				killer = root
			}
		}
		if = {
			limit = {
				scope:accused_character = {
					tour_travel_9020_valid_criminal_trigger = yes
				}
			}
			stress_impact = {
				arbitrary = minor_stress_impact_loss
				callous = minor_stress_impact_loss
				sadistic = minor_stress_impact_loss
				just = medium_stress_impact_loss
				forgiving = major_stress_impact_gain
				compassionate = major_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				arbitrary = minor_stress_impact_loss
				callous = minor_stress_impact_loss
				sadistic = minor_stress_impact_loss
				just = major_stress_impact_gain
				forgiving = major_stress_impact_gain
				compassionate = major_stress_impact_gain
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				factor = 0
				tour_travel_9020_valid_criminal_trigger = yes
				OR = {
					has_trait = compassionate
					has_trait = forgiving
				}
			}
			modifier = {
				factor = 0
				tour_travel_9020_valid_criminal_trigger = no
				OR = {
					has_trait = compassionate
					has_trait = forgiving
					has_trait = just
				}
			}
		}
	}

	option = { # Let them go
		name = tour_travel.9020.b
		root.location.county = {
			change_county_control = minor_county_control_loss
		}
		if = {
			limit = {
				scope:accused_character = {
					tour_travel_9020_valid_criminal_trigger = yes
				}
			}
			stress_impact = {
				forgiving = medium_stress_impact_loss
				compassionate = medium_stress_impact_loss
				arbitrary = minor_stress_impact_gain
				callous = minor_stress_impact_gain
				just = medium_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				just = minor_stress_impact_loss
				forgiving = minor_stress_impact_loss
				compassionate = minor_stress_impact_loss
				arbitrary = minor_stress_impact_gain
				callous = minor_stress_impact_gain
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				factor = 0
				tour_travel_9020_valid_criminal_trigger = yes
				OR = {
					has_trait = arbitrary
					has_trait = callous
					has_trait = sadistic
					has_trait = just
				}
			}
			modifier = {
				factor = 0
				tour_travel_9020_valid_criminal_trigger = no
				OR = {
					has_trait = arbitrary
					has_trait = callous
					has_trait = sadistic
				}
			}
		}
	}

	option = { # Let them serve you as penance
		name = tour_travel.9020.c
		trigger = {
			has_royal_court = yes
			OR = {
				has_trait = compassionate
				has_trait = forgiving
				has_trait = just
			}
		}
		add_courtier = scope:accused_character
		hidden_effect = {
			scope:accused_character = {
				if = {
					limit = { exists = scope:activity }
					add_to_activity_without_travel = scope:activity
				}
			}
		}
		current_travel_plan = {
			add_companion = scope:accused_character
		}
		add_hook = {
			type = indebted_hook
			target = scope:accused_character
		}
		distribute_determined_court_position_effect = {
			CANDIDATE = scope:accused_character
			EMPLOYER = root
		}
		consume_imprisonment_reasons = scope:accused_character
		if = {
			limit = {
				scope:accused_character = {
					tour_travel_9020_valid_criminal_trigger = yes
				}
			}
			stress_impact = {
				forgiving = medium_stress_impact_loss
				compassionate = medium_stress_impact_loss
				just = medium_stress_impact_loss
				arbitrary = minor_stress_impact_gain
				callous = minor_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				just = major_stress_impact_loss
				forgiving = major_stress_impact_loss
				compassionate = major_stress_impact_loss
				arbitrary = minor_stress_impact_gain
				callous = minor_stress_impact_gain
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				factor = 0
				tour_travel_9020_valid_criminal_trigger = yes
				OR = {
					has_trait = arbitrary
					has_trait = callous
					has_trait = sadistic
					has_trait = just
				}
			}
			modifier = {
				factor = 0
				tour_travel_9020_valid_criminal_trigger = no
				OR = {
					has_trait = arbitrary
					has_trait = callous
					has_trait = sadistic
				}
			}
		}
	}

	after = {
		if = {
			limit = {
				is_ai = yes
				scope:accused_character = {
					has_character_flag = silently_disappear_me
				}
			}
			scope:accused_character = {
				silent_disappearance_effect = yes
			}
		}
	}
}

############################
### Visit a tavern
### By James Beaumont
############################
tour_travel.9030 = {
	type = character_event
	title = tour_travel.9030.t
	desc = {
		desc = tour_travel.9030.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					drinks_alcohol_trigger = no
				}
				desc = tour_travel.9030.desc.mid.hashish
			}
			desc = tour_travel.9030.desc.mid
		}
		desc = tour_travel.9030.desc.outro
	}
	theme = travel_tour
	override_background = { reference = bp1_bonfire }
	left_portrait = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:drunky_entourage
		triggered_animation = {
			trigger = {
				drinks_alcohol_trigger = no
			}
			animation = admiration
		}
		animation = drink_goblet
	}

	cooldown = { years = 2 }

	trigger = {
		has_activity_intent = reduce_stress_intent
		is_adult = yes
		current_travel_plan = {
			any_entourage_character = {
				this != root
				is_ai = yes
				is_adult = yes
			}
		}
	}

	immediate = {
		current_travel_plan = {
			random_entourage_character = {
				limit = {
					this != root
					is_ai = yes
					is_adult = yes
				}
				weight = {
					base = 1
					modifier = {
						factor = 10
						OR = {
							has_trait = drunkard
							has_trait = hashishiyah
						}
					}
					modifier = {
						factor = 2
						has_trait = gluttonous
					}
					modifier = {
						factor = 2
						NOT = { has_trait = temperate }
					}
				}
				save_scope_as = drunky_entourage
			}
		}
	}

	option = { # Hell yeah, an easy break
		name = tour_travel.9030.a
		current_travel_plan = {
			delay_travel_plan = { weeks = 1 }
		}
		if = {
			limit = {
				drinks_alcohol_trigger = yes
			}
			add_character_modifier = {
				modifier = stress_drinking_binge
				years = 5
			}
		}
		else = {
			add_character_modifier = {
				modifier = hashish_with_friend_modifier
				years = 5
			}
		}
		stress_impact = {
			base = medium_stress_impact_loss
			lazy = minor_stress_impact_loss
			drunkard = minor_stress_impact_loss
			hashishiyah = minor_stress_impact_loss
			gluttonous = minor_stress_impact_loss
			diligent = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				factor = 0
				OR = {
					has_trait = diligent
					has_trait = impatient
				}
			}
		}
	}

	option = { # I have no time for distractions!
		name = tour_travel.9030.b
		stress_impact = {
			diligent = minor_stress_impact_loss
			impatient = minor_stress_impact_loss
			lazy = minor_stress_impact_gain
			drunkard = minor_stress_impact_gain
			hashishiyah = minor_stress_impact_gain
			gluttonous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = drunkard
					has_trait = hashishiyah
					has_trait = gluttonous
				}
			}
		}
	}
}

############################
### Peasants chatting about their favourite heroes
### By James Beaumont
############################
tour_travel.9040 = {
	type = character_event
	title = tour_travel.9040.t
	desc = tour_travel.9040.desc
	theme = travel_tour
	left_portrait = {
		character = root
		animation = personality_bold
		triggered_outfit = {
			remove_default_outfit = no
			outfit_tags = { beggar_rags }
		}
	}
	right_portrait = {
		character = scope:peasant
		triggered_animation = {
			trigger = {
				drinks_alcohol_trigger = no
			}
			animation = admiration
		}
		animation = drink_goblet
	}

	cooldown = { years = 2 }

	trigger = {
		has_activity_intent = spread_legend_intent
		is_location_valid_for_travel_event_on_land = yes
	}

	immediate = {
		root.location = {
			save_scope_as = county_scope
			save_scope_as = background_wilderness_scope # For theme
		}
		create_character = {
			location = scope:county_scope
			template = drunken_peasant_character
			culture = scope:county_scope.culture
			faith = scope:county_scope.faith
			save_scope_as = peasant
		}
	}

	option = { # Let me tell you about my legend :)
		name = tour_travel.9040.a
		current_travel_plan = {
			delay_travel_plan = { weeks = 1 }
		}
		duel = {
			skill = diplomacy
			target = scope:peasant
			50 = {
				desc = tour_travel.9040.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				send_interface_toast = {
					title = tour_travel.9040.a.success
					left_icon = root
					right_icon = scope:peasant
					add_prestige = medium_prestige_gain
					add_character_modifier = {
						modifier = ce1_legendary_taverns
						years = 15
					}
				}
			}
			50 = {
				desc = tour_travel.9040.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				send_interface_toast = {
					title = tour_travel.9040.a.failure
					left_icon = root
					add_prestige = medium_prestige_loss
					add_character_modifier = {
						modifier = ce1_legend_mocked
						years = 10
					}
				}
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # Ah, I shan't bother them
		name = tour_travel.9040.b
		add_stress = medium_stress_loss
		ai_chance = {
			base = 10
		}
	}
}
