#################################################
#
# PROVINCE EVENTS AND EVENTS AFFECTING PROVINCES
#
#################################################

# Province culture changes
province_event = {
	id = 55000
	
	hide_window = yes
	
	trigger = {
		owner = {
			NOT = { culture = ROOT }
			religion = ROOT
			#does not apply to vassals of a different culture than their liege
			NAND = {
				independent = no
				any_liege = { NOT = { culture = PREV } }
			}
			#do not change culture for rulers with papal type succession
			NOR = {
				has_landed_title = k_papal_state
				has_landed_title = k_papal_chalcedon
				has_landed_title = k_chalcedonian
				has_landed_title = d_celtic_pagan_reformed
				has_landed_title = d_pontifex_maximus
				has_landed_title = d_cathar
				has_landed_title = d_bogomilist
				has_landed_title = d_manichean
				has_landed_title = d_fraticelli
			}
			#english melting pot
			NAND = {
				ROOT = {
					region = custom_england
					OR = {
						culture = norman
						culture = frankish
						culture = occitan
						culture = saxon
						culture = english
					}
				}
				OR = {
					culture = norman
					culture = frankish
					culture = occitan
					culture = saxon
				}
			}
			any_demesne_province = {
				NOR = {
					has_province_flag = recent_depopulation_1
					has_province_flag = recent_depopulation_2
					has_province_flag = recent_depopulation_3
				}
			}
			#sicilian melting pot
			NAND = {
				ROOT = {
					region = custom_sicily
					OR = {
						culture = greek
						culture_group = arabic
						culture = norman
						culture = sicilian
						culture = sicilian_greek
						culture = sicilian_arabic
					}
				}
				OR = {
					culture = greek
					is_italian_trigger = yes
					culture_group = arabic
					culture = norman
				}
			}
			#anglo-norse melting pot
			NAND = {
				ROOT = {
					region = custom_england
					OR = {
						culture = saxon
						culture = norse
						culture = english_norse
					}
				}
				OR = {
					culture = saxon
					culture = norse
				}
			}
			#gallawa melting pot
			NAND = {
				ROOT = {
					OR = {
						region = custom_scotland
						region = custom_ireland
						region = custom_wales
						region = custom_brittany
					}
					OR = {
						culture_group = north_germanic
						culture = pictish
						culture = breton
						culture = cumbric
						culture = cornish
						culture = gallawa
					}
				}
				OR = {
					culture_group = north_germanic
					culture = pictish
					culture = breton
					culture = cumbric
					culture = cornish
				}
				NOT = { culture_group = ROOT }
			}
			#russian melting pot
			NAND = {
				NOT = { has_global_flag = russian_melting_pot }
				ROOT = {
					OR = {
						region = custom_rus
						region = custom_novgorod
						region = custom_muscovy
					}
					OR = {
						culture_group = east_slavic
						culture = norse
						culture = russian
					}
				}
				OR = {
					culture_group = east_slavic
					culture = norse
				}
			}
			#norman melting pot
			NAND = {
				ROOT = {
					region = world_europe_west_francia
					OR = {
						culture = norse
						culture = frankish
						culture = breton
						culture = occitan
						culture = norman
					}
				}
				OR = {
					culture = norse
					culture = frankish
					culture = breton
					culture = occitan
				}
			}
			#scots melting pot
			NAND = {
				ROOT = {
					region = custom_scotland
					OR = {
						culture = saxon
						culture = scottish
						culture = english
						culture = scots
					}
				}
				OR = {
					culture = saxon
					culture = scottish
					culture = english
				}
			}
			#yugoslavian melting pot
			NAND = {
				ROOT = {
					OR = {
						region = custom_croatia
						region = custom_bulgaria
						region = custom_serbia
					}
					OR = {
						culture = croatian
						culture = serbian
						culture = bulgarian
						culture = yugoslavian
					}
				}
				OR = {
					culture = croatian
					culture = serbian
					culture = bulgarian
				}
			}
			#dalmatian melting pot
			NAND = {
				ROOT = {
					region = custom_dalmatian_region
					OR = {
						is_dalmatian_meltingpot_culture_yugoslav = yes
						is_dalmatian_meltingpot_culture_italian = yes
						culture = dalmatian
					}
				}
				OR = {
					is_dalmatian_meltingpot_culture_yugoslav = yes
					is_dalmatian_meltingpot_culture_italian = yes
				}
			}
			#greco-persian melting pot
			NAND = {
				ROOT = {
					OR = {
						region = world_asia_minor
						region = world_persia
						region = custom_byzantium
						region = custom_mesopotamia
						region = custom_syria
					}
					OR = {
						is_greekpersian_meltingpot_greek = yes
						is_greekpersian_meltingpot_persian = yes
						culture = grecopersian
					}
				}
				OR = {
					is_greekpersian_meltingpot_greek = yes
					is_greekpersian_meltingpot_persian = yes
				}
			}
			#no flipping back to Norse culture before 1150
			NAND = {
				NOT = {	has_global_flag = norse_culture_flipping }
				ROOT = {
					OR = {
						culture = swedish
						culture = norwegian
						culture = danish
						culture = icelandic
					}
				}
				culture = norse
			}
		}
		#either the owner's capital or there is a neighbor province of that culture
		OR = {
			owner = { capital_scope = { province_id = ROOT } }
			any_neighbor_province = {
				has_owner = yes
				owner = {
					ROOT = {
						owner = {
							culture = PREVPREV
							culture = PREVPREVPREV
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 550
		modifier = {
			factor = 10
			owner = {
				top_liege = {
					has_law = culture_conversion_0
				}
			}
		}
		modifier = {
			factor = 0.5
			owner = {
				top_liege = {
					has_law = culture_conversion_2
				}
			}
		}
		modifier = {
			factor = 10
			owner = { independent = no }
			NOT = {
				any_neighbor_province = {
					has_owner = yes
					owner = {
						ROOT = {
							owner = {
								culture = PREVPREV
								culture = PREVPREVPREV
							}
						}
					}
				}
			}
		}
		modifier = {
			factor = 5
			owner = { independent = yes }
			NOT = {
				any_neighbor_province = {
					has_owner = yes
					owner = {
						ROOT = {
							owner = {
								culture = PREVPREV
								culture = PREVPREVPREV
							}
						}
					}
				}
			}
		}
		modifier = {
			factor = 0.80
			owner = { has_ambition = obj_civilize_province }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 1 } }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 2 } }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 3 } }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 4 } }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 5 } }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 6 } }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 7 } }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 8 } }
		}
		modifier = {
			factor = 1.05
			owner = { NOT = { learning = 9 } }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 11 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 12 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 13 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 14 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 15 }
		}
		modifier = {
			factor = 0.9
			owner = { learning = 16 }
		}
		modifier = {
			factor = 0.9
			owner = { learning = 17 }
		}
		modifier = {
			factor = 0.9
			owner = { learning = 18 }
		}
		modifier = {
			factor = 0.9
			owner = { learning = 19 }
		}
		modifier = {
			factor = 0.85
			owner = { learning = 20 }
		}
		modifier = {
			factor = 0.85
			owner = { learning = 21 }
		}
		modifier = {
			factor = 0.85
			owner = { learning = 22 }
		}
		modifier = {
			factor = 0.85
			owner = { learning = 23 }
		}
		modifier = {
			factor = 0.85
			owner = { learning = 24 }
		}
		modifier = {
			factor = 0.85
			owner = { learning = 25 }
		}
		modifier = {
			factor = 0.9
			owner = { trait = gregarious }
		}
		modifier = {
			factor = 1.1
			owner = { trait = shy }
		}
		modifier = {
			factor = 0.9
			owner = { trait = poet }
		}
		modifier = {
			factor = 0.9
			owner = { trait = diligent }
		}
		modifier = {
			factor = 1.1
			owner = { trait = humble }
		}
		modifier = {
			factor = 1.1
			owner = { trait = content }
		}
		modifier = {
			factor = 0.25
			owner = { culture = turkish }
			OR = {
				region = custom_nikaea
				region = custom_trebizond
				region = custom_armenia
			}
			NOT = { year = 1200 }
		}
		modifier = {
			factor = 0.5
			owner = { culture = mongol }
			culture_group = altaic
			NOT = { year = 1300 }
		}
		modifier = {
			factor = 2.0
			owner = { culture = mongol }
			NOT = { culture_group = altaic }
		}
		modifier = {
			factor = 0.75
			owner = { religion_group = muslim }
		}
		modifier = {
			factor = 0.4 # Altaic nomad steppe bonus vs non-Altaics
			owner = {
				culture_group = altaic
			}
			OR = {
				owner = {
					is_capital = ROOT
				}
				AND = {
					NOT = { culture_group = altaic }
					terrain = steppe
				}
			}
		}
		#catholics
		modifier = {
			factor = 5
			OR = {
				culture_group = north_germanic
				culture_group = central_germanic
				culture_group = west_germanic
				culture_group = latin
				culture_group = iberian
				culture_group = celtic
				culture_group = west_slavic
				culture_group = magyar
			}
			owner = {
				NOR = {
					culture_group = north_germanic
					culture_group = central_germanic
					culture_group = west_germanic
					culture_group = latin
					culture_group = iberian
					culture_group = celtic
					culture_group = west_slavic
					culture_group = magyar
				}
			}
		}
		#orthodox
		modifier = {
			factor = 5
			OR = {
				culture_group = byzantine
				culture_group = east_slavic
				culture_group = south_slavic
			}
			owner = {
				NOR = {
					culture = turkish #special
					culture_group = byzantine
					culture_group = east_slavic
					culture_group = south_slavic
				}
			}
		}
		#baltic pagans
		modifier = {
			factor = 5
			OR = {
				culture_group = finno_ugric
				culture_group = baltic
			}
			owner = {
				NOR = {
					culture_group = finno_ugric
					culture_group = baltic
				}
			}
		}
		#turks
		modifier = {
			factor = 5
			culture_group = altaic
			owner = {
				NOT = {
					culture_group = altaic
				}
			}
		}
		#arabs
		modifier = {
			factor = 5
			culture_group = arabic
			owner = {
				NOT = {
					culture_group = arabic
				}
			}
		}
		#persians
		modifier = {
			factor = 5
			culture_group = iranian
			owner = {
				NOT = {
					culture_group = iranian
				}
			}
		}
		#africa
		modifier = {
			factor = 5
			culture_group = west_african
			owner = {
				NOT = {
					culture_group = west_african
				}
			}
		}
		modifier = {
			factor = 5
			culture_group = east_african
			owner = {
				NOT = {
					culture_group = east_african
				}
			}
		}
		modifier = {
			factor = 0.75
			has_province_flag = recent_depopulation_1
		}
		modifier = {
			factor = 0.5
			has_province_flag = recent_depopulation_2
		}
		modifier = {
			factor = 0.25
			has_province_flag = recent_depopulation_3
		}
		modifier = {
			factor = 3
			OR = {
				has_game_rule = {
					name = culture_conversion
					value = slower_normal
				}
				has_game_rule = {
					name = culture_conversion
					value = faster_melting_pots_and_slower_normal
				}
			}
		}
		modifier = {
			factor = 0.95
			owner = {
				job_treasurer = {
					NOT = {
						stewardship = 10
					}
					stewardship = 8
					has_job_action = action_administer_realm
				}
			}
		}
		modifier = {
			factor = 0.75
			owner = {
				job_treasurer = {
					stewardship = 10
					has_job_action = action_administer_realm
				}
			}
		}
	}

	immediate = {
		if = {
			limit = { NOT = { has_province_flag = may_switch_culture } }
			set_province_flag = may_switch_culture
			break = yes
		}
		clr_province_flag = may_switch_culture
		save_event_target_as = converted_province
		add_province_modifier = {
			name = recent_culture_change
			duration = -1
		}
		owner = {
			ROOT = { culture = PREV }
			if = {
				limit = { has_ambition = obj_civilize_province }
				character_event = { id = Plus.334 }
			}
			if = {
				limit = {
					top_liege = {
						NOT = { character = PREV }
						culture = PREV
						has_ambition = obj_civilize_province
					}
				}
				top_liege = { character_event = { id = Plus.334 } }
			}
		}
	}
}

