namespace = migration_events

############################
## Mechanical Migration Events
## 0001-0099
############################

# migration_events.0001 - Arrival at Migration destination, title transfer

# Arrival at Migration destination, title transfer
migration_events.0001 = {
	type = character_event
	title = migration_events.0001.t
	desc = {
		first_valid = { # Season
			triggered_desc = {
				trigger = {
					any_character_situation = {
						any_situation_sub_region = {
							sub_region_current_phase = situation_steppe_severe_drought_season
							situation_sub_region_has_county = root.location.county
						}
					}
				}
				desc = migration_events.0001.desc.drought
			}
			triggered_desc = {
				trigger = {
					any_character_situation = {
						any_situation_sub_region = {
							sub_region_current_phase = situation_steppe_white_zud_season
							situation_sub_region_has_county = root.location.county
						}
					}
				}
				desc = migration_events.0001.desc.white_zud
			}
			triggered_desc = {
				trigger = {
					any_character_situation = {
						any_situation_sub_region = {
							sub_region_current_phase = situation_steppe_havsarsan_zud_season
							situation_sub_region_has_county = root.location.county
						}
					}
				}
				desc = migration_events.0001.desc.havsarsan_zud
			}
			triggered_desc = {
				trigger = {
					any_character_situation = {
						any_situation_sub_region = {
							sub_region_current_phase = situation_steppe_sky_blessing_season
							situation_sub_region_has_county = root.location.county
						}
					}
				}
				desc = migration_events.0001.desc.blessing
			}
			desc = migration_events.0001.desc.intro
		}
		first_valid = { # Relationship
			triggered_desc = {
				trigger = {
					has_variable = migrating_into_tributary_var
				}
				desc = migration_events.0001.desc.tributary
			}
			triggered_desc = {
				trigger = {
					scope:recipient = { government_has_flag = government_is_herder }
				}
				desc = migration_events.0001.desc.herder
			}
			triggered_desc = {
				trigger = {
					scope:recipient = {
						OR = {
							is_obedient_to = root 
							has_any_good_relationship_with_root_trigger = yes
						}
					}
				}
				desc = migration_events.0001.desc.nomad_obedient
			}
			triggered_desc = {
				trigger = {
					scope:recipient = {
						has_any_bad_relationship_with_root_trigger = yes
					}
				}
				desc = migration_events.0001.desc.nomad_angry
			}
			desc = migration_events.0001.desc.nomad
		}
		first_valid = { # Fertility
			triggered_desc = {
				trigger = {
					location.county.county_fertility >= good_county_fertility_level
				}
				desc = migration_events.0001.desc.good
			}
			triggered_desc = {
				trigger = {
					location.county.county_fertility <= bad_county_fertility_level
				}
				desc = migration_events.0001.desc.bad
			}
			desc = migration_events.0001.desc.meh
		}
	}
	theme = migration
	override_background = {
		trigger = {
			OR = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_white_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_cold_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_havsarsan_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
			}
		}
		reference = bp3_steppe_winter
	}
	override_background = {
		trigger = {
			NOR = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_white_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_cold_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_havsarsan_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_sky_blessing_season
						situation_sub_region_has_county = root.location.county
					}
				}			
			}
		}
		reference = mpo_steppe_evening
	}
	widgets = {
		widget = {
			is_shown = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_cold_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
			}
			gui = "event_window_widget_vfx_snow"
			container = "foreground_shader_vfx_container"
		}

		widget = {
			is_shown = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_havsarsan_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
			}
			gui = "event_window_widget_vfx_snowstorm"
			container = "foreground_shader_vfx_container"
		}
	}
	left_portrait = {
		character = scope:actor
		animation = horse_archer_idle
		camera = camera_event_horse_left
	}
	right_portrait = {
		character = scope:recipient
		triggered_animation = {
			trigger = {
				scope:recipient = { government_has_flag = government_is_herder }
			}
			animation = shepherd_with_sheep
		}
		triggered_animation = {
			trigger = {
				scope:recipient = { has_any_bad_relationship_with_root_trigger = yes }
			}
			animation = personality_callous
		}
		animation = throne_room_bow_1
		camera = camera_event_right_away
	}
	lower_right_portrait = {
		trigger = { exists = scope:overlord }
		character = scope:overlord
	}

	immediate = {
		remove_variable = migration_title
		if = {
			limit = {
				has_variable = migrating_into_tributary_var
			}
			var:migrating_into_tributary_var = {
				save_scope_as = overlord
			}
			save_scope_as = new_tributary # For the toasts to overlord
		}
		if = {
			limit = {
				NOT = { exists = scope:recipient }
			}
			hidden_effect = {
				create_character = {
					template = herder_character
					faith = root.location.county.faith
					culture = root.location.county.culture
					location = root.location
					save_scope_as = recipient
					after_creation = {
						remove_character_flag = peasant_outfit
						add_to_list = government_change
						add_character_flag = created
					}
				}
			}
		}
	}
	
	option = { # If you're moving to a Tributary's land we ask you to become a Tributary yourself - Accept
		name = migration_events.0001.aaa
		trigger = {
			has_variable = migrating_into_tributary_var
		}
		start_tributary_interaction_effect = {
			TRIBUTARY = root
			SUZERAIN = scope:overlord
		}
		hidden_effect = {
			scope:overlord = {
				send_interface_toast = {
					left_icon = scope:new_tributary
					title = msg_tributary_toast
					custom_tooltip = msg_tributary_toast_tt
				}
			}
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = { # If you're moving to a Tributary's land we ask you to become a Tributary yourself - Refuse
		name = migration_events.0001.aa
		trigger = {
			has_variable = migrating_into_tributary_var
		}
		scope:overlord = {
			custom_tooltip = {
				text = migration_events.0001.aa.cb_tt
				if = {
					limit = {
						NOT = { # You don't already have a Retaliation CB on this guy
							is_target_in_variable_list = {
								name = retaliation_cb_var_list
								target = root
							}
						}
					}
					add_to_variable_list = {
						name = retaliation_cb_var_list
						target = root
						years = 5
					}
				}
			}
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -50
			}
			hidden_effect = {
				scope:overlord = {
					send_interface_toast = {
						left_icon = scope:new_tributary
						title = msg_tributary_toast_bad
						custom_tooltip = msg_tributary_toast_bad_tt
					}
				}
			}
		}
		ai_chance = { # AI normally doesn't refuse
			base = 10
			modifier = { # Unless...
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				NOT = { has_trait = craven }
				add = 25
			}
			modifier = {
				current_military_strength >= scope:overlord.current_military_strength
				add = 125
			}
		}
	}

	option = { # Special option if your Astrologer wanted you to come here
		name = migration_events.0001.a
		add_internal_flag = special
		trigger = {
			var:astrologer_desired_area ?= root.primary_title
			NOT = { has_variable = migrating_into_tributary_var }
		}
		custom_tooltip = migration_events.0001.a.tt
		add_character_modifier = {
			modifier = astrologer_desired_area_modifier
			years = 5
		}
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = migration_events.0001.b
		trigger = {
			NOR = {
				var:astrologer_desired_area ?= root.primary_title
				has_variable = migrating_into_tributary_var
			}
		}
		ai_chance = {
			base = 100
		}
	}
	
	after = {
		remove_variable = migrating_into_tributary_var
		scope:recipient = {
			silent_disappearance_ai_if_created_effect = yes
		}
	}
}

# Arrival at Migration destination through war, triggered if you're moving into a Tributary's lands
migration_events.0002 = {
	type = character_event
	title = migration_events.0002.t
	desc = {
		desc = migration_events.0002.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					higher_or_equal_dominance_trigger = {
						FIRST_TARGET = root
						SECOND_TARGET = scope:overlord
					}
				}
				desc = migration_events.0002.desc.high_dominance
			}
			desc = migration_events.0002.desc
		}
	}
	theme = migration
	override_background = {
		trigger = {
			OR = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_white_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_cold_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_havsarsan_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
			}
		}
		reference = bp3_steppe_winter
	}
	widgets = {
		widget = {
			is_shown = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_cold_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
			}
			gui = "event_window_widget_vfx_snow"
			container = "foreground_shader_vfx_container"
		}

		widget = {
			is_shown = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_havsarsan_zud_season
						situation_sub_region_has_county = root.location.county
					}
				}
			}
			gui = "event_window_widget_vfx_snowstorm"
			container = "foreground_shader_vfx_container"
		}
	}
	left_portrait = {
		character = scope:actor
		animation = horse_archer_aggressive
		camera = camera_event_horse_left
	}
	lower_right_portrait = {
		trigger = { exists = scope:overlord }
		character = scope:overlord
	}

	immediate = {
		var:migrating_into_tributary_war_var = {
			save_scope_as = overlord
		}
		save_scope_as = new_tributary # For the toasts to overlord
	}
	
	option = { # Accept
		name = migration_events.0002.a
		trigger = {
			higher_dominance_trigger = {
				FIRST_TARGET = scope:overlord
				SECOND_TARGET = root
			}
		}
		start_tributary_interaction_effect = {
			TRIBUTARY = root
			SUZERAIN = scope:overlord
		}
		hidden_effect = {
			scope:overlord = {
				send_interface_toast = {
					left_icon = scope:new_tributary
					title = msg_tributary_toast
					custom_tooltip = msg_tributary_toast_tt
				}
			}
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = { # Refuse
		name = {
			trigger = {
				higher_dominance_trigger = {
					FIRST_TARGET = scope:overlord
					SECOND_TARGET = root
				}
			}
			text = migration_events.0002.b
		}
		name = {
			trigger = {
				higher_or_equal_dominance_trigger = {
					FIRST_TARGET = root
					SECOND_TARGET = scope:overlord
				}
			}
			text = migration_events.0002.b.alt
		}
		if = {
			limit = {
				higher_or_equal_dominance_trigger = {
					FIRST_TARGET = root
					SECOND_TARGET = scope:overlord
				}
			}
			add_legitimacy = medium_legitimacy_gain
		}
		scope:overlord = {
			custom_tooltip = {
				text = migration_events.0001.aa.cb_tt
				if = {
					limit = {
						NOT = { # You don't already have a Retaliation CB on this guy
							is_target_in_variable_list = {
								name = retaliation_cb_var_list
								target = root
							}
						}
					}
					add_to_variable_list = {
						name = retaliation_cb_var_list
						target = root
						years = 5
					}
				}
			}
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -50
			}
			hidden_effect = {
				scope:overlord = {
					send_interface_toast = {
						left_icon = scope:new_tributary
						title = msg_tributary_toast_bad
						custom_tooltip = msg_tributary_toast_bad_tt
					}
				}
			}
		}
		ai_chance = { # AI normally doesn't refuse
			base = 10
			modifier = { # Unless...
				OR = {
					has_trait = ambitious
					has_trait = arrogant
				}
				NOT = { has_trait = craven }
				add = 120
			}
		}
	}
	
	after = {
		remove_variable = migrating_into_tributary_war_var
	}
}

