###############################
# Migrations
#
# Written by Zusk
#
# zusk_event.11 -> zusk_event.15, zusk_event.53 General migration
# zusk_event.55, zusk_event.8, zusk_event.35, zusk_event.36 Slavic migration mechanic
###############################


# Triggered by Decision: begin_migration
narrative_event = {
	id = 990400
	title = EVTNAME62910
	desc = EVTDESC990400
	
	picture = GFX_evt_council
	border = GFX_event_narrative_frame_diplomacy
	
	is_triggered_only = yes

	option = {
		name = EVTOPTAmigration
		capital_scope = {
			ROOT = {
				spawn_unit = {
					province = PREV
					owner = ROOT
					match_character = ROOT
					match_mult = 0.5
					earmark = prepared_invasion
					attrition = 1.0
				}
				spawn_unit = {
					province = PREV
					owner = ROOT
					match_character = ROOT
					match_mult = 0.5
					earmark = prepared_invasion
					attrition = 1.0
				}
				spawn_unit = {
					province = PREV
					owner = ROOT
					match_character = ROOT
					match_mult = 0.5
					earmark = prepared_invasion
					attrition = 1.0
				}
			}
		}
	}
}


namespace = zusk_event

# Disband Troops
character_event = {
	id = zusk_event.11
	hide_window = yes
	
	
	is_triggered_only = yes
	
	immediate = {
		disband_event_forces = migration_mark
	}
	
	option = {
		name = OK
	}
}

# Set Migration Flag
character_event = {
	id = zusk_event.12
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		any_realm_province = {
			limit = {
				NOT = { has_province_flag = migration_give_away }
			}
			set_province_flag = migration_give_away
		}
		# Sets the flag for the timer to prevent migration within 10 years
		ROOT = {
			add_character_modifier = {
				modifier = launched_migration_war
				duration = 3650
			}
		}

	}
	
	option = {
		name = OK
	}
}

# Give troops
character_event = {
	id = zusk_event.13
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		capital_scope = {
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 20
			}
			new_character = {
				spawn_unit = {
					province = PREV
					home = PREV
					owner = ROOT
					troops = { light_infantry = { 2500 2500 } }
					earmark = mirgation_unit # Used for army name localization
				}
			}
		}
		any_realm_province = {
			limit = {
				has_province_flag = migration_give_away
				OR = {
					culture = ROOT
					religion = ROOT
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 20
			}
			new_character = {
				spawn_unit = {
					province = PREV
					home = PREV
					owner = ROOT
					troops = { light_infantry = { 100 100 } }
					earmark = mirgation_unit # Used for army name localization
				}
			}
		}
		if = {
			limit = {
				religion = germanic_pagan
			}
			spawn_fleet = {
				province = closest # closest sea zone
				owner = ROOT
				disband_on_peace = yes
				troops = { galleys = { 200 200 } }
				earmark = mirgation_fleet # Used for army name localization
			}
		}
	}
	
	option = {
		name = OK
	}
}

# Give away for migration
character_event = {
	id = zusk_event.14
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		any_realm_province = {
			limit = {
				has_province_flag = migration_give_away
			}
			county = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = PREV
					culture = PREV
					female = no
					age = 25
					trait = peasant_leader
				}
				new_character = {
					usurp_title_plus_barony_if_unlanded = PREV
					set_defacto_liege = THIS
					set_truce = {
						who = ROOT
						years = 10
					}
					ROOT = {
						set_truce = {
							who = PREV
							years = 10
						}
					}
				}
			}
			clr_province_flag = migration_give_away
		}
	}
	
	option = {
		name = OK
	}
}

# Remove Migration flag without giving away
character_event = {
	id = zusk_event.15
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		# Remove migration flag
		any_realm_province = {
			limit = {
				has_province_flag = migration_give_away
			}
			clr_province_flag = migration_give_away
		}
	}
	
	option = {
		name = OK
	}
}

