###################################
# Fall of Rome, historical invasions, etc..
#
# Written by Zusk
# 
# zusk_event.22 -> zusk_event.50
# historical_wtwsms.1 -> historical_wtwsms.6
###################################

namespace = zusk_event
namespace = historical_wtwsms

# Theodoric Invasion of Italy
character_event = {
	id = zusk_event.22
	desc = zusk_event.22.desc
	picture = GFX_evt_heretic
	
	is_triggered_only = yes
	
	option = {
		name = ZUSK22OP1
			add_claim = e_italy
			set_character_flag = give_italy_if_win
			spawn_unit = {
				earmark = theodoric_italy_invasion
				province = 460 # Varazdin
				owner = ROOT
				leader = ROOT
				match_character = ROOT
				match_mult = 0.5
				attrition = 0.5
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 23
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = 460 # Varazdin
					owner = ROOT
					leader = THIS
					match_character = ROOT
					match_mult = 0.5
					attrition = 0.5
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = 460 # Varazdin
					owner = ROOT
					leader = THIS
					match_character = ROOT
					match_mult = 0.5
					attrition = 0.5
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = 460 # Varazdin
					owner = ROOT
					leader = THIS
					match_character = ROOT
					match_mult = 0.5
					attrition = 0.5
				}
			}
		358 = {
			empire = {
				ROOT = {
					war = {
						casus_belli = unification
						target = PREVPREV # The top liege of the owner
						thirdparty_title = PREV # The de jure kingdom
					}
				}
			}
		}
	}

	option = {
		name = ZUSK22OP2
		ai_chance = { factor = 0 }
	}

}