scripted_trigger migration_events_1000_local_ruler_trigger = {
	NOR = {
		this = root
		is_allied_to = root
		has_truce = root
		has_any_good_relationship_with_character_trigger = { CHARACTER = root }
		is_liege_or_above_of = root
		is_vassal_or_below_of = root
	}
	OR = {
		NOT = {
			capital_county ?= root.location.county
		}
		highest_held_title_tier <= tier_duchy
	}
	gold >= 0
	NOT = {
		has_character_flag = migration_events_1000_victim_flag
	}
	#If they're present and able to defend, should be weak
	trigger_if = {
		limit = {
			government_has_flag = government_is_nomadic
			capital_county ?= root.location.county
		}
		domicile.herd <= root.domicile.herd
	}
}

######################
#Migration flavor events
#1000-1999
# by Jason Cantalini
######################

#There's some good hunting and plundering to be had here...
migration_events.1000 = {
	type = character_event
	title = migration_events.1000.t
	desc = {
		desc = migration_events.1000.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:local_ruler.capital_county ?= root.location.county
				}
				desc = migration_events.1000.desc.ruler_present
			}
			desc = migration_events.1000.desc.ruler_away
		}
		desc = migration_events.1000.desc_outro
	}
    theme = migration
	override_background = {
		reference = terrain
	}
	left_portrait = {
		character = root
		animation = standing_horse
		camera = camera_event_standing_with_horse_left
	}
	right_portrait = {
		character = scope:local_rep
		animation = war_defender
	}
	lower_right_portrait = scope:local_overlord

	trigger = {
		age >= 10
		is_migrating = yes
		has_mpo_dlc_trigger = yes
		location.county = {
			uses_county_fertility = yes
		}
		OR = {
			#Holder has lots of gold
			AND = {
				location.county = {
					uses_county_fertility = yes
					county_fertility >= 40
				}
				location.county.holder = {
					gold >= 200
				}
			}
			#Location is very fertile
			location.county = {
				county_fertility >= 70
			}
		}
		location.county.holder = {
			migration_events_1000_local_ruler_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			location.county.holder = {
				has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			add = 1
			location.county.holder = {
				gold > 500
			}
		}
		modifier = {
			add = 1
			location.county = {
				county_fertility >= 95
			}
		}
	}

	cooldown = {
		years = 5
	}

	immediate = {
		location.county = {
			save_scope_as = location_county
		}
		location.county.holder = {
			save_scope_as = local_ruler
			add_character_flag = {
				flag = migration_events_1000_victim_flag
				years = 5
			}
		}
		#Put in ruler if they are low tier
		if = {
			limit = {
				scope:location_county = scope:local_ruler.capital_county
				scope:local_ruler = {
					location.county = scope:location_county
					NOR = {
						is_incapable = yes
						has_trait = infirm
						age <= 8
					}
				}
			}
			scope:local_ruler = {
				save_scope_as = local_rep
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:local_rep
				}
			}
			scope:local_ruler = {
				random_councillor = {
					limit = {
						NOT = {
							is_spouse_of = root
						}
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:local_ruler }
					}
					save_scope_as = local_rep
				}
				save_scope_as = local_overlord
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:local_rep
				}
			}
			scope:local_ruler = {
				random_knight = {
					save_scope_as = local_rep
				}
				save_scope_as = local_overlord
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:local_rep
				}
			}
			scope:local_ruler = {
				random_courtier = {
					limit = {
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = scope:local_ruler }
						is_adult = yes
						basic_is_available_ai = yes
					}
					save_scope_as = local_rep
				}
				save_scope_as = local_overlord
			}
		}
	}
	#We can hunt for pelts too!
	option = {
		trigger = {
			has_trait = lifestyle_hunter
			NOT = {
				location = {
					terrain = desert
				}
			}
		}
		name = migration_events.1000.a
		flavor = migration_events.1000.a.flavor

		add_trait_xp = {
			trait = lifestyle_hunter
			value = medium_trait_xp
			track = hunter
		}
		add_trait_xp = {
			trait = lifestyle_hunter
			value = medium_trait_xp
			track = falconer
		}
		mpo_dominance_scaled_minor_gold_gain = yes
		reverse_add_opinion = {
			modifier = angry_opinion
			target = scope:local_ruler
			opinion = -20
		}
		stress_impact = {
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_energy = 1
			}
			modifier = {
				factor = 0.5
				scope:local_ruler = {
					government_has_flag = government_is_nomadic
					domicile.herd > root.domicile.herd
				}
			}
			modifier = {
				factor = 0
				has_trait = lazy
			}
		}
	}
	#I'm not leaving these people to their riches
	option = {
		trigger = {
			OR = {
				scope:local_ruler = {
					is_ai = yes
				}
				is_ai = no
			}
		}
		name = migration_events.1000.b
		flavor = migration_events.1000.b.flavor
		scope:local_ruler = {
			if = {
				limit = {
					treasury_or_gold >= minor_treasury_or_gold_value
				}
				pay_treasury_or_gold = {
					target = root
					value = minor_treasury_or_gold_value
				}
			}
		}
		if = {
			limit = {
				scope:local_ruler = {
					government_has_flag = government_is_herder
				}
			}
			domicile = {
				change_herd = miniscule_herd_gain
			}
			reverse_add_opinion = {
				target = scope:local_ruler
				modifier = angry_opinion
				opinion = -40
			}
		}
		else = {
			scope:local_ruler = {
				pay_herd = {
					target = root
					value = domicile.minor_herd_value
				}
				progress_towards_rival_effect = {
					REASON = rival_raided_me
					CHARACTER = root
					OPINION = -40
				}
			}
		}
		scope:location_county = {
			change_county_control = minor_county_control_loss
		}
		stress_impact = {
			greedy = miniscule_stress_impact_loss
			fickle = miniscule_stress_impact_loss
			just = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			craven = minor_stress_impact_gain
		}
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_greed = 0.5
				ai_honor = -0.5
			}
			modifier = {
				factor = 1.5
				scope:local_ruler = {
					government_has_flag = government_is_herder
				}
			}
			modifier = {
				factor = 0.25
				scope:local_ruler = {
					government_has_flag = government_is_nomadic
					domicile.herd > root.domicile.herd
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = just
					has_trait = generous
					has_trait = craven
				}
			}
		}
	}
	#Let the animals graze a while; lets grab some horses
	option = {
		name = migration_events.1000.c

		domicile = {
			change_herd = medium_herd_gain
		}
		reverse_add_opinion = {
			modifier = angry_opinion
			target = scope:local_ruler
			opinion = -20
		}
		current_travel_plan = {
			delay_travel_plan = { days = 30 }
		}
		stress_impact = {
			content = miniscule_stress_impact_loss
			impatient = medium_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = -0.5
				ai_greed = 0.5
			}
			modifier = {
				factor = 0.5
				scope:local_ruler = {
					government_has_flag = government_is_nomadic
					domicile.herd > root.domicile.herd
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = impatient
					has_trait = humble
				}
			}
		}
	}
	#Better to just keep moving
	option = {
		name = migration_events.1000.d
		scope:local_ruler = {
			add_opinion = {
				modifier = friendliness_opinion
				target = root
				opinion = 20
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_compassion = 0.5
			}
			modifier = {
				factor = 1.5
				scope:local_ruler = {
					government_has_flag = government_is_nomadic
					domicile.herd > root.domicile.herd
				}
			}
			modifier = {
				factor = 0
				has_trait = greedy
			}
		}
	}
}

scripted_trigger migration_events_1010_deserves_rest_trigger = {
	OR = {
		has_trait = wounded_2
		has_trait = wounded_3
		health <= poor_health
		has_trait = maimed
		has_trait = infirm
	}
}

