﻿namespace = rus_culture


# Events to spawn Rus Culture
# rus_culture.0001-0009													

rus_culture.0001 = {
	scope = none
	hidden = yes

	immediate = {
		
		#Rus gets the innovations from Svear and Ilmenian
		culture:russian = {
			# reset_culture_creation_date = yes
			get_all_innovations_from = culture:ilmenian
			get_all_innovations_from = culture:svear

		}

		every_county = {
			limit = {
				OR = {
					culture = { has_cultural_pillar = heritage_east_slavic }
					culture = { has_cultural_pillar = heritage_north_germanic }
				}
				title_province = {	
					geographical_region = ce_special_russian_culture_region
				}
			}
			add_to_list = rurikid_counties
		}

		every_in_list = {
			list = rurikid_counties

			# East Slavic and North Germanic Counties become Rus
			if = {
				limit = {
					OR = {
						culture = { has_cultural_pillar = heritage_north_germanic }
						culture = { has_cultural_pillar = heritage_east_slavic }
					}
					county.holder = { 
						culture = { has_cultural_pillar = heritage_north_germanic } 
					}
				}
				random = {
					chance = 40
					set_county_culture = culture:russian
				}

				# Rulers Flip Along
				holder = {
					if = {
						limit = {
							is_ai = yes
							culture = { has_cultural_pillar = heritage_north_germanic }
							capital_province = {
								geographical_region = ce_special_russian_culture_region
							}
						}
						set_culture = culture:russian
						set_character_faith = faith:slavic_pagan
						every_courtier = {
							limit = {
								OR = {
									culture = { has_cultural_pillar = heritage_east_slavic }
									culture = { has_cultural_pillar = heritage_north_germanic }
								}
							}
							set_culture = culture:russian
							set_character_faith = faith:slavic_pagan
						}
					}
				}
			}
			else = {
				limit = {
					county = {	
						OR = {
							this = title:c_novgorod
							this = title:c_kiev
							this = title:c_polotsk
							this = title:c_minsk
							this = title:c_smolensk
						}
					}
					county.holder = { 
						OR = {
							culture = { has_cultural_pillar = heritage_north_germanic } 
							culture = culture:russian
						}
					}
				}
				set_county_culture = culture:russian
			}
		}

		every_player = {
			if = {
				limit = {
					is_ai = no
					save_temporary_scope_as = player
					any_in_list = {
						list = rurikid_counties
						holder = {
							is_within_diplo_range = { CHARACTER = scope:player }
						}
					}
					culture = { has_cultural_pillar = heritage_east_slavic }
				}
				trigger_event = rus_culture.0002
			}
		}

	}

}

# Informative Event of the Shift
rus_culture.0002 = {
	type = character_event
	title = rus_culture.0002.t
	desc = rus_culture.0002.desc
	theme = culture_change
	left_portrait = root

	option = { #convert
		name = rus_culture.0002.a

		if = {
			limit = {
				culture = { has_cultural_pillar = heritage_north_germanic }
				capital_province = {
					geographical_region = ce_special_russian_culture_region
				}
			}
			set_culture = culture:russian
			set_character_faith = faith:slavic_pagan
			every_courtier = {
				limit = {
					OR = {
						culture = { has_cultural_pillar = heritage_east_slavic }
						culture = { has_cultural_pillar = heritage_north_germanic }
					}
				}
				set_culture = culture:russian
				set_character_faith = faith:slavic_pagan
			}
		}
	}

	option = { #stay
		name = rus_culture.0002.b

	}
}

scripted_trigger rus_culture_shift_trigger = {
	tier = tier_county
	exists = holder
	title_province = {
		geographical_region = ce_special_russian_culture_region
	}
	NOT = { exists = var:had_rus_county_conversion }
	culture = {
		NOR = {
			this = culture:russian
			any_parent_culture_or_above = {
				this = culture:russian
			}
		}
		OR = {
			has_cultural_pillar = heritage_east_slavic
			has_cultural_pillar = heritage_north_germanic
		}
	}
	any_neighboring_county = {
		culture = culture:russian
	}
}

rus_culture.0003 = {
	scope = none
	hidden = yes
	
	trigger = {
		OR = {
			culture = culture:russian
			culture = { has_cultural_pillar = heritage_north_germanic }
		}
		any_held_title = {
			rus_culture_shift_trigger = yes
		}
	}

	immediate = {
		random_held_title = {
			limit = { rus_culture_shift_trigger = yes }
			set_variable = {
				name = had_rus_county_conversion
				value = yes
			}
			set_county_culture = culture:russian
		}
	}

}
