namespace = mpo_the_great_steppe

###################################
# The Great Steppe Intro Event
# 0001
###################################
mpo_the_great_steppe.0001 = { # Fullscreen Intro Event
	type = character_event
	window = fullscreen_event
	title = mpo_the_great_steppe.0001.t
	desc = mpo_the_great_steppe.0001.desc
	theme = realm
	trigger = { # we need to prevent this from firing for all players when a new player joins in MP
		is_ai = no
		NOT = { has_variable = mpo_the_great_steppe_events_0001_var }
 	}
	hidden = yes
	override_background = { reference = mpo_fullscreen_the_great_steppe }
	override_sound = { reference = "event:/DLC/FP2/SFX/UI/fp2_struggle_ui_intro_animate" }

	cooldown = { years = 100 }

	widgets = {
		widget = {
 			gui = "event_window_widget_situation_info_the_great_steppe"
 			container = "dynamic_content_widget"
 			controller = situation_info
 			setup_scope = { situation:the_great_steppe = { save_scope_as = situation } }
		}
	}
	immediate = {
		play_music_cue = mx_cue_conquest_of_the_golden_horde
		set_variable = mpo_the_great_steppe_events_0001_var
		save_scope_value_as = {
			name = start
			value = yes
		}
	}
	option = {
		name = mpo_the_great_steppe.0001.a
		clicksound = "event:/DLC/FP2/SFX/UI/fp2_struggle_start_select"
	}
}

# Start Phase
mpo_the_great_steppe.0002 = {
	type = character_event
	title = mpo_the_great_steppe.0002.t
	hidden = yes
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					any_character_situation = {
						any_situation_sub_region = {
							sub_region_current_phase = situation_steppe_cold_zud_season
							situation_sub_region_has_county = root.capital_county
						}
					}
				}
				desc = mpo_the_great_steppe.0002.desc.cold_zud
			}
			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.capital_county
						}
					}
				}
				desc = mpo_the_great_steppe.0002.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.capital_county
						}
					}
				}
				desc = mpo_the_great_steppe.0002.desc.white_zud
			}
			triggered_desc = {
				trigger = {
					any_character_situation = {
						any_situation_sub_region = {
							sub_region_current_phase = situation_steppe_warm_nights_season
							situation_sub_region_has_county = root.capital_county
						}
					}
				}
				desc = mpo_the_great_steppe.0002.desc.warm_nights
			}
			triggered_desc = {
				trigger = {
					any_character_situation = {
						any_situation_sub_region = {
							sub_region_current_phase = situation_steppe_abundant_grazing_season
							situation_sub_region_has_county = root.capital_county
						}
					}
				}
				desc = mpo_the_great_steppe.0002.desc.abundant_grazing
			}
			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.capital_county
						}
					}
				}
				desc = mpo_the_great_steppe.0002.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.capital_county
						}
					}
				}
				desc = mpo_the_great_steppe.0002.desc.sky_blessing
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						any_character_situation = {
							any_situation_sub_region = {
								sub_region_current_phase = situation_steppe_cold_zud_season
								situation_sub_region_has_county = root.capital_county
							}
						}
						any_character_situation = {
							any_situation_sub_region = {
								sub_region_current_phase = situation_steppe_white_zud_season
								situation_sub_region_has_county = root.capital_county
							}
						}
					}
				}
				desc = mpo_the_great_steppe.0002.desc.obedience
			}
		}
	}
	theme = nomads
	override_background = {
		trigger = {
			has_zud_season_nomadic_capital_root_trigger = yes
		}
		reference = bp3_steppe_winter
	}
	override_background = {
		trigger = {
			has_zud_season_nomadic_capital_root_trigger = no
		}
		reference = wilderness
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				has_bad_season_nomadic_capital_root_trigger = yes
			}
			animation = horse_exhausted
		}
		animation = horse_surveying
		camera = camera_event_horse_left
	}
	lower_right_portrait = {
		trigger = { exists = scope:person }
		character = scope:person
	}
	
	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.capital_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"
		}
	}
	
	override_effect_2d = {
		reference = fog
		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
				}
			}
		}
	}
	override_effect_2d = {
		reference = rain
		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
				}
			}
		}
	}
	override_effect_2d = {
		reference = legend_glow
		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
				}
			}
		}
	}
	
	trigger = {
		NOT = { has_variable = steppe_game_start_var }
	}
	
	immediate = {
		custom_tooltip = mpo_the_great_steppe.0002.tt
		play_music_cue = mx_cue_conquest_of_the_golden_horde
		if = {
			limit = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_warm_nights_season
						situation_sub_region_has_county = root.location.county
					}
				}
			}
			if = {
				limit = {
					any_spouse = {
					}
				}
				random_spouse = {
					save_scope_as = person
				}
			}
			else_if = {
				limit = {
					any_courtier_or_guest = {
					}
				}
				random_courtier_or_guest = {
					save_scope_as = person
				}
			}
			else = {
				hidden_effect = {
					create_character = {
						template = pool_repopulate_local_flavor
						dynasty = none
						location = root.location
						save_scope_as = person
					}
				}
			}
		}
	}

	option = {
		name = mpo_the_great_steppe.0002.a
		if = {
			limit = { has_perk = souvenirs_aplenty_perk }
			add_internal_flag = special
			custom_tooltip = mpo_the_great_steppe_0002_souvenirs_aplenty_tt
			every_held_county = {
				limit = {
					uses_county_fertility = yes
					is_landless_type_title = no
				}
				add_county_modifier = {
					modifier = souvenirs_aplenty_perk_county_modifier
					years = 10
				}
			}
		}
		if = {
			limit = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_havsarsan_zud_season
						situation_sub_region_has_county = root.capital_county
					}
				}
			}
			every_held_county = {
				limit = { is_landless_type_title = no }
				change_county_control = -25
			}
			domicile = {
				change_herd = {
					value = root.domicile.herd
					multiply = -0.2
				}
			}
		}
		if = {
			limit = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_white_zud_season
						situation_sub_region_has_county = root.capital_county
					}
				}
			}
			every_held_county = {
				limit = { is_landless_type_title = no }
				change_county_control = -25
			}
			domicile = {
				change_herd = {
					value = root.domicile.herd
					multiply = -0.1
				}
			}
		}
		if = {
			limit = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_cold_zud_season
						situation_sub_region_has_county = root.capital_county
					}
				}
			}
			every_held_county = {	
				limit = { is_landless_type_title = no }
				change_county_control = -10
			}
		}
		
		ai_chance = {
			base = 100
		}
	}
}

mpo_the_great_steppe.0003 = {
	type = character_event
	hidden = yes
	
	immediate = {
		if = {
			limit = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_white_zud_season
						situation_sub_region_has_county = root.capital_county
					}
				}
			}
			every_held_county = {	
				limit = { 
					is_landless_type_title = no
					uses_county_fertility = yes
				}
				change_county_fertility = -50
			}
		}
		if = {
			limit = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_cold_zud_season
						situation_sub_region_has_county = root.capital_county
					}
				}
			}
			every_held_county = {	
				limit = { 
					is_landless_type_title = no
					uses_county_fertility = yes
				}
				change_county_fertility = -25
			}
		}
		if = {
			limit = {
				any_character_situation = {
					any_situation_sub_region = {
						sub_region_current_phase = situation_steppe_severe_drought_season
						situation_sub_region_has_county = root.capital_county
					}
				}
			}
			every_held_county = {	
				limit = {
					is_landless_type_title = no
					uses_county_fertility = yes
				}
				change_county_fertility = -10
			}
		}
	}
}