#Wife wants you to get into the great yurt
migration_events.1010 = {
	type = character_event
	title = migration_events.1010.t
	desc = migration_events.1010.desc
    theme = migration
	override_background = {
		reference = wilderness
	}
	left_portrait = {
		character = root
		animation = standing_horse
		camera = camera_event_standing_with_horse_left
	}
	right_portrait = {
		character = scope:spouse
		animation = flirtation_left
	}
	cooldown = { years = 5 }

	trigger = {
		is_married = yes
		can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
		is_migrating = yes
		has_mpo_dlc_trigger = yes
		NOT = {
			has_realm_law = nomadic_authority_1
		}
		is_available_travelling_adult = yes
		NOR = {
			has_trait = infirm
			has_character_modifier = obese_modifier
		}
		primary_spouse ?= {
			is_available_allow_travelling = yes
			NOT = {
				has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
			}
			opinion = {
				target = root
				value > 0
			}
			NOT = {
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			OR = {
				migration_events_1010_deserves_rest_trigger = yes
				has_trait = wounded_1
			}
		}
		modifier = {
			add = 1
			primary_spouse ?= {
				has_any_good_relationship_with_character_trigger = { CHARACTER = root }
			}
		}
	}

	immediate = {
		location.county = {
			save_scope_as = location_county
		}
		primary_spouse = {
			save_scope_as = spouse
		}
	}
	#Yeah... I need that anyway
	option = {
		trigger = {
			OR = {
				migration_events_1010_deserves_rest_trigger = yes
				has_trait = wounded_1
			}
		}
		name = migration_events.1010.a
		random_list = {
			10 = {
				trigger = {
					has_trait = wounded_1
				}
				remove_trait = wounded_1
			}
			10 = {
				trigger = {
					has_trait = wounded_2
				}
				remove_trait = wounded_2
			}
			10 = {
				trigger = {
					has_trait = wounded_3
				}
				remove_trait = wounded_3
			}
			10 = {
				trigger = {
					has_trait = ill
				}
				remove_trait = ill
			}
			10 = {
				trigger = {
					has_trait = pneumonic
				}
				remove_trait = pneumonic
			}
			10 = {
				add_character_modifier = {
					modifier = nomadic_comforts_modifier
					years = 5
				}
			}
		}

		stress_impact = {
			base = minor_stress_impact_loss
			craven = miniscule_stress_impact_loss
			paranoid = miniscule_stress_impact_loss
			diligent = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_energy = -0.5
			}
			modifier = {
				factor = 0.5
				has_trait = diligent
			}
		}
	}
	#Yeah of course, I love you wife
	option = {
		trigger = {
			OR = {
				has_any_good_relationship_with_character_trigger = { CHARACTER = scope:spouse }
				scope:spouse = {
					opinion = {
						target = root
						value >= 80
					}
				}
				has_trait = gregarious
				has_trait = compassionate
				has_trait = lustful
				has_trait = generous
			}
			is_attracted_to_gender_of = scope:spouse
			scope:spouse = {
				is_attracted_to_gender_of = root
				NOR = {
					has_trait = celibate
					has_trait = chaste
				}
			}
			NOR = {
				has_trait = celibate
			}
		}
		add_internal_flag = special
		name = migration_events.1010.b
		if = {
			limit = {
				scope:spouse = {
					is_obedient_to = root
				}
			}
			reverse_add_opinion = {
				target = scope:spouse
				modifier = love_opinion
				opinion = 40
			}
		}
		else = {
			scope:spouse = {
				add_opinion = {
					modifier = obedience_opinion
					target = root
				}
			}
		}

		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
		if = {
			limit = {
				has_relation_lover = scope:spouse
				NOT = {
					has_relation_soulmate = scope:spouse
				}
			}
			set_relation_soulmate = {
				target = scope:spouse
				reason = lover_made_love_on_yurt_wagon
			}
		}
		else = {
			progress_towards_lover_effect = {
				REASON = lover_made_love_on_yurt_wagon
				CHARACTER = scope:spouse
				OPINION = 0
			}
		}

		stress_impact = {
			lustful = miniscule_stress_impact_gain
			chaste = medium_stress_impact_gain
			humble = miniscule_stress_impact_gain
			just = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_honor = -0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = chaste
					has_trait = humble
					has_trait = just
				}
			}
		}
	}
	#I need to be seen riding with my men
	option = {
		name = migration_events.1010.c

		if = {
			limit = {
				migration_events_1010_deserves_rest_trigger = yes
				health < fine_health
			}
			add_legitimacy = minor_legitimacy_gain
			every_knight = {
				custom = custom.every_knight
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 20
				}
			}
			stress_impact = {
				base = medium_stress_impact_gain
				lazy = medium_stress_impact_gain
				arbitrary = minor_stress_impact_gain
				fickle = minor_stress_impact_gain
				arrogant = minor_stress_impact_gain
			}
		}
		else = {
			add_legitimacy = miniscule_legitimacy_gain
			every_knight = {
				custom = custom.every_knight
				add_opinion = {
					target = root
					modifier = respect_opinion
					opinion = 10
				}
			}
			stress_impact = {
				base = miniscule_stress_impact_gain
				lazy = medium_stress_impact_gain
				arbitrary = minor_stress_impact_gain
				fickle = minor_stress_impact_gain
				arrogant = minor_stress_impact_gain
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_energy = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = lazy
					has_trait = arbitrary
					has_trait = fickle
					has_trait = arrogant
				}
			}
		}
	}
	#It does sound comfy...
	option = {
		name = migration_events.1010.d
		flavor = migration_events.1010.d.flavor
		if = {
			limit = {
				any_consort = {
					NOT = {
						this = scope:spouse
					}
				}
			}
			every_consort = {
				custom = custom.every_consort
				scope:spouse = {
					add_opinion = {
						modifier = pleased_opinion
						target = root
						opinion = 10
					}
				}
			}
		}
		else = {
			scope:spouse = {
				add_opinion = {
					modifier = pleased_opinion
					target = root
					opinion = 20
				}
			}
		}

		if = {
			limit = {
				migration_events_1010_deserves_rest_trigger = no
				health < fine_health
			}
			add_prestige = miniscule_prestige_loss
		}


		stress_impact = {
			base = minor_stress_impact_loss
			lazy = miniscule_stress_impact_loss
			content = miniscule_stress_impact_loss
			diligent = minor_stress_impact_gain
			humble = miniscule_stress_impact_gain
			just = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = -1
				ai_energy = -1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = humble
					has_trait = just
				}
			}
		}
	}
}

scripted_trigger migration_events_1020_valid_aspirant_trigger = {
	NOR = {
		is_primary_heir_of = root
		is_player_heir_of = root
		is_heir_of = root
		has_trait = loyal
		is_obedient_to = root
		has_dread_level_towards = {
			target = root
			level >= 2
		}
	}
	is_adult = yes
	is_courtier_of = root
	is_imprisoned = no
	is_healthy = yes
	OR = {
		AND = {
			is_male = yes
			faith_dominant_gender_male_or_equal = yes
		}
		AND = {
			is_female = yes
			faith_dominant_gender_female_or_equal = yes
		}
	}
	ai_boldness >= 0
	ai_energy >= 0
	ai_compassion < medium_positive_ai_value
	health >= fine_health
}

scripted_trigger migration_events_1020_very_eager_trigger = {
	OR = {
		AND = {
			ai_boldness > medium_positive_ai_value
			ai_energy > medium_positive_ai_value
		}
		opinion = {
			target = root
			value < -60
		}
		NOT = { is_obedient_to = root }
	}
	NOT = {
		has_dread_level_towards = {
			target = root
			level >= 1
		}
	}
	migration_events_1020_valid_aspirant_trigger = yes
}

scripted_effect migration_events_1020_pay_minor_herd_effect = {
	if = {
		limit = {
			OR = {
				has_realm_law = nomadic_authority_5
				has_realm_law = nomadic_authority_4
			}
		}
	}
	else_if = {
		limit = {
			has_realm_law = nomadic_authority_3
		}
	}
	else_if = {
		limit = {
			has_realm_law = nomadic_authority_2
		}
	}
	else = {

	}
}