# AI Migration Event
# ROOT is the target, the event searches for a possible nation that can invade it, if it finds a suitable match then that nation declares war on the target
character_event = {
	id = zusk_event.53
	hide_window = yes
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_war
	
	only_independent = yes
	only_rulers = yes
	war = no # Ensures that the events activate correctly
	
	trigger = {
		NOT = { year = 800 } # The migration period ended around 800
		OR = { # Possible target religion groups
			religion_group = christian
			religion = finnish_pagan
			religion = germanic_pagan
			religion = baltic_pagan
			religion = scythian_pagan
			religion = slavic_pagan
		}
		independent = yes
		is_landed = yes # Need lands to settle, so exclude mercenaries, etc.
	}
	
	mean_time_to_happen = {
		years = 100 # Happens every 5 years or so in practice, due to MTTH being evaluated for ALL eligible rulers.
	}

	immediate = {
		random_playable_ruler = {
			limit = {
				ai = yes # Don't force the player to migrate
				independent = yes
				mercenary = no
				NOT = { higher_tier_than = KING } # If you are an empire, you dont migrate
				war = no # Ensures that the events activate correctly
				NOT = {
					culture = old_frankish # Western german AI's dont migrate
					culture = old_saxon
					culture = thuringian
					culture = alamannian
					culture = burgundian
				}
				OR = {
					AND = {
						religion = germanic_pagan # Most germanic pagans can migrate into Christian lands
						ROOT = { religion_group = christian }
					}
					AND = {
						religion = germanic_pagan # Finnish pagans are only invaded from Germanic pagan AIs if the germans are North Germanics.
						culture_group = north_germanic
						ROOT = { religion = finnish_pagan }
					}
					AND = {
						religion = slavic_pagan # Slavic pagans can migrate into christian, germanic and baltic lands
						ROOT = {
							OR = {
								religion_group = christian
								religion = germanic_pagan
								religion = baltic_pagan
							}
						}
					}
					AND = {
						religion = tengri_pagan # Tengri pagans can migrate into christian, scythian and slavic pagans.
						ROOT = {
							OR = {
								religion_group = christian
								religion = scythian_pagan
								religion = slavic_pagan
							}
						}
					}
					AND = {
						culture = alan # Alan culture characters can migrate into Christian lands
						ROOT = { religion_group = christian }
					}
				}
				OR = {
					NOT = {
						distance = { # Average distance a normal nation can migrate
							who = ROOT
							value = 200
						}
					}
					AND = {
						religion = germanic_pagan # Germanic pagans can extend their distance if they and their target have a port
						any_realm_province = {
							port = yes
						}
						ROOT = {
							any_realm_province = {
								port = yes
							}
						}
						NOT = {
							distance = { # Germanic pagans can migrate further if the target they are going to is coastal
								who = ROOT
								value = 400
							}
						}
					}
				}
			}
			war = {
				target = ROOT
				casus_belli = migration
			}
		}
	}
}

