﻿yearly_culture_pulse = {
	on_actions = {
		delay = { days = { 1 365 } }
		bosnian_emergence_culture_pulse
		delay = { days = { 1 365 } }
		russian_emergence_culture_pulse
		delay = { days = { 1 365 } }
		dissolve_biohrad_culture_pulse
		delay = { days = { 1 365 } }
		abrotite_assimilation_culture_pulse
		delay = { days = { 1 365 } }
		navvaro_aragonese_assimilation_culture_pulse
	}
}

bosnian_emergence_culture_pulse = {
	effect = {
		if = {
			limit = {
				current_date >= 1050.1.1 #No reason to check earlier since forming the kingdom requires the early medieval era
				AND = {
					has_global_variable = flag_founded_kingdom_of_bosnia
					NOT = { 
						has_global_variable = bosnian_culture_split 
						is_target_in_global_variable_list = {
							name = unavailable_unique_decisions
							target = flag:found_kingdom_of_illyria_decision
						}
					}
					
				}
			}
			random = {
				chance = 10
				set_global_variable = {
					name = bosnian_culture_split
					value = yes
				}
				trigger_event = {
					id = balkan_culture.0001
					days = { 365 3650 }
				}
			}
		}
	}
}

russian_emergence_culture_pulse = {
	effect = {
		if = {
			limit = {
				current_date <= 900.1.1 #No reason to check later
				NOT = { has_global_variable = rus_culture_emergence }
				OR = {
					title:c_novgorod.holder = {
						culture = { has_cultural_pillar = heritage_north_germanic }
					}
					title:c_kiev.holder = {
						culture = { has_cultural_pillar = heritage_north_germanic }
					}
					title:c_polotsk.holder = {
						culture = { has_cultural_pillar = heritage_north_germanic }
					}
					title:c_minsk.holder = {
						culture = { has_cultural_pillar = heritage_north_germanic }
					}
					title:c_smolensk.holder = {
						culture = { has_cultural_pillar = heritage_north_germanic }
					}
				}
			}
			random = {
				chance = 5
				modifier = {
					add = 5 # 10% chance
					current_date >= 875.1.1
				}
				modifier = {
					add = 30 # 40% chance
					current_date >= 885.1.1
				}
				modifier = {
					add = 20 # 60% chance
					current_date >= 890.1.1
				}
				modifier = {
					add = 20 # 80% chance
					current_date >= 895.1.1
				}
				modifier = {
					add = 20 # 100% chance
					current_date >= 899.1.1
				}
				set_global_variable = {
					name = rus_culture_emergence
					value = yes
				}
				trigger_event = {
					id = rus_culture.0001
					days = { 365 3650 }
				}
			}
		}
	}
}

dissolve_biohrad_culture_pulse = {
	effect = {
		if = {
			limit = {
				AND = {
					is_target_in_global_variable_list = {
						name = unavailable_unique_decisions
						target = flag:consolidate_danubian_frontier_decision
					}
					NOT = { 
						has_global_variable = biohrad_dissolved_happened 
						is_target_in_global_variable_list = {
							name = unavailable_unique_decisions
							target = flag:restore_roman_pannonia_decision
						}
					}
					OR = {
						NOT = { exists = title:d_szekesfehervar.holder }
						AND = {
							title:d_szekesfehervar.holder = {
								NOT = {
									OR = {
										culture = { has_cultural_pillar = heritage_south_slavic }
										culture = { has_cultural_pillar = heritage_west_slavic }
										culture = { has_cultural_pillar = heritage_east_slavic }
										culture = { has_cultural_pillar = heritage_latin }
										culture = { has_cultural_pillar = heritage_vlach }
										culture = { has_cultural_pillar = heritage_iberian }
										culture = { has_cultural_pillar = heritage_frankish }
									}
								}
							}
						}
					}
				}
			}
			random = {
				chance = 100
				save_scope_as = ruler
				set_global_variable = {
					name = biohrad_dissolved_happened
					value = yes
				}
				trigger_event = {
					id = balkan_flavour.0002
				}
			}
		}
	}
}

abrotite_assimilation_culture_pulse = {
	effect = {
		if = {
			limit = {
				current_date <= 910.1.1 #No reason to check later
				NOT = { has_global_variable = abotrite_assimilation_happened }
				AND = {
					title:k_hungary = { is_title_created = yes }
					title:k_hungary.holder = { culture = culture:mogyer }
				}
			}
			set_global_variable = {
				name = abotrite_assimilation_happened
				value = yes
			}
			trigger_event = {
				id = balkan_flavour.0003
			}
		}
	}
}

navvaro_aragonese_assimilation_culture_pulse = {
	effect = {
		if = {
			limit = {
				AND = {
					has_global_variable = flag_formed_kingdom_of_aragon
					NOT = { has_global_variable = navarro_aragonese_assimilation }
				}
			}
			random = {
				chance = 100
				set_global_variable = {
					name = navarro_aragonese_assimilation
					value = yes
				}
				trigger_event = {
					id = iberian_culture.0001
					days = { 1 2 }
				}
			}
		}
	}
}