#Family member wants to take land from local herder
migration_events.1020 = {
	type = character_event
	title = migration_events.1020.t
	desc = migration_events.1020.desc
    theme = migration
	override_background = {
		reference = terrain
	}
	left_portrait = {
		character = root
		animation = jockey_walk
		camera = camera_event_horse_left_forward
	}
	right_portrait = {
		character = scope:aspirant
		animation = horse_surveying
		camera = camera_event_horse_right_forward
	}
	lower_right_portrait = scope:herder
	lower_left_portrait = scope:herder_liege

	trigger = {
		age >= 6
		is_migrating = yes
		has_mpo_dlc_trigger = yes
		highest_held_title_tier >= tier_county
		is_available_allow_travelling = yes

		#location is takeable herder county
		location.county.holder = {
			government_has_flag = government_is_herder
			OR = {
				is_independent_ruler = yes
				liege = {
					OR = {
						is_ai = yes
						this = root
					}
					NOR = {
						is_at_war_with = root
						is_causing_raid_hostility_towards = root
						root = {
							is_causing_raid_hostility_towards = prev
						}
					}
				}
			}
		}
		location.county = {
			NOT = {
				any_county_province = {
					OR = {
						is_raided = yes
						is_occupied = yes
					}
				}
			}
		}

		#valid breakoff ruler
		OR = {
			any_child = {
				migration_events_1020_valid_aspirant_trigger = yes
			}
			any_sibling = {
				migration_events_1020_valid_aspirant_trigger = yes
			}
			dynasty ?= {
				any_dynasty_member = {
					migration_events_1020_valid_aspirant_trigger = yes
				}
			}
		}
		#A bit weird if you are great khan and your relatives are begging for some sheep
		NOT = {
			has_realm_law = nomadic_authority_5
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			OR = {
				any_child = {
					migration_events_1020_very_eager_trigger = yes
				}
				any_sibling = {
					migration_events_1020_very_eager_trigger = yes
				}
				dynasty ?= {
					any_dynasty_member = {
						migration_events_1020_very_eager_trigger = yes
					}
				}
			}
		}
		modifier = {
			add = -1
			has_realm_law = nomadic_authority_4
		}
	}

	cooldown = {
		years = 5
	}

	immediate = {
		location.county = {
			save_scope_as = location_county
			holder = {
				save_scope_as = herder
				if = {
					limit = {
						is_independent_ruler = no
					}
					liege = {
						save_scope_as = herder_liege
					}
				}
			}
		}
		if = {
			limit = {
				exists = dynasty
			}
			dynasty = {
				ordered_dynasty_member = {
					order_by = age
					limit = {
						migration_events_1020_valid_aspirant_trigger = yes
					}
					save_scope_as = aspirant
				}
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:aspirant
				}
			}
			ordered_sibling = {
				order_by = age
				limit = {
					migration_events_1020_valid_aspirant_trigger = yes
				}
				save_scope_as = aspirant
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:aspirant
				}
			}
			ordered_child = {
				order_by = age
				limit = {
					migration_events_1020_valid_aspirant_trigger = yes
				}
				save_scope_as = aspirant
			}
		}
		random_knight = {
			limit = {
				is_landed = no
				is_councillor = no
				has_any_court_position = no
				NOR = {
					is_spouse_of = root
					is_heir_of = root
					this = scope:aspirant
				}
				is_available_allow_travelling = yes
				is_acclaimed = no
				is_accolade_successor = no
			}
			save_scope_as = knight_1
		}
		random_knight = {
			limit = {
				is_landed = no
				is_councillor = no
				has_any_court_position = no
				NOR = {
					is_spouse_of = root
					is_heir_of = root
					this = scope:aspirant
					this = scope:knight_1
				}
				is_available_allow_travelling = yes
				is_acclaimed = no
				is_accolade_successor = no
			}
			save_scope_as = knight_2
		}
		save_scope_as = root_scope
	}
	#Yes, as my tributary of course!
	option = {
		trigger = {
			NOT = {
				exists = scope:herder_liege
			}
			OR = {
				has_realm_law = nomadic_authority_2
				has_realm_law = nomadic_authority_3
				has_realm_law = nomadic_authority_4
				has_realm_law = nomadic_authority_5
			}
		}
		add_internal_flag = special
		name = migration_events.1020.a

		add_prestige = minor_prestige_gain

		create_title_and_vassal_change = {
			type = usurped
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:location_county = {
			change_title_holder = {
				holder = scope:aspirant
				change = scope:change
			}
		}
		scope:aspirant = {
			add_opinion = {
				target = root
				modifier = helpful_opinion
				opinion = 20
			}
		}
		resolve_title_and_vassal_change = scope:change
		scope:aspirant = {
			change_government = nomad_government
			add_courtier = scope:herder
			scope:herder = {
				pay_short_term_gold = {
					target = scope:aspirant
					gold = current_gold_value
				}
			}
			start_tributary_interaction_effect = {
				TRIBUTARY = scope:aspirant
				SUZERAIN = root
			}
		}
		pay_herd = {
			target = scope:aspirant
			value = domicile.minor_herd_value
		}

		stress_impact = {
			generous = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			paranoid = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_greed = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = humble
					has_trait = compassionate
				}
			}
		}
	}
	#I will establish you here properly
	option = {
		trigger = {
			culture = scope:aspirant.culture
			domicile = {
				herd >= major_herd_value
			}
		}
		name = migration_events.1020.b
		flavor = migration_events.1020.b.flavor

		dynasty ?= {
			add_dynasty_prestige = miniscule_dynasty_prestige_gain

		}

		create_title_and_vassal_change = {
			type = usurped
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:location_county = {
			change_title_holder = {
				holder = scope:aspirant
				change = scope:change
			}
		}
		scope:aspirant = {
			add_opinion = {
				target = root
				modifier = helpful_opinion
				opinion = 60
			}
			progress_towards_friend_effect = {
				REASON = friend_granted_title
				CHARACTER = root
				OPINION = 0
			}
			if = {
				limit = {
					exists = scope:herder_liege
				}
				change_liege = {
					liege = scope:herder_liege
					change = scope:change
				}
			}
		}
		resolve_title_and_vassal_change = scope:change
		scope:aspirant = {
			change_government = nomad_government
		}
		scope:aspirant = {
			add_prestige = medium_prestige_gain
		}
		scope:location_county = {
			if = {
				limit = {
					NOT = {
						culture = scope:aspirant.culture
					}
				}
				set_county_culture = scope:aspirant.culture
			}
			if = {
				limit = {
					NOT = {
						faith = scope:aspirant.faith
					}
				}
				set_county_faith = scope:aspirant.faith
			}
		}
		scope:aspirant = {
			add_courtier = scope:herder
			scope:herder = {
				pay_short_term_gold = {
					target = scope:aspirant
					gold = current_gold_value
				}
			}
			if = {
				limit = {
					exists = scope:knight_1
				}
				add_courtier = scope:knight_1
				scope:knight_1 = {
					every_spouse = {
						limit = {
							is_imprisoned = no
							is_courtier_of = root
						}
						scope:aspirant = {
							add_courtier = prev
						}
					}
					hidden_effect = {
						every_child = {
							limit = {
								is_imprisoned = no
								is_courtier_of = root
								is_adult = no
							}
							scope:aspirant = {
								add_courtier = prev
							}
						}
					}
				}
			}
			if = {
				limit = {
					exists = scope:knight_2
				}
				add_courtier = scope:knight_2
				scope:knight_2 = {
					every_spouse = {
						limit = {
							is_imprisoned = no
							is_courtier_of = root
						}
						scope:aspirant = {
							add_courtier = prev
						}
					}
					hidden_effect = {
						every_child = {
							limit = {
								is_imprisoned = no
								is_courtier_of = root
								is_adult = no
							}
							scope:aspirant = {
								add_courtier = prev
							}
						}
					}
				}
			}
		}
		pay_herd = {
			target = scope:aspirant
			value = domicile.major_herd_value
		}
		add_prestige = medium_prestige_loss

		if = {
			limit = {
				scope:herder_liege ?= {
					NOT = {
						this = root
					}
				}
			}
			scope:herder_liege = {
				reverse_add_opinion = {
					target = root
					modifier = disrespect_opinion
					opinion = -30
				}
			}
		}

		stress_impact = {
			greedy = medium_stress_impact_gain
			paranoid = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -0.5
				ai_compassion = 0.5
			}
			modifier = {
				factor = 0
				has_trait = greedy
			}
		}
	}
	#Good luck kid
	option = {
		name = migration_events.1020.c
		create_title_and_vassal_change = {
			type = usurped
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:location_county = {
			change_title_holder = {
				holder = scope:aspirant
				change = scope:change
			}
		}
		scope:aspirant = {
			add_opinion = {
				target = root
				modifier = helpful_opinion
				opinion = 30
			}
			if = {
				limit = {
					exists = scope:herder_liege
				}
				change_liege = {
					liege = scope:herder_liege
					change = scope:change
				}
			}
		}
		resolve_title_and_vassal_change = scope:change
		scope:aspirant = {
			change_government = nomad_government
			add_courtier = scope:herder
			scope:herder = {
				pay_short_term_gold = {
					target = scope:aspirant
					gold = current_gold_value
				}
			}
		}
		pay_herd = {
			target = scope:aspirant
			value = domicile.minor_herd_value
		}

		if = {
			limit = {
				scope:herder_liege ?= {
					NOT = {
						this = root
					}
				}
			}
			scope:herder_liege = {
				reverse_add_opinion = {
					target = root
					modifier = disrespect_opinion
					opinion = -30
				}
			}
		}

		stress_impact = {
			paranoid = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_greed = 0.5
			}
		}
	}
	#No, remain with your people
	option = {
		name = migration_events.1020.d

		if = {
			limit = {
				OR = {
					has_trait = wrathful
					has_trait = sadistic
					has_trait = vengeful
					has_trait = paranoid
					has_trait = torturer
					has_trait = overseer
					has_trait = greatest_of_khans
					has_trait = irritable
				}
			}
			add_dread = miniscule_dread_gain
		}
		scope:aspirant = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -15
			}
		}

		stress_impact = {
			generous = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = trusting
				}
			}
		}
	}
}

#Your animals are hungry
migration_events.1030 = {
	type = character_event
	title = migration_events.1030.t
	desc = migration_events.1030.desc
    theme = migration
	override_background = {
		reference = mpo_steppe_evening
	}
	left_portrait = {
		character = root
		animation = horse_exhausted
		camera = camera_event_horse_left
	}
	lower_right_portrait = scope:local_ruler

	trigger = {
		age >= 6
		is_migrating = yes
		has_mpo_dlc_trigger = yes
		highest_held_title_tier >= tier_county
		is_available_allow_travelling = yes
		location.county.holder = {
			is_ai = yes
			NOR = {
				has_relation_rival = root
				has_relation_nemesis = root
				is_at_war_with = root
			}
		}
		location.county = {
			uses_county_fertility = yes
			NOT = {
				any_county_province = {
					OR = {
						is_raided = yes
						is_occupied = yes
					}
				}
			}
			county_fertility <= 40
		}
		domicile = {
			herd >= major_herd_value
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			OR = {
				has_realm_law = nomadic_authority_4
				has_realm_law = nomadic_authority_5
			}
		}
		modifier = {
			add = 1
			location.county = {
				county_fertility <= 10
			}
		}
		modifier = {
			add = 1
			location.county = {
				county_fertility <= 20
			}
		}
	}

	cooldown = {
		years = 5
	}

	immediate = {
		location.county = {
			save_scope_as = location_county
			holder = {
				save_scope_as = local_ruler
			}
		}
	}
	#The local ruler WILL provide good pasture
	option = {
		trigger = {
			dread >= 50
			OR = {
				scope:local_ruler = {
					has_dread_level_towards = {
						target = root
						level >= 1
					}
				}
				has_realm_law = nomadic_authority_5
				AND = {
					has_realm_law = nomadic_authority_4
					scope:local_ruler = {
						OR = {
							has_realm_law = nomadic_authority_2
							has_realm_law = nomadic_authority_1
						}
					}
				}
				AND = {
					has_realm_law = nomadic_authority_3
					scope:local_ruler = {
						has_realm_law = nomadic_authority_1
					}
				}
			}
		}
		name = migration_events.1030.a

		add_dread = minor_dread_gain

		reverse_add_opinion = {
			modifier = threatened_opinion
			target = scope:local_ruler
			opinion = -20
		}
		current_travel_plan = {
			delay_travel_plan = { days = 10 }
		}

		stress_impact = {
			arrogant = miniscule_stress_impact_loss
			craven = minor_stress_impact_gain
			just = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 300
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_honor = -0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = just
					has_trait = humble
				}
			}
		}
	}
	#Sell the animals to the local ruler
	option = {
		trigger = {
			diplomacy > high_skill_rating
			trigger_if = {
				limit = {
					OR = {
						has_realm_law = nomadic_authority_4
						has_realm_law = nomadic_authority_5
					}
				}
				scope:local_ruler.gold >= root.monumental_gold_value
			}
			trigger_if = {
				limit = {
					has_realm_law = nomadic_authority_3
				}
				scope:local_ruler.gold >= root.massive_gold_value
			}
			trigger_if = {
				limit = {
					has_realm_law = nomadic_authority_2
				}
				scope:local_ruler.gold >= root.major_gold_value
			}
			trigger_if = {
				limit = {
					has_realm_law = nomadic_authority_1
				}
				scope:local_ruler.gold >= root.medium_gold_value
			}
		}
		name = migration_events.1030.b
		flavor = migration_events.1030.b.flavor

		if = {
			limit = {
				OR = {
					has_realm_law = nomadic_authority_4
					has_realm_law = nomadic_authority_5
				}
			}
			scope:local_ruler = {
				pay_treasury_or_gold = {
					target = root
					value = root.monumental_treasury_or_gold_value
				}
			}
		}
		if = {
			limit = {
				has_realm_law = nomadic_authority_3
			}
			scope:local_ruler = {
				pay_treasury_or_gold = {
					target = root
					value = root.massive_treasury_or_gold_value
				}
			}
		}
		if = {
			limit = {
				has_realm_law = nomadic_authority_2
			}
			scope:local_ruler = {
				pay_treasury_or_gold = {
					target = root
					value = root.major_treasury_or_gold_value
				}
			}
		}
		if = {
			limit = {
				has_realm_law = nomadic_authority_1
			}
			scope:local_ruler = {
				pay_treasury_or_gold = {
					target = root
					value = root.medium_treasury_or_gold_value
				}
			}
		}

		pay_herd = {
			target = scope:local_ruler
			value = domicile.medium_herd_value
		}
		reverse_add_opinion = {
			modifier = pleased_opinion
			target = scope:local_ruler
			opinion = 20
		}

		stress_impact = {
			honest = minor_stress_impact_gain
			just = minor_stress_impact_gain
			generous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_greed = 0.5
				ai_honor = -0.5
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = honest
					has_trait = just
					has_trait = generous
				}
			}
		}
	}
	#Slaughter the animals and have a feast
	option = {
		name = migration_events.1030.c
		flavor = migration_events.1030.c.flavor

		if = {
			limit = {
				has_trait = lifestyle_reveler
			}
			add_trait_xp = {
				trait = lifestyle_reveler
				value = 10
			}
		}
		add_prestige = medium_prestige_gain
		every_courtier = {
			custom = custom.every_courtier
			add_opinion = {
				modifier = grateful_opinion
				target = root
				opinion = 20
			}
		}
		domicile = {
			change_herd = major_herd_loss
		}

		stress_impact = {
			gluttonous = minor_stress_impact_loss
			generous = miniscule_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			temperate = minor_stress_impact_gain
			stubborn = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 0.5
				ai_greed = -0.5
			}
			modifier = {
				factor = 0
				has_trait = temperate
			}
		}
	}
	#We need to search for somewhere they can graze
	option = {
		name = migration_events.1030.d

		duel = {
			skill = stewardship
			value = decent_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				modifier = {
					has_realm_law = nomadic_authority_1
					add = 20
				}
				modifier = {
					has_realm_law = nomadic_authority_2
					add = 10
				}
				desc = migration_events.1030.d.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = migration_events.1030.d.success
					left_icon = root
					if = {
						limit = {
							NOT = {
								has_trait = lifestyle_traveler
							}
						}
						add_trait = lifestyle_traveler
					}
					else = {
						add_trait_xp = {
							trait = lifestyle_traveler
							track = danger
							value = small_lifestyle_random_xp_mid
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				modifier = {
					OR = {
						has_realm_law = nomadic_authority_5
						has_realm_law = nomadic_authority_4
					}
					add = 20
				}
				desc = migration_events.1030.d.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = migration_events.1030.d.failure
					left_icon = root

					domicile = {
						change_herd = medium_herd_loss
					}
				}
			}
		}
		current_travel_plan = {
			delay_travel_plan = { days = 20 }
		}

		stress_impact = {
			impatient = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.5
			}
			modifier = {
				factor = 0
				has_trait = impatient
			}
		}
	}
}