# Ruler goes native
character_event = {
	id = 55001
	desc = "EVTDESC55001"
	picture = GFX_evt_throne_room
	
	only_rulers = yes
	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		NOT = { government = nomadic_government }
		capital_scope = {
			religion = ROOT
			NOT = { culture = ROOT }
			NOT = { any_neighbor_province = { has_owner = yes culture = ROOT } }
			NOT = {
				AND = {
					culture = greek
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = catholic
							religion = cathar
							religion = fraticelli
							religion = waldensian
							religion = lollard
							religion = adoptionist
						}
					}
				}
			}
			NOT = {
				AND = {
					OR = {
						culture = levantine_arabic
						culture = egyptian_arabic
						culture = bedouin_arabic
					}
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = catholic
							religion = cathar
							religion = fraticelli
							religion = waldensian
							religion = lollard
							religion = adoptionist
						}
					}
				}
			}
			NOT = {
				AND = {
					culture = saxon
					ROOT = {
						OR = {
							culture_group = north_germanic
							culture = norman
							culture = frankish
							culture = occitan
						}
					}
				}
			}
			NOT = {
				AND = {
					region = custom_sicily
					ROOT = {
						OR = {
							culture = greek
							culture = maghreb_arabic
							culture = norman
						}
					}
				}
			}
		}
		NOT = { has_character_flag = gone_native }
	}

	mean_time_to_happen = {
		months = 400
		modifier = {
			factor = 0.8
			NOT = { age = 20 }
		}
		modifier = {
			factor = 0.9
			NOT = { age = 30 }
		}
		modifier = {
			factor = 2.0
			age = 40
		}
		modifier = {
			factor = 2.0
			age = 50
		}
		modifier = {
			factor = 2.0
			age = 60
		}
		modifier = {
			factor = 2.0
			age = 70
		}
		modifier = {
			factor = 2.0
			age = 80
		}
		modifier = {
			factor = 0.75
			NOT = {
				any_demesne_province = { culture = ROOT }
			}
		}
		modifier = {
			factor = 2.0
			independent = no
			top_liege = { NOT = { culture = ROOT } }
		}
		modifier = {
			factor = 1.1
			demesne_size = 2
		}
		modifier = {
			factor = 1.1
			demesne_size = 4
		}
		modifier = {
			factor = 1.1
			demesne_size = 6
		}
		modifier = {
			factor = 1.1
			demesne_size = 8
		}
		modifier = {
			factor = 1.1
			demesne_size = 10
		}
		modifier = {
			factor = 0.9
			trait = gregarious
		}
		modifier = {
			factor = 1.25
			trait = shy
		}
		modifier = {
			factor = 0.9
			trait = poet
		}
		modifier = {
			factor = 0.9
			trait = diligent
		}
		modifier = {
			factor = 0.9
			trait = humble
		}
		modifier = {
			factor = 0.9
			trait = content
		}
		modifier = {
			factor = 5.0
			culture = turkish
			NOT = { year = 1200 }
		}
		modifier = {
			factor = 5.0
			culture = mongol
			NOT = { year = 1300 }
		}
	}

	option = {
		name = "EVTOPTA55001"
		ai_chance = { factor = 75 }
		capital_scope = {
			ROOT = {
				culture = PREV
				any_child = {
					limit = {
						is_adult = no
						is_liege_or_above = ROOT
					}
					culture = PREVPREV
				}
			}
		}
		set_character_flag = gone_native
		prestige = -10
	}
	option = {
		name = "EVTOPTB55001"
		ai_chance = {
			factor = 25
			modifier = {
				factor = 10
				tier = emperor
			}
			modifier = {
				factor = 5
				tier = king
			}
			modifier = {
				factor = 2
				tier = duke
			}
			#germanic + latin
			modifier = {
				factor = 5
				OR = {
					culture_group = north_germanic
					culture_group = central_germanic
					culture_group = west_germanic
					culture_group = latin
					culture_group = iberian
				}
				capital_scope = {
					NOR = {
						culture_group = north_germanic
						culture_group = central_germanic
						culture_group = west_germanic
						culture_group = latin
						culture_group = iberian
					}
				}
			}
			#west slavs
			modifier = {
				factor = 5
				OR = {
					culture_group = west_slavic
					culture_group = magyar
				}
				capital_scope = {
					NOR = {
						culture_group = west_slavic
						culture_group = magyar
					}
				}
			}
			#celts
			modifier = {
				factor = 5
				culture_group = celtic
				capital_scope = {
					NOT = { culture_group = celtic }
				}
			}
			#orthodox
			modifier = {
				factor = 5
				OR = {
					culture_group = byzantine
					culture_group = east_slavic
					culture_group = south_slavic
				}
				capital_scope = {
					NOR = {
						culture_group = byzantine
						culture_group = east_slavic
						culture_group = south_slavic
					}
				}
			}
			#baltic pagans
			modifier = {
				factor = 5
				OR = {
					culture_group = finno_ugric
					culture_group = baltic
				}
				capital_scope = {
					NOR = {
						culture_group = finno_ugric
						culture_group = baltic
					}
				}
			}
			#turks
			modifier = {
				factor = 5
				culture_group = altaic
				capital_scope = {
					NOT = { culture_group = altaic }
				}
			}
			#arabs
			modifier = {
				factor = 5
				culture_group = arabic
				capital_scope = {
					NOT = { culture_group = arabic }
				}
			}
			#persians
			modifier = {
				factor = 5
				culture_group = iranian
				capital_scope = {
					NOT = { culture_group = iranian }
				}
			}
			#africa
			modifier = {
				factor = 5
				culture_group = west_african
				capital_scope = {
					NOT = { culture_group = west_african }
				}
			}
			modifier = {
				factor = 5
				culture_group = east_african
				capital_scope = {
					NOT = { culture_group = east_african }
				}
			}
		}
		set_character_flag = gone_native
		prestige = 10
	}
}

# Notification to ruler of tribal changing government
character_event = {
	id = 55100
	desc = EVTDESC55100
	picture = GFX_evt_courier
	
	desc = {
		text = EVTDESC55100
		trigger = {
			FROM = { government = feudal_government }
		}
	}
	desc = {
		text = EVTDESC55100_muslim
		trigger = {
			FROM = { government = muslim_government }
		}
	}
	desc = {
		text = EVTDESC55100_merchant
		trigger = {
			FROM = { government = merchant_republic_government }
		}
	}
	desc = {
		text = EVTDESC55100_city
		trigger = {
			FROM = { government = republic_government }
		}
	}
	desc = {
		text = EVTDESC55100_theocracy
		trigger = {
			FROM = { government = theocracy_government }
		}
	}
	
	notification = yes
	
	is_triggered_only = yes

	option = {
		name = OK
	}
}