# Slavic Migration
province_event = {
	id = zusk_event.55
	hide_window = yes
	
	trigger = {
		#start of the new part of trigger, should be made more dynamic in the future
		year = 500
		#end of the new part of the trigger
		NOT = { year = 800 }
		NOT = { has_province_flag = no_slavs }
		NOT = { holder_scope = { top_liege = { religion = slavic_pagan } } }
		OR = {
			religion = slavic_pagan
			AND = {
				any_neighbor_province = {
					has_province_modifier = zusk_slav_timer
					religion = slavic_pagan
				}
				any_neighbor_province = {
					NOT = { has_province_modifier = zusk_slav_timer }
					religion = slavic_pagan
				}
			}
			NOT = {
				any_neighbor_province = {
					has_province_modifier = zusk_slav_timer
					religion = slavic_pagan
				}
			}
		}
	
		any_neighbor_province = {
			OR = {
				holder_scope = {
					top_liege = {
						religion = slavic_pagan # Use this instead of the culture, Slavs should stop migrating if they are converted
					}
				}
				religion = slavic_pagan
			}
		}
	}
	
	mean_time_to_happen = {
		#years = 15 #original base MTTH
		years = 10 #base MTTH after start date addition

		modifier = {
			factor = 10
			OR = {
				culture_group = finno_ugric
				culture_group = altaic
				AND = {
					culture_group = baltic
					NOT = { culture = vistula_veneti }
				}
			}
		}

		modifier = {
			factor = 1.1
			year = 500
		}
		modifier = {
			factor = 1.2
			year = 550
		}
		modifier = {
			factor = 1.4
			year = 600
		}
		modifier = {
			factor = 1.8
			year = 650
		}
		modifier = {
			factor = 2
			year = 700
		}
		modifier = {
			factor = 2.5
			year = 750
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = ca_wall_1 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = ca_wall_2 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = ca_wall_3 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = ca_wall_4 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = ca_wall_5 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = ct_wall_3 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = ct_wall_4 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = ct_wall_5 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = tp_wall_3 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = tp_wall_4 }
		}
		modifier = {
			factor = 1.05
			capital_holding = { has_building = tp_wall_5 }
		}
		modifier = {
			factor = 0.5
			OR = {
				e_dacia = { e_avar = { holder_scope = { num_of_realm_counties = { value = 10 title = PREVPREV } } } }
				e_dacia = { d_avars = { holder_scope = { num_of_realm_counties = { value = 10 title = PREVPREV } } } }
			}
		}
	}
	
	immediate = {
		holder_scope = {
			top_liege = {
				character_event = { id = zusk_event.8 }
			}
		}
	}
}