#Local ruler offers you traditional hospitality and a gift
migration_events.1040 = {
	type = character_event
	title = migration_events.1040.t
	desc = {
		desc = migration_events.1040.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					root.current_location = {
						OR = {
							terrain = taiga
							terrain = forest
							terrain = jungle
							terrain = wetlands
						}
					}
				}
				desc = migration_events.1040.furs
			}
			triggered_desc = {
				trigger = {
					root.current_location = {
						OR = {
							terrain = desert
							terrain = desert_mountains
						}
					}
				}
				desc = migration_events.1040.camels
			}
			triggered_desc = {
				trigger = {
					root.current_location = {
						OR = {
							terrain = hills
							terrain = mountains
							terrain = drylands
						}
					}
				}
				desc = migration_events.1040.wool
			}
			desc = migration_events.1040.horses
		}
	}
    theme = migration
	override_background = {
		reference = mpo_camp_steppe
	}
	left_portrait = {
		character = root
		animation = standing_horse
		camera = camera_event_standing_with_horse_left
	}
	right_portrait = {
		character = scope:local_ruler
		animation = throne_room_bow_1
	}

	trigger = {
		age >= 10
		is_migrating = yes
		has_mpo_dlc_trigger = yes
		location.county = {
			NOT = {
				any_county_province = {
					OR = {
						is_raided = yes
						is_occupied = yes
					}
				}
			}
		}
		location.county.holder = {
			NOT = { this = root }
			age >= 12
			basic_is_available_ai = yes
			mpo_lower_nomad_authority_trigger = { CHARACTER = root }
			OR = {
				government_has_flag = government_is_nomadic
				government_has_flag = government_is_herder
			}
			NOR = {
				has_character_flag = migration_events_1040_giver_flag
				is_at_war_with = root
				is_causing_raid_hostility_towards = root
				root = {
					is_causing_raid_hostility_towards = prev
				}
				has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
			}
			ai_greed <= low_positive_ai_value
			OR = {
				opinion = {
					target = root
					value >= -20
				}
				has_dread_level_towards = {
					target = root
					level >= 1
				}
			}
		}
	}

	weight_multiplier = {
		base = 2
		modifier = {
			add = -1
			location.county.holder = {
				opinion = {
					target = root
					value <= 0
				}
			}
		}
		modifier = {
			add = 1
			location.county.holder = {
				opinion = {
					target = root
					value >= 70
				}
			}
		}
		modifier = {
			add = 1
			location.county.holder = {
				is_vassal_or_below_of = root
			}
		}
		modifier = {
			add = 1
			location.county.holder = {
				is_allied_to = root
			}
		}
		modifier = {
			add = 1
			location.county.holder = {
				has_dread_level_towards = {
					target = root
					level >= 2
				}
			}
		}
	}

	cooldown = {
		years = 5
	}

	immediate = {
		location.county = {
			save_scope_as = location_county
		}
		location.county.holder = {
			save_scope_as = local_ruler
			add_character_flag = {
				flag = migration_events_1040_giver_flag
				years = 1
			}
		}
	}
	#That's all...?
	option = {
		trigger = {
			OR = {
				has_realm_law = nomadic_authority_5
				AND = {
					has_realm_law = nomadic_authority_4
					scope:local_ruler = {
						NOT = { has_realm_law = nomadic_authority_4 }
					}
				}
				AND = {
					has_realm_law = nomadic_authority_3
					scope:local_ruler = {
						NOT = { has_realm_law = nomadic_authority_3 }
					}
				}
			}
			OR = {
				has_trait = avaricious
				has_trait = conqueror
				has_trait = greatest_of_khans
				is_gurkhan = yes
				scope:local_ruler = {
					has_dread_level_towards = {
						target = root
						level >= 2
					}
				}
			}
		}
		name = migration_events.1040.a
		add_internal_flag = special

		add_prestige = minor_prestige_gain
		scope:local_ruler = {
			pay_herd = {
				target = root
				value = domicile.medium_herd_value
			}
		}
		scope:local_ruler = {
			add_opinion = {
				target = root
				modifier = humiliated_opinion
				opinion = -50
			}
			progress_towards_rival_effect = {
				REASON = rival_extorted_me_for_gifts
				CHARACTER = root
				OPINION = 0
			}
		}
		stress_impact = {
			base = minor_stress_impact_loss
			greedy = miniscule_stress_impact_loss
			temperate = miniscule_stress_impact_gain
			impatient = miniscule_stress_impact_gain
			humble = miniscule_stress_impact_gain
			generous = major_stress_impact_gain
			compassionate = medium_stress_impact_gain
			content = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
				ai_compassion = -1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = compassionate
					has_trait = content
				}
			}
		}
	}
	#We can trade gifts!
	option = {
		trigger = {
			domicile = {
				herd >= minor_herd_value
			}
		}
		name = migration_events.1040.b

		#Cultural acceptance gain
		if = {
			limit = {
				NOT = {
					culture = scope:local_ruler.culture
				}
				OR = {
					root.culture = {
						culture_head = root
					}
					scope:local_ruler.culture = {
						culture_head = scope:local_ruler
					}
				}
			}
			culture = {
				change_cultural_acceptance = {
					target = scope:local_ruler.culture
					value = minor_cultural_acceptance_gain
					desc = cultural_acceptance_meal_of_hospitality
				}
			}
		}
		else_if = {
			limit = {
				NOT = {
					culture = scope:local_ruler.culture
				}
				#These rulers should be at least a little significant
				NOT = {
					has_realm_law = nomadic_authority_1
				}
				is_ai = no
			}
			culture = {
				change_cultural_acceptance = {
					target = scope:local_ruler.culture
					value = miniscule_cultural_acceptance_gain
					desc = cultural_acceptance_meal_of_hospitality
				}
			}
		}
		scope:local_ruler = {
			add_opinion = {
				target = root
				modifier = friendliness_opinion
				opinion = 20
			}
		}
		stress_impact = {
			base = minor_stress_impact_loss
			gluttonous = miniscule_stress_impact_loss
			generous = miniscule_stress_impact_loss
			temperate = miniscule_stress_impact_gain
			impatient = miniscule_stress_impact_gain
			paranoid = miniscule_stress_impact_gain
			greedy = medium_stress_impact_gain
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_sociability = 1
				ai_greed = -1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = callous
					has_trait = sadistic
					AND = {
						OR = {
							has_realm_law = nomadic_authority_5
							has_realm_law = nomadic_authority_4
						}
						scope:local_ruler = {
							has_realm_law = nomadic_authority_1
						}
					}
				}
			}
		}
	}
	#We have no time to dawdle
	option = {
		name = migration_events.1040.c
		add_character_modifier = {
			modifier = mpo_refusing_diplomatic_stops_modifier
			months = 6
		}
		reverse_add_opinion = {
			target = scope:local_ruler
			modifier = spurned_gift_opinion
			opinion = -25
		}
		if = {
			limit = {
				is_ai = no
			}
			scope:local_ruler = {
				add_prestige = minor_prestige_loss
			}
		}
		stress_impact = {
			impatient = minor_stress_impact_loss
			gregarious = medium_stress_impact_gain
			gluttonous = medium_stress_impact_gain
			humble = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			lazy = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = -1
				ai_energy = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = gregarious
					has_trait = gluttonous
					has_trait = humble
					has_trait = patient

				}
			}
		}
	}
	#Yeah, thanks
	option = {
		name = migration_events.1040.d

		scope:local_ruler = {
			pay_herd = {
				target = root
				value = domicile.miniscule_herd_value
			}
		}
		stress_impact = {
			base = minor_stress_impact_loss
			gluttonous = miniscule_stress_impact_loss
			temperate = miniscule_stress_impact_gain
			impatient = miniscule_stress_impact_gain
			paranoid = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
				ai_greed = 1
			}
		}
	}
}