# Adopt Justinian
character_event = {
	id = zusk_event.24
	desc = zusk_event.24.desc
	picture = GFX_evt_monk
	border = GFX_event_normal_frame_religion
	
	only_playable = yes
	only_independent = yes
	min_age = 16
	has_global_flag = historical_events_fall_of_rome
	
	trigger = {
		NOT = { has_global_flag = justinian_adopted }
		has_landed_title = e_byzantium
		independent = yes
		year = 482
		NOT = { year = 565 }
		OR = {
			NOT = { current_heir = { dynasty = ROOT } }
			current_heir = { is_female = yes }
		}
		NOT = { trait = pregnant }
		NOT = { any_spouse = { trait = pregnant } }
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = {
		name = ZUSK24OP1
		set_global_flag = justinian_adopted
		create_random_soldier = {
			name = Justinian
			dynasty = ROOT
			religion = ROOT
			culture = roman #Actually Illyrian or Thracian
			age = 5
			attributes = {
				martial = 10
				diplomacy = 5
				intrigue = 6
				stewardship = 5
			}
			trait = "ambitious"
			trait = "just"
			trait = "mystic"
			trait = "genius"
			trait = "midas_touched"
			trait = "legendary_leader"
		}
		if = {
			limit = {
				ROOT = { is_female = yes }
			}
			new_character = {
				set_mother = ROOT
			}
		}
		else = {
			new_character = {
				set_father = ROOT
			}
		}
		recalc_succession = yes
	}

	option = {
		name = ZUSK22OP2
		ai_chance = { factor = 0 }
	}
}

# Julius Nepos gets WRE
character_event = {
	id = zusk_event.26
	desc = zusk_event.26.desc
	picture = GFX_evt_heretic
	
	is_triggered_only = yes
	
	option = {
		name = OK
		set_global_flag = julis_nepos_wre
		primary_title = {
			e_wre = {
				activate_title = { title = THIS status = yes } # Otherwise grant_title doesn't work
				grant_title = ROOT
				copy_title_laws = PREV
			}
		}
		clr_global_flag = bureaucratic_dalmatia
	}
}

# Ruler of the Franks decides what he wants to convert to
character_event = {
	id = zusk_event.27
	desc = zusk_event.27.desc
	
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion

	only_playable = yes
	only_independent = yes
	has_global_flag = historical_events_fall_of_rome
	
	trigger = {
		has_landed_title = k_franks
		NOT = { has_global_flag = franks_religion_flag }
		religion = germanic_pagan
		independent = yes
		year = 500
		has_game_rule = { # Has enabled old melting pot events
			name = melting_pots
			value = old
		}
	}
	
	mean_time_to_happen = {
		years = 1
	}
	
	option = {
		name = ZUSK27OP1
		ai_chance = { factor = 50 }

		religion = nicene
		culture = frankish

		set_global_flag = franks_religion_flag

		if = {
			limit = {
				trait = cynical
				NOT = { trait = zealous }
				age = 12
			}
			random = {
				chance = 60
				add_trait = sympathy_pagans
			}
		}
		else_if = {
			limit = {
				NOT = {
					trait = cynical
					trait = zealous
				}
				age = 12
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}
		
		prestige = -500
		piety = -50
		
		any_courtier = {
			limit = { is_close_relative = ROOT ai = yes religion = germanic_pagan culture = old_frankish }
			religion = nicene
			culture = frankish
		}
		any_spouse = {
			limit = { is_close_relative = ROOT ai = yes religion = germanic_pagan culture = old_frankish }
			religion = nicene
			culture = frankish
		}
		random_vassal = {
			limit = {
				ai = yes
				religion = germanic_pagan
				culture = old_frankish
			}
			religion = nicene
			culture = frankish
		}
		random_vassal = {
			limit = {
				ai = yes
				religion = germanic_pagan
				culture = old_frankish
			}
			religion = nicene
			culture = frankish
		}
		random_vassal = {
			limit = {
				ai = yes
				religion = germanic_pagan
				culture = old_frankish
			}
			religion = nicene
			culture = frankish
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = greek
			religion = nicene
			female = no
			age = 32
			attributes = {
				learning = 6
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}

	option = {
		name = ZUSK27OP2
		ai_chance = { factor = 20 }

		religion = arian
		culture = frankish

		set_global_flag = franks_religion_flag

		if = {
			limit = {
				trait = cynical
				NOT = { trait = zealous }
				age = 12
			}
			random = {
				chance = 60
				add_trait = sympathy_pagans
			}
		}
		else_if = {
			limit = {
				NOT = {
					trait = cynical
					trait = zealous
				}
				age = 12
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}
		
		prestige = -500
		piety = -50
		
		any_courtier = {
			limit = { is_close_relative = ROOT ai = yes religion = germanic_pagan culture = old_frankish }
			religion = arian
			culture = frankish
		}
		any_spouse = {
			limit = { is_close_relative = ROOT ai = yes religion = germanic_pagan culture = old_frankish }
			religion = arian
			culture = frankish
		}
		random_vassal = {
			limit = {
				ai = yes
				religion = germanic_pagan
				culture = old_frankish
			}
			religion = arian
			culture = frankish
		}
		random_vassal = {
			limit = {
				ai = yes
				religion = germanic_pagan
				culture = old_frankish
			}
			religion = arian
			culture = frankish
		}
		random_vassal = {
			limit = {
				ai = yes
				religion = germanic_pagan
				culture = old_frankish
			}
			religion = arian
			culture = frankish
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = visigothic
			religion = arian
			female = no
			age = 32
			attributes = {
				learning = 6
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}

	option = {
		name = ZUSK27OP3
		ai_chance = { factor = 30 }

		set_global_flag = franks_religion_flag

		piety = 500
		random = {
			chance = 50
			add_trait = zealous
		}
	}
}

# Avars Invade!
character_event = {
	id = zusk_event.28
	hide_window = yes

	picture = "GFX_evt_mongols"
	border = "GFX_event_normal_frame_war"

	is_triggered_only = yes

	option = {
		name = OK

		c_csanad = {
			grant_title = PREV
		}

		create_character = {
			random_traits = yes
			dynasty = none
			religion = tengri_pagan
			culture = avar
			female = no
			age = 23
			attributes = {
				martial = 6
			}
			trait = skilled_tactician
		}
		new_character = {
			spawn_unit = {
				province = 521 # Olvia
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = avar
			female = no
			age = 27
			attributes = {
				martial = 6
			}
			trait = skilled_tactician
		}
		new_character = {
			spawn_unit = {
				province = 521 # Olvia
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = avar
			female = no
			age = 27
			attributes = {
				martial = 6
			}
			trait = skilled_tactician
		}
		new_character = {
			spawn_unit = {
				province = 521 # Olvia
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
			}
		}
		522 = {
			kingdom = {
				ROOT = {
					war = {
						casus_belli = tribal_invasion
						target = PREVPREV # The top liege of the owner
						thirdparty_title = PREV # The de jure kingdom
					}
				}
			}
		}
	}
}

# Avars come to Constantinople looking for money
narrative_event = {
	id = zusk_event.29
	title = zusk_event.29.name
	desc = zusk_event.29.desc
	picture = "GFX_evt_mongols"
	border = "GFX_event_narrative_frame_war"
	
	has_global_flag = gokturk_arrived

	trigger = {
		year = 550
		NOT = { year = 600 }
		NOT = { has_global_flag = avar_arrived }
		496 = {
			owner = {
				OR = {
					is_liege_or_above = ROOT
					character = ROOT
				}
			}
		}
		e_avar = {
			has_holder = no
		}
		k_gepidia = {
			has_holder = yes
		}
	}
	
	mean_time_to_happen = {
		years = 15
	}
	
	option = {
		name = ZUSK29OP1
		ai_chance = {
			factor = 90
		}

		treasury = -500

		set_global_flag = avar_arrived

		custom_tooltip = {
			text = avar_attack_tooltip
			hidden_tooltip = {
				
				activate_title = { title = e_avar status = yes }

				521 = {
					create_random_soldier = {
						name = Bayan
						random_traits = no
						dynasty = random
						religion = tengri_pagan
						culture = avar
						female = no
						age = 45
					}
		
					new_character = {

						wealth = 500
						
						add_claim = e_dacia
					
						e_avar = {
							grant_title = PREV
						}
						set_defacto_liege = THIS
						
						character_event = { id = zusk_event.28 days = 25 }

					}
				}
			}
		}
	}

	option = {
		name = ZUSK29OP2
		ai_chance = {
			factor = 10
		}
		set_global_flag = avar_arrived
	}
}

# Fall of Rome to barbarians
narrative_event = {
	id = zusk_event.30
	title = zusk_event.30.name
	desc = zusk_event.30.desc
	
	picture = GFX_evt_fall_of_rome
	border = GFX_event_narrative_frame_diplomacy
	
	major = yes
	
	only_rulers = yes
	only_independent = yes
	
	# Fires for the sacker of Rome
	trigger = {
		NOT = { has_global_flag = fall_of_rome }
		has_romance_culture_trigger = no
		OR = {
			has_landed_title = c_roma
			c_roma = {
				holder_scope = {
					top_liege = {
						character = ROOT
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 7
	}

	immediate = {
		set_global_flag = fall_of_rome
		if = {
			limit = {
				NOT = {
					has_global_flag = western_regalia_transferred
				}
			}
			event_target:defeated_western_emperor = {
				if = {
					limit = { is_landed = no } #don't transfer the regalia if the defeated emperor remains landed
					
					any_artifact = {
						limit = { has_artifact_flag = western_regalia } # it's kind of a workaround
						transfer_artifact = {
							from = PREV
							to = ROOT
						}
					}
				}
			}
		}
		if = {
			limit = {
				ROOT = {
					any_artifact = { has_artifact_flag = western_regalia }
				}
			}
			ROOT = {
				character_event = { id = imperial_legacy.42 days = 2 } # Delay to ensure that e_wre has been granted beforehand
			}
		}
	}
	
	option = {
		name = ZUSK30OP1
		trigger = {
			NOT = { has_landed_title = e_byzantium }
			NOT = { religion = germanic_pagan }
			NOT = { religion = nicene }
			NOT = { character = 55 }
			NOT = { character = 93 }
			NOT = { character = 175110 }
		}
	}
	option = {
		name = ZUSK30OP2
		trigger = {
			NOT = { has_landed_title = e_byzantium }
			NOT = { character = 55 }
			NOT = { character = 93 }
			NOT = { character = 175110 }
			religion = germanic_pagan
		}
		piety = 100
	}
	option = {
		name = ZUSK30OP3
		trigger = {
			NOT = { has_landed_title = e_byzantium }
			NOT = { character = 55 }
			NOT = { character = 93 }
			NOT = { character = 175110 }
			religion = nicene
		}
		piety = -100
	}
	option = {
		name = ZUSK30OP4
		trigger = {
			character = 55
		}
		piety = 1000
		prestige = 1000
		disband_event_forces = history_mark
	}
	option = {
		name = ZUSK30OP5
		trigger = {
			character = 93
		}
	}
	option = {
		name = ZUSK30OP6
		trigger = {
			character = 175110
		}
		add_claim = e_italy
		character_event = { id = zusk_event.26 days = 1 } # Delay granting e_wre, so that below titular titles aren't transferred
	}
	option = {
		name = ZUSK30OP7
		trigger = {
			has_landed_title = e_byzantium
			NOT = { character = 55 }
			NOT = { character = 93 }
			NOT = { character = 175110 }
		}
		religion_authority = {
			modifier = fall_of_rome_moral_authority
			years = 100
		}
		piety = -1000
		prestige = -1000
	}
}

# Fall of Persia
character_event = {
	id = zusk_event.31
	hide_window = yes
	
	religion = zoroastrian

	trigger = {
		e_persia = {
			has_holder = no
		}
		NOT = { has_global_flag = fall_of_persia }
		controls_religion = yes
	}
	
	mean_time_to_happen = {
		days = 7
	}

	option = {
		name = OK
		
		trigger = {
			NOT = {
				any_playable_ruler = {
					culture = persian
					primary_title = { tier = EMPEROR }
				}
			}
		}
		set_global_flag = fall_of_persia
		any_playable_ruler = {
			narrative_event = { id = zusk_event.32 }
		}
	}

	option = {
		name = OK
		
		trigger = {
			any_playable_ruler = {
				culture = persian
				primary_title = { tier = EMPEROR }
			}
		}
		set_global_flag = fall_of_persia #Quiet fall of Persia, another empire for Persians exists in name to continue the legacy
	}
}

narrative_event = {
	id = zusk_event.32
	title = zusk_event.32.name
	desc = zusk_event.32.desc
	
	picture = GFX_evt_fall_of_persia
	border = GFX_event_narrative_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = ZUSK32OP1
		trigger = {
			NOT = {
				AND = {
					controls_religion = yes
					religion = zoroastrian
				}
			}
			NOT = { has_landed_title = e_byzantium }
			NOT = { has_landed_title = e_roman_empire }
			NOT = { has_landed_title = e_wre }
			NOT = { culture_group = altaic }
			NOT = { culture = persian }
		}
	}
	option = {
		name = ZUSK32OP2
		trigger = {
			OR = {
				has_landed_title = e_byzantium
				has_landed_title = e_roman_empire
				has_landed_title = e_wre
			}
		}
		piety = 100
	}
	option = {
		name = ZUSK32OP3
		trigger = {
			NOT = {
				AND = {
					controls_religion = yes
					religion = zoroastrian
				}
			}
			culture = persian
			OR = {
				dynasty = 1029100
				higher_tier_than = DUKE
				e_persia = {
					any_previous_holder = {
						character = ROOT
					}
				}
			}
		}
		add_claim = e_persia
		prestige = -100
		piety = -100
	}
	option = {
		name = ZUSK32OP4
		trigger = {
			NOT = {
				AND = {
					controls_religion = yes
					religion = zoroastrian
				}
			}
			culture = persian
			NOT = { dynasty = 1029100 }
			NOT = { higher_tier_than = DUKE }
			NOT = {
				e_persia = {
					any_previous_holder = {
						character = ROOT
					}
				}
			}
		}
		piety = -100
		prestige = -100
	}
	option = {
		name = ZUSK32OP5
		trigger = {
			culture_group = altaic
		}
	}
	option = {
		name = ZUSK32OP6
		trigger = {
			controls_religion = yes
			religion = zoroastrian
		}
		religion_authority = {
			modifier = fall_of_persia #Helps muslims convert Persia
			years = 100
		}
		piety = -1000
		prestige = -1000
	}
}

# Fall of Constantinople
character_event = {
	id = zusk_event.33
	hide_window = yes
	
	religion = miaphysite

	trigger = {
		e_byzantium = {
			has_holder = no
		}
		NOT = { has_global_flag = fall_of_constantinople }
		controls_religion = yes
	}
	
	mean_time_to_happen = {
		days = 7
	}

	option = {
		name = OK
		
		trigger = {
			e_roman_empire = {
				has_holder = no
			}
			NOT = {
				any_playable_ruler = {
					culture_group = byzantine
					primary_title = { tier = EMPEROR }
				}
			}
		}
		set_global_flag = fall_of_constantinople
		any_playable_ruler = {
			narrative_event = { id = zusk_event.34 }
		}
	}

	option = {
		name = OK
		
		trigger = {
			OR = {
				e_roman_empire = {
					has_holder = yes
				}
				any_playable_ruler = {
					culture_group = byzantine
					primary_title = { tier = EMPEROR }
				}
			}
		}
		set_global_flag = fall_of_constantinople #Quiet fall of Constantinople, another empire for Greeks exists in name to continue the legacy
	}
}

narrative_event = {
	id = zusk_event.34
	title = zusk_event.34.name
	desc = zusk_event.34.desc
	
	picture = GFX_evt_fall_of_constantinople
	border = GFX_event_narrative_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = ZUSK34OP
	}
}

# Eastern Roman Empire asks the Ostrogoths for help
character_event = {
	id = zusk_event.37
	desc = zusk_event.37.desc
	picture = GFX_evt_council
	
	has_global_flag = historical_events_fall_of_rome
	
	trigger = {
		year = 490
		NOT = { year = 550 }
		NOT = { has_global_flag = ostrogoths_arrived }
		NOT = { k_ostrogoths = { holder_scope = { war_with = ROOT } } }
		has_global_flag = fall_of_rome
		496 = {
			owner = {
				OR = {
					is_liege_or_above = ROOT
					character = ROOT
				}
			}
		}
		k_ostrogoths = {
			has_holder = yes
		}
	}

	mean_time_to_happen = {
		years = 1
	}
	
	immediate = {
		set_global_flag = ostrogoths_arrived
	}

	option = {
		name = ZUSK37OP1
		trigger = {
			any_playable_ruler = {
				has_landed_title = k_ostrogoths
			}
		}
		ai_chance = {
			factor = 90
		}
		treasury = -50
		custom_tooltip = {
			text = ostrogoth_attack_tooltip
			hidden_tooltip = {
				any_playable_ruler = {
					limit = {
						has_landed_title = k_ostrogoths
					}
					treasury = 50
					character_event = { id = zusk_event.22 days = 25 }
				}
			}
		}
	}
	option = {
		name = ZUSK37OP2
		ai_chance = {
			factor = 10
		}
	}
}

# Rouran arrives
province_event = {
	id = zusk_event.16
	hide_window = yes
	
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_war

	trigger = {
		year = 500
		NOT = { has_global_flag = rouran_arrived }
		province_id = 1423
	}
	
	mean_time_to_happen = {
		years = 20
	}
	
	immediate = {
		set_global_flag = rouran_arrived
		activate_title = { title = e_rouran status = yes }
		
		create_character = {
			name = Nagai
			random_traits = no
			dynasty = 100
			religion = tengri_pagan
			 culture = mongol
			female = no
			age = 45
		}
		
		new_character = {
			save_event_target_as = target_rouran

			wealth = 500

			e_rouran = {
				grant_title = PREV
			}
			set_defacto_liege = THIS

			c_fergana = {
				grant_title = PREV
			}

			create_character = {
				random_traits = yes
				dynasty = none
				religion = tengri_pagan
				culture = mongol
				female = no
				age = 23
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = mongol
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = mongol
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = mongol
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = mongol
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			
			# DoW on the province top liege
			1425 = {
				kingdom = {
					event_target:target_rouran = {
						war = {
							casus_belli = tribal_invasion
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
	}

	option = {
		name = "EVTOPTA_TOG_1000"
	}


}

# Gökturk arrives
province_event = {
	id = zusk_event.38
	hide_window = yes
	
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_war

	trigger = {
		year = 550
		NOT = { has_global_flag = gokturk_arrived }
		province_id = 1423
	}
	
	mean_time_to_happen = {
		years = 20
	}
	
		immediate = {
		set_global_flag = gokturk_arrived

			activate_title = { title = e_turkestan status = yes }

		create_character = {
						name = Bumin
			random_traits = no
			dynasty = random
			religion = tengri_pagan
						culture = turkish
			female = no
			age = 45
		}
		
		new_character = {
			save_event_target_as = target_gokturk
						wealth = 500

						e_turkestan = {
			grant_title = PREV
			}
						set_defacto_liege = THIS

						c_fergana = {
			grant_title = PREV
			}

			create_character = {
				random_traits = yes
				dynasty = none
				religion = tengri_pagan
				culture = turkish
				female = no
				age = 23
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = turkish
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = turkish
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = turkish
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = turkish
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			
			# DoW on the province top liege
					1425 = {
			kingdom = {
				event_target:target_gokturk = {
					war = {
						casus_belli = tribal_invasion
						target = PREVPREV # The top liege of the owner
						thirdparty_title = PREV # The de jure kingdom
					}
				}
			}
		}
	}
	

		}

	option = {
		name = "EVTOPTA_TOG_1000"
	}


}

# Uyghur arrives
province_event = {
	id = zusk_event.39
	hide_window = yes
	
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_war

	trigger = {
		year = 700
		NOT = { has_global_flag = uyghur_arrived }
		province_id = 1423
	}
	
	mean_time_to_happen = {
		years = 20
	}
	
	immediate = {
		set_global_flag = uyghur_arrived

		activate_title = { title = e_uyghur status = yes }

		create_character = {
			name = Qutlugh
			random_traits = no
			dynasty = random
			religion = manichean
			culture = uyghur
			female = no
			age = 45
		}
		
		new_character = {
			save_event_target_as = target_uyghur

			wealth = 500

			e_uyghur = {
				grant_title = PREV
			}
			set_defacto_liege = THIS

			c_fergana = {
				grant_title = PREV
			}

			add_claim = e_tartaria
					
			create_character = {
				random_traits = yes
				dynasty = none
				religion = manichean
				culture = uyghur
				female = no
				age = 23
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
				attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = manichean
				culture = uyghur
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
				attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = manichean
				culture = uyghur
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
				attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = manichean
				culture = uyghur
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
				attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = manichean
				culture = uyghur
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
				attrition = 0.25
				}
			}
			
			# DoW on the province top liege
			1425 = {
				empire = {
					event_target:target_uyghur = {
						war = {
							casus_belli = unification
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
	

	}

	option = {
		name = "EVTOPTA_TOG_1000"
	}


}

# Khanid arrives
province_event = {
	id = zusk_event.40
	hide_window = yes
	
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_war

	trigger = {
		year = 900
		NOT = { has_global_flag = khanid_arrived }
		province_id = 1423
	}
	
	mean_time_to_happen = {
		years = 20
	}
	
		immediate = {
		set_global_flag = khanid_arrived

			activate_title = { title = e_khanid status = yes }

		create_character = {
						name = Bilge
			random_traits = no
			dynasty = random
			religion = tengri_pagan
						culture = khanid
			female = no
			age = 45
		}
		
		new_character = {
			save_event_target_as = target_khanid

						wealth = 500

						e_khanid = {
			grant_title = PREV
			}
						set_defacto_liege = THIS

						c_fergana = {
			grant_title = PREV
			}

			create_character = {
				random_traits = yes
				dynasty = none
				religion = tengri_pagan
				culture = khanid
				female = no
				age = 23
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = khanid
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = khanid
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = khanid
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = khanid
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
				province = ROOT
				home = ROOT
				owner = PREV
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
				attrition = 0.25
							 }
					}
			
			# DoW on the province top liege
					1425 = {
			kingdom = {
				event_target:target_khanid = {
					war = {
						casus_belli = tribal_invasion
						target = PREVPREV # The top liege of the owner
						thirdparty_title = PREV # The de jure kingdom
					}
				}
			}
		}
	}
	

		}

	option = {
		name = "EVTOPTA_TOG_1000"
	}


}

# Khitan arrives
province_event = {
	id = zusk_event.41
	hide_window = yes
	
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_war

	trigger = {
		year = 1100
		NOT = { has_global_flag = khitan_arrived }
		province_id = 1423
	}
	
	mean_time_to_happen = {
		years = 20
	}
	
	immediate = {
		set_global_flag = khitan_arrived

		 activate_title = { title = e_khitan status = yes }

		create_character = {
			name = Yelu
			random_traits = no
			dynasty = random
			religion = tengri_pagan
			culture = khitan
			female = no
			age = 45
		}
		
		new_character = {
			save_event_target_as = target_khitan
			wealth = 500

			e_khitan = {
				grant_title = PREV
			}
			set_defacto_liege = THIS

			c_fergana = {
				grant_title = PREV
			}

			add_claim = e_tartaria

			create_character = {
				random_traits = yes
				dynasty = none
				religion = buddhist
				culture = khitan
				female = no
				age = 23
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops =
					{
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = buddhist
				culture = khitan
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops =
					{
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = buddhist
				culture = khitan
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops =
					{
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = buddhist
				culture = khitan
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops =
					{
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = buddhist
				culture = khitan
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops =
					{
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			
			# DoW on the province top liege
			1425 = {
				empire = {
					event_target:target_khitan = {
						war = {
							casus_belli = unification
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
	
	}

	option = {
		name = "EVTOPTA_TOG_1000"
	}
}

# Fall of Roman Culture
character_event = {
	id = zusk_event.42
	desc = "zusk_event.42.desc"
	picture = GFX_evt_stone_church
	
	trigger = {
		has_game_rule = { # Has enabled old melting pot events
			name = melting_pots
			value = old
		}
		NOT = { year = 800 }
		OR = {
			culture_group = west_germanic
			culture_group = central_germanic
			culture_group = east_germanic
			culture = berber_germanic
			culture = frankish
		}
		any_demesne_province = {
			culture = roman
		}
	}
	
	mean_time_to_happen = {
		years = 25
		modifier = {
			factor = 2
			NOT = { year = 500 }
		}
		modifier = {
			factor = 0.8
			year = 500
		}
		modifier = {
			factor = 0.6
			year = 525
		}
		modifier = {
			factor = 0.4
			year = 550
		}
		modifier = {
			factor = 1.2
			year = 580
		}
		modifier = {
			factor = 2.5
			year = 600
		}
		modifier = {
			factor = 2.5
			year = 700
		}
	}

	option = {
		name = ZUSK42OP
		random_demesne_province = {
			limit = {
				culture = roman
			}
			culture = latin
		}
	}
}

# Hunas arrives
province_event = {
	id = zusk_event.43
	hide_window = yes
	
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_war

	trigger = {
		year = 490
		NOT = { has_global_flag = hunas_arrived }
		province_id = 1342
	}
	
	mean_time_to_happen = {
		years = 20
	}
	
	immediate = {
		set_global_flag = hunas_arrived

		activate_title = { title = k_hunas status = yes }

		create_character = {
			name = Khingila
			random_traits = no
			dynasty = random
			religion = tengri_pagan #Religious conversion handled by zusk event 44
			culture = hunas
			female = no
			age = 45
		}
		
		new_character = {
			save_event_target_as = target_khingila

			wealth = 500

			k_hunas = {
				grant_title = PREV
			}
			set_defacto_liege = THIS

			c_purushapura = {
				grant_title = PREV
			}

			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = hunas
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
					attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = hunas
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
				attrition = 0.25
				}
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = tengri_pagan
				culture = hunas
				female = no
				age = 27
				attributes = {
					martial = 6
				}
				trait = skilled_tactician
			}
			new_character = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = PREV
					troops = {
						horse_archers = { 2700 2700 }
						light_cavalry = { 1600 1600 }
						light_infantry = { 541 541 }
						heavy_infantry = { 210 210 }
						knights = { 47 47 }
					}
				attrition = 0.25
				}
			}
			
			# DoW on the province top liege
			1191 = {
				kingdom = {
					event_target:target_khingila = {
						war = {
							casus_belli = tribal_invasion
							target = PREVPREV # The top liege of the owner
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
	}

	option = {
		name = "EVTOPTA_TOG_1000"
	}


}

# Tengri ruler of the Hunas decides what he wants to convert to
character_event = {
	id = zusk_event.44
	desc = zusk_event.44.desc
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	has_global_flag = historical_events_fall_of_rome
	religion = tengri_pagan
	
	trigger = {
		has_landed_title = k_hunas
		NOT = { has_global_flag = hunas_religion_flag }
		independent = yes
		year = 500
		NOT = { year = 550 }
	}
	
	mean_time_to_happen = {
		years = 1
	}
	
	option = {
		name = ZUSK44OP1
		ai_chance = { factor = 90 }

		religion = hindu

		set_global_flag = hunas_religion_flag

		if = {
			limit = {
				trait = cynical
				NOT = { trait = zealous }
				age = 12
			}
			random = {
				chance = 60
				add_trait = sympathy_pagans
			}
		}
		else_if = {
			limit = {
				NOT = {
					trait = cynical
					trait = zealous
				}
				age = 12
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}
		
		prestige = -500
		piety = -50
		
		any_courtier = {
			limit = { is_close_relative = ROOT ai = yes }
			religion = hindu
		}
		any_spouse = {
			limit = { is_consort = no ai = yes }
			religion = hindu
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = sanskrit
			religion = hindu
			female = no
			age = 32
			attributes = {
				learning = 6
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}

	option = {
		name = ZUSK44OP2
		ai_chance = { factor = 1 }
		trigger = {
			any_realm_province = {
				culture = kalash
				religion = hellenic_pagan
			}
		}
		religion = hellenic_pagan

		set_global_flag = hunas_religion_flag

		random = {
			chance = 50
			add_trait = zealous
		}
		
		prestige = -500
		piety = -50
		
		any_courtier = {
			limit = { is_close_relative = ROOT ai = yes }
			religion = hindu
		}
		any_spouse = {
			limit = { is_consort = no ai = yes }
			religion = hindu
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = kalash
			religion = hellenic_pagan
			female = no
			age = 32
			attributes = {
				learning = 6
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}

	option = {
		name = ZUSK44OP3
		ai_chance = { factor = 9 }
		piety = 500

		set_global_flag = hunas_religion_flag

		any_courtier = {
			limit = { is_close_relative = ROOT ai = yes }
			religion = hindu
		}
		any_spouse = {
			limit = { is_consort = no ai = yes }
			religion = hindu
		}
		random = {
			chance = 50
			add_trait = zealous
		}
	}
}

# Germanic ruler of England decides what he wants to convert to
character_event = {
	id = zusk_event.45
	desc = zusk_event.45.desc
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion

	has_global_flag = historical_events_fall_of_rome
	religion = germanic_pagan
	
	trigger = {
		has_landed_title = k_england
		NOT = { has_global_flag = england_religion_flag }
		OR = {
			culture_group = north_germanic
			culture_group = west_germanic
			culture_group = central_germanic
		}
		independent = yes
		year = 530
	}
	
	mean_time_to_happen = {
		years = 1
	}
	
	option = {
		name = ZUSK45OP1
		ai_chance = { factor = 50 }

		set_global_flag = england_religion_flag

		religion = nicene

		if = {
			limit = {
				trait = cynical
				NOT = { trait = zealous }
				age = 12
			}
			random = {
				chance = 60
				add_trait = sympathy_pagans
			}
		}
		else_if = {
			limit = {
				NOT = {
					trait = cynical
					trait = zealous
				}
				age = 12
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}
		
		prestige = -500
		piety = -50
		
		any_courtier = {
			limit = { is_close_relative = ROOT ai = yes }
			religion = nicene
		}
		any_spouse = {
			limit = { is_consort = no ai = yes }
			religion = nicene
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = nicene
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = nicene
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = nicene
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = greek
			religion = nicene
			female = no
			age = 32
			attributes = {
				learning = 6
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}

	option = {
		name = ZUSK45OP2
		ai_chance = { factor = 20 }

		religion = insular

		set_global_flag = england_religion_flag

		if = {
			limit = {
				trait = cynical
				NOT = { trait = zealous }
				age = 12
			}
			random = {
				chance = 60
				add_trait = sympathy_pagans
			}
		}
		else_if = {
			limit = {
				NOT = {
					trait = cynical
					trait = zealous
				}
				age = 12
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}
		
		prestige = -500
		piety = -50
		
		any_courtier = {
			limit = { is_close_relative = ROOT ai = yes }
			religion = insular
		}
		any_spouse = {
			limit = { is_consort = no ai = yes }
			religion = insular
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = insular
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = insular
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = insular
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = romano_british
			religion = insular
			female = no
			age = 32
			attributes = {
				learning = 6
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}

	option = {
		name = ZUSK45OP3
		ai_chance = { factor = 5 }
		trigger = {
			any_realm_province = {
				religion = celtic_pagan
			}
		}
		religion = celtic_pagan

		set_global_flag = england_religion_flag


		random = {
			chance = 50
			add_trait = zealous
		}
		
		prestige = -500
		piety = -50
		
		any_courtier = {
			limit = { is_close_relative = ROOT ai = yes }
			religion = celtic_pagan
		}
		any_spouse = {
			limit = { is_consort = no ai = yes }
			religion = celtic_pagan
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = celtic_pagan
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = celtic_pagan
		}
		random_vassal = {
			limit = {
				ai = yes
				culture = ROOT
				religion = germanic_pagan
			}
			religion = celtic_pagan
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = briton
			religion = celtic_pagan
			female = no
			age = 32
			attributes = {
				learning = 6
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}

	option = {
		name = ZUSK45OP4
		ai_chance = { factor = 25 }

		set_global_flag = england_religion_flag

		piety = 500
		random = {
			chance = 50
			add_trait = zealous
		}
	}
}

# Fall of Constantinople, Egypt decides to carry on the legacy of Rome
narrative_event = {
	id = zusk_event.46
	title = zusk_event.46.name
	desc = zusk_event.46.desc
	picture = GFX_evt_fall_of_constantinople
	border = GFX_event_narrative_frame_diplomacy
	
	has_global_flag = fall_of_constantinople
	war = no
	
	trigger = {
		e_byzantium = {
			has_holder = no
		}
		NOT = { has_global_flag = byzantine_egypt }
		k_egypt = {
			holder_scope = {
				character = ROOT
			}
		}
		prestige = 1000
	}
	
	mean_time_to_happen = {
		years = 100

		#Negative modifiers
		modifier = {
			factor = 2
			trait = cynical
		}
		modifier = {
			factor = 1.2
			trait = slow
		}
		modifier = {
			factor = 1.2
			trait = bastard
		}
		modifier = {
			factor = 1.2
			trait = clubfooted
		}
		modifier = {
			factor = 1.2
			trait = harelip
		}
		modifier = {
			factor = 1.2
			trait = lisp
		}
		modifier = {
			factor = 1.2
			trait = stutter
		}
		modifier = {
			factor = 1.2
			trait = homosexual
		}
		modifier = {
			factor = 1.5
			trait = hunchback
		}
		modifier = {
			factor = 2
			trait = imbecile
		}
		modifier = {
			factor = 5
			trait = inbred
		}
		modifier = {
			factor = 5
			trait = kinslayer
		}
		modifier = {
			factor = 10
			trait = excommunicated
		}
		#Should be healthy
		modifier = {
			factor = 10
			OR = {
				trait = stressed
				trait = depressed
				trait = lunatic
				trait = possessed
				trait = ill
				trait = pneumonic
				trait = syphilitic
				trait = leper
				trait = wounded
				trait = maimed
				trait = infirm
				trait = incapable
				trait = has_tuberculosis
				trait = has_typhoid_fever
				trait = has_typhus
				trait = has_bubonic_plague
				trait = has_measles
				trait = has_small_pox
			}
		}
		#Positive modifiers
		modifier = {
			factor = 0.1
			trait = roman_nostalgia
		}
		modifier = {
			factor = 0.9
			trait = proud
		}
		modifier = {
			factor = 0.9
			is_smart_trigger = yes
		}
		modifier = {
			factor = 0.9
			trait = just
		}
	}
	
	option = {
		name = ZUSK46OP

		set_global_flag = byzantine_egypt

		prestige = 5000
		piety = 1000
		give_nickname = nick_the_great
		k_egypt = {
			set_name = "BYZANTINE_EGYPT"
			adjective = "BYZANTINE_EGYPT_ADJ"
		}
		add_claim = e_byzantium
	}
}

#Alternate fall of Rome
character_event = {
	id = zusk_event.47
	hide_window = yes
	
	has_global_flag = historical_events_fall_of_rome

	trigger = {
		e_wre = {
			has_holder = no
		}
		NOT = { has_global_flag = fall_of_rome }
		ROOT = {
			controls_religion = yes
			religion = miaphysite
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}

	option = {
		name = OK
		
		trigger = {
			e_roman_empire = {
				has_holder = no
			}
			NOT = {
				any_playable_ruler = {
					culture_group = latin
					primary_title = { tier = EMPEROR }
				}
			}
		}
		set_global_flag = fall_of_rome
		any_playable_ruler = {
			narrative_event = { id = zusk_event.30 }
		}
	}

	option = {
		name = OK
		
		trigger = {
			OR = {
				e_wre = {
					has_holder = yes
				}
				any_playable_ruler = {
					culture_group = latin
					primary_title = { tier = EMPEROR }
				}
			}
		}
		set_global_flag = fall_of_rome #Quiet fall of rome, another empire for Latins exists in name to continue the legacy
	}
}

# Punic courtier appears at court
character_event = {
	id = zusk_event.48
	desc = zusk_event.48_desc
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion
	
	prisoner = no
	only_playable = yes

	trigger = {
		NOT = { year = 800 }
		OR = {
			culture_group = central_african
			culture = vandalic
			culture = coptic
			culture = african_romance
			religion = latin_solar_pagan
			religion = latin_solar_pagan_reformed
		}
		independent = yes
	}
	
	mean_time_to_happen = {
		months = 1100

		modifier = {
			factor = 0.9
			NOT = { year = 490 }
		}
		modifier = {
			factor = 1.1
			year = 500
		}
		modifier = {
			factor = 1.2
			year = 525
		}
		modifier = {
			factor = 1.4
			year = 550
		}
		modifier = {
			factor = 1.8
			year = 575
		}
		modifier = {
			factor = 2
			year = 600
		}
		modifier = {
			factor = 2.5
			year = 650
		}
		modifier = {
			factor = 2.5
			year = 700
		}
		modifier = {
			factor = 2.5
			year = 750
		}
	}
	
	option = {
		name = ZUSK48OP
		create_random_steward = {
			random_traits = yes
			culture = punic
			dynasty = culture
			religion = central_african_pagan
			female = no
			age = 40
			trait = fortune_builder
			attributes = {
				stewardship = 10
			}
			flag = ai_flag_refuse_conversion
		}
		new_character = {
			add_claim = e_north_africa
		}
	}
}

# Independent Romano-Hispanic Arians convert back to Nicene
character_event = {
	id = zusk_event.49
	hide_window = yes
	
	culture = romano_hispanic
	ai = yes
	religion = arian
	
	trigger = {
		NOT = { year = 800 }
		independent = yes
		any_realm_province = { #Still a sizable amount of Romano-Hispanics left within the realm
			religion = nicene
			culture = romano_hispanic
		}
		NOT = { trait = zealous }
		
	}
	
	mean_time_to_happen = {
		years = 1
	}
	
	option = {
		name = OK
		religion = nicene
		
		any_courtier = {
			limit = { is_close_relative = ROOT }
			religion = nicene
		}
		any_spouse = {
			limit = { is_consort = no }
			religion = nicene
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = romano_hispanic
			religion = nicene
			female = no
			age = 32
			attributes = {
				learning = 6
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}
}

# Roman vandal prisoners, Genseric took countless Romans back to Carthage as slaves during his sack of Rome
character_event = {
	id = zusk_event.50
	title = zusk_event.50.name
	desc = zusk_event.50.desc
	
	picture = GFX_evt_fall_of_rome
	
	is_triggered_only = yes

	option = {
		name = ZUSK50OP

		custom_tooltip = {
			text = vandal_slave_tooltip
			hidden_tooltip = {
				create_character = {
					name = "Gaudentius"
					random_traits = no
					age = 36
					female = no
					religion = hellenic_pagan
					culture = roman
					dynasty = none
					trait = "zealous"
					trait = "ambitious"
					trait = "diligent"
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 20
					female = yes
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 19
					female = yes
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 21
					female = yes
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 32
					female = yes
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 18
					female = yes
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 24
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 35
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 42
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 54
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 19
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 12
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 8
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 6
					religion = nicene
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 6
					religion = nicene
					culture = roman
					dynasty = none
					female = yes
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 12
					religion = nicene
					culture = roman
					dynasty = none
					female = yes
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 13
					religion = nicene
					culture = roman
					dynasty = none
					female = yes
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 28
					religion = manichean
					culture = roman
					dynasty = none
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 25
					religion = manichean
					culture = roman
					dynasty = none
					female = yes
				}
				new_character = {
					imprison = yes
				}
				create_character = {
					random_traits = yes
					age = 23
					religion = manichean
					culture = roman
					dynasty = none
					female = yes
				}
				new_character = {
					imprison = yes
				}
			}
		}
	}
}

# Zeno has won the war for the ERE against Basiliscus
narrative_event = {
	id = historical_wtwsms.1
	title = historical_wtwsms.1.name
	desc = {
		trigger = {
			has_landed_title = e_byzantium
		}
		text = historical_wtwsms.1.desc.a
	}
	desc = {
		trigger = {
			NOT = { has_landed_title = e_byzantium }
		}
		text = historical_wtwsms.1.desc.b
	}
	picture = GFX_evt_victory_arch_byzantine
	
	only_rulers = yes
	only_independent = yes
	
	major = yes
	
	trigger = {
		start_date = 476.2.2
		NOT = { year = 500 } # Zeno's war is in 476, this prevents the event from firing later in case vassals would rebel and Zeno had failed the rebellion
		ROOT = {
			has_landed_title = e_byzantium
			character = 70515 # Zeno
		}
		c_145226 = { # Basilikos
			ROOT = { has_truce = PREV }
		}
		NOT = { has_global_flag = zeno_tarasis_ere }
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		set_global_flag = zeno_tarasis_ere
	}
	
	option = {
		name = OK # To expand, maybe banquet event with Odoacer?
		trigger = {
			has_landed_title = e_byzantium
		}
		
		prestige = 100
		change_infamy = { # To avoid huge coalition
			value = -100
			localisation = CHANGE_INFAMY_EFFECT
		}
		c_145226 = { # Basilikos
			abdicate_to = ROOT
			imprison = ROOT
		}
	}
	option = {
		name = OK # To expand/look into options with WRE
		trigger = {
			NOT = { has_landed_title = e_byzantium }
		}
	}
}

# Theodoric has won the invasion of Italy against Odoacer
narrative_event = {
	id = historical_wtwsms.2
	title = historical_wtwsms.2.name
	desc = {
		trigger = {
			has_landed_title = k_ostrogoths
		}
		text = historical_wtwsms.2.desc.a
	}
	desc = {
		trigger = {
			NOT = { has_landed_title = k_ostrogoths }
		}
		text = historical_wtwsms.2.desc.b
	}
	picture = GFX_evt_heretic
	
	major = yes
	
	only_rulers = yes
	only_independent = yes
	has_global_flag = ostrogoths_arrived
	
	trigger = {
		ROOT = {
			has_landed_title = k_ostrogoths
			character = 63 # Theodoric the Great
		}
		k_italy = {
			any_previous_holder = {
				ROOT = { has_truce = PREV }
			}
		}
		OR = {
			c_roma = {
				holder_scope = {
					top_liege = {
						character = ROOT
					}
				}
			}
			c_ravenna = {
				holder_scope = {
					top_liege = {
						character = ROOT
					}
				}
			}
		}
		NOT = { has_global_flag = theodoric_won_italy_invasion }
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		set_global_flag = theodoric_won_italy_invasion
	}

	option = {
		name = OK
		trigger = {
			has_landed_title = k_ostrogoths
		}
		
		disband_event_forces = theodoric_italy_invasion
		prestige = 100
		change_infamy = { # To avoid huge coalition
			value = -100
			localisation = CHANGE_INFAMY_EFFECT
		}
	}
	
	option = {
		name = OK
		trigger = {
			NOT = { has_landed_title = k_ostrogoths }
		}
	}
}

# Julius Nepos reconquers Italy
narrative_event = {
	id = historical_wtwsms.3
	title = historical_wtwsms.3.name
	desc = {
		trigger = {
			has_landed_title = e_wre
		}
		text = historical_wtwsms.3.desc.a
	}
	desc = {
		trigger = {
			NOT = { has_landed_title = e_wre }
		}
		text = historical_wtwsms.3.desc.b
	}
	picture = GFX_evt_heretic
	
	major = yes
	
	only_rulers = yes
	only_independent = yes
	has_global_flag = julis_nepos_wre
	
	trigger = {
		OR = {
			start_date = 476.2.2
			start_date = 480.5.1
		}
		ROOT = {
			has_landed_title = e_wre
			character = 175110 # Julius Nepos
		}
		OR = {
			k_italy = {
				any_previous_holder = {
					ROOT = { has_truce = PREV }
				}
			}
			k_ostrogoths = {
				any_previous_holder = {
					ROOT = { has_truce = PREV }
				}
			}
		}
		OR = {
			c_roma = {
				holder_scope = {
					top_liege = {
						character = ROOT
					}
				}
			}
			c_ravenna = {
				holder_scope = {
					top_liege = {
						character = ROOT
					}
				}
			}
		}
		NOT = { has_global_flag = nepos_return_italy }
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		set_global_flag = nepos_return_italy
	}

	option = {
		name = historical_wtwsms.3.a
		trigger = {
			has_landed_title = e_wre
		}
		
		prestige = 100
		if = {
			limit = {
				k_ostrogoths = {
					holder_scope = {
						vassal_of = ROOT
					}
				}
			}
			k_ostrogoths = {
				holder_scope = {
					imprison = ROOT
					abdicate_to = ROOT
				}
			}
			k_ostrogoths = {
				destroy_landed_title = THIS
			}
		}
		if = {
			limit = {
				k_italy = {
					holder_scope = {
						vassal_of = ROOT
					}
				}
			}
			k_italy = {
				holder_scope = {
					imprison = ROOT
					abdicate_to = ROOT
				}
			}
			k_italy = {
				destroy_landed_title = THIS
			}
		}
		change_infamy = { # To avoid huge coalition
			value = -100
			localisation = CHANGE_INFAMY_EFFECT
		}
	}
	option = {
		name = historical_wtwsms.3.b
		trigger = {
			NOT = { has_landed_title = e_wre }
		}
	}
}

# Eastern Roman Emperor has won the Isaurian Wars
narrative_event = {
	id = historical_wtwsms.4
	title = historical_wtwsms.4.name
	desc = historical_wtwsms.4.desc
	picture = GFX_evt_victory_arch_byzantine
	
	only_rulers = yes
	only_independent = yes
	
	trigger = {
		start_date = 492.1.1
		NOT = { year = 520 } # the war should be ended by this year
		ROOT = {
			has_landed_title = e_byzantium
			OR = {
				has_landed_title = c_ephesos # Capital of Asia
				has_landed_title = c_ikonion # Capital of Pisidia
				any_realm_lord = {
					has_landed_title = c_ephesos # Capital of Asia
				}
				any_realm_lord = {
					has_landed_title = c_ikonion # Capital of Pisidia
				}
			}
		}
		d_isauria = {
			holder_scope = {
				has_truce = ROOT
			}
		}
		NOT = { has_global_flag = isaurian_war_ended }
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		set_global_flag = isaurian_war_ended
		d_isauria = { holder_scope = { save_event_target_as = target_isaurian_leader } }
	}
	
	option = {
		name = OK
		
		prestige = 100
		d_isauria = {
			holder_scope = {
				abdicate_to = ROOT
				imprison = ROOT
			}
		}
		clear_event_target = target_isaurian_leader
	}
}

# Isaurians have won the Isaurian Wars
narrative_event = {
	id = historical_wtwsms.5
	title = historical_wtwsms.5.name
	desc = historical_wtwsms.5.desc
	picture = GFX_evt_castle_hill
	
	only_rulers = yes
	only_independent = yes
	
	trigger = {
		start_date = 492.1.1
		NOT = { year = 520 } # the war should be ended by this year
		ROOT = {
			has_landed_title = d_isauria
			OR = {
				has_landed_title = c_ephesos # Capital of Asia
				has_landed_title = c_ikonion # Capital of Pisidia
				any_realm_lord = {
					has_landed_title = c_ephesos # Capital of Asia
				}
				any_realm_lord = {
					has_landed_title = c_ikonion # Capital of Pisidia
				}
			}
		}
		e_byzantium = {
			holder_scope = {
				has_truce = ROOT
			}
		}
		NOT = { has_global_flag = isaurian_war_ended }
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		set_global_flag = isaurian_war_ended
	}
	
	option = {
		name = OK
		
		prestige = 100
	}
}

# Julius Nepos dies without a heir
narrative_event = {
	id = historical_wtwsms.6
	title = historical_wtwsms.6.name
	desc = historical_wtwsms.6.desc
	picture = GFX_evt_fall_of_rome
	
	is_triggered_only = yes # On_actions event
	
	major = yes
	
	major_trigger = { # Informs Nepos' heir
		OR = {
			has_landed_title = e_wre
			has_landed_title = k_dalmatia
		}
	}
	
	only_playable = yes
	
	trigger = {
		has_landed_title = e_wre
		NOR = { #controls no land in Italia
			any_realm_province = {
				kingdom = { title = k_annonaria }
			}
			any_realm_province = {
				kingdom = { title = k_italia }
			}
		}
		character = 175110 # Julius Nepos
		current_heir = {
			from_ruler_dynasty = no # Doesn't have a heir
		}
	}
	
	immediate = {
		e_wre = { # The last Western Roman Emperor has died
			destroy_landed_title = THIS
		}
	}
	
	option = {
		name = historical_wtwsms.6.a
		prestige = -50
	}
}

# Riots breaks out in Constantinople against an Isaurian emperor
narrative_event = {
	id = historical_wtwsms.7
	title = historical_wtwsms.7.name
	desc = historical_wtwsms.7.desc
	picture = GFX_evt_riots_byzantine
	
	is_triggered_only = yes # On_actions event
	
	weight_multiplier = {
		days = 1
		#7 virtues
		modifier = {
			factor = 0.5
			trait = chaste
		}
		modifier = {
			factor = 0.5
			trait = temperate
		}
		modifier = {
			factor = 0.5
			trait = charitable
		}
		modifier = {
			factor = 0.5
			trait = diligent
		}
		modifier = {
			factor = 0.5
			trait = patient
		}
		modifier = {
			factor = 0.5
			trait = kind
		}
		modifier = {
			factor = 0.5
			trait = humble
		}
		#7 sins
		modifier = {
			factor = 2
			trait = lustful
		}
		modifier = {
			factor = 2
			trait = gluttonous
		}
		modifier = {
			factor = 2
			trait = greedy
		}
		modifier = {
			factor = 2
			trait = slothful
		}
		modifier = {
			factor = 2
			trait = wroth
		}
		modifier = {
			factor = 2
			trait = envious
		}
		modifier = {
			factor = 2
			trait = proud
		}
		#other
		# don't hesitate to add more here!
		modifier = {
			factor = 3
			trait = excommunicated
		}
		modifier = {
			factor = 2
			is_any_kinslayer_trigger = yes
		}
		modifier = {
			factor = 0.5
			trait = born_in_the_purple
		}
		modifier = {
			factor = 0.5
			trait = socializer
		}
	}
	
	only_playable = yes
	culture = isaurian
	
	trigger = {
		has_landed_title = e_byzantium
		capital_scope = {
			province = 496 # Constantinople
		}
		496 = {
			NOT = { culture = isaurian }
		}
		NOT = { 496 = { has_province_modifier = antiisaurian_revolt_timer } }
	}
	
	immediate = {
		if = { # use exiting claimants if available
			limit = {
				any_realm_character = {
					has_claim = e_byzantium
				}
			}
			random_realm_character = {
				limit = { has_claim = e_byzantium }
				save_event_target_as = target_antiisaurian_usurper
				set_character_flag = antiisaurian_usurper
			}
		}
		496 = {
			add_province_modifier = {
				name = antiisaurian_revolt_timer
				duration = 3650
				hidden = yes
			}
		}
	}
	
	option = { #stay in capital and fight
		name = historical_wtwsms.7.a
		
		496 = {
			if = {
				limit = { NOT = { ROOT = { any_realm_character = { has_character_flag = antiisaurian_usurper } } } }
				create_character = {
					random_traits = yes
					religion = THIS
					culture = THIS
					employer = e_rebels
					age = 35
					female = no
					attributes = {
						diplomacy = 10
						martial = 10
						stewardship = 5
						intrigue = 6
						learning = 7
					}
				}
				new_character = {
					save_event_target_as = target_antiisaurian_usurper
					add_claim = e_byzantium
					prestige = 100
					piety = 50
				}
			}
			
			event_target:target_antiisaurian_usurper = {
				set_defacto_liege = THIS
				create_title = {
					tier = EMPEROR
					culture = roman
					rebel = yes
					landless = yes
					temporary = yes
					#short_name = yes
					name = ANTI_ISAURIAN_REVOLT
					ruler = EMPEROR
					ruler_female = EMPRESS
					holder = THIS
				}
				spawn_unit = {
					owner = THIS
					leader = THIS
					province = 	PREV
					home = PREV
					troops = {
						archers = { 500 500 }
						light_infantry = { 750 750 }
						heavy_infantry = { 500 500 }
						light_cavalry = { 750 750 }
						knights = { 250 250 }
					}
					attrition = 1.0
				}
				spawn_unit = {
					owner = THIS
					province = PREV
					home = PREV
					troops = {
						archers = { 500 500 }
						light_infantry = { 750 750 }
						heavy_infantry = { 500 500 }
						light_cavalry = { 750 750 }
						knights = { 250 250 }
					}
					attrition = 1.0
				}
				spawn_unit = {
					owner = THIS
					province = PREV
					home = PREV
					troops = {
						archers = { 500 500 }
						light_infantry = { 750 750 }
						heavy_infantry = { 500 500 }
						light_cavalry = { 750 750 }
						knights = { 250 250 }
					}
					attrition = 1.0
				}
				
				if = {
					limit = {
						ROOT = { any_realm_title = { title = e_byzantium } }
					}
					e_byzantium = {
						ROOT = {
							reverse_war = {
								target = PREVPREV
								casus_belli = claim
								thirdparty_title = PREV
							}
						}
					}
				}
			}
		}
	}
	option = { #abandon the capital and fight
		name = historical_wtwsms.7.b
		if = {
			limit = {
				any_demesne_province = {
					duchy = { NOT = { title = d_europa } }
				}
			}
			random_demesne_province = {
				limit = {
					duchy = { NOT = { title = d_europa } }
				}
				ROOT = { capital = PREV }
			}
		}
		else_if = {
			limit = {
				any_demesne_province = {
					NOT = { province_id = 496 } #has provinces other than Constantinople
				}
			}
			random_demesne_province = {
				limit = {
					NOT = { province_id = 496 }
				}
				ROOT = { capital = PREV }
			}
		}
		496 = {
			if = {
				limit = { NOT = { ROOT = { any_realm_character = { has_character_flag = antiisaurian_usurper } } } }
				create_character = {
					random_traits = yes
					religion = THIS
					culture = THIS
					employer = e_rebels
					age = 35
					female = no
					attributes = {
						diplomacy = 10
						martial = 10
						stewardship = 5
						intrigue = 6
						learning = 7
					}
				}
				new_character = {
					save_event_target_as = target_antiisaurian_usurper
					add_claim = e_byzantium
					prestige = 100
					piety = 50
				}
			}
			
			event_target:target_antiisaurian_usurper = {
				set_defacto_liege = THIS
				create_title = {
					tier = EMPEROR
					culture = roman
					rebel = yes
					landless = yes
					temporary = yes
					#short_name = yes
					name = ANTI_ISAURIAN_REVOLT
					ruler = EMPEROR
					ruler_female = EMPRESS
					holder = THIS
				}
				spawn_unit = {
					owner = THIS
					leader = THIS
					province = 	PREV
					home = PREV
					troops = {
						archers = { 500 500 }
						light_infantry = { 750 750 }
						heavy_infantry = { 500 500 }
						light_cavalry = { 750 750 }
						knights = { 250 250 }
					}
					attrition = 1.0
				}
				spawn_unit = {
					owner = THIS
					province = PREV
					home = PREV
					troops = {
						archers = { 500 500 }
						light_infantry = { 750 750 }
						heavy_infantry = { 500 500 }
						light_cavalry = { 750 750 }
						knights = { 250 250 }
					}
					attrition = 1.0
				}
				spawn_unit = {
					owner = THIS
					province = PREV
					home = PREV
					troops = {
						archers = { 500 500 }
						light_infantry = { 750 750 }
						heavy_infantry = { 500 500 }
						light_cavalry = { 750 750 }
						knights = { 250 250 }
					}
					attrition = 1.0
				}
				
				if = {
					limit = {
						ROOT = { any_realm_title = { title = e_byzantium } }
					}
					e_byzantium = {
						ROOT = {
							reverse_war = {
								target = PREVPREV
								casus_belli = claim
								thirdparty_title = PREV
							}
						}
					}
				}
			}
		}
	}
	option = { #surrender
		name = historical_wtwsms.7.c
		
		custom_tooltip = { text = historical_wtwsms.7.c.tooltip } #TODO: (after HF compatch) check if the title name in the tooltip displays properly!
		496 = {
			create_character = {
				random_traits = yes
				religion = THIS
				culture = THIS
				age = 35
				female = no
				attributes = {
					diplomacy = 10
					martial = 10
					stewardship = 5
					intrigue = 6
					learning = 7
				}
			}
			new_character = {
				e_byzantium = {
					usurp_title_plus_barony_if_unlanded = { target = PREV type = claim }
				}
				ROOT = {
					any_demesne_title = {
						limit = {
							de_jure_liege_or_above = e_byzantium
						}
						usurp_title = { target = PREVPREV type = claim }
					}
					imprison = PREV
				}
			}
		}
	}
	after = {
		event_target:target_antiisaurian_usurper = { clr_character_flag = antiisaurian_usurper }
		clear_event_target = target_antiisaurian_usurper
	}
}