# Slavs
# FROM is the province being settled
character_event = {
	id = zusk_event.8
	desc = zusk_event.8.desc
	picture = GFX_evt_tribal_life
	
	is_triggered_only = yes
	
	option = { # Let them settle (making the Slavic chieftain their vassal and changing the religion and culture of the province)
		name = ZUSK8OP1
		ai_chance = {
			factor = 40
			# factors making it less likely
			modifier = {
				factor = 0.5
				trait = zealous
			}
			modifier = {
				factor = 0.5
				trait = proud
			}
			modifier = {
				factor = 0.5
				trait = ambitious
			}
			modifier = {
				factor = 0.5
				trait = impaler
			}
			modifier = { # Realm larger than 50 holdings, thus more powerful and less likely to accept negotiating with a Slavic chief
				factor = 0.5
				realm_size >= 50
			}
			modifier = {
				factor = 0.75
				realm_levies = 3000
			}
			modifier = {
				factor = 0.75
				realm_levies = 4000
			}
			modifier = {
				factor = 0.75
				realm_levies = 5000
			}
			modifier = {
				factor = 0.75
				realm_levies = 6000
			}
			modifier = {
				factor = 0.75
				realm_levies = 7000
			}
			modifier = {
				factor = 0.75
				realm_levies = 8000
			}
			# factors making it more likely
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 2
				trait = trusting
			}
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 2
				trait = kind
			}
			# factors making it impossible
			modifier = {
				factor = 0 # only options 2 and 3 for AI tribals
				is_tribal = yes
			}
		}
		FROM = {
			set_province_flag = no_slavs
			add_province_modifier = {
				name = zusk_slav_timer
				duration = 9125
				hidden = yes
			}
			IF = { #if province owner is not the top liege
				limit = {
					owner = {
						NOT = { religion = slavic_pagan }
						NOT = { character = ROOT }
					}
				}
				holder_scope = {
					character_event = { id = zusk_event.36 }
				}
			}
			owner = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = slavic_pagan
					culture = old_slavic
					female = no
					age = 25
					attributes = {
						martial = 5
					}
					trait = peasant_leader
				}

				new_character = {
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = byzantine
									culture_group = proto_carpathian
									culture_group = phrygian_group
									culture = bolghar
								}
							}
						}
						culture = bulgarian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = roman
									culture = latin
								}
							}
						}
						#culture = slovene
						culture = carantanian #ancestors of Slovenes
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = heruli
									culture = lusitanian
								}
							}
						}
						culture = polish
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								culture = dacian
							}
						}
						culture = romanian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								culture = illyrian
							}
						}
						culture = serbian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = illyro_roman
									culture = ostrogothic
								}
							}
						}
						culture = croatian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = rygir
									culture = gepid
									culture = iazyges
								}
							}
						}
						culture = bohemian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = lombard
									culture = german
								}
							}
						}
						culture = pommeranian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = central_germanic
									culture_group = east_germanic
								}
							}
						}
						culture = wends
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = romano_british
									culture = romano_gallic
									culture = frankish
									culture = norman
									culture = old_frankish
									culture_group = west_germanic
									culture_group = celtic
									culture_group = latin
								}
							}
						}
						culture = galliya
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = african_romance
									culture = berber_germanic
									culture = ethiopian
									culture_group = west_african
									culture_group = east_african
									culture_group = central_african
								}
							}
						}
						culture = afriki
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = central_semitic
									culture_group = south_semitic
									culture_group = iranian
								}
							}
						}
						culture = akhemenidov
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = dravidian_group
									culture_group = indo_aryan_group
								}
							}
						}
						culture = ved
						set_character_flag = decided_culture
					}
					
					FROM = { county = { usurp_title_plus_barony_if_unlanded = PREVPREV } }
					set_defacto_liege = PREV # top liege of the realm
					reverse_culture = FROM
					reverse_religion = FROM
					
					#spawn_unit = { #original code by Zusk, doesn't work properly
					#	province = PREV
					#	owner = ROOT
					#	match_character = ROOT
					#	match_mult = 0.75
					#	attrition = 0.000
					#}
					random_list = {
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_cavalry = { 4 4 }
									light_infantry = { 10 10 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_cavalry = { 4 4 }
									light_infantry = { 10 10 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						16 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_cavalry = { 3 3 }
									light_infantry = { 11 11 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_cavalry = { 3 3 }
									light_infantry = { 11 11 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						16 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_infantry = { 14 14 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_infantry = { 14 14 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
					}
				}
			}
		}
	}

	option = { # Fight them (fights against the Slavic chieftain who raises an army)
		name = ZUSK8OP2
		ai_chance = {
			factor = 30
			#traits making it more likely
			modifier = {
				factor = 2
				trait = zealous
			}
			modifier = {
				factor = 2
				trait = proud
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 2
				trait = impaler
			}
			#traits making it less likely
			modifier = {
				factor = 0.5
				trait = arbitrary
			}
			modifier = {
				factor = 0.5
				trait = trusting
			}
			modifier = {
				factor = 0.5
				trait = gregarious
			}
			modifier = {
				factor = 0.5
				trait = kind
			}
			#power
			modifier = {
				factor = 1.3
				realm_levies = 3000
			}
			modifier = {
				factor = 1.3
				realm_levies = 4000
			}
			modifier = {
				factor = 1.3
				realm_levies = 5000
			}
			modifier = {
				factor = 1.3
				realm_levies = 6000
			}
			modifier = {
				factor = 1.3
				realm_levies = 7000
			}
			modifier = {
				factor = 1.3
				realm_levies = 8000
			}
			modifier = {
				factor = 10
				realm_size < 3
			}
			modifier = {
				factor = 3
				realm_size < 4
			}
			modifier = {
				factor = 2
				realm_size < 5
			}
			modifier = {
				factor = 1.2
				realm_size < 6
			}
		}
		FROM = {
			set_province_flag = no_slavs
			add_province_modifier = {
				name = zusk_slav_timer
				duration = 9125
				hidden = yes
			}
			create_character = {
				random_traits = yes
				dynasty = none
				religion = slavic_pagan
				culture = old_slavic
				female = no
				age = 25
				attributes = {
					martial = 5
				}
				
				trait = peasant_leader
			}
			new_character = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = slavic_pagan
					culture = old_slavic
					female = no
					age = 25
					attributes = {
						martial = 5
					}
					trait = peasant_leader
				}

				new_character = {
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = byzantine
									culture_group = proto_carpathian
									culture_group = phrygian_group
									culture = bolghar
								}
							}
						}
						culture = bulgarian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = roman
									culture = latin
								}
							}
						}
						#culture = slovene
						culture = carantanian #ancestors of Slovenes
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = heruli
									culture = lusitanian
								}
							}
						}
						culture = polish
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								culture = dacian
							}
						}
						culture = romanian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								culture = illyrian
							}
						}
						culture = serbian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = illyro_roman
									culture = ostrogothic
								}
							}
						}
						culture = croatian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = rygir
									culture = gepid
									culture = iazyges
								}
							}
						}
						culture = bohemian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = lombard
									culture = german
								}
							}
						}
						culture = pommeranian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = central_germanic
									culture_group = east_germanic
								}
							}
						}
						culture = wends
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = romano_british
									culture = romano_gallic
									culture = frankish
									culture = norman
									culture = old_frankish
									culture_group = west_germanic
									culture_group = celtic
									culture_group = latin
								}
							}
						}
						culture = galliya
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = african_romance
									culture = berber_germanic
									culture = ethiopian
									culture_group = west_african
									culture_group = east_african
									culture_group = central_african
								}
							}
						}
						culture = afriki
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = central_semitic
									culture_group = south_semitic
									culture_group = iranian
								}
							}
						}
						culture = akhemenidov
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = dravidian_group
									culture_group = indo_aryan_group
								}
							}
						}
						culture = ved
						set_character_flag = decided_culture
					}
					
					#This is now done after victory in war
					#reverse_culture = FROM
					#reverse_religion = FROM
					
					create_title = {
						tier = DUKE
						landless = yes
						temporary = yes
						rebel = yes
						culture = FROM
						name = "PEASANT_REVOLT"
						holder = THIS
					}
					
					random_list = {
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_cavalry = { 4 4 }
									light_infantry = { 10 10 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_cavalry = { 4 4 }
									light_infantry = { 10 10 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						16 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_cavalry = { 3 3 }
									light_infantry = { 11 11 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_cavalry = { 3 3 }
									light_infantry = { 11 11 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						16 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_infantry = { 14 14 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_infantry = { 14 14 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
					}
					
					# DoW on the province top liege
					FROM = {
						owner = {
							top_liege = {
	#							set_defacto_vassal = PREVPREVPREV
								reverse_war = {
									target = PREVPREVPREV
									casus_belli = peasant_revolt
									thirdparty_title = FROM # The county
								}
								reverse_opinion = {
									who = PREVPREVPREV
									modifier = opinion_evil_tyrant
								}
							}
						}
					}
				}
			}
		}
	}
	
	option = { # Give away the province (making the county indepedent and giving it to the Slavic chieftain)
		name = ZUSK8OP3
		ai_chance = {
			factor = 30
			# factors making it less likely
			modifier = {
				factor = 0.5
				trait = zealous
			}
			modifier = {
				factor = 0.5
				trait = proud
			}
			modifier = {
				factor = 0.5
				trait = ambitious
			}
			modifier = {
				factor = 0.5
				trait = impaler
			}
			modifier = { # Realm larger than 50 holdings, thus more powerful and less likely to accept negotiating with a Slavic chief
				factor = 0.5
				realm_size >= 50
			}			
			modifier = {
				factor = 0.75
				realm_levies = 3000
			}
			modifier = {
				factor = 0.75
				realm_levies = 4000
			}
			modifier = {
				factor = 0.75
				realm_levies = 5000
			}
			modifier = {
				factor = 0.75
				realm_levies = 6000
			}
			modifier = {
				factor = 0.75
				realm_levies = 7000
			}
			modifier = {
				factor = 0.75
				realm_levies = 8000
			}
			# factors making it more likely
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 2
				trait = trusting
			}
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 2
				trait = kind
			}
		}
		FROM = {
			set_province_flag = no_slavs
			add_province_modifier = {
				name = zusk_slav_timer
				duration = 9125
				hidden = yes
			}
			IF = {
				limit = {
					owner = {
						NOT = { religion = slavic_pagan }
						NOT = { character = ROOT }
					}
				}
				holder_scope = {
					character_event = { id = zusk_event.36 }
				}
			}
			owner = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = slavic_pagan
					culture = old_slavic
					female = no
					age = 25
					attributes = {
						martial = 5
					}
					trait = peasant_leader
				}

				new_character = {
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = byzantine
									culture_group = proto_carpathian
									culture_group = phrygian_group
									culture = bolghar
								}
							}
						}
						culture = bulgarian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = roman
									culture = latin
								}
							}
						}
						#culture = slovene
						culture = carantanian #ancestors of Slovenes
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = heruli
									culture = lusitanian
								}
							}
						}
						culture = polish
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								culture = dacian
							}
						}
						culture = romanian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								culture = illyrian
							}
						}
						culture = serbian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = illyro_roman
									culture = ostrogothic
								}
							}
						}
						culture = croatian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = rygir
									culture = gepid
									culture = iazyges
								}
							}
						}
						culture = bohemian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = lombard
									culture = german
								}
							}
						}
						culture = pommeranian
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = central_germanic
									culture_group = east_germanic
								}
							}
						}
						culture = wends
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = romano_british
									culture = romano_gallic
									culture = frankish
									culture = norman
									culture = old_frankish
									culture_group = west_germanic
									culture_group = celtic
									culture_group = latin
								}
							}
						}
						culture = galliya
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture = african_romance
									culture = berber_germanic
									culture = ethiopian
									culture_group = west_african
									culture_group = east_african
									culture_group = central_african
								}
							}
						}
						culture = afriki
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = central_semitic
									culture_group = south_semitic
									culture_group = iranian
								}
							}
						}
						culture = akhemenidov
						set_character_flag = decided_culture
					}
					IF = {
						limit = {
							NOT = { has_character_flag = decided_culture }
							location = {
								OR = {
									culture_group = dravidian_group
									culture_group = indo_aryan_group
								}
							}
						}
						culture = ved
						set_character_flag = decided_culture
					}
					
					FROM = { county = { usurp_title_plus_barony_if_unlanded = PREVPREV } }
					set_defacto_liege = THIS # Makes the character independent
					opinion = { modifier = opinion_granted_county who = ROOT }
					reverse_culture = FROM
					reverse_religion = FROM
					
					#spawn_unit = { #original code by Zusk, doesn't work properly
					#	province = PREV
					#	owner = ROOT
					#	match_character = ROOT
					#	match_mult = 0.75
					#	attrition = 0.000
					#}
					random_list = {
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_cavalry = { 4 4 }
									light_infantry = { 10 10 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_cavalry = { 4 4 }
									light_infantry = { 10 10 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 4 4 }
										light_infantry = { 10 10 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						16 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_cavalry = { 3 3 }
									light_infantry = { 11 11 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_cavalry = { 3 3 }
									light_infantry = { 11 11 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_cavalry = { 3 3 }
										light_infantry = { 11 11 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						16 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.75
								troops = {
									archers = { 6 6 }
									light_infantry = { 14 14 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.75
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
						17 = {
							spawn_unit = {
								province = FROM
								home = FROM
								owner = THIS
								leader = THIS
								scaled_by_biggest_garrison = 0.5
								troops = {
									archers = { 6 6 }
									light_infantry = { 14 14 }
								}
								attrition = 1.0
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 30
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
							create_character = {
								random_traits = yes
								dynasty = none
								religion = THIS
								culture = THIS
								female = no
								age = 31
								trait = peasant_leader
								trait = tough_soldier
							}
							new_character = {
								spawn_unit = {
									province = FROM
									home = FROM
									owner = PREV
									scaled_by_biggest_garrison = 0.5
									troops = {
										archers = { 6 6 }
										light_infantry = { 14 14 }
									}
									attrition = 1.0
									disband_on_peace = yes
								}
							}
						}
					}
				}
			}
		}
	}
}

# Slavs settle in realm province of a Slavic top liege
province_event = {
	id = zusk_event.35
	desc = zusk_event.35.desc
	
	picture = GFX_evt_tribal_life
	
	trigger = {
		owner = {
			top_liege = {
				religion = slavic_pagan
			}
		}
		NOT = { has_province_modifier = zusk_slav_timer }
		NOT = { has_province_flag = slav_culture_flag }
		OR = {
			AND = {
				NOT = { culture_group = east_slavic }
				NOT = { culture_group = west_slavic }
				NOT = { culture_group = south_slavic }
			}
			NOT = { religion = slavic_pagan }
		}
		NOT = { year = 800 }
	}
	
	mean_time_to_happen = {
		years = 25

		modifier = {
			factor = 1.1
			year = 500
		}
		modifier = {
			factor = 1.2
			year = 550
		}
		modifier = {
			factor = 1.4
			year = 600
		}
		modifier = {
			factor = 1.8
			year = 650
		}
		modifier = {
			factor = 2
			year = 700
		}
		modifier = {
			factor = 2.5
			year = 750
		}
	}
	
	option = {
		name = OK
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture_group = byzantine
						culture_group = proto_carpathian
						culture_group = phrygian_group
						culture = bolghar
					}
				}
			}
			culture = bulgarian
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture = roman
						culture = latin
					}
				}
			}
			#culture = slovene
			culture = carantanian #ancestors of Slovenes
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture = heruli
						culture = lusitanian
					}
				}
			}
			culture = polish
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					culture = dacian
				}
			}
			culture = romanian
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					culture = illyrian
				}
			}
			culture = serbian
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture = dalmatian
						culture = ostrogothic
					}
				}
			}
			culture = croatian
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture = rygir
						culture = gepid
						culture = iazyges
					}
				}
			}
			culture = bohemian
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture = lombard
						culture = german
					}
				}
			}
			culture = pommeranian
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture_group = central_germanic
						culture_group = east_germanic
					}
				}
			}
			culture = wends
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture = romano_british
						culture = romano_gallic
						culture = frankish
						culture = norman
						culture = old_frankish
						culture_group = west_germanic
						culture_group = celtic
						culture_group = latin
					}
				}
			}
			culture = galliya
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture = african_romance
						culture = berber_germanic
						culture = ethiopian
						culture_group = west_african
						culture_group = east_african
						culture_group = central_african
					}
				}
			}
			culture = afriki
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture_group = central_semitic
						culture_group = south_semitic
						culture_group = iranian
					}
				}
			}
			culture = akhemenidov
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
				location = {
					OR = {
						culture_group = dravidian_group
						culture_group = indo_aryan_group
					}
				}
			}
			culture = ved
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		IF = {
			limit = {
				NOT = { has_province_modifier = zusk_slav_timer }
			}
			culture = old_slavic
			add_province_modifier = { name = zusk_slav_timer duration = 10 hidden = yes }
		}
		religion = slavic_pagan
		set_province_flag = slav_culture_flag
		IF = {
			limit = {
				owner = {
					NOT = { religion = slavic_pagan }
					top_liege = { NOT = { character = PREV } }
				}
			}
			holder_scope = { opinion = { modifier = opinion_revoked_my_title who = top_liege } }
		}
	}
}

character_event = {
	id = zusk_event.36
	desc = zusk_event.36.desc
	picture = GFX_evt_tribal_life
	
	is_triggered_only = yes
	option = {
		name = zusk_event.36.a
		opinion = { modifier = opinion_revoked_my_title who = top_liege }
	}
}