#Your warriors overrun a local settlement and offer you spoils
migration_events.1050 = {
	type = character_event
	title = migration_events.1050.t
	desc = migration_events.1050.desc
    theme = migration
	override_background = {
		reference = mpo_campfire_steppe
	}
	left_portrait = {
		character = root
		animation = personality_dishonorable
	}
	right_portrait = {
		character = scope:warrior
		animation = random_weapon_celebrate
	}
	lower_right_portrait = scope:local_ruler

	trigger = {
		age >= 6
		is_migrating = yes
		has_mpo_dlc_trigger = yes
		location.county = {
			NOT = {
				any_county_province = {
					OR = {
						is_raided = yes
						is_occupied = yes
					}
				}
			}
		}
		location.county.holder = {
			NOR = {
				has_character_flag = migration_events_1050_raided_flag
				has_any_good_relationship_with_character_trigger = { CHARACTER = root }
				is_tributary_of = root
				root = {
					is_tributary_of = prev
				}
				is_vassal_or_below_of = root
				root = {
					is_vassal_or_below_of = prev
				}
				is_allied_to = root
				house ?= root.house
				has_truce = root
			}
		}
		any_courtier = {
			is_adult = yes
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
			basic_is_available_ai = yes
		}
	}

	weight_multiplier = {
		base = 2
		modifier = {
			add = -1
			location.county.holder = {
				opinion = {
					target = root
					value >= 60
				}
			}
		}
		modifier = {
			add = -1
			location.county.holder = {
				culture = root.culture
			}
		}
		modifier = {
			add = 1
			location.county.holder = {
				OR = {
					is_at_war_with = root
					is_causing_raid_hostility_towards = root
					root = {
						is_causing_raid_hostility_towards = prev
					}
					has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
				}
			}
		}
	}

	cooldown = {
		years = 5
	}

	immediate = {

		location.county = {
			save_scope_as = location_county
		}
		location.county.holder = {
			save_scope_as = local_ruler
			add_character_flag = {
				flag = migration_events_1050_raided_flag
				years = 1
			}
		}
		random_dummy_gender_soldier_effect = { SCOPE_NAME = dummy_gender }
		hidden_effect = {
			scope:local_ruler = {
				random_list = {
					45 = {
						save_scope_value_as = {
							name = quality
							value = 5
						}
						save_scope_value_as = {
							name = wealth
							value = 5
						}
					}
					45 = {
						save_scope_value_as = {
							name = quality
							value = 10
						}
						save_scope_value_as = {
							name = wealth
							value = 10
						}
					}
					5 = {
						save_scope_value_as = {
							name = quality
							value = 20
						}
						save_scope_value_as = {
							name = wealth
							value = 20
						}
					}
					5 = {
						save_scope_value_as = {
							name = quality
							value = 30
						}
						save_scope_value_as = {
							name = wealth
							value = 30
						}
					}
					5 = {
						trigger = {
							scope:local_ruler = {
								highest_held_title_tier >= tier_kingdom
							}
						}
						save_scope_value_as = {
							name = quality
							value = 40
						}
						save_scope_value_as = {
							name = wealth
							value = 40
						}
					}
					5 = {
						trigger = {
							scope:local_ruler = {
								highest_held_title_tier >= tier_empire
							}
						}
						save_scope_value_as = {
							name = quality
							value = 50
						}
						save_scope_value_as = {
							name = wealth
							value = 50
						}
					}
				}
				clear_saved_scope = root
				save_scope_as = root
				random_list = {
					1 = {
						create_artifact_bow_effect = { OWNER = scope:local_ruler CREATOR = scope:dummy_gender SET_BOW_TYPE = flag:artifact_bow_type_composite }
					}
					1 = {
						create_artifact_necklace_effect = { OWNER = scope:local_ruler SMITH = scope:dummy_gender }
					}
					1 = {
						create_artifact_armor_effect = {
							OWNER = scope:local_ruler
							CREATOR = scope:dummy_gender
							SET_ARMOR_TYPE = flag:no
						}
					}
					1 = {
						create_artifact_animal_hide_effect = {
							OWNER = scope:local_ruler
							HUNTER = scope:local_ruler
							LEGENDARY = no
							ANIMAL = flag:none
						}
					}
					1 = {
						create_artifact_weapon_effect = {
							OWNER = scope:local_ruler
							CREATOR = scope:dummy_gender
							SET_WEAPON_TYPE = flag:no
						}
					}
					1 = {
						create_artifact_ring_effect = {
							OWNER = scope:local_ruler
							SMITH = scope:dummy_gender
						}
					}
					1 = {
						create_artifact_bowl_effect = {
							OWNER = scope:local_ruler
							SMITH = scope:dummy_gender
						}
					}
					1 = {
						create_artifact_brooch_effect = {
							OWNER = scope:local_ruler
							SMITH = scope:dummy_gender
						}
					}
				}
			}
		}
		clear_saved_scope = root
		save_scope_as = root

		random_knight = {
			limit = {
				is_acclaimed = yes
				is_courtier_of = root
			}
			save_scope_as = warrior
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			random_knight = {
				limit = {
					is_courtier_of = root
				}
				save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			random_courtier = {
				limit = {
					is_adult = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					basic_is_available_ai = yes
				}
				save_scope_as = warrior
			}
		}
		scope:warrior = {
			add_character_flag = need_military_outfit
		}
		scope:local_ruler = {
			add_opinion = {
				target = root
				opinion = -25
				modifier = raided_me_opinion
			}
			#Steal from AI if root is player
			if = {
				limit = {
					root = {
						is_ai = no
					}
				}
				if = {
					limit = {
						government_has_flag = government_is_nomadic
					}
					pay_herd = {
						target = root
						value = root.domicile.minor_herd_value
					}
				}
				else = {
					root.domicile = {
						change_herd = minor_herd_gain
					}
				}
				pay_short_term_gold = {
					target = root
					gold = root.minor_gold_value
				}
				root.location.county = {
					change_county_control = minor_county_control_loss
				}
			}
			#Simply gain resources if not
			else = {
				root = {
					domicile = {
						change_herd = minor_herd_gain
					}
					add_gold = minor_gold_value
				}
			}
		}
	}
	#You're a bold captain, warrior, and deserve acknowledgement
	option = {
		trigger = {
			OR = {
				has_trait = gallant
				has_trait = strategist
				has_trait = education_martial_prowess_2
				has_trait = education_martial_prowess_3
				has_trait = education_martial_prowess_4
				has_trait = education_martial_3
				has_trait = education_martial_4
				has_trait = education_martial_5
			}
		}
		name = migration_events.1050.a

		scope:newly_created_artifact = {
			add_artifact_history = {
				location = root.location
				actor = scope:local_ruler
				recipient = scope:warrior
				type = stolen
			}
			set_owner = scope:warrior
		}
		if = {
			limit = {
				scope:warrior = {
					is_acclaimed = yes
				}
			}
			scope:warrior.accolade = {
				add_glory = minor_glory_gain
			}
			scope:warrior = {
				add_martial_skill = 1
			}
		}
		else_if = {
			limit = {
				scope:warrior = {
					NOT = {
						has_trait = reaver
					}
				}
			}
			scope:warrior = {
				add_trait = reaver
				add_martial_skill = 1
			}
		}
		else = {
			scope:warrior = {
				add_martial_skill = 1
				add_prowess_skill = 1
			}
		}
		if = {
			limit = {
				scope:warrior = {
					NOT = { is_obedient_to = root }
				}
			}
			scope:warrior = {
				add_opinion = {
					modifier = obedience_opinion
					target = root
				}
			}
		}
		else_if = {
			limit = {
				scope:warrior = {
					NOT = {
						has_trait = disloyal
					}
				}
			}
			scope:warrior = {
				add_trait = loyal
			}
		}

		stress_impact = {
			greedy = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_honor = 1
			}
			modifier = {
				factor = 0
				OR = {

				}
			}
		}
	}
	#BURN AND DESPOIL AS WE GO
	option = {
		trigger = {
			NOT = {
				has_realm_law = nomadic_authority_1
			}
			OR = {
				has_trait = sadistic
				has_trait = greedy
				has_trait = wrathful
				has_trait = arbitrary
				has_trait = avaricious
				has_trait = torturer
				has_trait = conqueror
				has_trait = greatest_of_khans
				has_trait = overseer
				has_trait = viking
			}
		}
		name = migration_events.1050.b

		#Gain gold and herd every time you travel into a new province
		if = {
			limit = {
				OR = {
					has_realm_law = nomadic_authority_4
					has_realm_law = nomadic_authority_5
					has_realm_law = nomadic_authority_3
					culture = {
						culture_head = root
					}
				}
			}
			custom_tooltip = migration_raiding_effect_tt
		}
		else = {
			custom_tooltip = migration_raiding_effect_no_culture_tt
		}
		scope:newly_created_artifact = {
			add_artifact_history = {
				location = root.location
				actor = scope:local_ruler
				recipient = root
				type = stolen
			}
			set_owner = root
		}

		add_character_flag = {
			flag = migration_raiding_flag
			years = 1
		}
		add_dread = minor_dread_gain

		stress_impact = {
			compassionate = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			just = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 150
			ai_value_modifier = {
				ai_boldness = 1
				ai_compassion = -1
				ai_greed = 1
			}
			modifier = {
				factor = 0.5
				has_realm_law = nomadic_authority_3
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = content
					has_trait = craven
					has_trait = compassionate
					has_trait = just
					has_trait = paranoid
				}
			}
		}
	}
	#This was cruel, and all loot should be returned to the survivors
	option = {
		trigger = {
			OR = {
				has_trait = just
				has_trait = compassionate
				has_trait = generous
				has_trait = forgiving
				has_trait = trusting
				has_trait = humble
				has_trait = diplomat
				has_trait = education_diplomacy_3
				has_trait = education_diplomacy_4
				has_trait = education_diplomacy_5
			}
		}
		name = migration_events.1050.c

		hidden_effect = {
			destroy_artifact = scope:newly_created_artifact
		}
		#Increase culture acceptance
		if = {
			limit = {
				OR = {
					has_realm_law = nomadic_authority_4
					has_realm_law = nomadic_authority_5
					has_realm_law = nomadic_authority_3
					culture = {
						culture_head = root
					}
				}
				NOT = {
					culture = scope:local_ruler.culture
				}
			}
			culture = {
				change_cultural_acceptance = {
					target = scope:local_ruler.culture
					value = minor_cultural_acceptance_gain
					desc = cultural_acceptance_recompense_for_raiding
				}
			}

		}
		else = {
			add_piety = medium_piety_gain
		}
		scope:local_ruler = {
			add_opinion = {
				target = root
				modifier = kindness_opinion
				opinion = 50
			}
		}
		location.county = {
			change_county_control = minor_county_control_gain
		}
		remove_short_term_gold = minor_gold_value
		domicile = {
			change_herd = minor_herd_loss
		}

		stress_impact = {
			greedy = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			vengeful = miniscule_stress_impact_gain
			sadistic = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 1
				ai_greed = -1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = arbitrary
					has_trait = arrogant
					has_trait = sadistic
					has_trait = callous
				}
			}
		}
	}
	#Distribute my share among my men
	option = {
		name = migration_events.1050.d

		scope:newly_created_artifact = {
			add_artifact_history = {
				location = root.location
				actor = scope:local_ruler
				recipient = scope:warrior
				type = stolen
			}
			set_owner = scope:warrior
		}

		remove_short_term_gold = minor_gold_value
		domicile = {
			change_herd = minor_herd_loss
		}
		if = {
			limit = {
				any_knight = {
					NOT = {
						this = scope:warrior
					}
				}
			}
			every_knight = {
				custom = custom.every_knight
				if = {
					limit = {
						root = { has_realm_law = nomadic_authority_1 }
					}
					add_opinion = {
						target = root
						opinion = 25
						modifier = loyalty_opinion
					}
					add_prowess_skill = 1
				}
				else_if = {
					limit = {
						root = { has_realm_law = nomadic_authority_2 }
					}
					add_opinion = {
						target = root
						opinion = 20
						modifier = loyalty_opinion
					}
					add_prowess_skill = 1
				}
				else_if = {
					limit = {
						root = { has_realm_law = nomadic_authority_3 }
					}
					add_opinion = {
						target = root
						opinion = 15
						modifier = loyalty_opinion
					}
					add_stress = minor_stress_impact_loss
				}
				else = {
					add_opinion = {
						target = root
						opinion = 10
						modifier = loyalty_opinion
					}
					add_stress = minor_stress_impact_loss
				}
			}
		}
		else = {
			scope:warrior = {
				if = {
					limit = {
						root = { has_realm_law = nomadic_authority_1 }
					}
					add_prowess_skill = 1
				}
				else_if = {
					limit = {
						root = { has_realm_law = nomadic_authority_2 }
					}
					add_prowess_skill = 1
				}
				else_if = {
					limit = {
						root = { has_realm_law = nomadic_authority_3 }
					}
					add_stress = minor_stress_impact_loss
				}
				else = {
					add_stress = minor_stress_impact_loss
				}
			}
		}
		
		if = {
			limit = {
				any_knight = {
					NOT = { is_obedient_to = root }
				}
			}
			random_knight = {
				limit = { NOT = { is_obedient_to = root } }
				add_opinion = {
					modifier = obedience_opinion
					target = root
				}
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = -1
				ai_honor = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = arrogant
				}
			}
		}
	}
	#I will take my share
	option = {
		name = migration_events.1050.e

		#Gain artifact

		scope:newly_created_artifact = {
			add_artifact_history = {
				location = root.location
				actor = scope:local_ruler
				recipient = root
				type = stolen
			}
			set_owner = root
		}

		stress_impact = {
			generous = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			just = miniscule_stress_impact_gain
			compassionate = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = generous
					has_trait = humble
				}
			}
		}
	}
	after = {
		scope:warrior = {
			remove_character_flag = need_military_outfit
		}
	}
}

migration_events.1051 = {
	hidden = yes

	immediate = {
		location = {
			save_scope_as = raided_settlement
		}
		send_interface_message = {
			type = event_raiding_good_with_text
			title = migration_events.1051_title
			desc = migration_events.1051_tooltip
			left_icon = scope:local_ruler

			if = {
				limit = {
					OR = {
						has_realm_law = nomadic_authority_4
						has_realm_law = nomadic_authority_5
					}
				}
				add_gold = medium_gold_value
			}
			if = {
				limit = {
					OR = {
						has_realm_law = nomadic_authority_3
						has_realm_law = nomadic_authority_2
					}
				}
				add_gold = minor_gold_value
			}
			if = {
				limit = {
					has_realm_law = nomadic_authority_1
				}
				add_gold = miniscule_gold_value
			}
			domicile = {
				change_herd = miniscule_herd_gain
			}
			#Decrease culture acceptance and opinion wherever you go
			reverse_add_opinion = {
				opinion = -20
				modifier = raided_me_opinion
				target = scope:local_ruler
			}
			if = {
				limit = {
					NOT = {
						culture = scope:local_ruler.culture
					}
					OR = {
						has_realm_law = nomadic_authority_4
						has_realm_law = nomadic_authority_5
						has_realm_law = nomadic_authority_3
						culture = {
							culture_head = root
						}
					}
				}
				culture = {
					change_cultural_acceptance = {
						target = scope:local_ruler.culture
						value = miniscule_cultural_acceptance_loss
						desc = cultural_acceptance_raiding_migrators
					}
				}
			}
			if = {
				limit = {
					scope:local_ruler = {
						is_ai = yes
					}
				}
				location.county = {
					change_county_control = miniscule_county_control_loss
				}
			}
		}
	}
}

#It's tough going getting through the local terrain. Your young warriors are frustrated and want to ride ahead to the destination
migration_events.1060 = {
	type = character_event
	title = migration_events.1060.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					root = {
						location_has_harsh_winter_trigger = yes
						OR = {
							current_month >= 11
							current_month <= 4
						}
					}
				}
				desc = migration_events.1060.desc_winter
			}
			triggered_desc = {
				trigger = {
					root.location = {
						terrain = desert
					}
				}
				desc = migration_events.1060.desc_desert
			}
			triggered_desc = {
				trigger = {
					root.location = {
						OR = {
							terrain = forest
							terrain = taiga
						}
					}
				}
				desc = migration_events.1060.desc_forest
			}
			triggered_desc = {
				trigger = {
					root.location = {
						terrain = wetlands
					}
				}
				desc = migration_events.1060.desc_wetlands
			}
			desc = migration_events.1060.desc_hilly
		}
		desc = migration_events.1060.desc
	}
    theme = migration
	override_background = {
		reference = wilderness
	}
	left_portrait = {
		character = root
		animation = horse_exhausted
		camera = camera_event_horse_very_left
	}
	right_portrait = {
		character = scope:warrior
		animation = horse_surveying
		camera = camera_event_horse_right_facing_left
	}

	trigger = {
		age >= 10
		is_migrating = yes
		has_mpo_dlc_trigger = yes
		location = {
			OR = {
				terrain = desert_mountains
				terrain = mountains
				terrain = hills
				terrain = desert
				terrain = forest
				terrain = wetlands
				terrain = taiga
				AND = {
					has_province_modifier = winter_harsh_modifier
					OR = {
						current_month >= 11
						current_month <= 4
					}
				}
			}
		}
		any_courtier = {
			is_adult = yes
			age < 50
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
			basic_is_available_ai = yes
			ai_energy >= 0
		}
		current_travel_plan = {
			final_destination_province.county = {
				NOT = {
					has_county_modifier = mpo_migration_prepared_home_modifier
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 1
			location = {
				OR = {
					terrain = desert_mountains
					terrain = mountains
					terrain = desert
					terrain = wetlands
				}
			}
		}
	}

	cooldown = {
		years = 5
	}

	immediate = {
		location.county = {
			save_scope_as = location_county
		}
		location = {
			save_scope_as = root_location
		}
		location.county.holder = {
			save_scope_as = local_ruler
			add_character_flag = {
				flag = migration_events_1040_giver_flag
				years = 1
			}
		}
		if = {
			limit = {
				primary_heir = {
					is_courtier_of = root
					is_adult = yes
					age < 50
					basic_is_available_ai = yes
					ai_energy >= low_negative_ai_value
				}
			}
			primary_heir = {
				save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
				exists = house
			}
			random_close_family_member = {
				limit = {
					is_courtier_of = root
					is_adult = yes
					age < 50
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					basic_is_available_ai = yes
					ai_energy >= low_negative_ai_value
				}
				save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
				exists = house
			}
			random_councillor = {
				limit = {
					is_courtier_of = root
					is_adult = yes
					age < 50
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					basic_is_available_ai = yes
					ai_energy >= 0
				}
				save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
				exists = house
			}
			house = {
				random_house_member = {
					limit = {
						is_knight_of = root
						is_courtier_of = root
						is_adult = yes
						age < 50
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
						basic_is_available_ai = yes
						ai_energy >= 0
					}
					save_scope_as = warrior
				}
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			random_knight = {
				limit = {
					age < 50
					basic_is_available_ai = yes
					ai_energy >= 0
				}
				save_scope_as = warrior
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:warrior
				}
			}
			random_courtier = {
				limit = {
					is_adult = yes
					age < 50
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					basic_is_available_ai = yes
					ai_energy >= 0
				}
				save_scope_as = warrior
			}
		}
		domicile = {
			change_herd = miniscule_herd_loss
		}
		current_travel_plan = {
			final_destination_province.county = {
				save_scope_as = destination
			}
		}
	}
	#Come with me, I'll find us an easier route
	option = {
		trigger = {
			OR = {
				has_trait = lifestyle_traveler
				has_trait = organizer
				has_trait = logistician
				AND = {
					location = {
						OR = {
							terrain = hills
							terrain = mountains
							terrain = wetlands
						}
					}
					has_trait = rough_terrain_expert
				}
				AND = {
					location = {
						OR = {
							terrain = desert
							terrain = desert_mountains
						}
					}
					has_trait = desert_warrior
				}
				AND = {
					location = {
						OR = {
							terrain = forest
							terrain = taiga
						}
					}
					has_trait = forest_fighter
				}
				AND = {
					location_has_harsh_winter_trigger = yes
					has_trait = winter_soldier
					OR = {
						current_month >= 11
						current_month <= 4
					}
				}
			}
		}
		name = migration_events.1060.a

		duel = {
			skills = { martial stewardship }
			value = medium_skill_rating

			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2.5
					min = -49
				}
				modifier = {
					add = 30
					has_trait = lifestyle_traveler
					has_trait_xp = {
						trait = lifestyle_traveler
						track = danger
						value >= 50
					}
				}
				modifier = {
					add = 30
					has_trait = lifestyle_traveler
					has_trait_xp = {
						trait = lifestyle_traveler
						track = danger
						value >= 100
					}
				}
				modifier = {
					add = 30
					has_trait = lifestyle_traveler
					has_trait_xp = {
						trait = lifestyle_traveler
						track = travel
						value >= 50
					}
				}
				modifier = {
					add = 30
					has_trait = lifestyle_traveler
					has_trait_xp = {
						trait = lifestyle_traveler
						track = travel
						value >= 100
					}
				}
				modifier = {
					add = 15
					OR = {
						has_trait = organizer
						has_trait = logistician
						AND = {
							location = {
								OR = {
									terrain = hills
									terrain = mountains
									terrain = wetlands
								}
							}
							has_trait = rough_terrain_expert
						}
						AND = {
							location = {
								OR = {
									terrain = desert
									terrain = desert_mountains
								}
							}
							has_trait = desert_warrior
						}
						AND = {
							location = {
								OR = {
									terrain = forest
									terrain = taiga
								}
							}
							has_trait = forest_fighter
						}
						AND = {
							location_has_harsh_winter_trigger = yes
							has_trait = winter_soldier
							OR = {
								current_month >= 11
								current_month <= 4
							}
						}
					}
				}
				modifier = {
					add = 30
					OR = {
						AND = {
							has_trait = organizer
							has_trait_xp = {
								trait = organizer
								value >= 50
							}
						}
						AND = {
							has_trait = logistician
							has_trait_xp = {
								trait = logistician
								value >= 50
							}
						}
						AND = {
							location = {
								OR = {
									terrain = hills
									terrain = mountains
									terrain = wetlands
								}
							}
							AND = {
								has_trait = rough_terrain_expert
								has_trait_xp = {
									trait = rough_terrain_expert
									value >= 50
								}
							}
						}
						AND = {
							location = {
								OR = {
									terrain = desert
									terrain = desert_mountains
								}
							}
							AND = {
								has_trait = desert_warrior
								has_trait_xp = {
									trait = desert_warrior
									value >= 50
								}
							}
						}
						AND = {
							location = {
								OR = {
									terrain = forest
									terrain = taiga
								}
							}
							AND = {
								has_trait = forest_fighter
								has_trait_xp = {
									trait = forest_fighter
									value >= 50
								}
							}
						}
						AND = {
							location_has_harsh_winter_trigger = yes
							AND = {
								has_trait = winter_soldier
								has_trait_xp = {
									trait = winter_soldier
									value >= 50
								}
							}
							OR = {
								current_month >= 11
								current_month <= 4
							}
						}
					}
				}
				modifier = {
					add = 30
					OR = {
						AND = {
							has_trait = organizer
							has_trait_xp = {
								trait = organizer
								value >= 100
							}
						}
						AND = {
							has_trait = logistician
							has_trait_xp = {
								trait = logistician
								value >= 100
							}
						}
						AND = {
							location = {
								OR = {
									terrain = hills
									terrain = mountains
									terrain = wetlands
								}
							}
							AND = {
								has_trait = rough_terrain_expert
								has_trait_xp = {
									trait = rough_terrain_expert
									value >= 100
								}
							}
						}
						AND = {
							location = {
								OR = {
									terrain = desert
									terrain = desert_mountains
								}
							}
							AND = {
								has_trait = desert_warrior
								has_trait_xp = {
									trait = desert_warrior
									value >= 100
								}
							}
						}
						AND = {
							location = {
								OR = {
									terrain = forest
									terrain = taiga
								}
							}
							AND = {
								has_trait = forest_fighter
								has_trait_xp = {
									trait = forest_fighter
									value >= 100
								}
							}
						}
						AND = {
							location_has_harsh_winter_trigger = yes
							AND = {
								has_trait = winter_soldier
								has_trait_xp = {
									trait = winter_soldier
									value >= 100
								}
							}
							OR = {
								current_month >= 11
								current_month <= 4
							}
						}
					}
				}
				desc = mpo_migration_events.1060.a.success
				send_interface_toast = {
					type = event_toast_effect_good
					title = mpo_migration_events.1060.a.success
					left_icon = root

					if = {
						limit = {
							AND = {
								location = {
									OR = {
										terrain = hills
										terrain = mountains
										terrain = wetlands
									}
								}
								has_trait = rough_terrain_expert
							}
						}
						add_trait_xp = {
							trait = rough_terrain_expert
							value = 33
						}
					}
					else_if = {
						limit = {
							AND = {
								location = {
									OR = {
										terrain = desert
										terrain = desert_mountains
									}
								}
								has_trait = desert_warrior
							}
						}
						add_trait_xp = {
							trait = desert_warrior
							value = 33
						}
					}
					else_if = {
						limit = {
							AND = {
								location = {
									OR = {
										terrain = forest
										terrain = taiga
									}
								}
								has_trait = forest_fighter
							}
						}
						add_trait_xp = {
							trait = forest_fighter
							value = 33
						}
					}
					else_if = {
						limit = {
							AND = {
								location_has_harsh_winter_trigger = yes
								has_trait = winter_soldier
								OR = {
									current_month >= 11
									current_month <= 4
								}
							}
						}
						add_trait_xp = {
							trait = winter_soldier
							value = 33
						}
					}
					else_if = {
						limit = {
							has_trait = organizer
						}
						add_trait_xp = {
							trait = organizer
							value = 33
						}
					}
					else_if = {
						limit = {
							has_trait = logistician
						}
						add_trait_xp = {
							trait = logistician
							value = 33
						}
					}
					else_if = {
						limit = {
							has_trait = lifestyle_traveler
						}
						add_trait_xp = {
							trait = lifestyle_traveler
							track = danger
							value = 15
						}
					}
					add_character_modifier = {
						modifier = mpo_found_paths_for_herds_modifier
						months = 6
					}
					reverse_add_opinion = {
						modifier = impressed_opinion
						target = scope:warrior
						opinion = 15
					}

				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2.5
					min = -49
				}
				modifier = {
					add = 20
					health < fine_health
				}
				modifier = {
					add = 20
					health < poor_health
				}
				modifier = {
					add = 20
					NOR = {
						knows_language_of_culture = root.location.county.culture
						is_allied_to = root.location.county.holder
						has_any_good_relationship_with_character_trigger = { CHARACTER = root.location.county.holder }
						is_liege_or_above_of = root.location.county.holder
						is_vassal_of = root.location.county.holder
					}
				}
				desc = mpo_migration_events.1060.a.failure
				send_interface_toast = {
					type = event_toast_effect_bad
					title = mpo_migration_events.1060.a.failure
					left_icon = root

					add_stress = miniscule_stress_impact_gain
					domicile = {
						change_herd = minor_herd_loss
					}
					current_travel_plan = {
						delay_travel_plan = { days = 15 }
					}
				}
			}
		}


		stress_impact = {
			trusting = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
				ai_energy = 1
			}
			modifier = {
				add = 50
				stewardship >= high_skill_rating
			}
			modifier = {
				add = 50
				martial >= high_skill_rating
			}
			modifier = {
				add = 50
				stewardship >= extremely_high_skill_rating
			}
			modifier = {
				add = 50
				martial >= extremely_high_skill_rating
			}
			modifier = {
				add = -50
				stewardship < medium_skill_rating
			}
			modifier = {
				add = -50
				martial < medium_skill_rating
			}
			modifier = {
				add = -50
				stewardship <= low_skill_rating
			}
			modifier = {
				add = -50
				martial <= low_skill_rating
			}
			modifier = {
				add = -50
				health < poor_health
			}
			modifier = {
				add = 50
				has_trait = lifestyle_traveler
				has_trait_xp = {
					trait = lifestyle_traveler
					track = danger
					value >= 50
				}
			}
			modifier = {
				add = 50
				has_trait = lifestyle_traveler
				has_trait_xp = {
					trait = lifestyle_traveler
					track = travel
					value >= 50
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = trusting
					has_trait = content
				}
			}
		}
	}
	#You can ride ahead, but scout out our destination and prepare it well
	option = {
		name = migration_events.1060.b

		if = {
			limit = {
				scope:warrior = {
					NOT = { is_obedient_to = root }
				}
			}
			scope:warrior = {
				add_stress = medium_stress_loss
			}
		}
		else = {
			scope:warrior = {
				add_opinion = {
					modifier = obedience_opinion
					target = root
				}
			}
		}
		scope:warrior = {
			if = {
				limit = {
					OR = {
						has_trait = education_martial_1
						has_trait = education_martial_2
						has_trait = education_martial_3
						has_trait = education_martial_4
						has_trait = education_martial_5
					}
				}
				add_martial_lifestyle_xp = medium_lifestyle_xp
			}
			else_if = {
				limit = {
					OR = {
						has_trait = education_stewardship_1
						has_trait = education_stewardship_2
						has_trait = education_stewardship_3
						has_trait = education_stewardship_4
						has_trait = education_stewardship_5
					}
				}
				add_stewardship_lifestyle_xp = medium_lifestyle_xp
			}
			else = {
				add_prestige = medium_prestige_gain
			}
		}
		scope:destination = {
			add_county_modifier = {
				modifier = mpo_migration_prepared_home_modifier
				years = 5
			}
		}
		add_character_modifier = {
			modifier = mpo_migrating_without_labor_modifier
			months = 6
		}

		stress_impact = {
			craven = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = craven
					has_trait = stubborn
					has_trait = impatient
					has_trait = paranoid
				}
			}
		}
	}
	#You remain with us. There's hard labor to do
	option = {
		name = migration_events.1060.c

		scope:warrior = {
			if = {
				limit = {
					NOT = {
						has_trait = lifestyle_traveler
					}
				}
				add_trait = lifestyle_traveler
			}
			else = {
				add_trait_xp = {
					trait = lifestyle_traveler
					track = danger
					value = 20
				}
			}
			add_stress = miniscule_stress_gain
		}
		reverse_add_opinion = {
			modifier = refusal_opinion
			target = scope:warrior
			opinion = -20
		}


		stress_impact = {
			fickle = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
			trusting = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_rationality = 1
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = fickle
					has_trait = arbitrary
					has_trait = trusting
				}
			}
		}
	}
}
